mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
548 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cef8ac9fd9 | |||
| 45aa5df267 | |||
| dd98d0c11d | |||
| 00f6a823d6 | |||
| b4f4da26d6 | |||
| 1c9f7ac597 | |||
| 673139f5a9 | |||
| 3125a7a928 | |||
| f20c944c72 | |||
| 6d7dc6517b | |||
| 6fd84c6c8c | |||
| d37f31208c | |||
| c472b19e0d | |||
| 03a7eb0fd4 | |||
| c0a779727e | |||
| 52d3f0bc19 | |||
| c17497e304 | |||
| 6bc4ecbc73 | |||
| 2246077589 | |||
| 60ad1c10fd | |||
| 7696541430 | |||
| 614156f575 | |||
| 397abd51a5 | |||
| d311090ced | |||
| 505a3c6224 | |||
| 75a21ee162 | |||
| 440cf968d5 | |||
| 3daa374a51 | |||
| 5d83d912fc | |||
| 695fd3ba1c | |||
| 75f68904f2 | |||
| b99badda9f | |||
| dbd6be9520 | |||
| 42ef948fcc | |||
| 69f4ac3ed7 | |||
| 7d65d4b11a | |||
| 57ba4355f9 | |||
| 2eea44bc8c | |||
| cb982a1ad4 | |||
| 0aca0a0a5a | |||
| 7a153285c8 | |||
| c2d00ee819 | |||
| 3603787df8 | |||
| 5483a8d36b | |||
| 80ac89f16b | |||
| fcf9830aa6 | |||
| 887d963d8d | |||
| 8d89026d19 | |||
| 4e6e3ce5f0 | |||
| 3d7eced836 | |||
| 7130b1be34 | |||
| eee80b0f87 | |||
| 35dff37820 | |||
| 2f45a87669 | |||
| 185b3d54eb | |||
| f7f059b6c0 | |||
| 2a9044d066 | |||
| 9a1abe9819 | |||
| f8f9d55ab8 | |||
| 99b777a5eb | |||
| d1506ec9fa | |||
| 9fc74159ff | |||
| ec14915925 | |||
| f9f4efc383 | |||
| 12ad4e604b | |||
| e0ad062380 | |||
| b72f678c1d | |||
| 7b67dfa57c | |||
| 5153ac069b | |||
| a08b614bce | |||
| 59f41bcdec | |||
| e8aa709d4e | |||
| c4515aca3a | |||
| 3fde7b3f92 | |||
| d69601c2d2 | |||
| 912482beee | |||
| c0ca4189d3 | |||
| 134a214a0b | |||
| 95f604ec68 | |||
| d8bd9ef845 | |||
| d3a317ed4b | |||
| 37141b6ba3 | |||
| bd3cabd236 | |||
| c2403aa0b7 | |||
| bdf70dd99e | |||
| 9f18cbce01 | |||
| 05a6f6afaf | |||
| 3275182013 | |||
| ca2b6d78aa | |||
| 6a24fd149a | |||
| 4501adbc61 | |||
| 0c1864a136 | |||
| 3e2373687c | |||
| 779af49e0d | |||
| cb2f1c5577 | |||
| 446a0f9524 | |||
| 1c839e6c62 | |||
| f7d7dc8c6b | |||
| 6d789e966a | |||
| dd0ed96e5a | |||
| 25b30981ce | |||
| ebfee2376f | |||
| fa33af2304 | |||
| 6b9fc964b9 | |||
| 9242ab9743 | |||
| e14cc2d5c5 | |||
| cd73a4d9e3 | |||
| 1b39b9f416 | |||
| 4e57fda1f6 | |||
| f3d65cb04c | |||
| 4ba288978d | |||
| c862d58966 | |||
| c6effb6de2 | |||
| 96b34ee008 | |||
| 265db0216b | |||
| 76f2d81655 | |||
| 863144596c | |||
| a82a8977c3 | |||
| 0109c69e38 | |||
| 92ce5d81ad | |||
| 482da0dab3 | |||
| 32afe4f24e | |||
| 182dd9e072 | |||
| 2ba281a5ee | |||
| b3a30cf2ea | |||
| c321783b44 | |||
| 182cd8d74a | |||
| 98a1988d9a | |||
| acd9219b16 | |||
| 0cbcaa209c | |||
| a53e46be24 | |||
| ab8070aa56 | |||
| 6a930c5aa4 | |||
| 6c0715cc66 | |||
| f019dfbb07 | |||
| fefcef7da4 | |||
| 361bc70fe3 | |||
| 09b4ab5092 | |||
| e1fcf17b34 | |||
| c83a8a3a54 | |||
| 54f0635500 | |||
| bb48b57af9 | |||
| 8a000efb7f | |||
| 1c362612e3 | |||
| 78404c4ffe | |||
| 3a49869ce0 | |||
| a1a6e6c9a0 | |||
| 4199716550 | |||
| 6d68d7aee5 | |||
| cf346bd535 | |||
| 61e6b54710 | |||
| 536dac5fc9 | |||
| 65ba8ffd3b | |||
| c6467d67c5 | |||
| 5a9812887b | |||
| e637b47d68 | |||
| 0078a2e19b | |||
| d2713d0cfd | |||
| 4bf363f458 | |||
| c1b01029df | |||
| 4b299fedd7 | |||
| dc4074299c | |||
| 2d161f1341 | |||
| fea872d779 | |||
| 6c614051d9 | |||
| 2517316e2b | |||
| c83e50d164 | |||
| 66bc0223cb | |||
| 9ea09f95f8 | |||
| d66d95d4c6 | |||
| 024c288e12 | |||
| caac75fcc1 | |||
| eb88373ec5 | |||
| 4e86a9a08a | |||
| 099ebc3de9 | |||
| 4c3b9411b4 | |||
| 555b91e385 | |||
| 9713138f4f | |||
| 0934c2cda4 | |||
| bb204098a1 | |||
| c65e8d4a04 | |||
| a0cecd357f | |||
| 6a4f30d6fa | |||
| cfde4aa357 | |||
| 2a2f33fd6f | |||
| 8ad76e4e1f | |||
| b0b3d6b280 | |||
| 029e6c6df7 | |||
| e8257896d4 | |||
| 1e9a63083b | |||
| 2f525c1e4f | |||
| 40a1e15033 | |||
| 6c93c8b16c | |||
| 8813f8bb19 | |||
| e979defdee | |||
| cc585185dd | |||
| 9a5240cbba | |||
| 8e498c8299 | |||
| 706a2252fa | |||
| d423549ae4 | |||
| cef0adda0a | |||
| ab2ab7a407 | |||
| 62c401ae5b | |||
| d73d682cbc | |||
| c470363ec0 | |||
| 25be50f058 | |||
| 10931f937a | |||
| 647c8a3cde | |||
| 1d4f9b5c41 | |||
| 3de464a31e | |||
| 3429e8b345 | |||
| b3f5d84a51 | |||
| 23c2ecfe54 | |||
| 485dcb5272 | |||
| 1c9a9f53e3 | |||
| 62ad5bf127 | |||
| ecc1e974ae | |||
| ef61b90242 | |||
| 00bdf67b8a | |||
| ee83f6c826 | |||
| ec50e77695 | |||
| 72fbe98925 | |||
| 4ef62b88cb | |||
| 3e8d5926ba | |||
| 0284c8df70 | |||
| 3d4faa267e | |||
| edc0ae2b8d | |||
| ebaf0eb43a | |||
| eab40d6bb2 | |||
| e7d081aefb | |||
| cc2867e292 | |||
| 8e51f9bdbb | |||
| 92b0f4e654 | |||
| 46d4d76f26 | |||
| 53593c96af | |||
| 21f75547fb | |||
| ac8c99415f | |||
| 0daee49007 | |||
| 5a6a2f800f | |||
| 8e3df35232 | |||
| 521d7c1ee8 | |||
| f1e80adb9c | |||
| 3503eee5b6 | |||
| 1041802214 | |||
| cebc04b852 | |||
| dbfdffd0c5 | |||
| b8d2cba3ae | |||
| b56d62442d | |||
| 5d70f47ebc | |||
| 859351a8d1 | |||
| fbd408ec6d | |||
| c631b62e51 | |||
| 1286dbaaaf | |||
| 1dbeea42b8 | |||
| 0dc65baa25 | |||
| 50fec65617 | |||
| a5ea301e3e | |||
| fb40437d21 | |||
| cf66adea28 | |||
| 2b00698810 | |||
| b00fbeff53 | |||
| 819d1fad17 | |||
| 97f0958f09 | |||
| ce88c4ca95 | |||
| ac7614c4e6 | |||
| a69a992a0d | |||
| b4bb20bea7 | |||
| 949aed7bb4 | |||
| 2ce37e34c4 | |||
| 6ec4191483 | |||
| 3401c2b02e | |||
| 0dd0ad0023 | |||
| 8cf7809359 | |||
| 277dd4a464 | |||
| cb8466de27 | |||
| 1c2501eeb1 | |||
| 0d443743a8 | |||
| 8c7a22b726 | |||
| c8b8462d31 | |||
| a14b3eb8e2 | |||
| 6eaf590844 | |||
| fac279ba81 | |||
| 571a7ee2d1 | |||
| adb6d7bbc2 | |||
| f7fa638591 | |||
| edfa558a38 | |||
| b80ada4b4e | |||
| 492b821472 | |||
| d75a3a5587 | |||
| a8ce7eaad3 | |||
| 8cf78b9e58 | |||
| 28bcfafcc6 | |||
| e527db9515 | |||
| db2660a1a3 | |||
| 77b5ffb56d | |||
| ca70de93a4 | |||
| 04565bbdd4 | |||
| 4266857c6e | |||
| 8e6e510cd6 | |||
| 03919dcb33 | |||
| 46588b05b1 | |||
| dc0ea6a7f3 | |||
| a84c8cc471 | |||
| 986d0f0d95 | |||
| cd1bb3b658 | |||
| cd71bc0672 | |||
| 6caf517fe5 | |||
| d65d37476e | |||
| 14c9896773 | |||
| 19694bf32d | |||
| ffe85bd64f | |||
| d4c4b804c7 | |||
| 1de2807051 | |||
| 96e1280082 | |||
| ce41e42851 | |||
| b414fb961e | |||
| 0370948e98 | |||
| ccbd9da871 | |||
| cec8402adc | |||
| fd90f73c19 | |||
| 6447aeafa5 | |||
| aa3e0759d7 | |||
| 3db4bdc93f | |||
| 3003c66eba | |||
| cc4c0dd68e | |||
| 5692bee77a | |||
| e25a952279 | |||
| d6864e044a | |||
| ad69100d3f | |||
| b05a95d54e | |||
| 87a09faefb | |||
| 5e35517d71 | |||
| ca94882699 | |||
| 894f78d143 | |||
| eeac44a1ab | |||
| 77ece713ee | |||
| a8e3dd2ef5 | |||
| 20a2aa1ef1 | |||
| 7d10e1e995 | |||
| c3531cb19c | |||
| ba6de346dc | |||
| 5b44611560 | |||
| f2aa34b5ce | |||
| d43a724ee6 | |||
| cba68e2d2a | |||
| f8dd9fb085 | |||
| 39e95e8b49 | |||
| b98922dbfd | |||
| f57af6ecc1 | |||
| af77bf3f77 | |||
| 4578731001 | |||
| 72566e8064 | |||
| 346f0e9dd0 | |||
| e32bd8fd96 | |||
| de51108ba7 | |||
| 83a6e52df2 | |||
| b2e807ec33 | |||
| 1eba4aefa8 | |||
| 956508f994 | |||
| 4eb761eec3 | |||
| e27415bb84 | |||
| 2afbd3c429 | |||
| baf9fb4a93 | |||
| 0b8e833e77 | |||
| 94bb0f5306 | |||
| 8cadb329b9 | |||
| af7cb378ac | |||
| 81e075e715 | |||
| f7607e1c92 | |||
| 1022d29fe8 | |||
| fc3ce62ec7 | |||
| 3fac5441cb | |||
| 32bd8166d7 | |||
| 4acdd6dd20 | |||
| 518a4ddb2b | |||
| 895082cc93 | |||
| f16fa656e9 | |||
| f16318aebb | |||
| d8d540bd02 | |||
| a5c28b72bb | |||
| 290d50ebcc | |||
| 3de1152a3f | |||
| 93900a0be8 | |||
| 9ba32e031d | |||
| 109c891c1b | |||
| 1b2d803976 | |||
| 9f4613b15c | |||
| d69e4ca0ba | |||
| ab7e8a07be | |||
| 7603aceee1 | |||
| 7ea66d0bee | |||
| 0e8230cc7f | |||
| ef2963242a | |||
| 0229d928ab | |||
| cbfc2d5052 | |||
| 1a979fe30a | |||
| ff2146b671 | |||
| 4bdea2d154 | |||
| d1d5a46896 | |||
| 751a5d4d7d | |||
| dcc4342483 | |||
| ef5e71e941 | |||
| 5c1b611b88 | |||
| 4b1bd2fb70 | |||
| cbbf650c56 | |||
| b55cd751d1 | |||
| c7d5b60637 | |||
| 666f5c2f9e | |||
| 42b432b4de | |||
| c6e15b7526 | |||
| 08ca60091c | |||
| 88d9827d3f | |||
| bae672f718 | |||
| 00344df9ad | |||
| d9902ba6f9 | |||
| cfb060e142 | |||
| 633af32919 | |||
| 0565e6164b | |||
| 306cc3f985 | |||
| 2739dd3abd | |||
| 70e6df5aae | |||
| 40d3cd1a85 | |||
| 96030aa322 | |||
| fee801eeeb | |||
| 750273b526 | |||
| cfdb541c28 | |||
| 11121961d9 | |||
| 45828709ee | |||
| 40916e5ccc | |||
| 319610c58d | |||
| 1837a2737e | |||
| 686fc60860 | |||
| 51216f27f4 | |||
| 2eb33ddd22 | |||
| 58c80b052b | |||
| 5eee408eeb | |||
| 32103b8b9f | |||
| b6ae1f272c | |||
| 045f23d921 | |||
| d06b52988c | |||
| 4717b47388 | |||
| 31ce9f6a18 | |||
| e44c9fa4c9 | |||
| 3c59ba7a13 | |||
| 42e84249e8 | |||
| e2dbde8722 | |||
| 36c67d79d5 | |||
| cdc14d22f0 | |||
| baed05236b | |||
| c644f94c0b | |||
| 1244ba5fe5 | |||
| 087e4433f2 | |||
| bc11a5cf5f | |||
| d86303e290 | |||
| 51f1faa51a | |||
| 6775dccc2c | |||
| ee3b4c612d | |||
| 1144bb166c | |||
| a9752208f6 | |||
| 84016cf8cf | |||
| cb7edc373c | |||
| d1e43d68dc | |||
| b5ab5f9b2b | |||
| 761c5bec53 | |||
| 8cc7034c22 | |||
| ee1c385b54 | |||
| ded640825b | |||
| 84301531c8 | |||
| 66231b65c1 | |||
| 7aa2d36d85 | |||
| 310cd6d8fd | |||
| 2d37cf634a | |||
| 04880b4e1d | |||
| 1000b5d5bd | |||
| c324b4a11c | |||
| 982d2d1872 | |||
| a51fe4134c | |||
| 985d258bc1 | |||
| 71b1e4fbf3 | |||
| fee5c112b4 | |||
| 9b50f9fbc2 | |||
| 10f770fdbc | |||
| eb53c40135 | |||
| ded1655a04 | |||
| 20c11889aa | |||
| 910c2418d6 | |||
| e6ffdc0ae8 | |||
| 0335d330b8 | |||
| 1a1ec927e2 | |||
| af2e86e777 | |||
| bcf7d08c51 | |||
| 11886dcdf7 | |||
| 615d0b682c | |||
| 535028fa0e | |||
| c421936857 | |||
| 3580e84184 | |||
| 5a6386e08b | |||
| 1538997b63 | |||
| bdb902128d | |||
| bb41c8b85f | |||
| fbee170e87 | |||
| 9b5f762420 | |||
| 115917b9e5 | |||
| c67b78508e | |||
| 3d38fdd005 | |||
| 296dba3a4e | |||
| 38457c0115 | |||
| 40789fbd24 | |||
| 4adc16620b | |||
| 0bfe049e84 | |||
| a6d8deedcd | |||
| 26b69e8612 | |||
| 9fa00c8609 | |||
| 59bb3035bb | |||
| dbb757a954 | |||
| 55a2fb1b00 | |||
| e9c200e455 | |||
| 887898fe58 | |||
| 627d02b006 | |||
| c9fad9a83f | |||
| 9b05fa38ea | |||
| 7062a26561 | |||
| 311d35f332 | |||
| a7fb914f5e | |||
| c068fd2ee0 | |||
| cfbb7d1216 | |||
| abd2421cc1 | |||
| 592fbfccbb | |||
| cf51a10da9 | |||
| 5f2c00a017 | |||
| bb7b63c86e | |||
| 00ccd7f7a0 | |||
| 3604ca9450 | |||
| 01428dc78a | |||
| 8ae7e577f0 | |||
| d7922089ea | |||
| 3231593049 | |||
| 41dcf2eac4 | |||
| 9f62108376 | |||
| 0eedb80d36 | |||
| 8daa8dd509 | |||
| 8b82e48562 | |||
| 2425a40d36 | |||
| 4384ca2274 | |||
| b3590d66f0 | |||
| 14a8a4d8bb | |||
| 7a9549633b | |||
| 8507c8d4d9 |
141
Apple/IWork.cpp
Normal file
141
Apple/IWork.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
#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;
|
||||
}
|
||||
36
Apple/IWork.h
Normal file
36
Apple/IWork.h
Normal file
@ -0,0 +1,36 @@
|
||||
#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
|
||||
46
Apple/IWork.pro
Normal file
46
Apple/IWork.pro
Normal file
@ -0,0 +1,46 @@
|
||||
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
|
||||
0
Apple/test/examples/DO NOT REMOVE
Normal file
0
Apple/test/examples/DO NOT REMOVE
Normal file
45
Apple/test/main.cpp
Normal file
45
Apple/test/main.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* (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;
|
||||
}
|
||||
20
Apple/test/test.pro
Normal file
20
Apple/test/test.pro
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
8
Common/3dParty/apple/.gitignore
vendored
Normal file
8
Common/3dParty/apple/.gitignore
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
# Ignore everything in this directory
|
||||
glm
|
||||
mdds
|
||||
librevenge
|
||||
libodfgen
|
||||
libetonyek
|
||||
# Except this file
|
||||
!.gitignore
|
||||
36
Common/3dParty/apple/apple.pri
Normal file
36
Common/3dParty/apple/apple.pri
Normal file
@ -0,0 +1,36 @@
|
||||
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)
|
||||
|
||||
121
Common/3dParty/apple/fetch.py
Normal file
121
Common/3dParty/apple/fetch.py
Normal file
@ -0,0 +1,121 @@
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import base
|
||||
import os
|
||||
|
||||
if not base.is_dir("glm"):
|
||||
base.cmd("git", ["clone", "https://github.com/g-truc/glm.git"])
|
||||
base.cmd_in_dir("glm", "git", ["checkout", "33b4a621a697a305bc3a7610d290677b96beb181", "--quiet"])
|
||||
|
||||
if not base.is_dir("mdds"):
|
||||
base.cmd("git", ["clone", "https://github.com/kohei-us/mdds.git"])
|
||||
base.cmd_in_dir("mdds", "git", ["checkout", "0783158939c6ce4b0b1b89e345ab983ccb0f0ad0"], "--quiet")
|
||||
|
||||
fix_cpp_version = "#if __cplusplus < 201402L\n"
|
||||
fix_cpp_version += "#ifndef _MSC_VER\n"
|
||||
fix_cpp_version += "namespace std {\n"
|
||||
fix_cpp_version += " template<bool __v>\n"
|
||||
fix_cpp_version += " using bool_constant = integral_constant<bool, __v>;\n\n"
|
||||
fix_cpp_version += " template <class... _Types>\n"
|
||||
fix_cpp_version += " using void_t = void;\n"
|
||||
fix_cpp_version += "}\n#endif\n"
|
||||
fix_cpp_version += "#endif\n\n"
|
||||
fix_cpp_version += "namespace mdds {"
|
||||
|
||||
base.replaceInFile("./mdds/include/mdds/global.hpp", "namespace mdds {", fix_cpp_version)
|
||||
|
||||
if not base.is_dir("librevenge"):
|
||||
base.cmd("git", ["clone", "https://github.com/Distrotech/librevenge.git"])
|
||||
base.cmd_in_dir("librevenge", "git", ["checkout", "becd044b519ab83893ad6398e3cbb499a7f0aaf4", "--quiet"])
|
||||
|
||||
stat_windows = ""
|
||||
stat_windows += "#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)\n"
|
||||
stat_windows += "#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)\n"
|
||||
stat_windows += "#endif\n"
|
||||
stat_windows += "#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)\n"
|
||||
stat_windows += "#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)\n"
|
||||
stat_windows += "#endif\n"
|
||||
|
||||
base.replaceInFile("./librevenge/src/lib/RVNGDirectoryStream.cpp", "#include <librevenge-stream/librevenge-stream.h>",
|
||||
"#include <librevenge-stream/librevenge-stream.h>\n\n" + stat_windows)
|
||||
|
||||
fix_RVNG_H = "explicit RVNGFileStream(const char *filename);\n"
|
||||
fix_RVNG_H += " #if defined(_WIN32) || defined(_WIN64)\n"
|
||||
fix_RVNG_H += " explicit RVNGFileStream(const wchar_t *filename);\n"
|
||||
fix_RVNG_H += " #endif\n"
|
||||
|
||||
base.replaceInFile("./librevenge/inc/librevenge-stream/RVNGStreamImplementation.h", "explicit RVNGFileStream(const char *filename);", fix_RVNG_H)
|
||||
|
||||
fix_RVNG_CPP_include = "#if defined(_WIN32) || defined(_WIN64)\n"
|
||||
fix_RVNG_CPP_include += "#include <sys/stat.h>\n\n"
|
||||
fix_RVNG_CPP_include += "static __inline int wstat(wchar_t const* const _FileName, struct stat* const _Stat)\n"
|
||||
fix_RVNG_CPP_include += "{\n"
|
||||
fix_RVNG_CPP_include += " _STATIC_ASSERT(sizeof(struct stat) == sizeof(struct _stat64i32));\n";
|
||||
fix_RVNG_CPP_include += " return _wstat64i32(_FileName, (struct _stat64i32*)_Stat);\n";
|
||||
fix_RVNG_CPP_include += "}\n"
|
||||
fix_RVNG_CPP_include += "#endif\n\n"
|
||||
fix_RVNG_CPP_include += "namespace librevenge"
|
||||
|
||||
base.replaceInFile("./librevenge/src/lib/RVNGStreamImplementation.cpp", "namespace librevenge", fix_RVNG_CPP_include)
|
||||
|
||||
fix_RVNG_CPP = "#if defined(_WIN32) || defined(_WIN64)\n"
|
||||
fix_RVNG_CPP += "RVNGFileStream::RVNGFileStream(const wchar_t *filename) :\n"
|
||||
fix_RVNG_CPP += " RVNGInputStream(),\n"
|
||||
fix_RVNG_CPP += " d(new RVNGFileStreamPrivate())\n"
|
||||
fix_RVNG_CPP += "{\n"
|
||||
fix_RVNG_CPP += " d->file = _wfopen(filename, L\"rb\");\n"
|
||||
fix_RVNG_CPP += " if (!d->file || ferror(d->file))\n"
|
||||
fix_RVNG_CPP += " {\n"
|
||||
fix_RVNG_CPP += " delete d;\n"
|
||||
fix_RVNG_CPP += " d = 0;\n"
|
||||
fix_RVNG_CPP += " return;\n"
|
||||
fix_RVNG_CPP += " }\n\n"
|
||||
fix_RVNG_CPP += " struct stat status;\n"
|
||||
fix_RVNG_CPP += " const int retval = wstat(filename, &status);\n"
|
||||
fix_RVNG_CPP += " if ((0 != retval) || !S_ISREG(status.st_mode))\n"
|
||||
fix_RVNG_CPP += " {\n"
|
||||
fix_RVNG_CPP += " delete d;\n"
|
||||
fix_RVNG_CPP += " d = 0;\n"
|
||||
fix_RVNG_CPP += " return;\n"
|
||||
fix_RVNG_CPP += " }\n\n"
|
||||
fix_RVNG_CPP += " fseek(d->file, 0, SEEK_END);\n\n"
|
||||
fix_RVNG_CPP += " d->streamSize = (unsigned long) ftell(d->file);\n"
|
||||
fix_RVNG_CPP += " if (d->streamSize == (unsigned long)-1)\n"
|
||||
fix_RVNG_CPP += " d->streamSize = 0;\n"
|
||||
fix_RVNG_CPP += " if (d->streamSize > (std::numeric_limits<unsigned long>::max)() / 2)\n"
|
||||
fix_RVNG_CPP += " d->streamSize = (std::numeric_limits<unsigned long>::max)() / 2;\n"
|
||||
fix_RVNG_CPP += " fseek(d->file, 0, SEEK_SET);\n"
|
||||
fix_RVNG_CPP += "}\n"
|
||||
fix_RVNG_CPP += "#endif\n\n"
|
||||
fix_RVNG_CPP += "RVNGFileStream::~RVNGFileStream()"
|
||||
|
||||
base.replaceInFile("./librevenge/src/lib/RVNGStreamImplementation.cpp", "RVNGFileStream::~RVNGFileStream()", fix_RVNG_CPP)
|
||||
|
||||
if not base.is_dir("libodfgen"):
|
||||
base.cmd("git", ["clone", "https://github.com/Distrotech/libodfgen.git"])
|
||||
base.cmd_in_dir("libodfgen", "git", ["checkout", "8ef8c171ebe3c5daebdce80ee422cf7bb96aa3bc", "--quiet"])
|
||||
|
||||
if not base.is_dir("libetonyek"):
|
||||
base.cmd("git", ["clone", "https://github.com/LibreOffice/libetonyek.git"])
|
||||
base.cmd_in_dir("libetonyek", "git", ["checkout", "cb396b4a9453a457469b62a740d8fb933c9442c3", "--quiet"])
|
||||
|
||||
base.replaceInFile("./libetonyek/src/lib/IWORKTable.cpp", "is_tree_valid", "valid_tree")
|
||||
|
||||
cmd_args = sys.argv[1:]
|
||||
use_gperf = False
|
||||
|
||||
for arg in cmd_args:
|
||||
if '--gperf' == arg:
|
||||
use_gperf = True
|
||||
|
||||
if use_gperf:
|
||||
base_gperf_args = ["--compare-strncmp", "--enum", "--null-strings", "--readonly-tables", "--language", "C++"]
|
||||
base_gperf_files = ["IWORKToken.gperf", "KEY1Token.gperf", "KEY2Token.gperf", "NUM1Token.gperf", "PAG1Token.gperf"]
|
||||
|
||||
for file in base_gperf_files:
|
||||
base.cmd_in_dir("./libetonyek/src/lib", "gperf", base_gperf_args + [file, "--output-file", file[0:file.find(".")] + ".inc"])
|
||||
else:
|
||||
base.copy_dir_content("./headers", "./libetonyek/src/lib")
|
||||
|
||||
|
||||
|
||||
2563
Common/3dParty/apple/headers/IWORKToken.inc
Normal file
2563
Common/3dParty/apple/headers/IWORKToken.inc
Normal file
File diff suppressed because it is too large
Load Diff
727
Common/3dParty/apple/headers/KEY1Token.inc
Normal file
727
Common/3dParty/apple/headers/KEY1Token.inc
Normal file
@ -0,0 +1,727 @@
|
||||
/* 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"
|
||||
|
||||
300
Common/3dParty/apple/headers/KEY2Token.inc
Normal file
300
Common/3dParty/apple/headers/KEY2Token.inc
Normal file
@ -0,0 +1,300 @@
|
||||
/* 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"
|
||||
|
||||
151
Common/3dParty/apple/headers/NUM1Token.inc
Normal file
151
Common/3dParty/apple/headers/NUM1Token.inc
Normal file
@ -0,0 +1,151 @@
|
||||
/* 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"
|
||||
|
||||
209
Common/3dParty/apple/headers/PAG1Token.inc
Normal file
209
Common/3dParty/apple/headers/PAG1Token.inc
Normal file
@ -0,0 +1,209 @@
|
||||
/* 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"
|
||||
|
||||
@ -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="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep iphoneos | \
|
||||
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="NO" -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 -fembed-bitcode"
|
||||
-std=c++11 -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden"
|
||||
EXTRA_IOS_CPPFLAGS="$EXTRA_CPPFLAGS -mios-version-min=$MIN_IOS_VERSION"
|
||||
EXTRA_OSX_CPPFLAGS="$EXTRA_CPPFLAGS"
|
||||
|
||||
@ -259,20 +259,17 @@ 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
|
||||
|
||||
@ -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} -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"
|
||||
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"
|
||||
;;
|
||||
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} -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"
|
||||
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"
|
||||
;;
|
||||
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} -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"
|
||||
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"
|
||||
;;
|
||||
i386)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch i386"
|
||||
|
||||
@ -18,12 +18,12 @@ namespace NSCSS
|
||||
{
|
||||
typedef std::map<std::wstring, std::wstring>::const_iterator styles_iterator;
|
||||
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point)
|
||||
CCompiledStyle::CCompiledStyle() : m_nDpi(96), m_UnitMeasure(Point), m_dCoreFontSize(DEFAULT_FONT_SIZE)
|
||||
{}
|
||||
|
||||
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_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){}
|
||||
|
||||
@ -116,7 +116,10 @@ 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 dFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
|
||||
const double dParentFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
|
||||
|
||||
if (0 == unLevel)
|
||||
m_dCoreFontSize = dParentFontSize;
|
||||
|
||||
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
|
||||
{
|
||||
@ -128,15 +131,15 @@ namespace NSCSS
|
||||
CASE(L"font"):
|
||||
{
|
||||
m_oFont.SetValue(pPropertie.second, unLevel, bHardMode);
|
||||
m_oFont.UpdateSize(dFontSize);
|
||||
m_oFont.UpdateLineHeight(dFontSize);
|
||||
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
|
||||
m_oFont.UpdateLineHeight(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"font-size"):
|
||||
CASE(L"font-size-adjust"):
|
||||
{
|
||||
m_oFont.SetSize(pPropertie.second, unLevel, bHardMode);
|
||||
m_oFont.UpdateSize(dFontSize);
|
||||
m_oFont.UpdateSize(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"font-stretch"):
|
||||
@ -176,7 +179,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetValues(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateAll(dFontSize);
|
||||
m_oMargin.UpdateAll(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-top"):
|
||||
@ -196,7 +199,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetRight(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateRight(dFontSize);
|
||||
m_oMargin.UpdateRight(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-bottom"):
|
||||
@ -206,7 +209,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetBottom(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateBottom(dFontSize);
|
||||
m_oMargin.UpdateBottom(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-left"):
|
||||
@ -217,7 +220,7 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateLeft(dFontSize);
|
||||
m_oMargin.UpdateLeft(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
//PADDING
|
||||
@ -225,35 +228,35 @@ namespace NSCSS
|
||||
CASE(L"mso-padding-alt"):
|
||||
{
|
||||
m_oPadding.SetValues(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateAll(dFontSize);
|
||||
m_oPadding.UpdateAll(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-top"):
|
||||
CASE(L"mso-padding-top-alt"):
|
||||
{
|
||||
m_oPadding.SetTop(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateTop(dFontSize);
|
||||
m_oPadding.UpdateTop(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-right"):
|
||||
CASE(L"mso-padding-right-alt"):
|
||||
{
|
||||
m_oPadding.SetRight(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateRight(dFontSize);
|
||||
m_oPadding.UpdateRight(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-bottom"):
|
||||
CASE(L"mso-padding-bottom-alt"):
|
||||
{
|
||||
m_oPadding.SetBottom(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateBottom(dFontSize);
|
||||
m_oPadding.UpdateBottom(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"padding-left"):
|
||||
CASE(L"mso-padding-left-alt"):
|
||||
{
|
||||
m_oPadding.SetLeft(pPropertie.second, unLevel, bHardMode);
|
||||
m_oPadding.UpdateLeft(dFontSize);
|
||||
m_oPadding.UpdateLeft(dParentFontSize, m_dCoreFontSize);
|
||||
break;
|
||||
}
|
||||
// TEXT
|
||||
|
||||
@ -22,6 +22,7 @@ namespace NSCSS
|
||||
unsigned short int m_nDpi;
|
||||
UnitMeasure m_UnitMeasure;
|
||||
|
||||
double m_dCoreFontSize;
|
||||
public:
|
||||
NSProperties::CFont m_oFont;
|
||||
NSProperties::CIndent m_oMargin;
|
||||
|
||||
@ -13,14 +13,14 @@ namespace NSCSS
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure) const
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(arSelectors, bIsSettings, unitMeasure);
|
||||
return m_pInternal->GetCompiledStyle(arSelectors);
|
||||
}
|
||||
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure) const
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
@ -48,26 +48,11 @@ namespace NSCSS
|
||||
m_pInternal->AddStylesFromFile(wsFileName);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetUnitMeasure(const UnitMeasure& nType)
|
||||
{
|
||||
m_pInternal->SetUnitMeasure(nType);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetDpi(const unsigned short int& nValue)
|
||||
{
|
||||
m_pInternal->SetDpi(nValue);
|
||||
}
|
||||
|
||||
void CCssCalculator::SetBodyTree(const CTree &oTree)
|
||||
{
|
||||
m_pInternal->SetBodyTree(oTree);
|
||||
}
|
||||
|
||||
UnitMeasure CCssCalculator::GetUnitMeasure() const
|
||||
{
|
||||
return m_pInternal->GetUnitMeasure();
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::GetEncoding() const
|
||||
{
|
||||
return m_pInternal->GetEncoding();
|
||||
|
||||
@ -19,8 +19,8 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
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;
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors) const;
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors) const;
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
@ -30,11 +30,8 @@ namespace NSCSS
|
||||
void AddStyles (const std::wstring& wsStyle);
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void SetUnitMeasure(const UnitMeasure& nType);
|
||||
void SetDpi(const unsigned short int& nValue);
|
||||
void SetBodyTree(const CTree &oTree);
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ bool operator<(const std::vector<NSCSS::CNode> &arLeftSelectors, const std::vect
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_UnitMeasure(Point), m_mStatictics(NULL), m_sEncoding(L"UTF-8"){}
|
||||
CCssCalculator_Private::CCssCalculator_Private() : m_nDpi(96), m_nCountNodes(0), m_sEncoding(L"UTF-8"){}
|
||||
|
||||
CCssCalculator_Private::~CCssCalculator_Private()
|
||||
{
|
||||
@ -52,9 +52,6 @@ namespace NSCSS
|
||||
delete oIter->second;
|
||||
|
||||
m_mData.clear();
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
delete m_mStatictics;
|
||||
}
|
||||
|
||||
inline void CCssCalculator_Private::GetOutputData(KatanaOutput *oOutput)
|
||||
@ -155,7 +152,7 @@ namespace NSCSS
|
||||
arFindedElements.insert(arFindedElements.end(), arTempKins.begin(), arTempKins.end());
|
||||
}
|
||||
|
||||
std::vector<CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes, bool bIsSettings)
|
||||
std::vector<CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
return {};
|
||||
@ -193,17 +190,10 @@ namespace NSCSS
|
||||
{
|
||||
oFindId = m_mData.find(wsId);
|
||||
|
||||
if (oFindId != m_mData.end() && NULL != m_mStatictics)
|
||||
if (m_mData.cend() != oFindId)
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFindCountId = m_mStatictics->find(StatistickElement{StatistickElement::IsId, wsId});
|
||||
|
||||
if ((m_mStatictics->end() != oFindCountId) &&
|
||||
(((bIsSettings && oFindCountId->second < MaxNumberRepetitions) ||
|
||||
(!bIsSettings && oFindCountId->second >= MaxNumberRepetitions))))
|
||||
{
|
||||
if (!oFindId->second->Empty())
|
||||
arFindedElements.push_back(oFindId->second);
|
||||
}
|
||||
if (!oFindId->second->Empty())
|
||||
arFindedElements.push_back(oFindId->second);
|
||||
|
||||
FindPrevAndKindElements(oFindId->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
@ -211,40 +201,34 @@ namespace NSCSS
|
||||
|
||||
if (!arClasses.empty())
|
||||
{
|
||||
if (!bIsSettings)
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
|
||||
{
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iClass = arClasses.rbegin(); iClass != arClasses.rend(); ++iClass)
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
|
||||
if (oFindClass != m_mData.cend())
|
||||
{
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindClass = m_mData.find(*iClass);
|
||||
if (oFindClass != m_mData.end())
|
||||
{
|
||||
if (!oFindClass->second->Empty())
|
||||
arFindedElements.push_back(oFindClass->second);
|
||||
if (!oFindClass->second->Empty())
|
||||
arFindedElements.push_back(oFindClass->second);
|
||||
|
||||
FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
FindPrevAndKindElements(oFindClass->second, arNextNodes, arFindedElements, wsName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (oFindName != m_mData.end())
|
||||
if (oFindName != m_mData.cend())
|
||||
{
|
||||
if (!bIsSettings)
|
||||
{
|
||||
if (!oFindName->second->Empty())
|
||||
arFindedElements.push_back(oFindName->second);
|
||||
if (!oFindName->second->Empty())
|
||||
arFindedElements.push_back(oFindName->second);
|
||||
|
||||
FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
FindPrevAndKindElements(oFindName->second, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
[](CElement* oFirstElement, CElement* oSecondElement)
|
||||
{
|
||||
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
|
||||
});
|
||||
[](CElement* oFirstElement, CElement* oSecondElement)
|
||||
{
|
||||
return oFirstElement->GetWeight() > oSecondElement->GetWeight();
|
||||
});
|
||||
}
|
||||
|
||||
return arFindedElements;
|
||||
@ -473,46 +457,32 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors, const bool& bIsSettings, const UnitMeasure& unitMeasure)
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
GetCompiledStyle(oStyle, arSelectors);
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors, const bool &bIsSettings, const UnitMeasure &unitMeasure)
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
SetUnitMeasure(unitMeasure);
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (!bIsSettings)
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (NULL == m_mStatictics || m_mStatictics->empty())
|
||||
{
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
oStyle.SetUnitMeasure(m_UnitMeasure);
|
||||
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
|
||||
|
||||
return false;
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
oStyle.SetUnitMeasure(m_UnitMeasure);
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
@ -535,25 +505,10 @@ namespace NSCSS
|
||||
|
||||
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes, bIsSettings))
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
{
|
||||
std::map<StatistickElement, unsigned int>::const_iterator oFindCountStyle = m_mStatictics->find(StatistickElement{StatistickElement::IsStyle, arSelectors[i].m_wsStyle});
|
||||
|
||||
if (oFindCountStyle != m_mStatictics->end())
|
||||
{
|
||||
if ((bIsSettings && oFindCountStyle->second < MaxNumberRepetitions) ||
|
||||
(!bIsSettings && oFindCountStyle->second >= MaxNumberRepetitions))
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
else if (!bIsSettings)
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
}
|
||||
else /*if (bIsSettings)*/
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
}
|
||||
else
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
oStyle += oTempStyle;
|
||||
@ -569,7 +524,7 @@ namespace NSCSS
|
||||
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!bIsSettings && !oStyle.Empty())
|
||||
if (!oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
@ -597,7 +552,7 @@ namespace NSCSS
|
||||
SetPageData(oPageData, GetPageData(mRules[L"page"]), i + 1, true);
|
||||
}
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arNextNodes, false))
|
||||
for (const CElement* oElement : FindElements(arNodes, arNextNodes))
|
||||
{
|
||||
std::map<std::wstring, std::wstring> mRules = oElement->GetStyle();
|
||||
if (mRules.end() != mRules.find(L"page"))
|
||||
@ -654,19 +609,6 @@ namespace NSCSS
|
||||
m_nDpi = nValue;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetBodyTree(const CTree &oTree)
|
||||
{
|
||||
if (NULL == m_mStatictics)
|
||||
m_mStatictics = new std::map<StatistickElement, unsigned int>();
|
||||
|
||||
CTree::CountingNumberRepetitions(oTree, *m_mStatictics);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetUnitMeasure(const UnitMeasure& nType)
|
||||
{
|
||||
m_UnitMeasure = nType;
|
||||
}
|
||||
|
||||
unsigned short int CCssCalculator_Private::GetDpi() const
|
||||
{
|
||||
return m_nDpi;
|
||||
@ -677,11 +619,6 @@ namespace NSCSS
|
||||
return &m_mData;
|
||||
}
|
||||
|
||||
UnitMeasure CCssCalculator_Private::GetUnitMeasure() const
|
||||
{
|
||||
return m_UnitMeasure;
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator_Private::GetEncoding() const
|
||||
{
|
||||
return m_sEncoding;
|
||||
@ -691,7 +628,6 @@ namespace NSCSS
|
||||
{
|
||||
m_sEncoding = L"UTF-8";
|
||||
m_nDpi = 96;
|
||||
m_UnitMeasure = Point;
|
||||
|
||||
m_mData.clear();
|
||||
m_arFiles.clear();
|
||||
|
||||
@ -20,7 +20,6 @@ namespace NSCSS
|
||||
{
|
||||
unsigned short int m_nDpi;
|
||||
unsigned short int m_nCountNodes;
|
||||
UnitMeasure m_UnitMeasure;
|
||||
|
||||
std::list<std::wstring> m_arFiles;
|
||||
|
||||
@ -34,8 +33,6 @@ namespace NSCSS
|
||||
|
||||
std::vector<TPageData> m_arPageDatas;
|
||||
|
||||
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
|
||||
|
||||
@ -45,7 +42,7 @@ namespace NSCSS
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
|
||||
|
||||
void FindPrevAndKindElements(const CElement* pElement, const std::vector<std::wstring>& arNextNodes, std::vector<CElement*>& arFindedElements, const std::wstring& wsName, const std::vector<std::wstring>& arClasses = {});
|
||||
std::vector<CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes, bool bIsSettings);
|
||||
std::vector<CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
#endif
|
||||
|
||||
std::wstring m_sEncoding;
|
||||
@ -72,8 +69,8 @@ namespace NSCSS
|
||||
~CCssCalculator_Private();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
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);
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors);
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors);
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
@ -83,11 +80,8 @@ namespace NSCSS
|
||||
void AddStyles(const std::wstring& wsStyle);
|
||||
void AddStylesFromFile(const std::wstring& wsFileName);
|
||||
|
||||
void SetUnitMeasure(const UnitMeasure& nType);
|
||||
void SetDpi(unsigned short int nValue);
|
||||
void SetBodyTree(const CTree &oTree);
|
||||
|
||||
UnitMeasure GetUnitMeasure() const;
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
|
||||
@ -2,29 +2,6 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
bool StatistickElement::operator<(const StatistickElement &oStatistickElement) const
|
||||
{
|
||||
return sValue < oStatistickElement.sValue;
|
||||
}
|
||||
|
||||
void CTree::Clear()
|
||||
{
|
||||
m_arrChild.clear();
|
||||
m_oNode.Clear();
|
||||
}
|
||||
|
||||
void CTree::CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics)
|
||||
{
|
||||
if (!oTree.m_oNode.m_wsId.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsId, L'#' + oTree.m_oNode.m_wsId}];
|
||||
if (!oTree.m_oNode.m_wsStyle.empty())
|
||||
++mStatictics[StatistickElement{StatistickElement::IsStyle, oTree.m_oNode.m_wsStyle}];
|
||||
|
||||
if (!oTree.m_arrChild.empty())
|
||||
for (const CTree& oChildren : oTree.m_arrChild)
|
||||
CountingNumberRepetitions(oChildren, mStatictics);
|
||||
}
|
||||
|
||||
namespace NSConstValues
|
||||
{
|
||||
const std::map<std::wstring, std::wstring> COLORS
|
||||
|
||||
@ -16,28 +16,6 @@ namespace NSCSS
|
||||
ScalingDirectionY = 2
|
||||
} ScalingDirection;
|
||||
|
||||
struct StatistickElement
|
||||
{
|
||||
enum TypeElement
|
||||
{
|
||||
IsStyle = 0,
|
||||
IsId
|
||||
} m_enType;
|
||||
std::wstring sValue;
|
||||
|
||||
bool operator<(const StatistickElement& oStatistickElement) const;
|
||||
};
|
||||
|
||||
struct CTree
|
||||
{
|
||||
NSCSS::CNode m_oNode;
|
||||
std::vector<CTree> m_arrChild;
|
||||
|
||||
void Clear();
|
||||
|
||||
static void CountingNumberRepetitions(const CTree &oTree, std::map<StatistickElement, unsigned int> &mStatictics);
|
||||
};
|
||||
|
||||
namespace NSConstValues
|
||||
{
|
||||
extern const std::map<std::wstring, std::wstring> COLORS;
|
||||
|
||||
@ -2301,32 +2301,32 @@ namespace NSCSS
|
||||
return m_oLeft.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CIndent::UpdateAll(double dFontSize)
|
||||
void CIndent::UpdateAll(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateTop (dFontSize);
|
||||
UpdateRight (dFontSize);
|
||||
UpdateBottom(dFontSize);
|
||||
UpdateLeft (dFontSize);
|
||||
UpdateTop (dParentFontSize, dCoreFontSize);
|
||||
UpdateRight (dParentFontSize, dCoreFontSize);
|
||||
UpdateBottom(dParentFontSize, dCoreFontSize);
|
||||
UpdateLeft (dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateTop(double dFontSize)
|
||||
void CIndent::UpdateTop(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oTop, dFontSize);
|
||||
UpdateSide(m_oTop, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateRight(double dFontSize)
|
||||
void CIndent::UpdateRight(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oRight, dFontSize);
|
||||
UpdateSide(m_oRight, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateBottom(double dFontSize)
|
||||
void CIndent::UpdateBottom(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oBottom, dFontSize);
|
||||
UpdateSide(m_oBottom, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CIndent::UpdateLeft(double dFontSize)
|
||||
void CIndent::UpdateLeft(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
UpdateSide(m_oLeft, dFontSize);
|
||||
UpdateSide(m_oLeft, dParentFontSize, dCoreFontSize);
|
||||
}
|
||||
|
||||
const CDigit &CIndent::GetTop() const
|
||||
@ -2395,13 +2395,15 @@ namespace NSCSS
|
||||
return bTopResult || bRightResult || bBottomResult || bLeftResult;
|
||||
}
|
||||
|
||||
void CIndent::UpdateSide(CDigit &oSide, double dFontSize)
|
||||
void CIndent::UpdateSide(CDigit &oSide, const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
if (oSide.Empty())
|
||||
return;
|
||||
|
||||
if (NSCSS::Em == oSide.GetUnitMeasure() || NSCSS::Rem == oSide.GetUnitMeasure())
|
||||
oSide.ConvertTo(NSCSS::Twips, dFontSize);
|
||||
if (NSCSS::Em == oSide.GetUnitMeasure())
|
||||
oSide.ConvertTo(NSCSS::Twips, dParentFontSize);
|
||||
else if (NSCSS::Rem == oSide.GetUnitMeasure())
|
||||
oSide.ConvertTo(NSCSS::Twips, dCoreFontSize);
|
||||
}
|
||||
|
||||
// FONT
|
||||
@ -2644,16 +2646,20 @@ namespace NSCSS
|
||||
std::make_pair(L"700", L"bold"), std::make_pair(L"800", L"bold"), std::make_pair(L"900", L"bold")}, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CFont::UpdateSize(double dFontSize)
|
||||
void CFont::UpdateSize(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
if (NSCSS::Em == m_oSize.GetUnitMeasure() || NSCSS::Rem == m_oSize.GetUnitMeasure() || NSCSS::Percent == m_oSize.GetUnitMeasure())
|
||||
m_oSize.ConvertTo(NSCSS::Point, dFontSize);
|
||||
if (NSCSS::Em == m_oSize.GetUnitMeasure() || NSCSS::Percent == m_oSize.GetUnitMeasure())
|
||||
m_oSize.ConvertTo(NSCSS::Point, dParentFontSize);
|
||||
else if (NSCSS::Rem == m_oSize.GetUnitMeasure())
|
||||
m_oSize.ConvertTo(NSCSS::Point, dCoreFontSize);
|
||||
}
|
||||
|
||||
void CFont::UpdateLineHeight(double dFontSize)
|
||||
void CFont::UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
{
|
||||
if (NSCSS::Em == m_oLineHeight.GetUnitMeasure() || NSCSS::Rem == m_oLineHeight.GetUnitMeasure())
|
||||
m_oLineHeight.ConvertTo(NSCSS::Twips, dFontSize);
|
||||
if (NSCSS::Em == m_oLineHeight.GetUnitMeasure())
|
||||
m_oLineHeight.ConvertTo(NSCSS::Twips, dParentFontSize);
|
||||
else if (NSCSS::Rem == m_oLineHeight.GetUnitMeasure())
|
||||
m_oLineHeight.ConvertTo(NSCSS::Twips, dCoreFontSize);
|
||||
}
|
||||
|
||||
bool CFont::Bold() const
|
||||
|
||||
@ -656,11 +656,11 @@ namespace NSCSS
|
||||
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateAll (double dFontSize);
|
||||
void UpdateTop (double dFontSize);
|
||||
void UpdateRight (double dFontSize);
|
||||
void UpdateBottom(double dFontSize);
|
||||
void UpdateLeft (double dFontSize);
|
||||
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);
|
||||
|
||||
const CDigit& GetTop () const;
|
||||
const CDigit& GetRight () const;
|
||||
@ -675,7 +675,7 @@ namespace NSCSS
|
||||
bool operator!=(const CIndent& oIndent) const;
|
||||
private:
|
||||
bool SetValues(const std::wstring& wsTopValue, const std::wstring& wsRightValue, const std::wstring& wsBottomValue, const std::wstring& wsLeftValue, unsigned int unLevel, bool bHardMode = false);
|
||||
void UpdateSide(CDigit& oSide, double dFontSize);
|
||||
void UpdateSide(CDigit& oSide, const double& dParentFontSize, const double& dCoreFontSize);
|
||||
|
||||
CDigit m_oLeft;
|
||||
CDigit m_oTop;
|
||||
@ -702,8 +702,8 @@ namespace NSCSS
|
||||
bool SetVariant (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateSize(double dFontSize);
|
||||
void UpdateLineHeight(double dFontSize);
|
||||
void UpdateSize(const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateLineHeight(const double& dParentFontSize, const double& dCoreFontSize);
|
||||
|
||||
void Clear();
|
||||
|
||||
|
||||
@ -55,6 +55,11 @@ static void replace_all(std::string& s, const std::string& s1, const std::string
|
||||
}
|
||||
}
|
||||
|
||||
static bool NodeIsUnprocessed(const std::string& wsTagName)
|
||||
{
|
||||
return "xml" == wsTagName;
|
||||
}
|
||||
|
||||
static bool IsUnckeckedNodes(const std::string& sValue)
|
||||
{
|
||||
return unchecked_nodes_new.end() != std::find(unchecked_nodes_new.begin(), unchecked_nodes_new.end(), sValue);
|
||||
@ -592,6 +597,9 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
if (bCheckValidNode)
|
||||
bCheckValidNode = !IsUnckeckedNodes(tagname);
|
||||
|
||||
|
||||
1
Common/3dParty/hunspell/.gitignore
vendored
1
Common/3dParty/hunspell/.gitignore
vendored
@ -2,3 +2,4 @@ emsdk/
|
||||
hunspell/
|
||||
deploy/
|
||||
o
|
||||
hunspell.data
|
||||
|
||||
@ -14,6 +14,12 @@ 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("../")
|
||||
|
||||
|
||||
|
||||
@ -14,12 +14,32 @@ 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)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter kernel hunspell)
|
||||
# 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
|
||||
|
||||
|
||||
@ -20,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 -fembed-bitcode"
|
||||
CFLAGS="-O3 -D__STDC_INT64__ -fno-exceptions -fno-short-wchar -fno-short-enums"
|
||||
|
||||
CXXFLAGS="${CFLAGS} -std=c++11 -fembed-bitcode"
|
||||
CXXFLAGS="${CFLAGS} -std=c++11"
|
||||
|
||||
#will set value to 1
|
||||
defines_config_set_1=(
|
||||
@ -215,9 +215,9 @@ function build() {
|
||||
|
||||
export CXX="$(xcrun -find clang++)"
|
||||
export CC="$(xcrun -find clang)"
|
||||
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}"
|
||||
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}"
|
||||
|
||||
mkdir -p ${BUILD_DIR}
|
||||
cd ${BUILD_DIR}
|
||||
|
||||
@ -84,24 +84,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} -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"
|
||||
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"
|
||||
;;
|
||||
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} -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"
|
||||
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"
|
||||
;;
|
||||
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} -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"
|
||||
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"
|
||||
;;
|
||||
i386)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch i386"
|
||||
@ -120,9 +120,9 @@ function set_ios_cpu_feature() {
|
||||
sim-arm64)
|
||||
export CC="xcrun -sdk iphonesimulator clang -arch arm64"
|
||||
export CXX="xcrun -sdk iphonesimulator clang++ -arch arm64"
|
||||
export CFLAGS="-arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -fembed-bitcode -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aaarch64-apple-darwin -march=armv8 -isysroot ${sysroot} -fembed-bitcode -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -fembed-bitcode -DIOS -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export CFLAGS="-arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -Wno-unused-function -fstrict-aliasing -Oz -Wno-ignored-optimization-argument -DIOS -isysroot ${sysroot} -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
export LDFLAGS="-arch arm64 -target aaarch64-apple-darwin -march=armv8 -isysroot ${sysroot} -L${sysroot}/usr/lib "
|
||||
export CXXFLAGS="-std=c++11 -arch arm64 -target aarch64-apple-darwin -march=armv8 -mcpu=generic -fstrict-aliasing -DIOS -mios-simulator-version-min=${ios_min_target} -I${sysroot}/usr/include"
|
||||
;;
|
||||
*)
|
||||
log_error "not support" && exit 1
|
||||
|
||||
@ -107,26 +107,26 @@ function configure_make() {
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "arm64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "i386" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure darwin-i386-cc no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
sed -i -e 's/-mtune=intel//g' "Makefile"
|
||||
|
||||
elif [[ "${ARCH_NAME}" == "sim_arm64" ]]; then
|
||||
|
||||
# openssl1.1.1d can be set normally, 1.1.0f does not take effect
|
||||
./Configure iphoneos-cross no-shared --prefix="${PREFIX_DIR}" enable-ssl3 enable-ssl3-method enable-md2
|
||||
sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
#sed -ie "s!-fno-common!-fno-common -fembed-bitcode !" "Makefile"
|
||||
|
||||
else
|
||||
log_error "not support" && exit 1
|
||||
|
||||
@ -244,3 +244,4 @@
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_LIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005d)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_ROWLIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005e)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_DETECT (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x005f)
|
||||
#define AVS_FILEUTILS_ERROR_CONVERT_CELLLIMITS (AVS_ERROR_FIRST + AVS_FILEUTILS_ERROR_FIRST + 0x0060)
|
||||
|
||||
@ -740,13 +740,33 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
if (OfficeUtils.IsArchive(fileName) == S_OK && (false == isPdfFormatFile(bufferDetect, dwDetectdBytes, sDocumentID)))
|
||||
{
|
||||
if (isOOXFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOpenOfficeFormatFile(fileName, sDocumentID))
|
||||
return true;
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOnlyOfficeFormatFile(fileName))
|
||||
return true;
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isXpsFile(fileName))
|
||||
return true;
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -879,6 +899,12 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
else if (0 == sExt.compare(L".numbers"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
else if (0 == sExt.compare(L".key"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
@ -1345,6 +1371,7 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOTM:
|
||||
return L".dotm";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_DOC_FLAT:
|
||||
return L".doc";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT:
|
||||
return L".odt";
|
||||
|
||||
@ -56,6 +56,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0015
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCXF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0016
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0017
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
@ -72,6 +73,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000a
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX_PACKAGE AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000b
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000c
|
||||
#define AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY AVS_OFFICESTUDIO_FILE_PRESENTATION + 0x000d
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET 0x0100
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x0001
|
||||
@ -87,6 +89,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000a
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000b
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_PACKAGE AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000c
|
||||
#define AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS AVS_OFFICESTUDIO_FILE_SPREADSHEET + 0x000d
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM 0x0200
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0001
|
||||
|
||||
@ -148,7 +148,7 @@ mac {
|
||||
CONFIG += core_mac
|
||||
CONFIG += core_mac_64
|
||||
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ core_mac {
|
||||
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.11
|
||||
QMAKE_LFLAGS += -isysroot $$QMAKE_MAC_SDK_PATH
|
||||
|
||||
# xcode15 add new linker
|
||||
# xcode15 add new linker
|
||||
QMAKE_LFLAGS += -Wl,-ld_classic
|
||||
|
||||
QMAKE_CFLAGS += "-Wno-implicit-function-declaration"
|
||||
@ -301,22 +301,25 @@ linux_arm64 {
|
||||
core_ios {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = ios
|
||||
|
||||
!versionAtLeast(QMAKE_XCODE_VERSION, 16.0) {
|
||||
QMAKE_CFLAGS += -fembed-bitcode
|
||||
QMAKE_CXXFLAGS += -fembed-bitcode
|
||||
QMAKE_LFLAGS += -fembed-bitcode
|
||||
} else {
|
||||
CONFIG -= bitcode
|
||||
}
|
||||
|
||||
|
||||
CONFIG(iphonesimulator, iphoneos|iphonesimulator): {
|
||||
message("iphonesimulator")
|
||||
CORE_BUILDS_PLATFORM_PREFIX = ios_simulator
|
||||
|
||||
QMAKE_CFLAGS += -fembed-bitcode
|
||||
QMAKE_CXXFLAGS += -fembed-bitcode
|
||||
QMAKE_LFLAGS += -fembed-bitcode
|
||||
QMAKE_CFLAGS += -fobjc-arc
|
||||
QMAKE_CXXFLAGS += -fobjc-arc
|
||||
} else {
|
||||
|
||||
QMAKE_IOS_DEPLOYMENT_TARGET = 11.0
|
||||
|
||||
QMAKE_CFLAGS += -fembed-bitcode
|
||||
QMAKE_CXXFLAGS += -fembed-bitcode
|
||||
QMAKE_LFLAGS += -fembed-bitcode
|
||||
QMAKE_CFLAGS += -fobjc-arc
|
||||
QMAKE_CXXFLAGS += -fobjc-arc
|
||||
|
||||
@ -573,7 +576,7 @@ defineTest(ADD_DEPENDENCY) {
|
||||
libs = $$ARGS
|
||||
for(lib, libs) {
|
||||
CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH
|
||||
|
||||
|
||||
isEqual(lib, videoplayer) {
|
||||
libvlc {
|
||||
CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH/mediaplayer
|
||||
@ -586,7 +589,7 @@ defineTest(ADD_DEPENDENCY) {
|
||||
isEqual(lib, qtascdocumentscore):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH_DST/xp
|
||||
isEqual(lib, videoplayer):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH_DST/xp
|
||||
isEqual(lib, ooxmlsignature):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH_DST/xp
|
||||
}
|
||||
}
|
||||
!bundle_dylibs:LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH_DST -l$$lib
|
||||
bundle_dylibs:LIBS += -F$$CORE_BUILDS_LIBRARIES_PATH_DST -framework $$lib
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <stdio.h>
|
||||
#define LOG_BUFFER_SIZE 1000
|
||||
|
||||
// not intended for use in production. only for testing/debugging purposes
|
||||
namespace Logging
|
||||
{
|
||||
void logBytes(char* name, unsigned char* str, int len)
|
||||
|
||||
@ -847,40 +847,10 @@ namespace agg
|
||||
if (calculate_tensor_coefs)
|
||||
calculate_tensor();
|
||||
|
||||
float minxres = m_oGradientInfo.shading.patch[0][0].x;
|
||||
float minyres = m_oGradientInfo.shading.patch[0][0].y;
|
||||
float maxxres = m_oGradientInfo.shading.patch[0][0].x;
|
||||
float maxyres = m_oGradientInfo.shading.patch[0][0].y;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int j = 0; j < 4; j++)
|
||||
{
|
||||
if (m_oGradientInfo.shading.patch[i][j].x > maxxres)
|
||||
{
|
||||
maxxres = m_oGradientInfo.shading.patch[i][j].x;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].y > maxyres)
|
||||
{
|
||||
maxyres = m_oGradientInfo.shading.patch[i][j].y;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].x < minxres)
|
||||
{
|
||||
minxres = m_oGradientInfo.shading.patch[i][j].x;
|
||||
}
|
||||
if (m_oGradientInfo.shading.patch[i][j].y < minyres)
|
||||
{
|
||||
minyres = m_oGradientInfo.shading.patch[i][j].y;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RES = std::max(1.0f, std::max(maxxres - minxres, maxyres - minyres) / 3);
|
||||
float delta = 1.0 / RES;
|
||||
float u = 0, v = 0;
|
||||
auto start_p = get_p_curve(u, v);
|
||||
xmax_curve = xmin_curve = start_p.x;
|
||||
ymax_curve = ymin_curve = start_p.y;
|
||||
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
|
||||
|
||||
/*
|
||||
* Небольшая оптимизация основанная на том, что данная фигура не выходит за границы своих опорных точек.
|
||||
@ -918,7 +888,7 @@ namespace agg
|
||||
RES = nRES;
|
||||
}
|
||||
precalc = std::vector<std::vector<ColorT>>(RES, std::vector<ColorT>(RES, {0, 0, 0, 0}));
|
||||
delta = 1.0f / RES;
|
||||
float delta = 1.0f / RES;
|
||||
std::vector<std::pair<int, int>> next_indexes(RES + 1);
|
||||
u = 0;
|
||||
for (int i = 0; i < RES; ++i)
|
||||
@ -956,8 +926,6 @@ namespace agg
|
||||
}
|
||||
ColorT ifswapRGB(const ColorT &c)
|
||||
{
|
||||
|
||||
|
||||
if (m_bSwapRGB) {
|
||||
return c;
|
||||
}
|
||||
|
||||
@ -250,3 +250,123 @@ namespace NSBase64
|
||||
return Base64DecodeBase(szSrc, nSrcLen, pbDest, pnDestLen);
|
||||
}
|
||||
}
|
||||
|
||||
#include <cstring>
|
||||
namespace NSBase32
|
||||
{
|
||||
const unsigned char PADDING_CHAR_32 = '=';
|
||||
|
||||
inline void pad(unsigned char* buf, int len)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
buf[i] = PADDING_CHAR_32;
|
||||
}
|
||||
inline unsigned char shift_right(unsigned char byte, signed char offset)
|
||||
{
|
||||
if (offset > 0)
|
||||
return byte >> offset;
|
||||
else
|
||||
return byte << -offset;
|
||||
}
|
||||
inline unsigned char shift_left(unsigned char byte, signed char offset)
|
||||
{
|
||||
return shift_right(byte, - offset);
|
||||
}
|
||||
|
||||
unsigned char encode_char(unsigned char c)
|
||||
{
|
||||
static unsigned char base32[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
|
||||
return base32[c & 0x1F];
|
||||
}
|
||||
|
||||
int decode_char(unsigned char c)
|
||||
{
|
||||
char retval = -2;
|
||||
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
retval = c - 'A';
|
||||
else if (c >= '2' && c <= '7')
|
||||
retval = c - '2' + 26;
|
||||
else if (c == PADDING_CHAR_32)
|
||||
retval = -1;
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
int decode_sequence(const unsigned char* coded, unsigned char* plain)
|
||||
{
|
||||
plain[0] = 0;
|
||||
for (int block = 0; block < 8; block++)
|
||||
{
|
||||
int offset = (8 - 5 - (5*block) % 8);
|
||||
int octet = (block*5) / 8;
|
||||
|
||||
int c = decode_char(coded[block]);
|
||||
if (c < 0)
|
||||
return c;
|
||||
|
||||
plain[octet] |= shift_left(c, offset);
|
||||
if (offset < 0)
|
||||
{ // does this block overflows to next octet?
|
||||
plain[octet+1] = shift_left(c, 8 + offset);
|
||||
}
|
||||
}
|
||||
return 5;
|
||||
}
|
||||
|
||||
bool Decode(unsigned char* in, int inLen, unsigned char* out)
|
||||
{
|
||||
for (size_t i = 0, j = 0; (i + 8) <= inLen; i += 8, j += 5)
|
||||
{
|
||||
int n = decode_sequence(&in[i], &out[j]);
|
||||
if (n == -2)
|
||||
return false;
|
||||
if (n < 5)
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void encode_sequence(const unsigned char* plain, int len, unsigned char* coded)
|
||||
{
|
||||
for (int block = 0; block < 8; block++)
|
||||
{
|
||||
int octet = (block*5) / 8;
|
||||
int junk = (8 - 5 - (5*block) % 8);
|
||||
|
||||
if (octet >= len)
|
||||
{
|
||||
pad(&coded[block], 8 - block);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char c = shift_right(plain[octet], junk); // first part
|
||||
|
||||
if (junk < 0 // is there a second part?
|
||||
&& octet < len - 1) // is there still something to read?
|
||||
{
|
||||
c |= shift_right(plain[octet+1], 8 + junk);
|
||||
}
|
||||
coded[block] = encode_char(c);
|
||||
}
|
||||
}
|
||||
|
||||
bool Encode(unsigned char* src, int len, unsigned char* dst)
|
||||
{
|
||||
for (int i = 0, j = 0; i < len; i += 5, j += 8)
|
||||
{
|
||||
int tmpLen = len - i;
|
||||
encode_sequence(&src[i], tmpLen > 5 ? 5 : tmpLen, &dst[j]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int DecodeGetRequiredLength(int bytes)
|
||||
{
|
||||
return (((bytes)/8)*5);
|
||||
}
|
||||
int EncodeGetRequiredLength(int bytes)
|
||||
{
|
||||
return (((bytes)/5)*8 + ((bytes) % 5 ? 8 : 0));
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,4 +58,13 @@ namespace NSBase64
|
||||
KERNEL_DECL int Base64Decode(const wchar_t* szSrc, int nSrcLen, BYTE *pbDest, int *pnDestLen);
|
||||
}
|
||||
|
||||
namespace NSBase32
|
||||
{
|
||||
KERNEL_DECL bool Decode(unsigned char* in, int inLen, unsigned char* out);
|
||||
KERNEL_DECL bool Encode(unsigned char* in, int inLen, unsigned char* out);
|
||||
|
||||
KERNEL_DECL int DecodeGetRequiredLength(int bytes);
|
||||
KERNEL_DECL int EncodeGetRequiredLength(int bytes);
|
||||
}
|
||||
|
||||
#endif//_BUILD_BASE64_CROSSPLATFORM_DEFINE
|
||||
|
||||
@ -1535,6 +1535,11 @@ namespace NSFile
|
||||
return bIsSuccess;
|
||||
}
|
||||
|
||||
bool CFileBinary::IsGlobalTempPathUse()
|
||||
{
|
||||
return g_overrideTmpPath.empty() ? false : true;
|
||||
}
|
||||
|
||||
std::wstring CFileBinary::GetTempPath()
|
||||
{
|
||||
if (!g_overrideTmpPath.empty())
|
||||
|
||||
@ -189,6 +189,7 @@ namespace NSFile
|
||||
|
||||
static void SetTempPath(const std::wstring& strTempPath);
|
||||
static std::wstring GetTempPath();
|
||||
static bool IsGlobalTempPathUse();
|
||||
|
||||
static std::wstring CreateTempFileWithUniqueName(const std::wstring& strFolderPathRoot, const std::wstring& Prefix);
|
||||
static bool OpenTempFile(std::wstring *pwsName, FILE **ppFile, wchar_t *wsMode, wchar_t *wsExt, wchar_t *wsFolder, wchar_t* wsName = NULL);
|
||||
|
||||
@ -648,7 +648,7 @@ namespace NSStringUtils
|
||||
}
|
||||
void CStringBuilder::AddInt(int val)
|
||||
{
|
||||
AddSize(10);
|
||||
AddSize(11);
|
||||
AddIntNoCheck(val);
|
||||
}
|
||||
void CStringBuilder::AddUInt(unsigned int val)
|
||||
@ -682,7 +682,11 @@ namespace NSStringUtils
|
||||
}
|
||||
if (val < 0)
|
||||
{
|
||||
val = -val;
|
||||
if (val == -2147483648)
|
||||
val = 2147483647;
|
||||
else
|
||||
val = -val;
|
||||
|
||||
*m_pDataCur++ = (wchar_t)'-';
|
||||
++m_lSizeCur;
|
||||
}
|
||||
|
||||
@ -145,13 +145,23 @@ namespace NSDoctRenderer
|
||||
NSHyphen::CEngine::Init(private_GetFile(sConfigDir, oNodeDict.GetText()));
|
||||
}
|
||||
|
||||
bool bIsAbsoluteFontsPath = false;
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
std::wstring sAllFontsPath = oNode.ReadNodeText(L"allfonts");
|
||||
if (!sAllFontsPath.empty())
|
||||
{
|
||||
m_strAllFonts = private_GetFile(sConfigDir, sAllFontsPath);
|
||||
if (NSFile::CFileBinary::Exists(sConfigDir + sAllFontsPath))
|
||||
m_strAllFonts = sConfigDir + sAllFontsPath;
|
||||
else if (NSFile::CFileBinary::Exists(sAllFontsPath))
|
||||
m_strAllFonts = sAllFontsPath;
|
||||
else
|
||||
{
|
||||
std::wstring sAllFontsDir = NSFile::GetDirectoryName(sAllFontsPath);
|
||||
if (NSDirectory::Exists(sConfigDir + sAllFontsDir))
|
||||
m_strAllFonts = sConfigDir + sAllFontsPath;
|
||||
else
|
||||
m_strAllFonts = sAllFontsPath;
|
||||
}
|
||||
|
||||
// на папку может не быть прав
|
||||
if (!NSFile::CFileBinary::Exists(m_strAllFonts))
|
||||
@ -163,8 +173,6 @@ namespace NSDoctRenderer
|
||||
if (NSDirectory::CreateDirectory(sAppDir + L"/docbuilder"))
|
||||
{
|
||||
m_strAllFonts = sAppDir + L"/docbuilder/AllFonts.js";
|
||||
// файл может не существовать пока - и тогда private_GetFile не учтет его
|
||||
bIsAbsoluteFontsPath = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -175,9 +183,6 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bIsAbsoluteFontsPath)
|
||||
m_strAllFonts = private_GetFile(sConfigDir, m_strAllFonts);
|
||||
}
|
||||
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
|
||||
@ -83,6 +83,10 @@ public class CDocBuilder {
|
||||
return new CDocBuilderContext(c_GetContext(c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderContext getContext(boolean enterContext) {
|
||||
return new CDocBuilderContext(c_GetContextWithEnterParam(c_internal, enterContext));
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
c_Initialize();
|
||||
}
|
||||
@ -135,6 +139,7 @@ public class CDocBuilder {
|
||||
private static native String c_GetVersion(long self);
|
||||
|
||||
private static native long c_GetContext(long self);
|
||||
private static native long c_GetContextWithEnterParam(long self, boolean enterContext);
|
||||
|
||||
private static native void c_Initialize();
|
||||
private static native void c_InitializeWithDirectory(String directory);
|
||||
|
||||
@ -40,7 +40,7 @@ public class NativeLibraryLoader {
|
||||
throw new RuntimeException("Unsupported OS");
|
||||
}
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "doctrenderer", "docbuilder.jni"};
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "PdfFile", "XpsFile", "DjVuFile", "DocxRenderer", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
String prefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
|
||||
@ -162,6 +162,12 @@ jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong s
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam(JNIEnv* env, jclass cls, jlong self, jboolean enterContext)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext((bool)enterContext)));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
|
||||
@ -167,6 +167,14 @@ JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_GetContextWithEnterParam
|
||||
* Signature: (JZ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContextWithEnterParam
|
||||
(JNIEnv *, jclass, jlong, jboolean);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Initialize
|
||||
|
||||
@ -17,7 +17,6 @@ public class Program {
|
||||
builder.createFile(FileTypes.Document.DOCX);
|
||||
|
||||
CDocBuilderContext context = builder.getContext();
|
||||
CDocBuilderContextScope scope = context.createScope();
|
||||
|
||||
CDocBuilderValue global = context.getGlobal();
|
||||
|
||||
|
||||
@ -203,7 +203,7 @@ def _loadLibrary(path):
|
||||
_lib.CDocBuilder_GetVersion.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_GetVersion.restype = STRING_HANDLE
|
||||
|
||||
_lib.CDocBuilder_GetContext.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_GetContext.argtypes = [OBJECT_HANDLE, ctypes.c_bool]
|
||||
_lib.CDocBuilder_GetContext.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilder_Initialize.argtypes = []
|
||||
@ -492,8 +492,8 @@ class CDocBuilder:
|
||||
_lib.DeleteCharP(ctypes.cast(strVersion, ctypes.c_char_p))
|
||||
return version
|
||||
|
||||
def GetContext(self):
|
||||
return CDocBuilderContext(OBJECT_HANDLE(_lib.CDocBuilder_GetContext(self._internal)))
|
||||
def GetContext(self, enterContext=True):
|
||||
return CDocBuilderContext(OBJECT_HANDLE(_lib.CDocBuilder_GetContext(self._internal, ctypes.c_bool(enterContext))))
|
||||
|
||||
@classmethod
|
||||
def Initialize(cls, directory=None):
|
||||
|
||||
@ -301,9 +301,9 @@ char* CDocBuilder_GetVersion(CDocBuilder* self)
|
||||
return self->GetVersion();
|
||||
}
|
||||
|
||||
CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self)
|
||||
CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self, bool enterContext)
|
||||
{
|
||||
return new CDocBuilderContext(self->GetContext());
|
||||
return new CDocBuilderContext(self->GetContext(enterContext));
|
||||
}
|
||||
|
||||
void CDocBuilder_Initialize()
|
||||
|
||||
@ -97,7 +97,7 @@ DOCBUILDER_FUNC_DECL bool CDocBuilder_IsSaveWithDoctrendererMode(CDocBuilder* se
|
||||
|
||||
DOCBUILDER_FUNC_DECL char* CDocBuilder_GetVersion(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self, bool enterContext);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_Initialize();
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_InitializeWithDirectory(const wchar_t* directory);
|
||||
|
||||
@ -56,7 +56,6 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
CJSContextScope scope(m_context);
|
||||
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = m_context->GetExceptions();
|
||||
@ -297,7 +296,7 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
else if (1 == m_nFileType)
|
||||
pNative->m_strEditorType = L"presentation";
|
||||
else if (7 == m_nFileType)
|
||||
pNative->m_strEditorType = L"draw";
|
||||
pNative->m_strEditorType = L"visio";
|
||||
else
|
||||
pNative->m_strEditorType = L"spreadsheet";
|
||||
|
||||
|
||||
@ -728,22 +728,13 @@ namespace NSDoctRenderer
|
||||
oBuilder.WriteEncodeXmlString(sFolder);
|
||||
oBuilder.WriteString(L"/Editor.bin</m_sFileTo><m_nFormatTo>8192</m_nFormatTo>");
|
||||
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(m_sX2tPath + L"/sdkjs/common");
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
}
|
||||
else
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
}
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
|
||||
oBuilder.WriteString(L"<m_bIsNoBase64>true</m_bIsNoBase64>");
|
||||
oBuilder.WriteString(L"<m_sThemeDir>./sdkjs/slide/themes</m_sThemeDir><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
|
||||
@ -1054,22 +1045,13 @@ namespace NSDoctRenderer
|
||||
oBuilder.WriteString(L"</m_sThemeDir><m_bFromChanges>true</m_bFromChanges><m_bDontSaveAdditional>true</m_bDontSaveAdditional>");
|
||||
oBuilder.WriteString(L"<m_nCsvTxtEncoding>46</m_nCsvTxtEncoding><m_nCsvDelimiter>4</m_nCsvDelimiter>");
|
||||
|
||||
if (!m_bIsNotUseConfigAllFontsDir)
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(m_sX2tPath + L"/sdkjs/common");
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
}
|
||||
else
|
||||
{
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
oBuilder.WriteString(L"<m_sFontDir>");
|
||||
oBuilder.WriteEncodeXmlString(NSFile::GetDirectoryName(m_strAllFonts));
|
||||
oBuilder.WriteString(L"</m_sFontDir>");
|
||||
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
}
|
||||
oBuilder.WriteString(L"<m_sAllFontsPath>");
|
||||
oBuilder.WriteEncodeXmlString(m_strAllFonts);
|
||||
oBuilder.WriteString(L"</m_sAllFontsPath>");
|
||||
|
||||
if (!sConvertionParams.empty())
|
||||
{
|
||||
|
||||
@ -445,7 +445,7 @@ namespace NSDoctRenderer
|
||||
strError = L"code=\"save\"";
|
||||
bIsBreak = true;
|
||||
}
|
||||
else
|
||||
else if (!js_result2->isNull())
|
||||
{
|
||||
JSSmart<CJSTypedArray> typedArray = js_result2->toTypedArray();
|
||||
NSJSBase::CJSDataBuffer oBuffer = typedArray->getData();
|
||||
@ -575,7 +575,6 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
@ -987,7 +986,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::VISIO;
|
||||
m_pInternal->m_strEditorType = L"draw";
|
||||
m_pInternal->m_strEditorType = L"visio";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -1067,7 +1066,6 @@ namespace NSDoctRenderer
|
||||
{
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CNativeControlEmbed>();
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
|
||||
@ -121,7 +121,7 @@ drawingfile_support {
|
||||
embed/DrawingFileEmbed.h
|
||||
|
||||
SOURCES += \
|
||||
../../HtmlRenderer/src/HTMLRendererText.cpp \
|
||||
../graphics/pro/js/wasm/src/HTMLRendererText.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
|
||||
@ -38,8 +38,8 @@
|
||||
#include "../../PdfFile/PdfFile.h"
|
||||
#include "../../XpsFile/XpsFile.h"
|
||||
#include "../../DjVuFile/DjVu.h"
|
||||
#include "../../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
|
||||
#include "../../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "../graphics/pro/js/wasm/src/serialize.h"
|
||||
#include "../graphics/pro/js/wasm/src/HTMLRendererText.h"
|
||||
#include "../../DocxRenderer/DocxRenderer.h"
|
||||
|
||||
#define CHECKER_FILE_BUFFER_LEN 4096
|
||||
@ -542,8 +542,8 @@ private:
|
||||
}
|
||||
if (m_nType == 0)
|
||||
nRotate = ((CPdfFile*)m_pFile)->GetRotate(nPageIndex);
|
||||
nWidth = dWidth;
|
||||
nHeight = dHeight;
|
||||
nWidth = round(dWidth);
|
||||
nHeight = round(dHeight);
|
||||
nPageDpiX = dPageDpiX;
|
||||
}
|
||||
|
||||
|
||||
@ -100,12 +100,12 @@ namespace NSDoctRenderer
|
||||
}
|
||||
case DoctRendererEditorType::VISIO:
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/draw/sdk-all-min.js"))
|
||||
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/visio/sdk-all-min.js"))
|
||||
return L"";
|
||||
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all-min.js");
|
||||
AppendScript(builder, config->m_strSdkPath + L"/visio/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/draw/sdk-all";
|
||||
AppendScript(builder, config->m_strSdkPath + L"/visio/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/visio/sdk-all";
|
||||
break;
|
||||
}
|
||||
case DoctRendererEditorType::PDF:
|
||||
@ -147,7 +147,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
case DoctRendererEditorType::VISIO:
|
||||
{
|
||||
return config->m_strSdkPath + L"/draw/sdk-all.bin";
|
||||
return config->m_strSdkPath + L"/visio/sdk-all.bin";
|
||||
}
|
||||
case DoctRendererEditorType::PDF:
|
||||
{
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include "./MemoryStreamEmbed.h"
|
||||
#include "./TextMeasurerEmbed.h"
|
||||
#include "./HashEmbed.h"
|
||||
#include "./GraphicsEmbed.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
@ -13,5 +14,6 @@ namespace NSJSBase
|
||||
CJSContext::Embed<CMemoryStreamEmbed>();
|
||||
CJSContext::Embed<CTextMeasurerEmbed>();
|
||||
CJSContext::Embed<CHashEmbed>();
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,8 +1,178 @@
|
||||
#include "GraphicsEmbed.h"
|
||||
#include "../graphics.h"
|
||||
#include <map>
|
||||
#include "../../../Common/Network/FileTransporter/include/FileTransporter.h"
|
||||
|
||||
// APPLICATION INFO
|
||||
class CGraphicsAppImage_private
|
||||
{
|
||||
public:
|
||||
NSFonts::IApplicationFonts* m_pFonts;
|
||||
std::wstring m_sFontsDirectory;
|
||||
std::wstring m_sImagesDirectory;
|
||||
std::wstring m_sThemesDirectory;
|
||||
bool m_bIsRgba;
|
||||
|
||||
std::map<std::wstring, std::wstring> m_mapDownloads;
|
||||
|
||||
CGraphicsAppImage_private()
|
||||
{
|
||||
m_pFonts = NULL;
|
||||
m_sFontsDirectory = L"";
|
||||
m_sImagesDirectory = L"";
|
||||
m_sThemesDirectory = L"";
|
||||
m_bIsRgba = false;
|
||||
}
|
||||
~CGraphicsAppImage_private()
|
||||
{
|
||||
RELEASEINTERFACE(m_pFonts);
|
||||
|
||||
for (std::map<std::wstring, std::wstring>::iterator i = m_mapDownloads.begin(); i != m_mapDownloads.end(); i++)
|
||||
{
|
||||
std::wstring sTmp = i->second;
|
||||
if (NSFile::CFileBinary::Exists(sTmp))
|
||||
NSFile::CFileBinary::Remove(sTmp);
|
||||
}
|
||||
}
|
||||
|
||||
bool IsNeedDownload(const std::wstring& sUrl)
|
||||
{
|
||||
if ((0 == sUrl.find(L"www.")) ||
|
||||
(0 == sUrl.find(L"http://")) ||
|
||||
(0 == sUrl.find(L"https://")))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::wstring GetImagePath(const std::wstring& sUrl)
|
||||
{
|
||||
std::map<std::wstring, std::wstring>::iterator find = m_mapDownloads.find(sUrl);
|
||||
if (find != m_mapDownloads.end())
|
||||
return find->second;
|
||||
|
||||
NSNetwork::NSFileTransport::CFileDownloader oDownloader(sUrl, false);
|
||||
|
||||
std::wstring sTmpFile = NSFile::CFileBinary::CreateTempFileWithUniqueName(NSFile::CFileBinary::GetTempPath(), L"IMG");
|
||||
if (NSFile::CFileBinary::Exists(sTmpFile))
|
||||
NSFile::CFileBinary::Remove(sTmpFile);
|
||||
sTmpFile = sTmpFile + L".png";
|
||||
|
||||
oDownloader.SetFilePath(sTmpFile);
|
||||
oDownloader.Start(0);
|
||||
while ( oDownloader.IsRunned() )
|
||||
{
|
||||
NSThreads::Sleep( 10 );
|
||||
}
|
||||
bool bIsDownloaded = oDownloader.IsFileDownloaded();
|
||||
|
||||
if (bIsDownloaded)
|
||||
{
|
||||
m_mapDownloads.insert(std::pair<std::wstring, std::wstring>(sUrl, sTmpFile));
|
||||
return sTmpFile;
|
||||
}
|
||||
|
||||
return sUrl;
|
||||
}
|
||||
};
|
||||
|
||||
CGraphicsAppImage::CGraphicsAppImage()
|
||||
{
|
||||
m_internal = new CGraphicsAppImage_private();
|
||||
}
|
||||
CGraphicsAppImage::~CGraphicsAppImage()
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetFontsDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sFontsDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetFontsDirectory()
|
||||
{
|
||||
return m_internal->m_sFontsDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetImagesDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sImagesDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetImagesDirectory()
|
||||
{
|
||||
return m_internal->m_sImagesDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetThemesDirectory(const std::wstring& dir)
|
||||
{
|
||||
m_internal->m_sThemesDirectory = dir;
|
||||
}
|
||||
std::wstring CGraphicsAppImage::GetThemesDirectory()
|
||||
{
|
||||
return m_internal->m_sThemesDirectory;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetFonts(NSFonts::IApplicationFonts* fonts)
|
||||
{
|
||||
m_internal->m_pFonts = fonts;
|
||||
ADDREFINTERFACE(fonts);
|
||||
}
|
||||
NSFonts::IApplicationFonts* CGraphicsAppImage::GetFonts()
|
||||
{
|
||||
return m_internal->m_pFonts;
|
||||
}
|
||||
|
||||
void CGraphicsAppImage::SetRgba(const bool& isRgba)
|
||||
{
|
||||
m_internal->m_bIsRgba = isRgba;
|
||||
}
|
||||
bool CGraphicsAppImage::GetRgba()
|
||||
{
|
||||
return m_internal->m_bIsRgba;
|
||||
}
|
||||
|
||||
unsigned char* CGraphicsAppImage::GetBits(int& w, int& h)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
unsigned char* CGraphicsAppImage::AllocBits(const int& w, const int& h)
|
||||
{
|
||||
return new unsigned char[4 * w * h];
|
||||
}
|
||||
|
||||
// APPLICATION INFO END
|
||||
|
||||
CGraphicsEmbed::CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics())
|
||||
{
|
||||
}
|
||||
CGraphicsEmbed::~CGraphicsEmbed()
|
||||
{
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
CGraphicsAppImage* CGraphicsEmbed::GetAppImage()
|
||||
{
|
||||
return m_pInternal->m_pAppImage;
|
||||
}
|
||||
|
||||
void CGraphicsEmbed::SetAppImage(CGraphicsAppImage* appImage)
|
||||
{
|
||||
m_pInternal->m_pAppImage = appImage;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm)
|
||||
{
|
||||
m_pInternal->init((NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject(), width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
NSNativeControl::CNativeControl* pControl = NULL;
|
||||
if (!Native->isNull())
|
||||
{
|
||||
pControl = (NSNativeControl::CNativeControl*)Native->toObject()->getNative()->getObject();
|
||||
|
||||
if (m_pInternal->m_pAppImage)
|
||||
delete m_pInternal->m_pAppImage;
|
||||
m_pInternal->m_pAppImage = new CGraphicsAppImage();
|
||||
m_pInternal->m_pAppImage->SetFontsDirectory(pControl->m_strFontsDirectory);
|
||||
m_pInternal->m_pAppImage->SetImagesDirectory(pControl->m_strImagesDirectory);
|
||||
}
|
||||
|
||||
m_pInternal->init(width_px->toDouble(), height_px->toDouble(), width_mm->toDouble(), height_mm->toDouble());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
@ -150,11 +320,19 @@ JSSmart<CJSValue> CGraphicsEmbed::ClearLastFont()
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage2(JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect)
|
||||
{
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
std::wstring sUrl = img->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->drawImage(sUrl, x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::drawImage (JSSmart<CJSValue> img, JSSmart<CJSValue> x, JSSmart<CJSValue> y, JSSmart<CJSValue> w, JSSmart<CJSValue> h, JSSmart<CJSValue> alpha, JSSmart<CJSValue> srcRect, JSSmart<CJSValue> nativeImage)
|
||||
{
|
||||
std::wstring sUrl = img->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->drawImage(img->toStringW(), x->toDouble(), y->toDouble(), w->toDouble(), h->toDouble(), alpha->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
@ -459,7 +637,11 @@ JSSmart<CJSValue> CGraphicsEmbed::GetBrushColor()
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTexture(JSSmart<CJSValue> src, JSSmart<CJSValue> type)
|
||||
{
|
||||
m_pInternal->put_brushTexture(src->toStringW(), type->toInt32());
|
||||
std::wstring sUrl = src->toStringW();
|
||||
if (m_pInternal->m_pAppImage && m_pInternal->m_pAppImage->m_internal->IsNeedDownload(sUrl))
|
||||
sUrl = m_pInternal->m_pAppImage->m_internal->GetImagePath(sUrl);
|
||||
|
||||
m_pInternal->put_brushTexture(sUrl, type->toInt32());
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::put_brushTextureMode(JSSmart<CJSValue> mode)
|
||||
|
||||
@ -1,21 +1,57 @@
|
||||
#ifndef _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
#define _BUILD_NATIVE_GRAPHICS_EMBED_H_
|
||||
|
||||
#include "../graphics.h"
|
||||
#include "../../graphics/pro/Fonts.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
class CGraphicsAppImage_private;
|
||||
class JS_DECL CGraphicsAppImage
|
||||
{
|
||||
public:
|
||||
CGraphicsAppImage();
|
||||
virtual ~CGraphicsAppImage();
|
||||
public:
|
||||
void SetFontsDirectory(const std::wstring& dir);
|
||||
std::wstring GetFontsDirectory();
|
||||
|
||||
void SetImagesDirectory(const std::wstring& dir);
|
||||
std::wstring GetImagesDirectory();
|
||||
|
||||
void SetThemesDirectory(const std::wstring& dir);
|
||||
std::wstring GetThemesDirectory();
|
||||
|
||||
void SetFonts(NSFonts::IApplicationFonts* fonts);
|
||||
NSFonts::IApplicationFonts* GetFonts();
|
||||
|
||||
void SetRgba(const bool& isRgba);
|
||||
bool GetRgba();
|
||||
|
||||
virtual unsigned char* GetBits(int& w, int& h);
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h);
|
||||
|
||||
private:
|
||||
CGraphicsAppImage_private* m_internal;
|
||||
|
||||
friend class CGraphicsEmbed;
|
||||
};
|
||||
|
||||
namespace NSGraphics { class CGraphics; }
|
||||
|
||||
using namespace NSJSBase;
|
||||
class CGraphicsEmbed : public CJSEmbedObject
|
||||
class JS_DECL CGraphicsEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
NSGraphics::CGraphics* m_pInternal;
|
||||
|
||||
public:
|
||||
CGraphicsEmbed() : m_pInternal(new NSGraphics::CGraphics()) {}
|
||||
~CGraphicsEmbed() { RELEASEOBJECT(m_pInternal); }
|
||||
CGraphicsEmbed();
|
||||
~CGraphicsEmbed();
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pInternal; }
|
||||
|
||||
CGraphicsAppImage* GetAppImage();
|
||||
void SetAppImage(CGraphicsAppImage* appImage);
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> create(JSSmart<CJSValue> Native, JSSmart<CJSValue> width_px, JSSmart<CJSValue> height_px, JSSmart<CJSValue> width_mm, JSSmart<CJSValue> height_mm);
|
||||
JSSmart<CJSValue> Destroy();
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "./../docbuilder_p.h"
|
||||
|
||||
#include "../../common/Directory.h"
|
||||
#include "../server.h"
|
||||
|
||||
JSSmart<CJSValue> CBuilderDocumentEmbed::IsValid()
|
||||
{
|
||||
@ -68,13 +69,23 @@ void CBuilderDocumentEmbed::_OpenFile(const std::wstring& sFile, const std::wstr
|
||||
int nConvertResult = pBuilder->ConvertToInternalFormat(m_sFolder, sFileCopy, sParams);
|
||||
|
||||
if (0 == nConvertResult)
|
||||
{
|
||||
if (CServerInstance::getInstance().IsEnable())
|
||||
CServerInstance::getInstance().AddTmpFile(m_sFolder);
|
||||
m_bIsValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
void CBuilderDocumentEmbed::_CloseFile()
|
||||
{
|
||||
if (!m_sFolder.empty())
|
||||
{
|
||||
NSDirectory::DeleteDirectory(m_sFolder);
|
||||
|
||||
if (m_bIsValid && CServerInstance::getInstance().IsEnable())
|
||||
CServerInstance::getInstance().RemoveTmpFile(m_sFolder);
|
||||
}
|
||||
|
||||
m_bIsValid = false;
|
||||
m_sFolder = L"";
|
||||
}
|
||||
|
||||
@ -10,18 +10,35 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#define ENABLE_GR_LOGS
|
||||
#endif
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
void CGraphics::init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm)
|
||||
void CGraphics::init(double width_px, double height_px, double width_mm, double height_mm)
|
||||
{
|
||||
m_sApplicationImagesDirectory = oNative->m_strImagesDirectory;
|
||||
m_sApplicationFontsDirectory = oNative->m_strFontsDirectory;
|
||||
#ifdef _DEBUG
|
||||
std::wcout << L"init "<< m_sApplicationImagesDirectory << L" " << m_sApplicationFontsDirectory << L" " << width_px << L" " << height_px << L" " << width_mm << L" " << height_mm << std::endl;
|
||||
if (!m_pAppImage)
|
||||
return;
|
||||
|
||||
if (NULL == m_pAppImage->GetFonts())
|
||||
{
|
||||
NSFonts::IApplicationFonts* pFonts = NSFonts::NSApplication::Create();
|
||||
std::wstring sFontsDir = m_pAppImage->GetFontsDirectory();
|
||||
pFonts->InitializeFromFolder(sFontsDir.empty() ? NSFile::GetProcessDirectory() : sFontsDir);
|
||||
m_pAppImage->SetFonts(pFonts);
|
||||
RELEASEINTERFACE(pFonts);
|
||||
}
|
||||
|
||||
NSFonts::IFontManager* pManager = m_pAppImage->GetFonts()->GenerateFontManager();
|
||||
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"init "<<
|
||||
m_pAppImage->GetImagesDirectory() << L" " <<
|
||||
m_pAppImage->GetFontsDirectory() << L" " <<
|
||||
width_px << L" " << height_px << L" " <<
|
||||
width_mm << L" " << height_mm << std::endl;
|
||||
#endif
|
||||
m_pApplicationFonts = NSFonts::NSApplication::Create();
|
||||
m_pApplicationFonts->InitializeFromFolder(m_sApplicationFontsDirectory.empty() ? NSFile::GetProcessDirectory() : m_sApplicationFontsDirectory);
|
||||
NSFonts::IFontManager* pManager = m_pApplicationFonts->GenerateFontManager();
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->SetFontManager(pManager);
|
||||
@ -42,7 +59,19 @@ namespace NSGraphics
|
||||
if (nRasterH < 1) nRasterH = 0;
|
||||
}
|
||||
|
||||
BYTE* pData = new BYTE[4 * nRasterW * nRasterH];
|
||||
int nExistW = 0;
|
||||
int nExistH = 0;
|
||||
BYTE* pData = m_pAppImage->GetBits(nExistW, nExistH);
|
||||
if (pData != NULL)
|
||||
{
|
||||
nRasterW = nExistW;
|
||||
nRasterH = nExistH;
|
||||
}
|
||||
else
|
||||
{
|
||||
pData = m_pAppImage->AllocBits(nRasterW, nRasterH);
|
||||
}
|
||||
|
||||
unsigned int back = 0xffffff;
|
||||
unsigned int* pData32 = (unsigned int*)pData;
|
||||
unsigned int* pData32End = pData32 + nRasterW * nRasterH;
|
||||
@ -55,21 +84,21 @@ namespace NSGraphics
|
||||
m_oFrame.put_Stride(4 * nRasterW);
|
||||
|
||||
m_pRenderer->CreateFromBgraFrame(&m_oFrame);
|
||||
m_pRenderer->SetSwapRGB(false);
|
||||
m_pRenderer->SetSwapRGB(m_pAppImage->GetRgba());
|
||||
|
||||
m_pRenderer->put_Width(width_mm);
|
||||
m_pRenderer->put_Height(height_mm);
|
||||
}
|
||||
void CGraphics::put_GlobalAlpha(bool enable, double alpha)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_GlobalAlpha " << enable << " " << alpha << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_GlobalAlphaEnabled(enable, alpha);
|
||||
}
|
||||
void CGraphics::End_GlobalAlpha()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "End_GlobalAlpha " << std::endl;
|
||||
#endif
|
||||
bool bIsInteger = m_pRenderer->get_IntegerGrid();
|
||||
@ -86,7 +115,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::p_color(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_color " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenColor(r | (g << 8) | (b << 16));
|
||||
@ -94,14 +123,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::p_width(double w)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_width " << w << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenSize(w / 1000.0);
|
||||
}
|
||||
void CGraphics::p_dash(size_t length, double* dash)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "p_dash " << length << std::endl;
|
||||
#endif
|
||||
if(length > 0)
|
||||
@ -119,7 +148,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::b_color1(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "b_color1 " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
@ -128,7 +157,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::b_color2(int r, int g, int b, int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "b_color2 " << r << " " << g << " " << b << " " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushColor2(r | (g << 8) | (b << 16));
|
||||
@ -136,42 +165,42 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::transform(double sx, double shy, double shx, double sy, double tx, double ty)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "transform " << sx << " " << shy << " " << shx << " " << sy << " " << tx << " " << ty << std::endl;
|
||||
#endif
|
||||
m_pRenderer->SetTransform(sx, shy, shx, sy, tx, ty);
|
||||
}
|
||||
void CGraphics::CalculateFullTransform()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "CalculateFullTransform " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CalculateFullTransform();
|
||||
}
|
||||
void CGraphics::_s()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_s " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
void CGraphics::_e()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_e " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
}
|
||||
void CGraphics::_z()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_z " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandClose();
|
||||
}
|
||||
void CGraphics::_m(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_m " << x << " " << y << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -184,7 +213,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_l(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_l " << x << " " << y << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -197,7 +226,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_c (double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_c " << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -212,7 +241,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::_c2(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "_c2 " << x1 << " " << y1 << " " << x2 << " " << y2 << std::endl;
|
||||
#endif
|
||||
if (!m_pRenderer->get_IntegerGrid())
|
||||
@ -226,28 +255,28 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::ds()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "ds " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->Stroke();
|
||||
}
|
||||
void CGraphics::df()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "df " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->Fill();
|
||||
}
|
||||
void CGraphics::save()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "save " << std::endl;
|
||||
#endif
|
||||
m_oFrame.SaveFile(m_sApplicationImagesDirectory + L"/img.png", _CXIMAGE_FORMAT_PNG);
|
||||
m_oFrame.SaveFile(m_pAppImage->GetImagesDirectory() + L"/img.png", _CXIMAGE_FORMAT_PNG);
|
||||
}
|
||||
void CGraphics::restore()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "restore " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nResetClipType);
|
||||
@ -255,7 +284,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::clip()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "clip " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
@ -263,43 +292,46 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::reset()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "reset " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->ResetTransform();
|
||||
}
|
||||
void CGraphics::FreeFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "FreeFont " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CloseFont();
|
||||
}
|
||||
void CGraphics::ClearLastFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "ClearLastFont " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->ClearInstallFont();
|
||||
}
|
||||
void CGraphics::drawImage(const std::wstring& img, double x, double y, double w, double h, BYTE alpha)
|
||||
{
|
||||
std::wstring strImage = (0 == img.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + img;
|
||||
#ifdef _DEBUG
|
||||
std::wstring strImage = img;
|
||||
if (!NSFile::CFileBinary::Exists(img))
|
||||
strImage = (0 == img.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + img;
|
||||
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"drawImage " << strImage << L" " << x << " " << y << L" " << w << L" " << h << L" " << alpha << std::endl;
|
||||
#endif
|
||||
m_pRenderer->DrawImageFromFile(strImage, x, y, w, h, alpha);
|
||||
}
|
||||
std::wstring CGraphics::GetFont()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetFont " << std::endl;
|
||||
#endif
|
||||
return m_pRenderer->GetFontManager()->GetName();
|
||||
}
|
||||
void CGraphics::SetFont(const std::wstring& name, int face, double size, int style)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"SetFont " << name << L" " << face << L" " << size << L" " << style << std::endl;
|
||||
#endif
|
||||
double DpiX, DpiY;
|
||||
@ -314,21 +346,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::FillText(double x, double y, int text)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"FillText " << (wchar_t)text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CommandDrawTextCHAR(text, x, y, 0, 0);
|
||||
}
|
||||
void CGraphics::t(double x, double y, const std::wstring& text)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"t " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->CommandDrawText(text, x, y, 0, 0);
|
||||
}
|
||||
void CGraphics::tg(int text, double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"tg " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_FontStringGID(TRUE);
|
||||
@ -337,21 +369,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SetIntegerGrid(bool param)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SetIntegerGrid " << param << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_IntegerGrid(param);
|
||||
}
|
||||
bool CGraphics::GetIntegerGrid()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetIntegerGrid " << std::endl;
|
||||
#endif
|
||||
return m_pRenderer->get_IntegerGrid();
|
||||
}
|
||||
void CGraphics::DrawStringASCII (const std::wstring& text, double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"DrawStringASCII " << text << L" " << x << L" " << y << std::endl;
|
||||
#endif
|
||||
double DpiY;
|
||||
@ -373,7 +405,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawHeaderEdit(double yPos)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawHeaderEdit " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -416,7 +448,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawFooterEdit(double yPos)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawFooterEdit " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -459,7 +491,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawLockParagraph (double x, double y1, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawLockParagraph " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -531,7 +563,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawLockObjectRect(double x, double y, double w, double h)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawLockObjectRect " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -557,7 +589,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawEmptyTableLine(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawEmptyTableLine " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->PathCommandEnd();
|
||||
@ -642,7 +674,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawSpellingLine (double y0, double x0, double x1, double w)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawSpellingLine " << std::endl;
|
||||
#endif
|
||||
Aggplus::CMatrix* pMatrix = m_pRenderer->GetTransformMatrix();
|
||||
@ -988,7 +1020,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::SaveGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "SaveGrState " << std::endl;
|
||||
#endif
|
||||
CGrStateState* pState = new CGrStateState();
|
||||
@ -1004,7 +1036,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::RestoreGrState()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "RestoreGrState " << std::endl;
|
||||
#endif
|
||||
if (m_oGrState.States.empty())
|
||||
@ -1068,14 +1100,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::StartClipPath()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "StartClipPath " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->BeginCommand(c_nClipType);
|
||||
}
|
||||
void CGraphics::EndClipPath()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "EndClipPath " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->EndCommand(c_nClipType);
|
||||
@ -1133,7 +1165,7 @@ namespace NSGraphics
|
||||
}
|
||||
std::string CGraphics::toDataURL(std::wstring type)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << "toDataURL " << type << std::endl;
|
||||
#endif
|
||||
std::wstring sFormat = (type.length() > 6) ? type.substr(6) : type;
|
||||
@ -1178,11 +1210,11 @@ namespace NSGraphics
|
||||
{
|
||||
if (src.find(L"data:") == 0)
|
||||
{
|
||||
std::wstring strImage = m_sApplicationImagesDirectory + L"/texture.png";
|
||||
std::wstring strImage = m_pAppImage->GetImagesDirectory() + L"/texture.png";
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if(src.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"put_brushTexture " << src << L" " << type << std::endl;
|
||||
#endif
|
||||
src.erase(0, src.find(L',') + 1);
|
||||
@ -1221,7 +1253,10 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring strImage = (0 == src.find(L"theme") ? m_sApplicationThemesDirectory : m_sApplicationImagesDirectory) + L'/' + src;
|
||||
std::wstring strImage = src;
|
||||
if (!NSFile::CFileBinary::Exists(src))
|
||||
strImage = (0 == src.find(L"theme") ? m_pAppImage->GetThemesDirectory() : m_pAppImage->GetImagesDirectory()) + L'/' + src;
|
||||
|
||||
std::wstring sName = strImage.substr(0, strImage.rfind(L'.') + 1);
|
||||
std::wstring sExt = src.substr(src.rfind(L'.') + 1);
|
||||
if (sExt == L"svg")
|
||||
@ -1231,7 +1266,7 @@ namespace NSGraphics
|
||||
else if (NSFile::CFileBinary::Exists(sName + L"emf") && src.find(L"display") == 0)
|
||||
strImage = sName + L"emf";
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pApplicationFonts);
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(m_pAppImage->GetFonts());
|
||||
pMetafile->LoadFromFile(strImage.c_str());
|
||||
|
||||
double x = 0, y = 0, w = 0, h = 0;
|
||||
@ -1244,7 +1279,7 @@ namespace NSGraphics
|
||||
}
|
||||
else
|
||||
sName += sExt;
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::wcout << L"put_brushTexture " << sName << L" " << type << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushType(c_BrushTypeTexture);
|
||||
@ -1254,21 +1289,21 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_brushTextureMode(int mode)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_brushTextureMode " << mode << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushTextureMode(mode);
|
||||
}
|
||||
void CGraphics::put_BrushTextureAlpha(int a)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_BrushTextureAlpha " << a << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_BrushTextureAlpha(a == 0 ? 255 : a);
|
||||
}
|
||||
void CGraphics::put_BrushGradient(LONG* pColors, double* pPositions, size_t nCount, double x0, double y0, double x1, double y1, double r0, double r1)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_BrushGradient " << nCount << " " << x0 << " " << y0 << " " << x1 << " " << y1 << " " << r0 << " " << r1 << std::endl;
|
||||
for (size_t i = 0; i < nCount; i++)
|
||||
std::cout << pPositions[i] << " " << pColors[i] << " ";
|
||||
@ -1293,7 +1328,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::TransformPointX(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "TransformPointX " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
@ -1301,7 +1336,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::TransformPointY(double x, double y)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "TransformPointY " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->GetFullTransform()->TransformPoint(x, y);
|
||||
@ -1309,14 +1344,14 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_LineJoin(int nJoin)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_LineJoin " << std::endl;
|
||||
#endif
|
||||
m_pRenderer->put_PenLineJoin(nJoin);
|
||||
}
|
||||
int CGraphics::GetLineJoin()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetLineJoin " << std::endl;
|
||||
#endif
|
||||
BYTE nRes;
|
||||
@ -1325,7 +1360,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::put_TextureBounds(double x, double y, double w, double h)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "put_TextureBounds " << x << " " << y << " " << w << " " << h << std::endl;
|
||||
#endif
|
||||
if(m_pRenderer->get_IntegerGrid())
|
||||
@ -1341,7 +1376,7 @@ namespace NSGraphics
|
||||
}
|
||||
double CGraphics::GetlineWidth()
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "GetlineWidth " << std::endl;
|
||||
#endif
|
||||
double nRes;
|
||||
@ -1350,7 +1385,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::DrawPath(int path)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "DrawPath " << path << std::endl;
|
||||
#endif
|
||||
if(path == 257)
|
||||
@ -1363,7 +1398,7 @@ namespace NSGraphics
|
||||
}
|
||||
void CGraphics::CoordTransformOffset(double tx, double ty)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
#ifdef ENABLE_GR_LOGS
|
||||
std::cout << "CoordTransformOffset " << tx << " " << ty << std::endl;
|
||||
#endif
|
||||
m_pRenderer->SetCoordTransformOffset(tx, ty);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "../common/File.h"
|
||||
#include "nativecontrol.h"
|
||||
#include "../graphics/pro/Graphics.h"
|
||||
#include "embed/GraphicsEmbed.h"
|
||||
|
||||
namespace NSGraphics
|
||||
{
|
||||
@ -114,28 +115,32 @@ namespace NSGraphics
|
||||
class CGraphics
|
||||
{
|
||||
public:
|
||||
std::wstring m_sApplicationFontsDirectory;
|
||||
std::wstring m_sApplicationImagesDirectory;
|
||||
std::wstring m_sApplicationThemesDirectory;
|
||||
CGraphicsAppImage* m_pAppImage;
|
||||
CBgraFrame m_oFrame;
|
||||
|
||||
private:
|
||||
NSFonts ::IApplicationFonts* m_pApplicationFonts;
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
CBgraFrame m_oFrame;
|
||||
CGrState m_oGrState;
|
||||
|
||||
public:
|
||||
CGraphics() {}
|
||||
CGraphics()
|
||||
{
|
||||
m_pAppImage = NULL;
|
||||
}
|
||||
~CGraphics()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void init(NSNativeControl::CNativeControl* oNative, double width_px, double height_px, double width_mm, double height_mm);
|
||||
void init(double width_px, double height_px, double width_mm, double height_mm);
|
||||
void Destroy()
|
||||
{
|
||||
int w, h;
|
||||
if (m_pAppImage && m_pAppImage->GetBits(w, h))
|
||||
m_oFrame.put_Data(NULL);
|
||||
|
||||
RELEASEINTERFACE(m_pRenderer);
|
||||
RELEASEINTERFACE(m_pApplicationFonts);
|
||||
RELEASEOBJECT(m_pAppImage);
|
||||
}
|
||||
void EndDraw() {}
|
||||
void put_GlobalAlpha(bool enable, double globalAlpha);
|
||||
|
||||
@ -54,9 +54,9 @@ v8::Local<v8::String> CreateV8String(v8::Isolate* i, const std::string& str);
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
||||
#ifdef _DEBUG
|
||||
//#ifdef _DEBUG
|
||||
#define ANDROID_LOGS
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
#ifdef ANDROID_LOGS
|
||||
#include <android/log.h>
|
||||
@ -488,7 +488,11 @@ namespace NSJSBase
|
||||
|
||||
virtual CJSEmbedObject* getNative()
|
||||
{
|
||||
if (0 == value->InternalFieldCount())
|
||||
return NULL;
|
||||
v8::Handle<v8::External> field = v8::Handle<v8::External>::Cast(value->GetInternalField(0));
|
||||
if (field.IsEmpty())
|
||||
return NULL;
|
||||
return (CJSEmbedObject*)field->Value();
|
||||
}
|
||||
|
||||
@ -991,67 +995,76 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define PROPERTY_GET(NAME, NAME_EMBED) \
|
||||
void NAME(v8::Local<v8::String> _name, const v8::PropertyCallbackInfo<v8::Value>& info) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(info.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(info.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
|
||||
js_return(info, ret); \
|
||||
}
|
||||
|
||||
#define FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
|
||||
js_return(args, ret); \
|
||||
#define FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
|
||||
#define FUNCTION_WRAPPER_V8(NAME, NAME_EMBED) FUNCTION_WRAPPER_V8_0(NAME, NAME_EMBED)
|
||||
|
||||
#define FUNCTION_WRAPPER_V8_1(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0])); \
|
||||
js_return(args, ret); \
|
||||
#define FUNCTION_WRAPPER_V8_1(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_2(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \
|
||||
js_return(args, ret); \
|
||||
#define FUNCTION_WRAPPER_V8_2(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_3(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_4(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_5(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_6(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5])); \
|
||||
js_return(args, ret); \
|
||||
}
|
||||
#define FUNCTION_WRAPPER_V8_7(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
|
||||
js_value(args[5]), js_value(args[6])); \
|
||||
js_return(args, ret); \
|
||||
@ -1059,7 +1072,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_8(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
|
||||
js_value(args[5]), js_value(args[6]), js_value(args[7])); \
|
||||
js_return(args, ret); \
|
||||
@ -1067,7 +1081,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_9(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), \
|
||||
js_value(args[5]), js_value(args[6]), js_value(args[7]), js_value(args[8])); \
|
||||
js_return(args, ret); \
|
||||
@ -1075,7 +1090,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_10(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \
|
||||
js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9])); \
|
||||
js_return(args, ret); \
|
||||
@ -1083,7 +1099,8 @@ inline void js_return(const v8::PropertyCallbackInfo<v8::Value>& info, JSSmart<N
|
||||
#define FUNCTION_WRAPPER_V8_13(NAME, NAME_EMBED) \
|
||||
void NAME(const v8::FunctionCallbackInfo<v8::Value>& args) \
|
||||
{ \
|
||||
CURRENTWRAPPER* _this = (CURRENTWRAPPER*)unwrap_native(args.Holder()); \
|
||||
CURRENTWRAPPER* _this = dynamic_cast<CURRENTWRAPPER*>(unwrap_native(args.Holder())); \
|
||||
if (!_this) return; \
|
||||
JSSmart<CJSValue> ret = _this->NAME_EMBED(js_value(args[0]), js_value(args[1]), js_value(args[2]), js_value(args[3]), js_value(args[4]), js_value(args[5]), \
|
||||
js_value(args[6]), js_value(args[7]), js_value(args[8]), js_value(args[9]), js_value(args[10]), js_value(args[11]), \
|
||||
js_value(args[12])); \
|
||||
|
||||
@ -99,6 +99,11 @@ namespace NSJSON
|
||||
return m_internal->m_type == CTypedValue::vtObject;
|
||||
}
|
||||
|
||||
bool IValue::IsImage() const
|
||||
{
|
||||
return m_internal->m_type == CTypedValue::vtImage;
|
||||
}
|
||||
|
||||
bool IValue::ToBool() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtPrimitive)
|
||||
@ -350,6 +355,11 @@ namespace NSJSON
|
||||
strRes += "}";
|
||||
break;
|
||||
}
|
||||
case CTypedValue::vtImage:
|
||||
{
|
||||
// TODO: implement like typed array?
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return strRes;
|
||||
@ -497,6 +507,82 @@ namespace NSJSON
|
||||
return static_cast<CObject*>(m_internal->m_value.get())->getPropertyNames();
|
||||
}
|
||||
|
||||
const BYTE* IValue::GetImageBits() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getBits();
|
||||
}
|
||||
|
||||
BYTE* IValue::GetImageBits()
|
||||
{
|
||||
return const_cast<BYTE*>(static_cast<const CValue&>(*this).GetImageBits());
|
||||
}
|
||||
|
||||
int IValue::GetImageWidth() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getWidth();
|
||||
}
|
||||
|
||||
int IValue::GetImageHeight() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getHeight();
|
||||
}
|
||||
|
||||
ImageFormat IValue::GetImageFormat() const
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return ImageFormat::ifInvalid;
|
||||
}
|
||||
return static_cast<CImage*>(m_internal->m_value.get())->getFormat();
|
||||
}
|
||||
|
||||
void IValue::ImageExternalize()
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static_cast<CImage*>(m_internal->m_value.get())->externalize();
|
||||
}
|
||||
|
||||
void IValue::ImageAlloc(const int& width, const int& height, const ImageFormat& format)
|
||||
{
|
||||
if (m_internal->m_type != CTypedValue::vtImage)
|
||||
{
|
||||
#ifdef JSON_DEBUG
|
||||
throw std::bad_cast();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
static_cast<CImage*>(m_internal->m_value.get())->alloc(width, height, format);
|
||||
}
|
||||
|
||||
CValue::CValue() : IValue()
|
||||
{
|
||||
@ -590,6 +676,35 @@ namespace NSJSON
|
||||
NSJSBase::NSAllocator::Free(data, size);
|
||||
}
|
||||
|
||||
CValue CValue::CreateImage(BYTE* bits, int width, int height, ImageFormat format, bool isExternalize)
|
||||
{
|
||||
CValue ret;
|
||||
if (width <= 0 || height <= 0)
|
||||
return ret;
|
||||
|
||||
ret.m_internal->m_value = std::make_shared<CImage>(bits, width, height, format, isExternalize);
|
||||
ret.m_internal->m_type = CTypedValue::vtImage;
|
||||
return ret;
|
||||
}
|
||||
|
||||
CValue CValue::CreateEmptyImage(ImageFormat format)
|
||||
{
|
||||
CValue ret;
|
||||
ret.m_internal->m_value = std::make_shared<CImage>((BYTE*)NULL, 0, 0, format, false);
|
||||
ret.m_internal->m_type = CTypedValue::vtImage;
|
||||
return ret;
|
||||
}
|
||||
|
||||
BYTE* CValue::AllocImageBits(int width, int height)
|
||||
{
|
||||
return new BYTE[4 * width * height];
|
||||
}
|
||||
|
||||
void CValue::FreeImageBits(BYTE* bits)
|
||||
{
|
||||
delete[] bits;
|
||||
}
|
||||
|
||||
CValue CValue::CreateObject()
|
||||
{
|
||||
CValue ret;
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
#endif
|
||||
|
||||
// uncomment to enable exceptions throwing
|
||||
//#define JSON_DEBUG
|
||||
// #define JSON_DEBUG
|
||||
|
||||
#ifdef JSON_DEBUG
|
||||
#include <stdexcept>
|
||||
@ -29,6 +29,14 @@
|
||||
namespace NSJSON
|
||||
{
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
enum class ImageFormat
|
||||
{
|
||||
ifRGBA,
|
||||
ifBGRA,
|
||||
ifARGB,
|
||||
ifInvalid
|
||||
};
|
||||
|
||||
class CValue;
|
||||
class CValueRef;
|
||||
@ -88,6 +96,10 @@ namespace NSJSON
|
||||
* Returns true if the value is an object.
|
||||
*/
|
||||
bool IsObject() const;
|
||||
/**
|
||||
* Returns true if the value is an image.
|
||||
*/
|
||||
bool IsImage() const;
|
||||
|
||||
// FUNCTIONS FOR WORKING WITH PRIMITIVE VALUES
|
||||
/**
|
||||
@ -193,6 +205,39 @@ namespace NSJSON
|
||||
*/
|
||||
std::vector<std::string> GetPropertyNames() const;
|
||||
|
||||
// FUNCTIONS FOR WORKING WITH IMAGES
|
||||
/**
|
||||
* Gets bits of image.
|
||||
* @return the pointer to memory, allocated for the image. If current value is not an image, returns nullptr.
|
||||
*/
|
||||
const BYTE* GetImageBits() const;
|
||||
BYTE* GetImageBits();
|
||||
/**
|
||||
* Gets width of the image.
|
||||
* @returns Returns the width of the image. If current value is not an image, returns 0.
|
||||
*/
|
||||
int GetImageWidth() const;
|
||||
/**
|
||||
* Gets height of the image.
|
||||
* @returns Returns the height of the image. If current value is not an image, returns 0.
|
||||
*/
|
||||
int GetImageHeight() const;
|
||||
/**
|
||||
* Gets format of the image.
|
||||
* @returns Returns the image format. If current value is not an image, returns ImageFormat::ifInvalid.
|
||||
*/
|
||||
ImageFormat GetImageFormat() const;
|
||||
|
||||
/**
|
||||
* Make image bits external.
|
||||
*/
|
||||
void ImageExternalize();
|
||||
|
||||
/**
|
||||
* Alloc image bits as internal.
|
||||
*/
|
||||
void ImageAlloc(const int& width, const int& height, const ImageFormat& format);
|
||||
|
||||
protected:
|
||||
std::shared_ptr<CTypedValue> m_internal;
|
||||
};
|
||||
@ -251,6 +296,30 @@ namespace NSJSON
|
||||
*/
|
||||
static void FreeTypedArray(BYTE* data, size_t size);
|
||||
|
||||
// IMAGE
|
||||
/**
|
||||
* Creates and returns new image object.
|
||||
* @param bits The pointer to image data. The pointer should be acquired with AllocImageBits().
|
||||
* @param width The width of the image.
|
||||
* @param height The height of the image.
|
||||
* @param format The format of the image.
|
||||
* @param isExternalize If true the memory will not be reclaimed when the created image is destroyed.
|
||||
* If this parameter is false then the memory will be released using FreeImageBits() during the image object destruction.
|
||||
*/
|
||||
static CValue CreateImage(BYTE* bits, int width, int height, ImageFormat format = ImageFormat::ifBGRA, bool isExternalize = true);
|
||||
static CValue CreateEmptyImage(ImageFormat format = ImageFormat::ifBGRA);
|
||||
/**
|
||||
* Allocates the memory for an image.
|
||||
* @param width The width of the image.
|
||||
* @param height The height of the image.
|
||||
*/
|
||||
static BYTE* AllocImageBits(int width, int height);
|
||||
/**
|
||||
* Frees the memory for a image bits.
|
||||
* @param data The allocated memory to be released.
|
||||
*/
|
||||
static void FreeImageBits(BYTE* bits);
|
||||
|
||||
// OBJECT CONSTRUCTOR
|
||||
/**
|
||||
* Creates and returns empty object.
|
||||
|
||||
@ -17,7 +17,8 @@ namespace NSJSON
|
||||
vtPrimitive,
|
||||
vtArray,
|
||||
vtTypedArray,
|
||||
vtObject
|
||||
vtObject,
|
||||
vtImage
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
@ -211,4 +211,56 @@ namespace NSJSON
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
CImage::CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize) :
|
||||
m_bits(bits), m_width(width), m_height(height), m_format(format), m_isExternalize(isExternalize)
|
||||
{
|
||||
}
|
||||
|
||||
CImage::~CImage()
|
||||
{
|
||||
if (!m_isExternalize)
|
||||
{
|
||||
CValue::FreeImageBits(m_bits);
|
||||
}
|
||||
}
|
||||
|
||||
void CImage::alloc(const int& width, const int& height, const ImageFormat& format)
|
||||
{
|
||||
if (!m_isExternalize && m_bits)
|
||||
{
|
||||
CValue::FreeImageBits(m_bits);
|
||||
}
|
||||
|
||||
m_bits = CValue::AllocImageBits(width, height);
|
||||
m_width = width;
|
||||
m_height = height;
|
||||
m_format = format;
|
||||
m_isExternalize = false;
|
||||
}
|
||||
|
||||
BYTE* CImage::getBits()
|
||||
{
|
||||
return m_bits;
|
||||
}
|
||||
|
||||
int CImage::getWidth()
|
||||
{
|
||||
return m_width;
|
||||
}
|
||||
|
||||
int CImage::getHeight()
|
||||
{
|
||||
return m_height;
|
||||
}
|
||||
|
||||
ImageFormat CImage::getFormat()
|
||||
{
|
||||
return m_format;
|
||||
}
|
||||
|
||||
void CImage::externalize()
|
||||
{
|
||||
m_isExternalize = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,6 +113,28 @@ namespace NSJSON
|
||||
private:
|
||||
storage_t m_values;
|
||||
};
|
||||
}
|
||||
|
||||
class CImage : public IBaseValue
|
||||
{
|
||||
public:
|
||||
CImage(BYTE* bits, const int& width, const int& height, const ImageFormat& format, const bool& isExternalize = true);
|
||||
~CImage();
|
||||
|
||||
public:
|
||||
BYTE* getBits();
|
||||
int getWidth();
|
||||
int getHeight();
|
||||
ImageFormat getFormat();
|
||||
void externalize();
|
||||
void alloc(const int& width, const int& height, const ImageFormat& format);
|
||||
|
||||
private:
|
||||
BYTE* m_bits;
|
||||
int m_width;
|
||||
int m_height;
|
||||
ImageFormat m_format;
|
||||
bool m_isExternalize;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // JSON_VALUES_H_
|
||||
|
||||
@ -3,9 +3,75 @@
|
||||
|
||||
#include "json.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../embed/GraphicsEmbed.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class CAppImageTo : public CGraphicsAppImage
|
||||
{
|
||||
private:
|
||||
NSJSON::CValueRef* m_image;
|
||||
|
||||
public:
|
||||
CAppImageTo(const NSJSON::CValue& image) : CGraphicsAppImage()
|
||||
{
|
||||
m_image = new NSJSON::CValueRef(image);
|
||||
}
|
||||
virtual ~CAppImageTo()
|
||||
{
|
||||
if (m_image)
|
||||
delete m_image;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual unsigned char* GetBits(int& w, int& h)
|
||||
{
|
||||
unsigned char* bits = m_image->GetImageBits();
|
||||
if (NULL != bits)
|
||||
{
|
||||
w = m_image->GetImageWidth();
|
||||
h = m_image->GetImageHeight();
|
||||
}
|
||||
return bits;
|
||||
}
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h)
|
||||
{
|
||||
m_image->ImageAlloc(w, h, GetRgba() ? NSJSON::ImageFormat::ifRGBA : NSJSON::ImageFormat::ifBGRA);
|
||||
return m_image->GetImageBits();
|
||||
}
|
||||
};
|
||||
|
||||
class CAppImageFrom : public CGraphicsAppImage
|
||||
{
|
||||
public:
|
||||
unsigned char* m_pData;
|
||||
int m_nW;
|
||||
int m_nH;
|
||||
public:
|
||||
CAppImageFrom() : CGraphicsAppImage()
|
||||
{
|
||||
m_pData = NULL;
|
||||
m_nW = 0;
|
||||
m_nH = 0;
|
||||
}
|
||||
virtual ~CAppImageFrom()
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual unsigned char* GetBits(int& w, int& h)
|
||||
{
|
||||
return m_pData;
|
||||
}
|
||||
virtual unsigned char* AllocBits(const int& w, const int& h)
|
||||
{
|
||||
m_nW = w;
|
||||
m_nH = h;
|
||||
m_pData = NSJSON::CValue::AllocImageBits(w, h);
|
||||
return m_pData;
|
||||
}
|
||||
};
|
||||
|
||||
namespace NSJSON
|
||||
{
|
||||
static JSSmart<NSJSBase::CJSValue> toJS(const CValue& value)
|
||||
@ -50,6 +116,12 @@ namespace NSJSON
|
||||
JSSmart<NSJSBase::CJSTypedArray> jsTypedArr = NSJSBase::CJSContext::createUint8Array(const_cast<BYTE*>(value.GetData()), value.GetCount());
|
||||
ret = jsTypedArr->toValue();
|
||||
}
|
||||
else if (value.IsImage())
|
||||
{
|
||||
JSSmart<CJSObject> wrap = CJSContext::createEmbedObject("CGraphicsEmbed");
|
||||
((CGraphicsEmbed*)wrap->getNative())->SetAppImage(new CAppImageTo(value));
|
||||
ret = wrap->toValue();
|
||||
}
|
||||
// objects (there is no need for IsObject())
|
||||
else
|
||||
{
|
||||
@ -130,6 +202,25 @@ namespace NSJSON
|
||||
else if (jsValue->isObject())
|
||||
{
|
||||
JSSmart<NSJSBase::CJSObject> jsObj = jsValue->toObject();
|
||||
|
||||
CJSEmbedObject* pNative = jsObj->getNative();
|
||||
if (pNative != NULL)
|
||||
{
|
||||
CGraphicsEmbed* pGrEmbed = dynamic_cast<CGraphicsEmbed*>(pNative);
|
||||
if (pGrEmbed)
|
||||
{
|
||||
CAppImageFrom* pAppImage = dynamic_cast<CAppImageFrom*>(pGrEmbed->GetAppImage());
|
||||
if (pAppImage)
|
||||
{
|
||||
return NSJSON::CValue::CreateImage(pAppImage->m_pData,
|
||||
pAppImage->m_nW,
|
||||
pAppImage->m_nH,
|
||||
pAppImage->GetRgba() ? ImageFormat::ifRGBA : ImageFormat::ifBGRA,
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> properties = jsObj->getPropertyNames();
|
||||
ret = CValue::CreateObject();
|
||||
for (const std::string& name : properties)
|
||||
|
||||
@ -44,7 +44,10 @@ CImagesWorker::CImagesWorker(const std::wstring& sFolder)
|
||||
std::wstring CImagesWorker::GetImageLocal(const std::wstring& sUrl)
|
||||
{
|
||||
if (CServerInstance::getInstance().IsEnable())
|
||||
return L"error";
|
||||
{
|
||||
if (!CServerInstance::getInstance().CheckTmpDirectory(sUrl))
|
||||
return L"error";
|
||||
}
|
||||
std::wstring sExt = NSFile::GetFileExtention(sUrl);
|
||||
std::wstring sRet = L"image" + std::to_wstring(m_nIndex++) + L"." + sExt;
|
||||
m_mapImages.insert(std::make_pair(sUrl, sRet));
|
||||
|
||||
@ -32,11 +32,19 @@
|
||||
#ifndef SERVER_SETTINGS_H
|
||||
#define SERVER_SETTINGS_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "../common/File.h"
|
||||
#include "../common/StringBuilder.h"
|
||||
#include <iostream>
|
||||
|
||||
// class for server version (disable local files and etc)
|
||||
class CServerInstance
|
||||
{
|
||||
private:
|
||||
bool m_bIsEnabled;
|
||||
std::map<std::wstring, bool> m_arMapTmpFiles;
|
||||
|
||||
CServerInstance()
|
||||
{
|
||||
m_bIsEnabled = false;
|
||||
@ -58,6 +66,32 @@ public:
|
||||
{
|
||||
return m_bIsEnabled;
|
||||
}
|
||||
|
||||
void AddTmpFile(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sDirectory = sFolder + L"/media";
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
if (findDir == m_arMapTmpFiles.end())
|
||||
m_arMapTmpFiles.insert(std::make_pair(sDirectory, true));
|
||||
}
|
||||
|
||||
void RemoveTmpFile(const std::wstring& sFolder)
|
||||
{
|
||||
std::wstring sDirectory = sFolder + L"/media";
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
if (findDir != m_arMapTmpFiles.end())
|
||||
m_arMapTmpFiles.erase(findDir);
|
||||
}
|
||||
|
||||
bool CheckTmpDirectory(const std::wstring& sFile)
|
||||
{
|
||||
std::wstring sDirectory = NSFile::GetDirectoryName(sFile);
|
||||
NSStringUtils::string_replace(sDirectory, L"\\", L"/");
|
||||
std::map<std::wstring, bool>::iterator findDir = m_arMapTmpFiles.find(sDirectory);
|
||||
return (findDir != m_arMapTmpFiles.end()) ? true : false;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -467,6 +467,62 @@ TEST_F(CJSONTest, object)
|
||||
EXPECT_FALSE(compare(obj, jsObj->toValue(), false));
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_externalize)
|
||||
{
|
||||
int width = 1080;
|
||||
int height = 480;
|
||||
BYTE* bits = CValue::AllocImageBits(width, height);
|
||||
CValue img = CValue::CreateImage(bits, width, height, ifBGRA);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifBGRA);
|
||||
|
||||
CValue::FreeImageBits(bits);
|
||||
|
||||
width = 50;
|
||||
height = 100;
|
||||
bits = CValue::AllocImageBits(width, height);
|
||||
img = CValue::CreateImage(bits, width, height, ifRGBA);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifRGBA);
|
||||
|
||||
CValue::FreeImageBits(bits);
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_not_externalize)
|
||||
{
|
||||
int width = 320;
|
||||
int height = 480;
|
||||
BYTE* bits = CValue::AllocImageBits(width, height);
|
||||
CValue img = CValue::CreateImage(bits, width, height, ifARGB, false);
|
||||
|
||||
EXPECT_TRUE(img.IsImage());
|
||||
EXPECT_EQ(img.GetImageBits(), bits);
|
||||
EXPECT_EQ(img.GetImageWidth(), width);
|
||||
EXPECT_EQ(img.GetImageHeight(), height);
|
||||
EXPECT_EQ(img.GetImageFormat(), ifARGB);
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, image_wrong_size)
|
||||
{
|
||||
BYTE* bits = CValue::AllocImageBits(100, 100);
|
||||
CValue img = CValue::CreateImage(bits, 0, 100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, -1, 100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, 0, 0, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
img = CValue::CreateImage(bits, -100, -100, ifARGB, false);
|
||||
EXPECT_TRUE(img.IsUndefined());
|
||||
}
|
||||
|
||||
TEST_F(CJSONTest, references)
|
||||
{
|
||||
CValue val = 42;
|
||||
@ -526,12 +582,20 @@ TEST_F(CJSONTest, wrong_usage)
|
||||
EXPECT_THROW(val.GetPropertyNames(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetCount(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetData(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageBits(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageFormat(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageHeight(), std::bad_cast);
|
||||
EXPECT_THROW(val.GetImageWidth(), std::bad_cast);
|
||||
#else
|
||||
EXPECT_TRUE(val["name"].IsUndefined());
|
||||
EXPECT_TRUE(val[0].IsUndefined());
|
||||
EXPECT_TRUE(val.GetPropertyNames().empty());
|
||||
EXPECT_EQ(val.GetCount(), 0);
|
||||
EXPECT_EQ(val.GetData(), nullptr);
|
||||
EXPECT_EQ(val.GetImageBits(), nullptr);
|
||||
EXPECT_EQ(val.GetImageFormat(), ifInvalid);
|
||||
EXPECT_EQ(val.GetImageHeight(), 0);
|
||||
EXPECT_EQ(val.GetImageWidth(), 0);
|
||||
#endif
|
||||
EXPECT_DOUBLE_EQ(val.ToDouble(), 42.0);
|
||||
#ifdef JSON_DEBUG
|
||||
@ -1601,7 +1665,11 @@ TEST_F(CJSONTest, FromJSON_arrays)
|
||||
CValue val = CValue::FromJSON(strJson);
|
||||
EXPECT_TRUE(val.IsArray());
|
||||
EXPECT_EQ(val.GetCount(), 0);
|
||||
#ifndef JSON_DEBUG
|
||||
EXPECT_TRUE(val[0].IsUndefined());
|
||||
#else
|
||||
EXPECT_THROW(val[0], std::out_of_range);
|
||||
#endif
|
||||
|
||||
strJson = "[1, 2, 3]";
|
||||
val = CValue::FromJSON(strJson);
|
||||
|
||||
@ -109,7 +109,7 @@ FT_Error FT_Load_Glyph_Wrapper( FT_Face face,
|
||||
FT_Err_Invalid_Reference = 0x86;
|
||||
*/
|
||||
|
||||
if ((bHintsSupport == TRUE) && ((nErr > 0x10 && nErr < 0x28) || nErr == 0x83 || nErr == 0x86))
|
||||
if ((bHintsSupport == TRUE) && ((nErr > 0x10 && nErr < 0x28) || (nErr >= 0x83 && nErr <= 0x8D)))
|
||||
{
|
||||
int nErr2 = FT_Load_Glyph(face, glyph_index, 40970);
|
||||
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
#include "AlphaMask.h"
|
||||
#include <string.h>
|
||||
#include "AlphaMask_p.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
@ -33,7 +32,6 @@ namespace Aggplus
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,130 +63,26 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CSoftMask::CSoftMask() : m_unWidth(0), m_unHeight(0), m_pImageData(NULL), m_pAlphaBufferData(NULL) {}
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip) : m_pImageData(NULL), m_pAlphaBufferData(NULL)
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bFlip, bool bRGB, bool bAlpha)
|
||||
{
|
||||
LoadFromBuffer(pBuffer, unWidth, unHeight, enDataType, bExternalBuffer, bFlip);
|
||||
if (bAlpha)
|
||||
m_pInternal = new CSoftMaskAlpha(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
else
|
||||
{
|
||||
if (bRGB)
|
||||
m_pInternal = new CSoftMaskBGRAgray(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
else
|
||||
m_pInternal = new CSoftMaskRGBAgray(pBuffer, unWidth, unHeight, false, bFlip);
|
||||
}
|
||||
}
|
||||
CSoftMask::~CSoftMask()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
}
|
||||
|
||||
EMaskDataType CSoftMask::GetDataType() const { return m_enDataType; }
|
||||
unsigned int CSoftMask::GetStep() const
|
||||
{
|
||||
switch(m_enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
unsigned int CSoftMask::GetWidth() const { return m_unWidth; }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_unHeight; }
|
||||
|
||||
void CSoftMask::SetType(EMaskDataType enDataType)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
|
||||
switch (enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
m_pImageData = new AMaskFromImage(m_oRenderingBuffer);
|
||||
m_pImageData->m_oRendererBase.attach(m_pImageData->m_oPixfmt);
|
||||
m_pImageData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
m_pAlphaBufferData = new AMaskFromABuffer(m_oRenderingBuffer);
|
||||
m_pAlphaBufferData->m_oRendererBase.attach(m_pAlphaBufferData->m_oPixfmt);
|
||||
m_pAlphaBufferData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status CSoftMask::Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType)
|
||||
{
|
||||
if (0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = false;
|
||||
|
||||
UINT unSize = unWidth * unHeight * GetStep();
|
||||
BYTE* pAlphaBufffer = new BYTE[unSize];
|
||||
if (!pAlphaBufffer)
|
||||
return OutOfMemory;
|
||||
|
||||
memset(pAlphaBufffer, 0x00, unSize);
|
||||
|
||||
Set(pAlphaBufffer, unWidth, unHeight, enDataType);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CSoftMask::LoadFromBuffer(BYTE *pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
if (NULL == pBuffer || 0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
|
||||
Set(pBuffer, unWidth, unHeight, enDataType, bFlip);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
RenBaseBGRA32& CSoftMask::GetRendererBaseImage()
|
||||
{
|
||||
return m_pImageData->m_oRendererBase;
|
||||
}
|
||||
|
||||
ScanlineBGRA32Gray& CSoftMask::GetScanlineImage()
|
||||
{
|
||||
return m_pImageData->m_oScanLine;
|
||||
}
|
||||
|
||||
ScanlineBGRA32A& CSoftMask::GetScanlineABuffer()
|
||||
{
|
||||
return m_pAlphaBufferData->m_oScanLine;
|
||||
}
|
||||
|
||||
BYTE* CSoftMask::GetBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer.buf();
|
||||
}
|
||||
|
||||
agg::rendering_buffer& CSoftMask::GetRenderingBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer;
|
||||
}
|
||||
|
||||
void CSoftMask::Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
|
||||
SetType(enDataType);
|
||||
}
|
||||
unsigned int CSoftMask::GetStep() const { return m_pInternal->GetStep(); }
|
||||
unsigned int CSoftMask::GetWidth() const { return m_pInternal->GetWidth(); }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_pInternal->GetHeight(); }
|
||||
BYTE* CSoftMask::GetBuffer() { return m_pInternal->GetBuffer(); }
|
||||
ESoftMaskType CSoftMask::GetDataType() { return m_pInternal->GetDataType(); }
|
||||
}
|
||||
|
||||
@ -1,23 +1,16 @@
|
||||
#ifndef _BUILD_ALPHAMASK_H_
|
||||
#define _BUILD_ALPHAMASK_H_
|
||||
|
||||
#include <string>
|
||||
#include "aggplustypes.h"
|
||||
#include "../common/IGrObject.h"
|
||||
#include "./config.h"
|
||||
|
||||
#include "../agg-2.4/include/agg_renderer_base.h"
|
||||
#include "../agg-2.4/include/agg_pixfmt_rgba.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
enum class EMaskDataType
|
||||
{
|
||||
ImageBuffer,
|
||||
AlphaBuffer,
|
||||
Alpha4Buffer
|
||||
AlphaBuffer
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CAlphaMask : public IGrObject
|
||||
@ -39,56 +32,30 @@ namespace Aggplus
|
||||
bool m_bExternalBuffer;
|
||||
};
|
||||
|
||||
template <class PixelFormat, class AlphaMask>
|
||||
struct TAlphaMaskData
|
||||
enum class ESoftMaskType
|
||||
{
|
||||
TAlphaMaskData(agg::rendering_buffer& oRenderingBuffer) : m_oPixfmt(oRenderingBuffer), m_oScanLine(m_oAlphaMask) {};
|
||||
|
||||
PixelFormat m_oPixfmt;
|
||||
agg::renderer_base<PixelFormat> m_oRendererBase;
|
||||
AlphaMask m_oAlphaMask;
|
||||
agg::scanline_u8_am<AlphaMask> m_oScanLine;
|
||||
RGBGrayBuffer,
|
||||
BGRGrayBuffer,
|
||||
Alpha4Buffer
|
||||
};
|
||||
|
||||
typedef agg::renderer_base<agg::pixfmt_bgra32> RenBaseBGRA32;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32gray> ScanlineBGRA32Gray;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32a> ScanlineBGRA32A;
|
||||
|
||||
class CSoftMask_private;
|
||||
class GRAPHICS_DECL CSoftMask : public IGrObject
|
||||
{
|
||||
public:
|
||||
CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
virtual ~CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bFlip, bool bRGB, bool bAlpha);
|
||||
~CSoftMask();
|
||||
|
||||
EMaskDataType GetDataType() const;
|
||||
unsigned int GetStep() const;
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int GetHeight() const;
|
||||
BYTE* GetBuffer();
|
||||
ESoftMaskType GetDataType();
|
||||
|
||||
void SetType(EMaskDataType enDataType);
|
||||
Status Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType);
|
||||
Status LoadFromBuffer(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
|
||||
agg::rendering_buffer& GetRenderingBuffer();
|
||||
RenBaseBGRA32& GetRendererBaseImage();
|
||||
ScanlineBGRA32Gray& GetScanlineImage();
|
||||
ScanlineBGRA32A& GetScanlineABuffer();
|
||||
BYTE* GetBuffer();
|
||||
private:
|
||||
void Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip = false);
|
||||
CSoftMask_private* m_pInternal;
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
EMaskDataType m_enDataType;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32gray> AMaskFromImage;
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32a> AMaskFromABuffer;
|
||||
|
||||
AMaskFromImage* m_pImageData;
|
||||
AMaskFromABuffer* m_pAlphaBufferData;
|
||||
friend class CGraphics;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
96
DesktopEditor/graphics/AlphaMask_p.h
Normal file
96
DesktopEditor/graphics/AlphaMask_p.h
Normal file
@ -0,0 +1,96 @@
|
||||
#ifndef _BUILD_ALPHAMASK_P_H_
|
||||
#define _BUILD_ALPHAMASK_P_H_
|
||||
|
||||
#include "AlphaMask.h"
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
#include "../agg-2.4/include/agg_rendering_buffer.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
class CSoftMask_private
|
||||
{
|
||||
public:
|
||||
virtual ~CSoftMask_private()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int GetStep() const { return 4; }
|
||||
unsigned int GetWidth() const { return m_unWidth; }
|
||||
unsigned int GetHeight() const { return m_unHeight; }
|
||||
BYTE* GetBuffer() { return m_oRenderingBuffer.buf(); }
|
||||
|
||||
virtual ESoftMaskType GetDataType() const = 0;
|
||||
virtual bool GetSwapRGB() const { return true; };
|
||||
|
||||
protected:
|
||||
CSoftMask_private(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
}
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
};
|
||||
|
||||
class CSoftMaskBGRAgray : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskBGRAgray(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_bgra32gray>& GetScanline() { return m_oScanLine; }
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::BGRGrayBuffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_bgra32gray m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_bgra32gray> m_oScanLine;
|
||||
};
|
||||
|
||||
class CSoftMaskRGBAgray : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskRGBAgray(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32gray>& GetScanline() { return m_oScanLine; }
|
||||
virtual bool GetSwapRGB() const override { return false; };
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::RGBGrayBuffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_rgba32gray m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32gray> m_oScanLine;
|
||||
};
|
||||
|
||||
class CSoftMaskAlpha : public CSoftMask_private
|
||||
{
|
||||
public:
|
||||
CSoftMaskAlpha(BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, bool bExternalBuffer, bool bFlip)
|
||||
: CSoftMask_private(pBuffer, unWidth, unHeight, bExternalBuffer, bFlip), m_oAlphaMask(m_oRenderingBuffer), m_oScanLine(m_oAlphaMask) {}
|
||||
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32a>& GetScanline() { return m_oScanLine; }
|
||||
virtual ESoftMaskType GetDataType() const override { return ESoftMaskType::Alpha4Buffer; }
|
||||
|
||||
private:
|
||||
agg::alpha_mask_rgba32a m_oAlphaMask;
|
||||
agg::scanline_u8_am<agg::alpha_mask_rgba32a> m_oScanLine;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_ALPHAMASK_P_H_
|
||||
@ -107,9 +107,14 @@ namespace NSThreads
|
||||
{
|
||||
if (i->ID == nThreadId)
|
||||
{
|
||||
CBaseThreadInfo last;
|
||||
last.ID = i->ID;
|
||||
last.Instance = i->Instance;
|
||||
|
||||
m_listThreads.erase(i);
|
||||
m_listThreads.insert(m_listThreads.begin(), *i);
|
||||
return i->Instance;
|
||||
m_listThreads.insert(m_listThreads.begin(), last);
|
||||
|
||||
return last.Instance;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
@ -142,6 +142,14 @@ std::vector<double> Curve::GetYValues() const noexcept
|
||||
return {Segment1.P.Y, Segment2.P.Y + Segment2.HI.Y, Segment2.P.Y + Segment2.HO.Y, Segment2.P.Y};
|
||||
}
|
||||
|
||||
std::vector<double> Curve::GetBound() const noexcept
|
||||
{
|
||||
return {min(Segment1.P.X, Segment2.P.X + Segment2.HI.X, Segment2.P.X + Segment2.HO.X, Segment2.P.X),
|
||||
min(Segment1.P.Y, Segment2.P.Y + Segment2.HI.Y, Segment2.P.Y + Segment2.HO.Y, Segment2.P.Y),
|
||||
max(Segment1.P.X, Segment2.P.X + Segment2.HI.X, Segment2.P.X + Segment2.HO.X, Segment2.P.X),
|
||||
max(Segment1.P.Y, Segment2.P.Y + Segment2.HI.Y, Segment2.P.Y + Segment2.HO.Y, Segment2.P.Y)};
|
||||
}
|
||||
|
||||
std::vector<double> Curve::GetPeeks() const
|
||||
{
|
||||
std::vector<double> x = GetXValues(),
|
||||
@ -232,6 +240,7 @@ double Curve::GetTimeOf(const PointD& point) const noexcept
|
||||
if (getDistance(point, GetPoint(u)) <= GEOMETRIC_EPSILON)
|
||||
return u;
|
||||
}
|
||||
roots.clear();
|
||||
}
|
||||
}
|
||||
bool firstDist = d0 <= GEOMETRIC_EPSILON,
|
||||
@ -249,9 +258,9 @@ double Curve::GetTimeAt(const double& offset) const noexcept
|
||||
double a = forward ? start : 0,
|
||||
b = forward ? 1 : start,
|
||||
rangeLength = GetLength(a, b),
|
||||
diff = abs(offset) - rangeLength;
|
||||
diff = fabs(offset) - rangeLength;
|
||||
|
||||
if (abs(diff) < EPSILON)
|
||||
if (fabs(diff) < EPSILON)
|
||||
return forward ? b : a;
|
||||
else if (diff > EPSILON)
|
||||
return MIN;
|
||||
@ -269,8 +278,31 @@ double Curve::GetTimeAt(const double& offset) const noexcept
|
||||
by = 6 * (y[0] + y[2]) - 12 * y[1],
|
||||
cy = 3 * (y[1] - y[0]);
|
||||
|
||||
return findRoot(length, start, offset, ax, bx, cx,
|
||||
ay, by, cy, start + guess, a, b);
|
||||
double vx = start + guess;
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
length += integrate(ax, bx, cx, ay, by, cy, start, vx, getIterations(start, vx));
|
||||
start = vx;
|
||||
|
||||
double dx = vx - (length - offset) / CurveLength(vx, ax, bx, cx, ay, by, cy);
|
||||
if (fabs(vx - dx) < EPSILON)
|
||||
{
|
||||
vx = dx;
|
||||
break;
|
||||
}
|
||||
|
||||
if (length - offset > 0)
|
||||
{
|
||||
b = vx;
|
||||
vx = dx <= a ? (a + b) * 0.5 : dx;
|
||||
}
|
||||
else{
|
||||
a = vx;
|
||||
vx = dx >= b ? (a + b) * 0.5 : dx;
|
||||
}
|
||||
}
|
||||
|
||||
return clamp(vx, a, b);
|
||||
}
|
||||
|
||||
PointD Curve::Get(const double& t, const int& type) const noexcept
|
||||
@ -312,8 +344,8 @@ PointD Curve::Get(const double& t, const int& type) const noexcept
|
||||
}
|
||||
else if (t > tMax)
|
||||
{
|
||||
x0 = 3 * (x[3] - y[2]);
|
||||
y0 = 3 * (y[3] - x[2]);
|
||||
x0 = 3 * (x[3] - x[2]);
|
||||
y0 = 3 * (y[3] - y[2]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -369,7 +401,7 @@ Curve Curve::GetPart(double from, double to) const noexcept
|
||||
result.Segment2.HO.X -= result.Segment2.P.X;
|
||||
result.Segment2.HO.Y -= result.Segment2.P.Y;
|
||||
}
|
||||
else if (to < 1)
|
||||
if (to < 1)
|
||||
{
|
||||
result = result.Subdivide((to - from) / (1 - from))[0];
|
||||
result.Segment2.HI.X -= result.Segment2.P.X;
|
||||
@ -407,15 +439,15 @@ std::vector<std::pair<double, double>> Curve::GetOverlaps(const Curve& curve) co
|
||||
std::swap(y1, y2);
|
||||
}
|
||||
|
||||
double d20 = getDistance(px, py, vx, vy, x2[0], y2[0], true),
|
||||
d23 = getDistance(px, py, vx, vy, x2[3], y2[3], true);
|
||||
double d20 = fabs(getSignedDistance(px, py, vx, vy, x2[0], y2[0], true)),
|
||||
d23 = fabs(getSignedDistance(px, py, vx, vy, x2[3], y2[3], true));
|
||||
|
||||
if (d20 < GEOMETRIC_EPSILON && d23 < GEOMETRIC_EPSILON)
|
||||
{
|
||||
double d11 = getDistance(px, py, vx, vy, x1[1], y1[1], true),
|
||||
d12 = getDistance(px, py, vx, vy, x1[2], y1[2], true),
|
||||
d21 = getDistance(px, py, vx, vy, x2[1], y2[1], true),
|
||||
d22 = getDistance(px, py, vx, vy, x2[2], y2[2], true);
|
||||
double d11 = fabs(getSignedDistance(px, py, vx, vy, x1[1], y1[1], true)),
|
||||
d12 = fabs(getSignedDistance(px, py, vx, vy, x1[2], y1[2], true)),
|
||||
d21 = fabs(getSignedDistance(px, py, vx, vy, x2[1], y2[1], true)),
|
||||
d22 = fabs(getSignedDistance(px, py, vx, vy, x2[2], y2[2], true));
|
||||
|
||||
if (!straightBoth &&
|
||||
d11 < GEOMETRIC_EPSILON &&
|
||||
@ -448,8 +480,8 @@ std::vector<std::pair<double, double>> Curve::GetOverlaps(const Curve& curve) co
|
||||
: std::pair<double, double>(t2, t1);
|
||||
if (pairs.empty())
|
||||
pairs.push_back(pair);
|
||||
else if (abs(pair.first - pairs[0].first) > TIME_EPSILON &&
|
||||
abs(pair.second - pairs[0].second) > TIME_EPSILON)
|
||||
else if (fabs(pair.first - pairs[0].first) > TIME_EPSILON &&
|
||||
fabs(pair.second - pairs[0].second) > TIME_EPSILON)
|
||||
pairs.push_back(pair);
|
||||
}
|
||||
|
||||
@ -464,10 +496,10 @@ std::vector<std::pair<double, double>> Curve::GetOverlaps(const Curve& curve) co
|
||||
Curve o1 = GetPart(pairs[0].first, pairs[1].first),
|
||||
o2 = curve.GetPart(pairs[0].second, pairs[1].second);
|
||||
|
||||
double dox = abs(o2.Segment2.HO.X - o1.Segment2.HO.X),
|
||||
doy = abs(o2.Segment2.HO.Y - o1.Segment2.HO.Y),
|
||||
dix = abs(o2.Segment2.HI.X - o1.Segment2.HI.X),
|
||||
diy = abs(o2.Segment2.HI.Y - o1.Segment2.HI.Y);
|
||||
double dox = fabs(o2.Segment2.HO.X - o1.Segment2.HO.X),
|
||||
doy = fabs(o2.Segment2.HO.Y - o1.Segment2.HO.Y),
|
||||
dix = fabs(o2.Segment2.HI.X - o1.Segment2.HI.X),
|
||||
diy = fabs(o2.Segment2.HI.Y - o1.Segment2.HI.Y);
|
||||
|
||||
if (dox > GEOMETRIC_EPSILON ||
|
||||
doy > GEOMETRIC_EPSILON ||
|
||||
@ -578,9 +610,9 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
std::vector<double>& roots, const double& mn, const double& mx) const noexcept
|
||||
{
|
||||
int count = 0;
|
||||
double f = max(abs(a), abs(b), abs(c), abs(d));
|
||||
double f = max(fabs(a), fabs(b), fabs(c), fabs(d));
|
||||
double x, b1, c2, qd, q;
|
||||
if (f < 1e-8 || f > 1e8)
|
||||
if (f != 0 && (f < 1e-8 || f > 1e8))
|
||||
{
|
||||
f = pow(2, -round(log2(f)));
|
||||
a *= f;
|
||||
@ -589,14 +621,14 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
d *= f;
|
||||
}
|
||||
|
||||
if (abs(a) < EPSILON)
|
||||
if (fabs(a) < EPSILON)
|
||||
{
|
||||
a = b;
|
||||
b1 = c;
|
||||
c2 = d;
|
||||
x = MAX;
|
||||
}
|
||||
else if (abs(d) <EPSILON)
|
||||
else if (fabs(d) <EPSILON)
|
||||
{
|
||||
b1 = b;
|
||||
c2 = c;
|
||||
@ -611,10 +643,10 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
q = c2 * x + d;
|
||||
|
||||
double t = q / a,
|
||||
r = pow(abs(t), 1 / 3),
|
||||
r = pow(fabs(t), 1.0 / 3.0),
|
||||
s = t < 0 ? -1 : 1,
|
||||
td = -qd / a,
|
||||
rd = td > 0 ? 1.324717957244746 * std::max(r, sqrt(td)) : r,
|
||||
rd = td > 0 ? 1.324717957244746 * std::max(r, std::sqrt(td)) : r,
|
||||
x0 = x - s * rd;
|
||||
|
||||
if (x0 != x)
|
||||
@ -629,7 +661,7 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
x0 = qd == 0 ? x : x - q / qd / (1 + MACHINE_EPSILON);
|
||||
} while (s * x0 > s * x);
|
||||
|
||||
if (abs(a) * x * x > abs(d / x))
|
||||
if (fabs(a) * x * x > fabs(d / x))
|
||||
{
|
||||
c2 = -d / x;
|
||||
b1 = (c2 - c) / x;
|
||||
@ -653,8 +685,11 @@ int Curve::SolveCubic(double a, double b, double c, double d,
|
||||
|
||||
void Curve::Flip() noexcept
|
||||
{
|
||||
PointD tmpHI = Segment2.P + Segment2.HI;
|
||||
PointD tmpHO = Segment2.P + Segment2.HO;
|
||||
std::swap(Segment1.P, Segment2.P);
|
||||
std::swap(Segment1.HI, Segment1.HO);
|
||||
Segment2.HI = tmpHI - Segment2.P;
|
||||
Segment2.HO = tmpHO - Segment2.P;
|
||||
}
|
||||
|
||||
bool Curve::IsStraight() const noexcept
|
||||
@ -707,10 +742,12 @@ bool Location::IsTouching() noexcept
|
||||
|
||||
CBooleanOperations::CBooleanOperations(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op) :
|
||||
BooleanOpType op,
|
||||
long fillType) :
|
||||
Op(op),
|
||||
Close1(path1.Is_poly_closed()),
|
||||
Close2(path2.Is_poly_closed()),
|
||||
FillType(fillType),
|
||||
Path1(path1),
|
||||
Path2(path2)
|
||||
{
|
||||
@ -742,9 +779,7 @@ void CBooleanOperations::TraceBoolean()
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (Locations.empty())
|
||||
SetWinding();
|
||||
else
|
||||
if (!Locations.empty())
|
||||
{
|
||||
int length = static_cast<int>(Locations.size());
|
||||
for (int i = 0; i < length; i++)
|
||||
@ -772,31 +807,9 @@ void CBooleanOperations::TraceBoolean()
|
||||
TraceAllOverlap();
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
Segment start = l->S,
|
||||
s = GetNextSegment(l->S);
|
||||
|
||||
if (s.IsEmpty() || s.Inters || s == start)
|
||||
continue;
|
||||
|
||||
int count = 0,
|
||||
touchCount = 0;
|
||||
for (const auto& c : (s.Id == 1 ? OriginCurves2 : OriginCurves1))
|
||||
count += CheckInters(MIN_POINT, s, c, touchCount);
|
||||
|
||||
do
|
||||
{
|
||||
if (s.Id == 1 )
|
||||
Segments1[s.Index].Winding = count % 2;
|
||||
else
|
||||
Segments2[s.Index].Winding = count % 2;
|
||||
s = GetNextSegment(s);
|
||||
} while (!s.IsEmpty() && !s.Inters && s != start);
|
||||
}
|
||||
}
|
||||
|
||||
SetWinding();
|
||||
TracePaths();
|
||||
}
|
||||
|
||||
@ -1014,7 +1027,7 @@ void CBooleanOperations::TracePaths()
|
||||
start = true;
|
||||
while (valid)
|
||||
{
|
||||
if (!start || (Op == Intersection && s.Inters))
|
||||
if (!start || (Op == Intersection && s.Inters && !GetNextSegment(s).Inters))
|
||||
SetVisited(s);
|
||||
|
||||
if (start)
|
||||
@ -1066,12 +1079,12 @@ void CBooleanOperations::PreparePath(const CGraphicsPath& path, int id,
|
||||
bool reverse)
|
||||
{
|
||||
bool isPolyClosed = path.Is_poly_closed();
|
||||
int length = isPolyClosed ? (path.GetPointCount() - 1) : path.GetPointCount();
|
||||
int length = path.GetPointCount();
|
||||
int idx = 0;
|
||||
if (reverse)
|
||||
{
|
||||
bool isCurve = false;
|
||||
for (int i = length; i > 0; i--)
|
||||
for (int i = length - 1; i >= 0; i--)
|
||||
{
|
||||
std::vector<PointD> points = path.GetPoints(isCurve ? i - 2 : i, isCurve ? 3 : 1);
|
||||
if (isCurve) std::reverse(points.begin(), points.end());
|
||||
@ -1111,10 +1124,10 @@ void CBooleanOperations::PreparePath(const CGraphicsPath& path, int id,
|
||||
}
|
||||
}
|
||||
|
||||
length = segments.size();
|
||||
length = isPolyClosed ? static_cast<int>(segments.size()) : static_cast<int>(segments.size()) - 1;
|
||||
|
||||
for (int i = 0; i < length; i++)
|
||||
curves.push_back(Curve(segments[i], i == (length - 1) ? segments[0] : segments[i + 1]));
|
||||
curves.push_back(Curve(segments[i], isPolyClosed && (i == (length - 1)) ? segments[0] : segments[i + 1]));
|
||||
}
|
||||
|
||||
void CBooleanOperations::InsertSegment(Segment& segment, const Segment& handles, bool updateHandles)
|
||||
@ -1240,35 +1253,22 @@ void CBooleanOperations::SetVisited(const Segment& segment)
|
||||
Segments2[segment.Index].Visited = true;
|
||||
}
|
||||
|
||||
std::vector<std::vector<double>> CBooleanOperations::GetBoundsForCurves(const std::vector<Curve>& curves) const noexcept
|
||||
{
|
||||
std::vector<std::vector<double>> bounds;
|
||||
for (int i = 0; i < curves.size(); i++)
|
||||
{
|
||||
std::vector<double> x = curves[i].GetXValues(),
|
||||
y = curves[i].GetYValues();
|
||||
bounds.push_back({min(x[0], x[1], x[2], x[3]),
|
||||
min(y[0], y[1], y[2], y[3]),
|
||||
max(x[0], x[1], x[2], x[3]),
|
||||
max(y[0], y[1], y[2], y[3])});
|
||||
}
|
||||
return bounds;
|
||||
}
|
||||
|
||||
std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
{
|
||||
std::vector<std::vector<double>> bounds1 = GetBoundsForCurves(Curves1);
|
||||
std::vector<std::vector<double>> bounds2 = GetBoundsForCurves(Curves2);
|
||||
std::vector<std::vector<double>> allBounds, bounds2;
|
||||
for (const auto& c : Curves1)
|
||||
allBounds.push_back(c.GetBound());
|
||||
for (const auto& c : Curves2)
|
||||
bounds2.push_back(c.GetBound());
|
||||
|
||||
bool self = bounds1 == bounds2;
|
||||
bool self = allBounds == bounds2;
|
||||
|
||||
std::vector<std::vector<double>> allBounds(bounds1);
|
||||
if (!self)
|
||||
for (auto it = bounds2.begin(); it != bounds2.end(); ++it) // std::copy(bounds2.begin(), bounds2.end(), std::back_inserter(allBounds));
|
||||
for (auto it = bounds2.begin(); it != bounds2.end(); ++it)
|
||||
allBounds.push_back(*it);
|
||||
|
||||
int allLength = static_cast<int>(allBounds.size()),
|
||||
length1 = static_cast<int>(bounds1.size());
|
||||
length1 = static_cast<int>(Curves1.size());
|
||||
|
||||
std::vector<int> allIdicesByPri1(allLength);
|
||||
for (int i = 0; i < allLength; i++)
|
||||
@ -1284,56 +1284,47 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
std::vector<std::vector<int>> allCollisions(length1);
|
||||
for (int i = 0; i < allLength; i++)
|
||||
{
|
||||
int curIndex = allIdicesByPri1[i];
|
||||
std::vector<double> curBounds = allBounds[curIndex];
|
||||
std::vector<int> curCollisions;
|
||||
bool isCurrent1 = curIndex < length1,
|
||||
bool isCurrent1 = allIdicesByPri1[i] < length1,
|
||||
isCurrent2 = self || !isCurrent1;
|
||||
int origIndex = self ? curIndex : curIndex - length1;
|
||||
int origIndex = self ? allIdicesByPri1[i] : allIdicesByPri1[i] - length1;
|
||||
|
||||
if (!activeIndicesByPri2.empty())
|
||||
{
|
||||
int pruneCount = binarySearch(allBounds, activeIndicesByPri2, 2,
|
||||
curBounds[0] - GEOMETRIC_EPSILON) + 1;
|
||||
allBounds[allIdicesByPri1[i]][0] - GEOMETRIC_EPSILON) + 1;
|
||||
|
||||
activeIndicesByPri2.erase(activeIndicesByPri2.begin(),
|
||||
activeIndicesByPri2.begin() + pruneCount);
|
||||
|
||||
double curSec2 = curBounds[3],
|
||||
curSec1 = curBounds[1];
|
||||
for (int j = 0; j < static_cast<int>(activeIndicesByPri2.size()); j++)
|
||||
{
|
||||
int activeIndex = activeIndicesByPri2[j];
|
||||
std::vector<double> activeBounds = allBounds[activeIndex];
|
||||
bool isActive1 = activeIndex < length1,
|
||||
bool isActive1 = activeIndicesByPri2[j] < length1,
|
||||
isActive2 = self || !isActive1,
|
||||
isActive1Or2 = (isCurrent1 && isActive2) || (isCurrent2 && isActive1),
|
||||
inRange1 = curSec1 <= activeBounds[3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = curSec2 >= activeBounds[1] - GEOMETRIC_EPSILON;
|
||||
inRange1 = allBounds[allIdicesByPri1[i]][1] <= allBounds[activeIndicesByPri2[j]][3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = allBounds[allIdicesByPri1[i]][3] >= allBounds[activeIndicesByPri2[j]][1] - GEOMETRIC_EPSILON;
|
||||
|
||||
if (isActive1Or2 && (inRange2 && inRange1))
|
||||
{
|
||||
if (isCurrent1 && isActive2)
|
||||
curCollisions.push_back(self ? activeIndex : activeIndex - length1);
|
||||
curCollisions.push_back(self ? activeIndicesByPri2[j] : activeIndicesByPri2[j] - length1);
|
||||
if (isCurrent2 && isActive1)
|
||||
allCollisions[activeIndex].push_back(origIndex);
|
||||
allCollisions[activeIndicesByPri2[j]].push_back(origIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isCurrent1)
|
||||
{
|
||||
if (bounds1 == bounds2)
|
||||
curCollisions.push_back(curIndex);
|
||||
allCollisions[curIndex] = curCollisions;
|
||||
if (self) curCollisions.push_back(allIdicesByPri1[i]);
|
||||
allCollisions[allIdicesByPri1[i]] = curCollisions;
|
||||
}
|
||||
if (activeIndicesByPri2.size() > 0)
|
||||
{
|
||||
double curPri2 = curBounds[2];
|
||||
int index = binarySearch(allBounds, activeIndicesByPri2, 2, curPri2);
|
||||
activeIndicesByPri2.insert(activeIndicesByPri2.begin() + (1 + index), curIndex);
|
||||
int index = 1 + binarySearch(allBounds, activeIndicesByPri2, 2, allBounds[allIdicesByPri1[i]][2]);
|
||||
activeIndicesByPri2.insert(activeIndicesByPri2.begin() + index, allIdicesByPri1[i]);
|
||||
}
|
||||
else
|
||||
activeIndicesByPri2.push_back(curIndex);
|
||||
activeIndicesByPri2.push_back(allIdicesByPri1[i]);
|
||||
}
|
||||
|
||||
for (auto& c : allCollisions)
|
||||
@ -1406,11 +1397,6 @@ bool CBooleanOperations::IsCrossing(std::shared_ptr<Location> loc) noexcept
|
||||
return t1Inside ? inRange1 : inRange2;
|
||||
}
|
||||
|
||||
bool CBooleanOperations::FilterIntersections(std::shared_ptr<Location> loc) noexcept
|
||||
{
|
||||
return loc->Overlap || IsCrossing(loc);
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IntersectsBounds() noexcept
|
||||
{
|
||||
RectF_T<double> rect1, rect2;
|
||||
@ -1425,17 +1411,12 @@ bool CBooleanOperations::IntersectsBounds() noexcept
|
||||
|
||||
void CBooleanOperations::GetIntersection()
|
||||
{
|
||||
if (!IntersectsBounds())
|
||||
return;
|
||||
if (!IntersectsBounds()) return;
|
||||
|
||||
std::vector<std::vector<int>> boundsCollisions = FindBoundsCollisions();
|
||||
for (int index1 = 0; index1 < Curves1.size(); index1++)
|
||||
{
|
||||
std::vector<int> collisions1 = boundsCollisions[index1];
|
||||
if (!collisions1.empty())
|
||||
for (int j = 0; j < collisions1.size(); j++)
|
||||
GetCurveIntersection(Curves1[index1], Curves2[collisions1[j]]);
|
||||
}
|
||||
for (int j = 0; j < boundsCollisions[index1].size(); j++)
|
||||
GetCurveIntersection(Curves1[index1], Curves2[boundsCollisions[index1][j]]);
|
||||
}
|
||||
|
||||
void CBooleanOperations::GetCurveIntersection(const Curve& curve1, const Curve& curve2)
|
||||
@ -1543,7 +1524,7 @@ void CBooleanOperations::AddCurveLineIntersection(const Curve& curve1, const Cur
|
||||
}
|
||||
}
|
||||
|
||||
int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const Curve& startCurve1,
|
||||
int CBooleanOperations::AddCurveIntersection(const Curve& curve1, const Curve& curve2, const Curve& startCurve1,
|
||||
const Curve& startCurve2, bool flip,
|
||||
int recursion, int calls, double tMin,
|
||||
double tMax, double uMin, double uMax)
|
||||
@ -1556,19 +1537,19 @@ int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const C
|
||||
x2 = curve2.GetXValues(),
|
||||
y2 = curve2.GetYValues();
|
||||
|
||||
double d1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[1], y2[1]),
|
||||
d2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[2], y2[2]),
|
||||
double d1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[1], y2[1], false),
|
||||
d2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x2[2], y2[2], false),
|
||||
factor = (d1 * d2) > 0 ? 3.0 / 4.0 : 4.0 / 9.0,
|
||||
dMin = factor * min(0, d1, d2),
|
||||
dMax = factor * max(0, d1, d2),
|
||||
dp0 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[0], y1[0]),
|
||||
dp1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[1], y1[1]),
|
||||
dp2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[2], y1[2]),
|
||||
dp3 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[3], y1[3]);
|
||||
dp0 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[0], y1[0], false),
|
||||
dp1 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[1], y1[1], false),
|
||||
dp2 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[2], y1[2], false),
|
||||
dp3 = getSignedDistance(x2[0], y2[0], x2[3], y2[3], x1[3], y1[3], false);
|
||||
|
||||
std::vector<std::vector<PointD>> hull = getConvexHull(dp0, dp1, dp2, dp3);
|
||||
std::vector<PointD> top = hull[0],
|
||||
bottom = hull[1];
|
||||
std::vector<PointD> top;
|
||||
std::vector<PointD> bottom;
|
||||
getConvexHull(dp0, dp1, dp2, dp3, top, bottom);
|
||||
|
||||
double tMinClip = clipConvexHull(top, bottom, dMin, dMax);
|
||||
|
||||
@ -1599,14 +1580,14 @@ int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const C
|
||||
}
|
||||
else
|
||||
{
|
||||
curve1 = curve1.GetPart(tMinClip, tMaxClip);
|
||||
Curve newCurve1 = curve1.GetPart(tMinClip, tMaxClip);
|
||||
double uDiff = uMax - uMin;
|
||||
|
||||
if (tMaxClip - tMinClip > 0.8)
|
||||
{
|
||||
if (tMaxNew - tMinNew > uDiff)
|
||||
{
|
||||
std::vector<Curve> parts = curve1.Subdivide(0.5);
|
||||
std::vector<Curve> parts = newCurve1.Subdivide(0.5);
|
||||
double t = (tMinNew + tMaxNew) / 2;
|
||||
|
||||
parts[0].Segment2.SetHandles(parts[0].Segment2.HI, parts[0].Segment2.HO);
|
||||
@ -1625,19 +1606,19 @@ int CBooleanOperations::AddCurveIntersection(Curve curve1, Curve curve2, const C
|
||||
parts[0].Segment2.SetHandles(parts[0].Segment2.HI, parts[0].Segment2.HO);
|
||||
parts[1].Segment2.SetHandles(parts[1].Segment2.HI, parts[1].Segment2.HO);
|
||||
|
||||
calls = AddCurveIntersection(parts[0], curve1, startCurve2, startCurve1,
|
||||
calls = AddCurveIntersection(parts[0], newCurve1, startCurve2, startCurve1,
|
||||
!flip, recursion, calls, uMin, u, tMinNew, tMaxNew);
|
||||
calls = AddCurveIntersection(parts[1], curve1, startCurve2, startCurve1,
|
||||
calls = AddCurveIntersection(parts[1], newCurve1, startCurve2, startCurve1,
|
||||
!flip, recursion, calls, u, uMax, tMinNew, tMaxNew);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uDiff == 0 || uDiff >= LINE_EPSILON)
|
||||
calls = AddCurveIntersection(curve2, curve1, startCurve2, startCurve1,
|
||||
calls = AddCurveIntersection(curve2, newCurve1, startCurve2, startCurve1,
|
||||
!flip, recursion, calls, uMin, uMax, tMinNew, tMaxNew);
|
||||
else
|
||||
calls = AddCurveIntersection(curve1, curve2, startCurve1, startCurve2,
|
||||
calls = AddCurveIntersection(newCurve1, curve2, startCurve1, startCurve2,
|
||||
flip, recursion, calls, tMinNew, tMaxNew, uMin, uMax);
|
||||
}
|
||||
}
|
||||
@ -1650,14 +1631,12 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
PointD pt{};
|
||||
if (intersect({point.X, point.Y, segment.P.X, segment.P.Y, curve.Segment1.P.X, curve.Segment1.P.Y, curve.Segment2.P.X, curve.Segment2.P.Y}, pt))
|
||||
{
|
||||
if (getDistance(segment.P, pt) <= GEOMETRIC_EPSILON) return (touchCount + 1) % 2;
|
||||
if (getDistance(curve.Segment1.P, pt) <= GEOMETRIC_EPSILON || getDistance(curve.Segment2.P, pt) <= GEOMETRIC_EPSILON)
|
||||
{
|
||||
int tmp = touchCount % 2;
|
||||
touchCount++;
|
||||
return tmp;
|
||||
}
|
||||
return ++touchCount % 2;
|
||||
else if (curve.IsStraight())
|
||||
{
|
||||
touchCount++;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@ -1678,31 +1657,63 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
|
||||
void CBooleanOperations::SetWinding()
|
||||
{
|
||||
Segment s1, s2;
|
||||
if (Locations.empty() || (Locations.size() == 2 && Locations[0]->Ends))
|
||||
{
|
||||
Segment s1, s2;
|
||||
|
||||
for (const auto& s : Segments1)
|
||||
if (!s.Inters)
|
||||
s1 = s;
|
||||
for (const auto& s : Segments1)
|
||||
if (!s.Inters)
|
||||
s1 = s;
|
||||
|
||||
for (const auto& s : Segments2)
|
||||
if (!s.Inters)
|
||||
s2 = s;
|
||||
for (const auto& s : Segments2)
|
||||
if (!s.Inters)
|
||||
s2 = s;
|
||||
|
||||
int count = 0,
|
||||
int count = 0,
|
||||
touchCount = 0;
|
||||
for (const auto& c : OriginCurves2)
|
||||
count += CheckInters(MIN_POINT, s1, c, touchCount);
|
||||
|
||||
for (auto& s : Segments1)
|
||||
s.Winding = count % 2;
|
||||
|
||||
count = 0;
|
||||
touchCount = 0;
|
||||
for (const auto& c : OriginCurves2)
|
||||
count += CheckInters(MIN_POINT, s1, c, touchCount);
|
||||
for (const auto& c : OriginCurves1)
|
||||
count += CheckInters(MIN_POINT, s2, c, touchCount);
|
||||
|
||||
for (auto& s : Segments1)
|
||||
s.Winding = count % 2;
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = count % 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
Segment start = l->S,
|
||||
s = GetNextSegment(l->S);
|
||||
|
||||
count = 0;
|
||||
touchCount = 0;
|
||||
for (const auto& c : OriginCurves1)
|
||||
count += CheckInters(MIN_POINT, s2, c, touchCount);
|
||||
if (s.IsEmpty() || s.Inters || s == start)
|
||||
continue;
|
||||
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = count % 2;
|
||||
int count = 0,
|
||||
touchCount = 0;
|
||||
for (const auto& c : (s.Id == 1 ? OriginCurves2 : OriginCurves1))
|
||||
count += CheckInters(MIN_POINT, s, c, touchCount);
|
||||
|
||||
do
|
||||
{
|
||||
if (s.Id == 1 )
|
||||
Segments1[s.Index].Winding = count % 2;
|
||||
else
|
||||
Segments2[s.Index].Winding = count % 2;
|
||||
s = GetNextSegment(s);
|
||||
} while (!s.IsEmpty() && !s.Inters && s != start);
|
||||
}
|
||||
}
|
||||
|
||||
if (FillType & c_nStroke)
|
||||
for (auto& s : Segments2)
|
||||
s.Winding = 0;
|
||||
}
|
||||
|
||||
void CBooleanOperations::DivideLocations()
|
||||
@ -1872,7 +1883,7 @@ void CBooleanOperations::AddLocation(Curve curve1, Curve curve2, double t1,
|
||||
loc1->Inters = loc2;
|
||||
loc2->Inters = loc1;
|
||||
|
||||
if (!filter || FilterIntersections(loc1))
|
||||
if (!filter || loc1->Overlap || IsCrossing(loc1))
|
||||
InsertLocation(loc1, overlap);
|
||||
}
|
||||
}
|
||||
@ -1894,7 +1905,8 @@ void CBooleanOperations::AddOffsets(std::vector<double>& offsets,
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op)
|
||||
BooleanOpType op,
|
||||
long fillType)
|
||||
{
|
||||
std::vector<CGraphicsPath> paths1 = path1.GetSubPaths(),
|
||||
paths2 = path2.GetSubPaths(),
|
||||
@ -1904,7 +1916,7 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
{
|
||||
for (const auto& p2 : paths2)
|
||||
{
|
||||
CBooleanOperations operation(p1, p2, op);
|
||||
CBooleanOperations operation(p1, p2, op, fillType);
|
||||
paths.push_back(operation.GetResult());
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,6 +54,7 @@ namespace Aggplus
|
||||
|
||||
std::vector<double> GetXValues() const noexcept;
|
||||
std::vector<double> GetYValues() const noexcept;
|
||||
std::vector<double> GetBound() const noexcept;
|
||||
std::vector<double> GetPeeks() const;
|
||||
double GetLength(double a = 0, double b = 1) const;
|
||||
double GetSquaredLineLength() const noexcept;
|
||||
@ -81,7 +82,6 @@ namespace Aggplus
|
||||
void Flip() noexcept;
|
||||
|
||||
bool IsStraight() const noexcept;
|
||||
bool HasHandle() const noexcept;
|
||||
bool operator==(const Curve& other) const noexcept;
|
||||
bool operator!=(const Curve& other) const noexcept;
|
||||
};
|
||||
@ -107,7 +107,7 @@ namespace Aggplus
|
||||
class CBooleanOperations
|
||||
{
|
||||
public:
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op);
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
|
||||
@ -128,19 +128,17 @@ namespace Aggplus
|
||||
void SetVisited(const Segment& segment);
|
||||
|
||||
// Bounds
|
||||
std::vector<std::vector<double>> GetBoundsForCurves(const std::vector<Curve>& curves) const noexcept;
|
||||
std::vector<std::vector<int>> FindBoundsCollisions();
|
||||
|
||||
// Intersection
|
||||
bool IsCrossing(std::shared_ptr<Location> loc) noexcept;
|
||||
bool FilterIntersections(std::shared_ptr<Location> loc) noexcept;
|
||||
bool IntersectsBounds() noexcept;
|
||||
void GetIntersection();
|
||||
void GetCurveIntersection(const Curve& curve1, const Curve& curve2);
|
||||
void LinkIntersection(std::shared_ptr<Location> form, std::shared_ptr<Location> to);
|
||||
void AddLineIntersection(const Curve& curve1, const Curve& curve2);
|
||||
void AddCurveLineIntersection(const Curve& curve1, const Curve& curve2, bool flip);
|
||||
int AddCurveIntersection(Curve curve1, Curve curve2, const Curve& startCurve1, const Curve& startCurve2, bool flip,
|
||||
int AddCurveIntersection(const Curve& curve1, const Curve& curve2, const Curve& startCurve1, const Curve& startCurve2, bool flip,
|
||||
int recursion = 0, int calls = 0, double tMin = 0.0, double tMax = 1.0, double uMin = 0.0, double uMax = 1.0);
|
||||
int CheckInters(const PointD& point, const Segment& segment, const Curve& curve, int& touchCount) const;
|
||||
void SetWinding();
|
||||
@ -159,6 +157,9 @@ namespace Aggplus
|
||||
bool Close1 = true;
|
||||
bool Close2 = true;
|
||||
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
CGraphicsPath Path1;
|
||||
CGraphicsPath Path2;
|
||||
CGraphicsPath Result;
|
||||
|
||||
@ -1297,7 +1297,9 @@ namespace Aggplus
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
RELEASEINTERFACE(m_pSoftMask);
|
||||
|
||||
m_pSoftMask = new CSoftMask(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), bAlpha ? EMaskDataType::Alpha4Buffer : EMaskDataType::ImageBuffer, false, m_frame_buffer.ren_buf().stride() < 0);
|
||||
unsigned int unWidth = m_frame_buffer.ren_buf().width(), unHeight = m_frame_buffer.ren_buf().height();
|
||||
bool bFlip = m_frame_buffer.ren_buf().stride() < 0;
|
||||
m_pSoftMask = new CSoftMask(pBuffer, unWidth, unHeight, bFlip, m_bSwapRGB, bAlpha);
|
||||
|
||||
pBuffer = m_arLayers.empty() ? m_pPixels : m_arLayers.top()->GetBuffer();
|
||||
if (!pBuffer)
|
||||
@ -1306,7 +1308,7 @@ namespace Aggplus
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), m_frame_buffer.ren_buf().stride());
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, unWidth, unHeight, m_frame_buffer.ren_buf().stride());
|
||||
|
||||
return m_pSoftMask;
|
||||
}
|
||||
@ -1401,19 +1403,13 @@ namespace Aggplus
|
||||
}
|
||||
else if (m_pSoftMask)
|
||||
{
|
||||
switch(m_pSoftMask->GetDataType())
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
ESoftMaskType nType = m_pSoftMask->GetDataType();
|
||||
if (nType == ESoftMaskType::RGBGrayBuffer)
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<0, 1, 2>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
else if (nType == ESoftMaskType::BGRGrayBuffer)
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<2, 1, 0>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
else if (nType == ESoftMaskType::Alpha4Buffer)
|
||||
Aggplus::BlendTo<agg::one_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer() + 3, m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1549,10 +1545,13 @@ namespace Aggplus
|
||||
{
|
||||
if (m_pSoftMask)
|
||||
{
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::ImageBuffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineImage());
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineABuffer());
|
||||
ESoftMaskType nType = m_pSoftMask->GetDataType();
|
||||
if (nType == ESoftMaskType::RGBGrayBuffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskRGBAgray*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
if (nType == ESoftMaskType::BGRGrayBuffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskBGRAgray*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
if (nType == ESoftMaskType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, ((CSoftMaskAlpha*)m_pSoftMask->m_pInternal)->GetScanline());
|
||||
}
|
||||
render_scanlines_3(ras, ren, m_rasterizer.get_scanline());
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@
|
||||
#include "Matrix.h"
|
||||
#include "GraphicsLayerBlend.h"
|
||||
#include "GraphicsPath.h"
|
||||
#include "AlphaMask.h"
|
||||
#include "AlphaMask_p.h"
|
||||
#include "Clip.h"
|
||||
#include "Brush.h"
|
||||
#include "Image.h"
|
||||
|
||||
@ -76,7 +76,7 @@ namespace Aggplus
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
CloseFigure();
|
||||
if (p.Is_poly_closed()) CloseFigure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ namespace Aggplus
|
||||
Exclusion = 3
|
||||
};
|
||||
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op);
|
||||
GRAPHICS_DECL CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType = c_nWindingFillMode);
|
||||
|
||||
} // namespace Aggplus
|
||||
|
||||
|
||||
@ -955,61 +955,62 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
}
|
||||
|
||||
Aggplus::CBrushTexture* pTextureBrush = NULL;
|
||||
|
||||
if (NULL != m_pCache)
|
||||
{
|
||||
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
|
||||
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
|
||||
if (NULL != m_oBrush.Image)
|
||||
{
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
}
|
||||
else if (m_oBrush.TexturePath.find(L"data:") == 0)
|
||||
{
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
|
||||
int countErase = (int)(m_oBrush.TexturePath.find(',') + 1);
|
||||
int nInputSize = (int)(m_oBrush.TexturePath.length() - countErase);
|
||||
const wchar_t* pInputSrc = m_oBrush.TexturePath.c_str() + countErase;
|
||||
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nInputSize);
|
||||
BYTE* pImageData = new BYTE[nDecodeLen];
|
||||
if (TRUE == NSBase64::Base64Decode(pInputSrc, nInputSize, pImageData, &nDecodeLen))
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
if (bIsOnlyOfficeHatch)
|
||||
{
|
||||
int nSize = (int)sqrt(nDecodeLen >> 2);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width(nSize);
|
||||
oFrame.put_Height(nSize);
|
||||
oFrame.put_Stride(4 * nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
oFrame.put_IsRGBA(false);
|
||||
oFrame.Decode(pImageData, nDecodeLen);
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
// pImage отдается pTextureBrush и освобождается вместе с pBrush
|
||||
Aggplus::CImage* pImage = new Aggplus::CImage();
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef BUILDING_WASM_MODULE
|
||||
if (NULL != m_oBrush.Image)
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
else if (m_oBrush.TexturePath.find(L"data:") == 0)
|
||||
if (NULL != m_pCache)
|
||||
{
|
||||
bool bIsOnlyOfficeHatch = false;
|
||||
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
|
||||
bIsOnlyOfficeHatch = true;
|
||||
std::string sBase64MultyByte(m_oBrush.TexturePath.begin(), m_oBrush.TexturePath.end());
|
||||
sBase64MultyByte.erase(0, sBase64MultyByte.find(',') + 1);
|
||||
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(sBase64MultyByte.length());
|
||||
BYTE* pImageData = new BYTE[nDecodeLen + 64];
|
||||
if (TRUE == NSBase64::Base64Decode(sBase64MultyByte.c_str(), sBase64MultyByte.length(), pImageData, &nDecodeLen))
|
||||
{
|
||||
CBgraFrame oFrame;
|
||||
if (bIsOnlyOfficeHatch)
|
||||
{
|
||||
int nSize = (int)sqrt(nDecodeLen >> 2);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.put_Data(pImageData);
|
||||
oFrame.put_Width(nSize);
|
||||
oFrame.put_Height(nSize);
|
||||
oFrame.put_Stride(4 * nSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
oFrame.put_IsRGBA(false);
|
||||
oFrame.Decode(pImageData, nDecodeLen);
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
}
|
||||
// pImage отдается pTextureBrush и освобождается вместе с pBrush
|
||||
Aggplus::CImage* pImage = new Aggplus::CImage();
|
||||
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
|
||||
oFrame.ClearNoAttack();
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
|
||||
pTextureBrush->m_bReleaseImage = TRUE;
|
||||
}
|
||||
else
|
||||
RELEASEARRAYOBJECTS(pImageData);
|
||||
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
|
||||
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
|
||||
}
|
||||
#else
|
||||
if (NULL != m_oBrush.Image)
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
|
||||
else
|
||||
{
|
||||
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.TexturePath, oMode);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if( pTextureBrush )
|
||||
|
||||
@ -312,14 +312,14 @@ namespace Aggplus
|
||||
agg::trans_affine& m1 = mm1->m_internal->m_agg_mtx;
|
||||
agg::trans_affine& m2 = mm2->m_internal->m_agg_mtx;
|
||||
|
||||
bool bMain = (fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps) ? true : false;
|
||||
bool bMain = fabs(m1.sx - m2.sx) < eps &&
|
||||
fabs(m1.sy - m2.sy) < eps &&
|
||||
fabs(m1.shx - m2.shx) < eps &&
|
||||
fabs(m1.shy - m2.shy) < eps;
|
||||
|
||||
if (!bMain || bIsOnlyMain)
|
||||
return bMain;
|
||||
|
||||
return (fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps) ? true : false;
|
||||
return fabs(m1.tx - m2.tx) < eps && fabs(m1.ty - m2.ty) < eps;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,7 @@ constexpr double CURVETIME_EPSILON = 1e-8;
|
||||
constexpr double LINE_EPSILON = 1e-9;
|
||||
constexpr double MIN = std::numeric_limits<double>::min();
|
||||
constexpr double MAX = std::numeric_limits<double>::max();
|
||||
const Aggplus::PointD MIN_POINT(-500.0, -500.0);
|
||||
const Aggplus::PointD MIN_POINT = Aggplus::PointD(-100000.0, -100000.0);
|
||||
|
||||
const std::vector<double> ABSCISSAS[16] = {
|
||||
{0.5773502691896257645091488},
|
||||
@ -124,14 +124,12 @@ inline double clamp(const double& value, const double& mn, const double& mx)
|
||||
|
||||
inline bool isCollinear(const Aggplus::PointD& p1, const Aggplus::PointD& p2)
|
||||
{
|
||||
return abs(p1.X * p2.X + p1.Y * p2.Y) <= sqrt((p1.X * p1.X + p1.Y * p1.Y) * (p2.X * p2.X + p2.Y * p2.Y)) * TRIGANOMETRIC_EPSILON;
|
||||
return fabs(p1.X * p2.X + p1.Y * p2.Y) <= sqrt((p1.X * p1.X + p1.Y * p1.Y) * (p2.X * p2.X + p2.Y * p2.Y)) * TRIGANOMETRIC_EPSILON;
|
||||
}
|
||||
|
||||
inline int getIterations(const double& a, const double& b)
|
||||
{
|
||||
double n1 = 2.0, n2 = 16.0;
|
||||
|
||||
return std::max(n1, std::min(n2, ceil(abs(b - a) * 32)));
|
||||
return std::max(2, std::min(16, static_cast<int>(ceil(fabs(b - a) * 32))));
|
||||
}
|
||||
|
||||
inline double CurveLength(const double& t, const double& ax, const double& bx, const double& cx,
|
||||
@ -143,64 +141,17 @@ inline double CurveLength(const double& t, const double& ax, const double& bx, c
|
||||
inline double integrate(const double& ax, const double& bx, const double& cx, const double& ay,
|
||||
const double& by, const double& cy, const double& a, const double& b, size_t n = 16)
|
||||
{
|
||||
std::vector<double> x = ABSCISSAS[n - 2],
|
||||
w = WEIGHT[n - 2];
|
||||
|
||||
double A = (b - a) * 0.5,
|
||||
B = A + a;
|
||||
double sum = n & 1 ? CurveLength(B, ax, bx, cx, ay, by, cy) : 0.0;
|
||||
double A = (b - a) * 0.5;
|
||||
double sum = n & 1 ? CurveLength(A + a, ax, bx, cx, ay, by, cy) : 0.0;
|
||||
|
||||
for (size_t i = 0; i < (n + 1) >> 1; i++)
|
||||
{
|
||||
double Ax = A * x[i];
|
||||
sum += w[i] * (CurveLength(B + Ax, ax, bx, cx, ay, by, cy) +
|
||||
CurveLength(B - Ax, ax, bx, cx, ay, by, cy));
|
||||
}
|
||||
sum += WEIGHT[n - 2][i] * (CurveLength(A + a + A * ABSCISSAS[n - 2][i], ax, bx, cx, ay, by, cy) +
|
||||
CurveLength(A + a - A * ABSCISSAS[n - 2][i], ax, bx, cx, ay, by, cy));
|
||||
|
||||
return A * sum;
|
||||
}
|
||||
|
||||
double fLength(const double& t, double& length, double& start, const double& offset,
|
||||
const double& ax, const double& bx, const double& cx, const double& ay,
|
||||
const double& by, const double& cy)
|
||||
{
|
||||
length += integrate(ax, bx, cx, ay, by, cy, start, t, getIterations(start, t));
|
||||
start = t;
|
||||
|
||||
return length - offset;
|
||||
}
|
||||
|
||||
double findRoot(double& length, double& start, const double& offset, const double& ax,
|
||||
const double& bx, const double& cx, const double& ay, const double& by,
|
||||
const double& cy, double x, double a, double b)
|
||||
{
|
||||
for (size_t i = 0; i < 32; i++)
|
||||
{
|
||||
double fx = fLength(x, length, start, offset, ax, bx, cx, ay, by, cy),
|
||||
dx = fx / CurveLength(x, ax, bx, cx, ay, by, cy),
|
||||
nx = x - dx;
|
||||
|
||||
if (abs(dx) < EPSILON)
|
||||
{
|
||||
x = nx;
|
||||
break;
|
||||
}
|
||||
|
||||
if (fx > 0)
|
||||
{
|
||||
b = x;
|
||||
x = nx <= a ? (a + b) * 0.5 : nx;
|
||||
}
|
||||
else{
|
||||
a = x;
|
||||
x = nx >= b ? (a + b) * 0.5 : nx;
|
||||
}
|
||||
}
|
||||
|
||||
return clamp(x, a, b);
|
||||
}
|
||||
|
||||
bool intersect(std::vector<double> v, Aggplus::PointD& res)
|
||||
inline bool intersect(std::vector<double> v, Aggplus::PointD& res)
|
||||
{
|
||||
v[2] -= v[0];
|
||||
v[3] -= v[1];
|
||||
@ -229,8 +180,10 @@ bool intersect(std::vector<double> v, Aggplus::PointD& res)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::vector<Aggplus::PointD>> getConvexHull(const double& dq0, const double& dq1,
|
||||
const double& dq2, const double& dq3)
|
||||
inline void getConvexHull(const double& dq0, const double& dq1,
|
||||
const double& dq2, const double& dq3,
|
||||
std::vector<Aggplus::PointD>& top,
|
||||
std::vector<Aggplus::PointD>& bottom)
|
||||
{
|
||||
Aggplus::PointD p0 = Aggplus::PointD(0.0, dq0),
|
||||
p1 = Aggplus::PointD(1.0 / 3.0, dq1),
|
||||
@ -240,30 +193,62 @@ std::vector<std::vector<Aggplus::PointD>> getConvexHull(const double& dq0, const
|
||||
double dist1 = dq1 - (2.0 * dq0 + dq3) / 3.0,
|
||||
dist2 = dq2 - (dq0 + 2.0 * dq3) / 3.0;
|
||||
|
||||
std::vector<std::vector<Aggplus::PointD>> hull;
|
||||
|
||||
if (dist1 * dist2 < 0.0)
|
||||
{
|
||||
hull = {{p0, p1, p3}, {p0, p2, p3}};
|
||||
top.reserve(3);
|
||||
top.push_back(p0);
|
||||
top.push_back(p1);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(3);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p2);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
else
|
||||
{
|
||||
double distRatio = dist1 / dist2;
|
||||
if (distRatio >= 2.0)
|
||||
hull = {{p0, p1, p3}, {p0, p3}};
|
||||
{
|
||||
top.reserve(3);
|
||||
top.push_back(p0);
|
||||
top.push_back(p1);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(2);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
else if (distRatio <= 0.5)
|
||||
hull = {{p0, p2, p3}, {p0, p3}};
|
||||
{
|
||||
top.reserve(3);
|
||||
top.push_back(p0);
|
||||
top.push_back(p2);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(2);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
else
|
||||
hull = {{p0, p1, p2, p3}, {p0, p3}};
|
||||
{
|
||||
top.reserve(4);
|
||||
top.push_back(p0);
|
||||
top.push_back(p1);
|
||||
top.push_back(p2);
|
||||
top.push_back(p3);
|
||||
|
||||
bottom.reserve(2);
|
||||
bottom.push_back(p0);
|
||||
bottom.push_back(p3);
|
||||
}
|
||||
}
|
||||
|
||||
if (dist1 < 0.0 || dist2 < 0.0)
|
||||
std::reverse(hull.begin(), hull.end());
|
||||
|
||||
return hull;
|
||||
std::swap(top, bottom);
|
||||
}
|
||||
|
||||
double clipConvexHullPart(const std::vector<Aggplus::PointD>& part, const bool& top,
|
||||
inline double clipConvexHullPart(const std::vector<Aggplus::PointD>& part, const bool& top,
|
||||
const double& threshold)
|
||||
{
|
||||
double px = part[0].X,
|
||||
@ -314,7 +299,7 @@ inline int binarySearch(const std::vector<std::vector<double>>& allBounds,
|
||||
}
|
||||
|
||||
inline double getSignedDistance(const double& px, const double& py, double vx, double vy,
|
||||
const double& x, const double& y, bool asVector = false)
|
||||
const double& x, const double& y, const bool& asVector)
|
||||
{
|
||||
if (!asVector)
|
||||
{
|
||||
@ -337,38 +322,6 @@ inline double getSignedDistance(const double& px, const double& py, double vx, d
|
||||
return vx0 ? distX : vy0 ? distY : distXY;
|
||||
}
|
||||
|
||||
inline double getDistance(const double& px, const double& py, const double& vx, const double& vy,
|
||||
const double& x, const double& y, const bool& asVector)
|
||||
{
|
||||
return abs(getSignedDistance(px, py, vx, vy, x, y, asVector));
|
||||
}
|
||||
|
||||
inline double getDistance(const double& px, const double& py, const double& vx, const double& vy,
|
||||
const double& x, const double& y)
|
||||
{
|
||||
if (vx == 0)
|
||||
{
|
||||
if (vy > 0)
|
||||
return std::abs(x - px);
|
||||
else
|
||||
return std::abs(px - x);
|
||||
}
|
||||
if (vy == 0)
|
||||
{
|
||||
if (vx < 0)
|
||||
return std::abs(y - py);
|
||||
else
|
||||
return std::abs(py -y);
|
||||
}
|
||||
|
||||
bool dir = vy > vx;
|
||||
double dist = (x- px) * vy - (y - py) * vx,
|
||||
epsY = vy * sqrt(1 + (vx * vx) / (vy * vy)),
|
||||
epsX = vx * sqrt(1 + (vy * vy) / (vx * vx));
|
||||
|
||||
return dist / (dir ? epsY : epsX);
|
||||
}
|
||||
|
||||
inline double getDistance(const double& x1, const double& y1, const double& x2, const double& y2)
|
||||
{
|
||||
return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||
@ -394,7 +347,7 @@ inline double getDiscriminant(const double& a, const double& b, const double& c)
|
||||
double D = b * b - a * c,
|
||||
E = b * b + a * c;
|
||||
|
||||
if (abs(D) * 3 < E)
|
||||
if (fabs(D) * 3 < E)
|
||||
{
|
||||
std::pair<double, double> ad = split(a),
|
||||
bd = split(b),
|
||||
@ -416,14 +369,14 @@ inline double getDiscriminant(const double& a, const double& b, const double& c)
|
||||
return D;
|
||||
}
|
||||
|
||||
int solveQuadratic(double a, double b, double c, std::vector<double>& roots,
|
||||
inline int solveQuadratic(double a, double b, double c, std::vector<double>& roots,
|
||||
const double& mn, const double& mx)
|
||||
{
|
||||
double x1 = MAX, x2 = MAX;
|
||||
if (abs(a) < EPSILON)
|
||||
if (fabs(a) < EPSILON)
|
||||
{
|
||||
if (abs(b) < EPSILON)
|
||||
return abs(c) < EPSILON ? -1 : 0;
|
||||
if (fabs(b) < EPSILON)
|
||||
return fabs(c) < EPSILON ? -1 : 0;
|
||||
x1 = -c / b;
|
||||
}
|
||||
else
|
||||
@ -431,10 +384,10 @@ int solveQuadratic(double a, double b, double c, std::vector<double>& roots,
|
||||
b *= -0.5;
|
||||
|
||||
double D = getDiscriminant(a, b, c);
|
||||
if (D != 0 && abs(D) < MACHINE_EPSILON)
|
||||
if (D != 0 && fabs(D) < MACHINE_EPSILON)
|
||||
{
|
||||
double f = max(abs(a), abs(b), abs(c));
|
||||
if (f < 1e-8 || f < 1e8)
|
||||
double f = max(fabs(a), fabs(b), fabs(c));
|
||||
if ((f != 0) && (f < 1e-8 || f < 1e8))
|
||||
{
|
||||
f = pow(2, -round(log2(f)));
|
||||
a *= f;
|
||||
|
||||
@ -75,6 +75,7 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
|
||||
m_pPopupPr = NULL;
|
||||
m_pFreeTextPr = NULL;
|
||||
m_pCaretPr = NULL;
|
||||
m_pStampPr = NULL;
|
||||
m_pWidgetPr = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
@ -89,6 +90,7 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pPopupPr);
|
||||
RELEASEOBJECT(m_pFreeTextPr);
|
||||
RELEASEOBJECT(m_pCaretPr);
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
}
|
||||
|
||||
@ -156,6 +158,15 @@ void CAnnotFieldInfo::SetType(int nType)
|
||||
m_pTextMarkupPr = new CAnnotFieldInfo::CTextMarkupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
m_pMarkupPr = new CAnnotFieldInfo::CMarkupAnnotPr();
|
||||
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
m_pStampPr = new CAnnotFieldInfo::CStampAnnotPr();
|
||||
break;
|
||||
}
|
||||
case 13:
|
||||
{
|
||||
RELEASEOBJECT(m_pMarkupPr);
|
||||
@ -221,6 +232,7 @@ BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
}
|
||||
const std::wstring& CAnnotFieldInfo::GetNM() { return m_wsNM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetLM() { return m_wsLM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetOUserID() { return m_wsOUserID; }
|
||||
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
|
||||
const std::vector<double>& CAnnotFieldInfo::GetC() { return m_arrC; }
|
||||
|
||||
@ -284,6 +296,10 @@ bool CAnnotFieldInfo::IsCaret() const
|
||||
{
|
||||
return (m_nType == 13);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsStamp() const
|
||||
{
|
||||
return (m_nType == 12);
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CMarkupAnnotPr* CAnnotFieldInfo::GetMarkupAnnotPr() { return m_pMarkupPr; }
|
||||
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr() { return m_pTextPr; }
|
||||
@ -295,6 +311,7 @@ CAnnotFieldInfo::CPolygonLineAnnotPr* CAnnotFieldInfo::GetPolygonLineAnnotPr()
|
||||
CAnnotFieldInfo::CPopupAnnotPr* CAnnotFieldInfo::GetPopupAnnotPr() { return m_pPopupPr; }
|
||||
CAnnotFieldInfo::CFreeTextAnnotPr* CAnnotFieldInfo::GetFreeTextAnnotPr() { return m_pFreeTextPr; }
|
||||
CAnnotFieldInfo::CCaretAnnotPr* CAnnotFieldInfo::GetCaretAnnotPr() { return m_pCaretPr; }
|
||||
CAnnotFieldInfo::CStampAnnotPr* CAnnotFieldInfo::GetStampAnnotPr() { return m_pStampPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr* CAnnotFieldInfo::GetWidgetAnnotPr() { return m_pWidgetPr; }
|
||||
|
||||
bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
@ -348,6 +365,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -372,6 +391,8 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_pFreeTextPr->Read(pReader, nFlags);
|
||||
else if (IsCaret())
|
||||
m_pCaretPr->Read(pReader, nFlags);
|
||||
else if (IsStamp())
|
||||
m_pStampPr->Read(pReader, nFlags);
|
||||
}
|
||||
else if (IsPopup())
|
||||
m_pPopupPr->Read(pReader);
|
||||
@ -624,6 +645,19 @@ void CAnnotFieldInfo::CCaretAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
|
||||
m_nSy = pReader->ReadByte();
|
||||
}
|
||||
|
||||
double CAnnotFieldInfo::CStampAnnotPr::GetRotate() { return m_nRotate; }
|
||||
const std::wstring& CAnnotFieldInfo::CStampAnnotPr::GetName() { return m_wsName; }
|
||||
void CAnnotFieldInfo::CStampAnnotPr::GetInRect(double& dRD1, double& dRD2, double& dRD3, double& dRD4) { dRD1 = m_dInRect[0]; dRD2 = m_dInRect[1]; dRD3 = m_dInRect[2]; dRD4 = m_dInRect[3]; }
|
||||
void CAnnotFieldInfo::CStampAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
m_wsName = pReader->ReadString();
|
||||
m_nRotate = pReader->ReadDouble();
|
||||
m_dInRect[0] = pReader->ReadDouble();
|
||||
m_dInRect[1] = pReader->ReadDouble();
|
||||
m_dInRect[2] = pReader->ReadDouble();
|
||||
m_dInRect[3] = pReader->ReadDouble();
|
||||
}
|
||||
|
||||
bool CAnnotFieldInfo::CPopupAnnotPr::IsOpen() const { return m_bOpen; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
@ -931,6 +965,11 @@ int CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetMaxLen() const { return m
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetV() { return m_wsV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetRV() { return m_wsRV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetAPV() { return m_wsAPV; }
|
||||
BYTE* CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::GetRender(LONG& nLen)
|
||||
{
|
||||
nLen = m_nRenderLen;
|
||||
return m_pRender;
|
||||
}
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags, int nWidgetFlag)
|
||||
{
|
||||
if (nFlags & (1 << 9))
|
||||
@ -941,6 +980,12 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
if (nFlags & (1 << 13))
|
||||
{
|
||||
m_nRenderLen = pReader->ReadInt() - 4;
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
}
|
||||
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetTI() const { return m_nTI; }
|
||||
@ -949,6 +994,11 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetAPV() {
|
||||
const std::vector<int>& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetI() { return m_arrI; }
|
||||
const std::vector<std::wstring>& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetArrV() { return m_arrV; }
|
||||
const std::vector< std::pair<std::wstring, std::wstring> >& CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetOpt() { return m_arrOpt; }
|
||||
BYTE* CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::GetRender(LONG& nLen)
|
||||
{
|
||||
nLen = m_nRenderLen;
|
||||
return m_pRender;
|
||||
}
|
||||
void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
if (nFlags & (1 << 9))
|
||||
@ -979,6 +1029,12 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CChoiceWidgetPr::Read(NSOnlineOfficeBinToP
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrI.push_back(pReader->ReadInt());
|
||||
}
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
m_nRenderLen = pReader->ReadInt() - 4;
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
}
|
||||
|
||||
CAnnotFieldDelete::CAnnotFieldDelete() : IAdvancedCommand(AdvancedCommandType::DeleteAnnot) {}
|
||||
|
||||
@ -86,6 +86,7 @@ public:
|
||||
const std::wstring& GetV();
|
||||
const std::wstring& GetRV();
|
||||
const std::wstring& GetAPV();
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags, int nWidgetFlag);
|
||||
|
||||
@ -94,6 +95,8 @@ public:
|
||||
std::wstring m_wsV;
|
||||
std::wstring m_wsRV;
|
||||
std::wstring m_wsAPV;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CChoiceWidgetPr
|
||||
@ -105,6 +108,7 @@ public:
|
||||
const std::vector<int>& GetI();
|
||||
const std::vector<std::wstring>& GetArrV();
|
||||
const std::vector< std::pair<std::wstring, std::wstring> >& GetOpt();
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
@ -115,6 +119,8 @@ public:
|
||||
std::vector<int> m_arrI;
|
||||
std::vector<std::wstring> m_arrV;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > m_arrOpt;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CSignatureWidgetPr
|
||||
@ -399,6 +405,21 @@ public:
|
||||
double m_dRD[4]{};
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CStampAnnotPr
|
||||
{
|
||||
public:
|
||||
double GetRotate();
|
||||
const std::wstring& GetName();
|
||||
void GetInRect(double& dRD1, double& dRD2, double& dRD3, double& dRD4);
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
private:
|
||||
double m_nRotate;
|
||||
std::wstring m_wsName;
|
||||
double m_dInRect[4]{};
|
||||
};
|
||||
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
|
||||
@ -414,6 +435,7 @@ public:
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
const std::wstring& GetLM();
|
||||
const std::wstring& GetOUserID();
|
||||
const std::wstring& GetContents();
|
||||
const std::vector<double>& GetC();
|
||||
|
||||
@ -432,6 +454,7 @@ public:
|
||||
bool IsPopup() const;
|
||||
bool IsFreeText() const;
|
||||
bool IsCaret() const;
|
||||
bool IsStamp() const;
|
||||
|
||||
CMarkupAnnotPr* GetMarkupAnnotPr();
|
||||
CTextAnnotPr* GetTextAnnotPr();
|
||||
@ -443,6 +466,7 @@ public:
|
||||
CPopupAnnotPr* GetPopupAnnotPr();
|
||||
CFreeTextAnnotPr* GetFreeTextAnnotPr();
|
||||
CCaretAnnotPr* GetCaretAnnotPr();
|
||||
CStampAnnotPr* GetStampAnnotPr();
|
||||
CWidgetAnnotPr* GetWidgetAnnotPr();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
@ -466,6 +490,7 @@ private:
|
||||
int m_nPage;
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
std::wstring m_wsContents;
|
||||
std::pair<BYTE, double> m_pBE;
|
||||
std::vector<double> m_arrC;
|
||||
@ -483,6 +508,7 @@ private:
|
||||
CPopupAnnotPr* m_pPopupPr;
|
||||
CFreeTextAnnotPr* m_pFreeTextPr;
|
||||
CCaretAnnotPr* m_pCaretPr;
|
||||
CStampAnnotPr* m_pStampPr;
|
||||
CWidgetAnnotPr* m_pWidgetPr;
|
||||
};
|
||||
|
||||
|
||||
@ -123,6 +123,7 @@ namespace MetaFile
|
||||
|
||||
virtual bool LoadFromFile(const wchar_t* wsFilePath) = 0;
|
||||
virtual bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize) = 0;
|
||||
virtual bool LoadFromString(const std::wstring& data) = 0;
|
||||
virtual bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight) = 0;
|
||||
virtual void Close() = 0;
|
||||
virtual void GetBounds(double* pdX, double* pdY, double* pdW, double* pdH) = 0;
|
||||
@ -131,6 +132,7 @@ namespace MetaFile
|
||||
virtual NSFonts::IFontManager* get_FontManager() = 0;
|
||||
|
||||
virtual std::wstring ConvertToSvg(unsigned int unWidth = 0, unsigned int unHeight = 0) = 0;
|
||||
virtual void SetTempDirectory(const std::wstring& dir) = 0;
|
||||
|
||||
//Для тестов
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
|
||||
@ -59,7 +59,8 @@ SOURCES += \
|
||||
|
||||
# alpha mask
|
||||
HEADERS += \
|
||||
./../AlphaMask.h
|
||||
./../AlphaMask.h \
|
||||
./../AlphaMask_p.h
|
||||
|
||||
SOURCES += \
|
||||
./../AlphaMask.cpp
|
||||
|
||||
@ -135,7 +135,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "./wasm/src/",
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp"]
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp", "HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
@ -201,10 +201,6 @@
|
||||
"folder": "../",
|
||||
"files": ["officedrawingfile.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../HtmlRenderer/src/",
|
||||
"files": ["HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../UnicodeConverter/",
|
||||
"files": ["UnicodeConverter.cpp"]
|
||||
@ -227,7 +223,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../DocxRenderer/src/logic/elements",
|
||||
"files": ["BaseItem.cpp", "ContText.cpp", "DropCap.cpp", "Paragraph.cpp", "Shape.cpp", "TextLine.cpp"]
|
||||
"files": ["BaseItem.cpp", "ContText.cpp", "Paragraph.cpp", "Shape.cpp", "TextLine.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../common",
|
||||
|
||||
@ -19,7 +19,7 @@ include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
include(../../freetype.pri)
|
||||
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel, HtmlRenderer)
|
||||
ADD_DEPENDENCY(UnicodeConverter, kernel)
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$CORE_ROOT_DIR/DesktopEditor/agg-2.4/include \
|
||||
@ -704,7 +704,6 @@ HEADERS += \
|
||||
SOURCES += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/BaseItem.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \
|
||||
@ -720,14 +719,15 @@ SOURCES += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/DocxRenderer.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/resources/resources.cpp
|
||||
|
||||
HEADERS += $$CORE_ROOT_DIR/HtmlRenderer/include/HTMLRendererText.h
|
||||
SOURCES += $$CORE_ROOT_DIR/HtmlRenderer/src/HTMLRendererText.cpp
|
||||
HEADERS += $$CORE_ROOT_DIR/DesktopEditor/doctrenderer/drawingfile.h
|
||||
|
||||
HEADERS += \
|
||||
../wasm/src/drawingfile.h \
|
||||
../wasm/src/serialize.h
|
||||
../wasm/src/serialize.h \
|
||||
../wasm/src/HTMLRendererText.h \
|
||||
../wasm/src/Text.h
|
||||
|
||||
SOURCES += \
|
||||
../wasm/src/pdfwriter.cpp \
|
||||
../wasm/src/HTMLRendererText.cpp \
|
||||
../wasm/src/drawingfile.cpp \
|
||||
../wasm/src/drawingfile_test.cpp
|
||||
|
||||
@ -68,16 +68,6 @@ CFile.prototype.unlockPageNumForFontsLoader = function()
|
||||
drawingFile.fontPageUpdateType = UpdateFontsSource.Undefined;
|
||||
};
|
||||
|
||||
CFile.prototype.getOriginPage = function(originIndex)
|
||||
{
|
||||
for (let i = 0; i < this.pages.length; ++i)
|
||||
{
|
||||
if (this.pages[i]["originIndex"] == originIndex)
|
||||
return this.pages[i];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
CFile.prototype["getPages"] = function()
|
||||
{
|
||||
return this.pages;
|
||||
@ -126,6 +116,11 @@ CFile.prototype["loadFromDataWithPassword"] = function(password)
|
||||
return error;
|
||||
};
|
||||
|
||||
CFile.prototype["getType"] = function()
|
||||
{
|
||||
return this.type;
|
||||
};
|
||||
|
||||
CFile.prototype["close"] = function()
|
||||
{
|
||||
this._closeFile();
|
||||
@ -236,15 +231,17 @@ CFile.prototype["getLinks"] = function(pageIndex)
|
||||
// TEXT
|
||||
CFile.prototype["getGlyphs"] = function(pageIndex)
|
||||
{
|
||||
let page = this.getOriginPage(pageIndex);
|
||||
if (!page || page.fonts.length > 0)
|
||||
let page = this.pages[pageIndex];
|
||||
if (page.originIndex == undefined)
|
||||
return [];
|
||||
if (page.fonts.length > 0)
|
||||
{
|
||||
// waiting fonts
|
||||
return null;
|
||||
}
|
||||
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Page);
|
||||
let res = this._getGlyphs(pageIndex);
|
||||
let res = this._getGlyphs(page.originIndex);
|
||||
// there is no need to delete the result; this buffer is used as a text buffer
|
||||
// for text commands on other pages. After receiving ALL text pages,
|
||||
// you need to call destroyTextInfo()
|
||||
@ -488,14 +485,18 @@ function readAnnot(reader, rec)
|
||||
// Date of last change - M
|
||||
if (flags & (1 << 5))
|
||||
rec["LastModified"] = reader.readString();
|
||||
// AP
|
||||
rec["AP"]["have"] = (flags >> 6) & 1;
|
||||
// User ID
|
||||
if (flags & (1 << 7))
|
||||
rec["OUserID"] = reader.readString();
|
||||
}
|
||||
function readAnnotAP(reader, AP)
|
||||
{
|
||||
// number for relations with AP
|
||||
AP["i"] = reader.readInt();
|
||||
AP["x"] = reader.readInt();
|
||||
AP["y"] = reader.readInt();
|
||||
AP["x"] = reader.readDouble();
|
||||
AP["y"] = reader.readDouble();
|
||||
AP["w"] = reader.readInt();
|
||||
AP["h"] = reader.readInt();
|
||||
let n = reader.readInt();
|
||||
@ -1124,7 +1125,7 @@ CFile.prototype["getAnnotationsInfo"] = function(pageIndex)
|
||||
// FreeText
|
||||
else if (rec["Type"] == 2)
|
||||
{
|
||||
// Bachground color - C->IC
|
||||
// Background color - C->IC
|
||||
if (rec["C"])
|
||||
{
|
||||
rec["IC"] = rec["C"];
|
||||
@ -1274,6 +1275,15 @@ CFile.prototype["getAnnotationsInfo"] = function(pageIndex)
|
||||
if (flags & (1 << 26))
|
||||
rec["Desc"] = reader.readString();
|
||||
}
|
||||
// Stamp
|
||||
else if (rec["Type"] == 12)
|
||||
{
|
||||
rec["Icon"] = reader.readString();
|
||||
rec["Rotate"] = reader.readDouble2();
|
||||
rec["InRect"] = [];
|
||||
for (let i = 0; i < 8; ++i)
|
||||
rec["InRect"].push(reader.readDouble2());
|
||||
}
|
||||
res.push(rec);
|
||||
}
|
||||
|
||||
@ -1370,15 +1380,17 @@ CFile.prototype["free"] = function(pointer)
|
||||
// PIXMAP
|
||||
CFile.prototype["getPagePixmap"] = function(pageIndex, width, height, backgroundColor)
|
||||
{
|
||||
let page = this.getOriginPage(pageIndex);
|
||||
if (!page || page.fonts.length > 0)
|
||||
let page = this.pages[pageIndex];
|
||||
if (page.originIndex == undefined)
|
||||
return null;
|
||||
if (page.fonts.length > 0)
|
||||
{
|
||||
// waiting fonts
|
||||
return null;
|
||||
}
|
||||
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Page);
|
||||
let ptr = this._getPixmap(pageIndex, width, height, backgroundColor);
|
||||
let ptr = this._getPixmap(page.originIndex, width, height, backgroundColor);
|
||||
this.unlockPageNumForFontsLoader();
|
||||
|
||||
if (page.fonts.length > 0)
|
||||
@ -1435,6 +1447,43 @@ function fontToMemory(file, isCheck)
|
||||
Module["_free"](idPointer);
|
||||
}
|
||||
|
||||
// FONTS
|
||||
CFile.prototype["addPage"] = function(pageIndex, pageObj)
|
||||
{
|
||||
this.pages.splice(pageIndex, 0, pageObj);
|
||||
if (this.fontStreams)
|
||||
{
|
||||
for (let i in this.fontStreams)
|
||||
{
|
||||
let pages = this.fontStreams[i].pages;
|
||||
for (let j = 0; j < pages.length; j++)
|
||||
{
|
||||
if (pages[j] >= pageIndex)
|
||||
pages[j] += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
CFile.prototype["removePage"] = function(pageIndex)
|
||||
{
|
||||
let result = this.pages.splice(pageIndex, 1);
|
||||
if (this.fontStreams)
|
||||
{
|
||||
for (let i in this.fontStreams)
|
||||
{
|
||||
let pages = this.fontStreams[i].pages;
|
||||
for (let j = 0; j < pages.length; j++)
|
||||
{
|
||||
if (pages[j] > pageIndex)
|
||||
pages[j] -= 1;
|
||||
else if (pages[j] == pageIndex)
|
||||
pages.splice(j, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
// ONLY WEB
|
||||
self["AscViewer"]["Free"] = function(pointer)
|
||||
{
|
||||
|
||||
@ -144,7 +144,7 @@ CFile.prototype._getInteractiveFormsInfo = function()
|
||||
|
||||
CFile.prototype._getAnnotationsInfo = function(pageIndex)
|
||||
{
|
||||
g_module_pointer.ptr = g_native_drawing_file["GetAnnotationsInfo"](pageIndex);
|
||||
g_module_pointer.ptr = g_native_drawing_file["GetAnnotationsInfo"](pageIndex === undefined ? -1 : pageIndex);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#include "../include/HTMLRendererText.h"
|
||||
#include "./Text.h"
|
||||
#include "HTMLRendererText.h"
|
||||
#include "Text.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
@ -40,52 +40,35 @@ namespace NSHtmlRenderer
|
||||
double m_dWidth;
|
||||
double m_dHeght;
|
||||
|
||||
NSStructures::CBrush m_oBrush;
|
||||
NSStructures::CBrush m_oLastBrush;
|
||||
|
||||
NSStructures::CFont m_oFont;
|
||||
NSStructures::CFont* m_pFont;
|
||||
NSStructures::CFont m_oInstalledFont;
|
||||
LONG m_lCurrentFont;
|
||||
double m_dCurrentFontSize;
|
||||
|
||||
Aggplus::CMatrix m_oTransform;
|
||||
Aggplus::CMatrix m_oLastTransform;
|
||||
|
||||
bool m_bIsChangedFontParamBetweenDrawText;
|
||||
LONG m_lCurrentCommandType;
|
||||
LONG m_lSrcFileType;
|
||||
|
||||
CHText m_oSmartText;
|
||||
CMetafile m_oPage;
|
||||
NSWasm::CData m_oPage;
|
||||
|
||||
int* m_pTempUnicodes;
|
||||
int m_nTempUnicodesAlloc;
|
||||
int m_nTempUnicodesLen;
|
||||
int* m_pTempUnicodes; // массив юникодов
|
||||
int m_nTempUnicodesAlloc; // размер выделенной памяти
|
||||
int m_nTempUnicodesLen; // размер используемой памяти
|
||||
|
||||
bool m_bIsFontsInit;
|
||||
|
||||
public:
|
||||
CHTMLRendererText_Private()
|
||||
{
|
||||
m_bIsChangedFontParamBetweenDrawText = true;
|
||||
m_lSrcFileType = 0;
|
||||
m_pTempUnicodes = NULL;
|
||||
m_nTempUnicodesLen = 0;
|
||||
m_nTempUnicodesAlloc = 0;
|
||||
|
||||
m_bIsFontsInit = false;
|
||||
|
||||
m_lCurrentFont = 0;
|
||||
m_dCurrentFontSize = 0;
|
||||
m_pFont = &m_oFont;
|
||||
}
|
||||
~CHTMLRendererText_Private()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pTempUnicodes);
|
||||
}
|
||||
|
||||
public:
|
||||
void GetUnicodes(const std::wstring& sText)
|
||||
{
|
||||
int nLen = (int)sText.length();
|
||||
@ -101,7 +84,7 @@ namespace NSHtmlRenderer
|
||||
|
||||
if (sizeof(wchar_t) == 2)
|
||||
{
|
||||
for (int nIndex = 0, nGlyphIndex = 0; nIndex < nLen; ++nIndex, ++nGlyphIndex)
|
||||
for (int nIndex = 0; nIndex < nLen; ++nIndex)
|
||||
{
|
||||
int code = (int)pWchars[nIndex];
|
||||
if (code >= 0xD800 && code <= 0xDFFF && (nIndex + 1) < nLen)
|
||||
@ -109,32 +92,25 @@ namespace NSHtmlRenderer
|
||||
++nIndex;
|
||||
code = 0x10000 + (((code & 0x3FF) << 10) | (0x03FF & pWchars[nIndex]));
|
||||
}
|
||||
|
||||
m_pTempUnicodes[m_nTempUnicodesLen++] = code;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int nIndex = 0; nIndex < nLen; ++nIndex )
|
||||
{
|
||||
for (int nIndex = 0; nIndex < nLen; ++nIndex)
|
||||
m_pTempUnicodes[m_nTempUnicodesLen++] = (int)pWchars[nIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WriteText(const int* pUnicodes, const int* pGids, const int& nCount, const double& x, const double& y,
|
||||
const double& width, const double& height, const bool& bIsChangedFontParamBetweenDrawText)
|
||||
void WriteText(const int* pUnicodes, const int* pGids, const int& nCount, const double& x, const double& y)
|
||||
{
|
||||
bool bIsDumpFont = false;
|
||||
if (!m_oInstalledFont.IsEqual(&m_oFont))
|
||||
{
|
||||
m_oInstalledFont = m_oFont;
|
||||
bIsDumpFont = true;
|
||||
|
||||
m_dCurrentFontSize = m_oInstalledFont.Size;
|
||||
}
|
||||
|
||||
m_oSmartText.CommandText(pUnicodes, pGids, nCount, x, y, width, height, bIsDumpFont, this);
|
||||
m_oSmartText.CommandText(pUnicodes, pGids, nCount, x, y, bIsDumpFont);
|
||||
}
|
||||
};
|
||||
|
||||
@ -149,9 +125,6 @@ namespace NSHtmlRenderer
|
||||
|
||||
void CHTMLRendererText::Init(IOfficeDrawingFile* pFile, int nCacheSize)
|
||||
{
|
||||
m_pInternal->m_oBrush.SetDefaultParams();
|
||||
m_pInternal->m_oLastBrush.SetDefaultParams();
|
||||
|
||||
m_pInternal->m_oFont.SetDefaultParams();
|
||||
m_pInternal->m_oInstalledFont.SetDefaultParams();
|
||||
m_pInternal->m_oInstalledFont.Name = L"";
|
||||
@ -159,87 +132,38 @@ namespace NSHtmlRenderer
|
||||
m_pInternal->m_oTransform.Reset();
|
||||
m_pInternal->m_oLastTransform.Reset();
|
||||
|
||||
m_pInternal->m_oLastBrush.Color1 = -1;
|
||||
m_pInternal->m_dCurrentFontSize = 0.0;
|
||||
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
m_pInternal->m_lCurrentCommandType = -1;
|
||||
|
||||
m_pInternal->m_oSmartText.NewPage();
|
||||
|
||||
if (!m_pInternal->m_bIsFontsInit)
|
||||
{
|
||||
m_pInternal->m_oSmartText.m_oFontManager.m_pFont = &m_pInternal->m_oFont;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pLastBrush = &m_pInternal->m_oLastBrush;
|
||||
m_pInternal->m_oSmartText.m_pBrush = &m_pInternal->m_oBrush;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pFont = &m_pInternal->m_oFont;
|
||||
|
||||
m_pInternal->m_oSmartText.m_oFontManager.Init(pFile->GetFonts(), nCacheSize);
|
||||
m_pInternal->m_oSmartText.m_pTransform = &m_pInternal->m_oTransform;
|
||||
m_pInternal->m_oSmartText.m_pLastTransform = &m_pInternal->m_oLastTransform;
|
||||
|
||||
m_pInternal->m_oSmartText.m_pPageMeta = &m_pInternal->m_oPage;
|
||||
|
||||
OfficeDrawingFileType eType = pFile->GetType();
|
||||
switch (eType)
|
||||
{
|
||||
case odftPDF:
|
||||
{
|
||||
m_pInternal->m_lSrcFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF;
|
||||
m_pInternal->m_oSmartText.m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
case odftDJVU:
|
||||
{
|
||||
m_pInternal->m_lSrcFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
m_pInternal->m_oSmartText.m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
case odftXPS:
|
||||
{
|
||||
m_pInternal->m_lSrcFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
m_pInternal->m_oSmartText.m_dTextSpaceEps = 0.1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_pInternal->m_bIsFontsInit = true;
|
||||
m_pInternal->m_oSmartText.Init(pFile->GetFonts(), nCacheSize);
|
||||
}
|
||||
|
||||
m_pInternal->m_oPage.ClearNoAttack();
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
|
||||
m_pInternal->m_oPage.SkipLen();
|
||||
// статистика
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
m_pInternal->m_oPage.WriteLONG(0);
|
||||
|
||||
m_pInternal->m_oPage.AddInt(0);
|
||||
m_pInternal->m_oPage.AddInt(0);
|
||||
m_pInternal->m_oPage.AddInt(0);
|
||||
m_pInternal->m_oPage.AddInt(0);
|
||||
}
|
||||
|
||||
BYTE* CHTMLRendererText::GetBuffer()
|
||||
{
|
||||
m_pInternal->m_oSmartText.ClosePage();
|
||||
LONG lPos = m_pInternal->m_oPage.GetPosition();
|
||||
m_pInternal->m_oPage.Seek(0);
|
||||
// len
|
||||
m_pInternal->m_oPage.WriteLONG(lPos);
|
||||
// stat
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountParagraphs);
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountWords);
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountSymbols);
|
||||
m_pInternal->m_oPage.WriteLONG(m_pInternal->m_oSmartText.m_lCountSpaces);
|
||||
// seek to end
|
||||
m_pInternal->m_oPage.Seek(lPos);
|
||||
|
||||
m_pInternal->m_oPage.WriteLen();
|
||||
// статистика
|
||||
m_pInternal->m_oPage.AddInt(m_pInternal->m_oSmartText.m_nCountParagraphs, 4);
|
||||
m_pInternal->m_oPage.AddInt(m_pInternal->m_oSmartText.m_nCountWords, 8);
|
||||
m_pInternal->m_oPage.AddInt(m_pInternal->m_oSmartText.m_nCountSymbols, 12);
|
||||
m_pInternal->m_oPage.AddInt(m_pInternal->m_oSmartText.m_nCountSpaces, 16);
|
||||
|
||||
m_pInternal->m_oSmartText.ClearStatistics();
|
||||
return m_pInternal->m_oPage.GetData();
|
||||
return m_pInternal->m_oPage.GetBuffer();
|
||||
}
|
||||
|
||||
HRESULT CHTMLRendererText::get_Type(LONG* lType)
|
||||
{
|
||||
*lType = c_nHtmlRendrererText;
|
||||
@ -247,10 +171,7 @@ namespace NSHtmlRenderer
|
||||
}
|
||||
|
||||
//-------- Функции для работы со страницей --------------------------------------------------
|
||||
HRESULT CHTMLRendererText::NewPage()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::NewPage() { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_Height(double* dHeight)
|
||||
{
|
||||
*dHeight = m_pInternal->m_dHeght;
|
||||
@ -311,36 +232,12 @@ namespace NSHtmlRenderer
|
||||
HRESULT CHTMLRendererText::put_BrushTransform(const Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
|
||||
// brush ------------------------------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::get_BrushType(LONG* lType)
|
||||
{
|
||||
*lType = m_pInternal->m_oBrush.Type;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_BrushType(const LONG& lType)
|
||||
{
|
||||
m_pInternal->m_oBrush.Type = lType;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_BrushColor1(LONG* lColor)
|
||||
{
|
||||
*lColor = m_pInternal->m_oBrush.Color1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_BrushColor1(const LONG& lColor)
|
||||
{
|
||||
m_pInternal->m_oBrush.Color1 = lColor;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_BrushAlpha1(LONG* lAlpha)
|
||||
{
|
||||
*lAlpha = m_pInternal->m_oBrush.Alpha1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_BrushAlpha1(const LONG& lAlpha)
|
||||
{
|
||||
m_pInternal->m_oBrush.Alpha1 = lAlpha;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_BrushType(LONG* lType) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushType(const LONG& lType) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushColor1(LONG* lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushColor1(const LONG& lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushAlpha1(LONG* lAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushAlpha1(const LONG& lAlpha) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushColor2(LONG* lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::put_BrushColor2(const LONG& lColor) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::get_BrushAlpha2(LONG* lAlpha) { return S_OK; }
|
||||
@ -366,7 +263,6 @@ namespace NSHtmlRenderer
|
||||
HRESULT CHTMLRendererText::put_FontName(const std::wstring& bsName)
|
||||
{
|
||||
m_pInternal->m_oFont.Name = bsName;
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontPath(std::wstring* bsName)
|
||||
@ -377,7 +273,6 @@ namespace NSHtmlRenderer
|
||||
HRESULT CHTMLRendererText::put_FontPath(const std::wstring& bsName)
|
||||
{
|
||||
m_pInternal->m_oFont.Path = bsName;
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontSize(double* dSize)
|
||||
@ -387,11 +282,7 @@ namespace NSHtmlRenderer
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontSize(const double& dSize)
|
||||
{
|
||||
if (m_pInternal->m_oFont.Size != dSize)
|
||||
{
|
||||
m_pInternal->m_oFont.Size = dSize;
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
}
|
||||
m_pInternal->m_oFont.Size = dSize;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontStyle(LONG* lStyle)
|
||||
@ -401,12 +292,7 @@ namespace NSHtmlRenderer
|
||||
}
|
||||
HRESULT CHTMLRendererText::put_FontStyle(const LONG& lStyle)
|
||||
{
|
||||
LONG lOld = m_pInternal->m_oFont.GetStyle();
|
||||
if (lOld != lStyle)
|
||||
{
|
||||
m_pInternal->m_oFont.SetStyle(lStyle);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = true;
|
||||
}
|
||||
m_pInternal->m_oFont.SetStyle(lStyle);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::get_FontStringGID(INT* bGID)
|
||||
@ -443,58 +329,34 @@ namespace NSHtmlRenderer
|
||||
//-------- Функции для вывода текста --------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::CommandDrawTextCHAR(const LONG& c, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
int _c = (int)c;
|
||||
m_pInternal->WriteText(&_c, NULL, 1, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
m_pInternal->WriteText(&_c, NULL, 1, x, y);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::CommandDrawText(const std::wstring& bsText, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
m_pInternal->GetUnicodes(bsText);
|
||||
m_pInternal->WriteText(m_pInternal->m_pTempUnicodes, NULL, m_pInternal->m_nTempUnicodesLen, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
m_pInternal->WriteText(m_pInternal->m_pTempUnicodes, NULL, m_pInternal->m_nTempUnicodesLen, x, y);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::CommandDrawTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
int _c = (int)c;
|
||||
int _g = (int)gid;
|
||||
|
||||
m_pInternal->WriteText(&_c, &_g, 1, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
m_pInternal->WriteText(&_c, &_g, 1, x, y);
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
|
||||
{
|
||||
if (c_nHyperlinkType == m_pInternal->m_lCurrentCommandType)
|
||||
return S_OK;
|
||||
|
||||
m_pInternal->GetUnicodes(bsUnicodeText);
|
||||
m_pInternal->WriteText(m_pInternal->m_pTempUnicodes, (const int*)pGids, m_pInternal->m_nTempUnicodesLen, x, y, w, h, m_pInternal->m_bIsChangedFontParamBetweenDrawText);
|
||||
m_pInternal->m_bIsChangedFontParamBetweenDrawText = false;
|
||||
m_pInternal->WriteText(m_pInternal->m_pTempUnicodes, (const int*)pGids, m_pInternal->m_nTempUnicodesLen, x, y);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
//-------- Маркеры для команд ---------------------------------------------------------------
|
||||
HRESULT CHTMLRendererText::BeginCommand(const DWORD& lType)
|
||||
{
|
||||
m_pInternal->m_lCurrentCommandType = lType;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::EndCommand(const DWORD& lType)
|
||||
{
|
||||
m_pInternal->m_lCurrentCommandType = -1;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CHTMLRendererText::BeginCommand(const DWORD& lType) { return S_OK; }
|
||||
HRESULT CHTMLRendererText::EndCommand(const DWORD& lType) { return S_OK; }
|
||||
|
||||
//-------- Функции для работы с Graphics Path -----------------------------------------------
|
||||
HRESULT CHTMLRendererText::PathCommandMoveTo(const double& x, const double& y) { return S_OK; }
|
||||
@ -32,8 +32,8 @@
|
||||
#ifndef _ASC_HTMLRENDERER3_TEXT_H_
|
||||
#define _ASC_HTMLRENDERER3_TEXT_H_
|
||||
|
||||
#include "../../DesktopEditor/graphics/IRenderer.h"
|
||||
#include "../../DesktopEditor/graphics/pro/officedrawingfile.h"
|
||||
#include "../../../../IRenderer.h"
|
||||
#include "../../../officedrawingfile.h"
|
||||
|
||||
#ifndef HTMLRENDERER_USE_DYNAMIC_LIBRARY
|
||||
#define HTMLRENDERER_DECL_EXPORT
|
||||
409
DesktopEditor/graphics/pro/js/wasm/src/Text.h
Normal file
409
DesktopEditor/graphics/pro/js/wasm/src/Text.h
Normal file
@ -0,0 +1,409 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef _ASC_HTMLRENDERER_TEXT_H_
|
||||
#define _ASC_HTMLRENDERER_TEXT_H_
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "serialize.h"
|
||||
#include "../../../../structures.h"
|
||||
#include "../../../Fonts.h"
|
||||
|
||||
namespace NSHtmlRenderer
|
||||
{
|
||||
struct CHFontInfo
|
||||
{
|
||||
int m_lAscent;
|
||||
int m_lDescent;
|
||||
int m_lUnitsPerEm;
|
||||
|
||||
CHFontInfo() : m_lAscent(0), m_lDescent(0), m_lUnitsPerEm(0) {}
|
||||
CHFontInfo(const CHFontInfo& oSrc) : m_lAscent(oSrc.m_lAscent), m_lDescent(oSrc.m_lDescent), m_lUnitsPerEm(oSrc.m_lUnitsPerEm) {}
|
||||
CHFontInfo& operator=(const CHFontInfo& oSrc)
|
||||
{
|
||||
m_lAscent = oSrc.m_lAscent;
|
||||
m_lDescent = oSrc.m_lDescent;
|
||||
m_lUnitsPerEm = oSrc.m_lUnitsPerEm;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
class CFontManagerWrapper
|
||||
{
|
||||
private:
|
||||
NSFonts::IFontManager* m_pManager;
|
||||
public:
|
||||
NSStructures::CFont* m_pFont;
|
||||
CHFontInfo m_oCurrentInfo;
|
||||
|
||||
public:
|
||||
CFontManagerWrapper() : m_pManager(NULL) {}
|
||||
virtual ~CFontManagerWrapper()
|
||||
{
|
||||
RELEASEOBJECT(m_pManager);
|
||||
}
|
||||
|
||||
void Init(NSFonts::IApplicationFonts* pApplicationFonts, int nCacheSize = 0)
|
||||
{
|
||||
RELEASEOBJECT(m_pManager);
|
||||
m_pManager = pApplicationFonts->GenerateFontManager();
|
||||
if (nCacheSize)
|
||||
{
|
||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||
pFontCache->SetStreams(pApplicationFonts->GetStreams());
|
||||
pFontCache->SetCacheSize(nCacheSize);
|
||||
m_pManager->SetOwnerCache(pFontCache);
|
||||
}
|
||||
}
|
||||
void SetStringGID(INT bGid)
|
||||
{
|
||||
m_pManager->SetStringGID(bGid);
|
||||
}
|
||||
void LoadCurrentFont()
|
||||
{
|
||||
if (m_pFont->Path.empty())
|
||||
LoadFontByName(m_pFont->Name, m_pFont->Size, m_pFont->GetStyle());
|
||||
else
|
||||
LoadFontByFile(m_pFont->Path, m_pFont->Size);
|
||||
}
|
||||
double MeasureString(const unsigned int* symbols, const int& count, double x, double y)
|
||||
{
|
||||
if (!m_pManager)
|
||||
return 0;
|
||||
|
||||
m_pManager->LoadString1(symbols, count, (float)x, (float)y);
|
||||
TBBox _box = m_pManager->MeasureString2();
|
||||
|
||||
return abs((_box.fMaxX - _box.fMinX) * 25.4 / 72.0);
|
||||
}
|
||||
|
||||
private:
|
||||
inline void LoadFontByName(const std::wstring& strName, const double& dSize, const LONG& lStyle)
|
||||
{
|
||||
m_pManager->LoadFontByName(strName, dSize, lStyle, 72.0, 72.0);
|
||||
LoadFontMetrics();
|
||||
}
|
||||
inline void LoadFontByFile(const std::wstring& strPath, const double& dSize)
|
||||
{
|
||||
m_pManager->LoadFontFromFile(strPath, 0, dSize, 72.0, 72.0);
|
||||
LoadFontMetrics();
|
||||
}
|
||||
void LoadFontMetrics()
|
||||
{
|
||||
m_pManager->AfterLoad();
|
||||
m_oCurrentInfo.m_lAscent = abs(m_pManager->GetAscender());
|
||||
m_oCurrentInfo.m_lDescent = abs(m_pManager->GetDescender());
|
||||
m_oCurrentInfo.m_lUnitsPerEm = abs(m_pManager->GetUnitsPerEm());
|
||||
}
|
||||
};
|
||||
|
||||
struct CHText
|
||||
{
|
||||
CFontManagerWrapper m_oFontManager;
|
||||
Aggplus::CMatrix* m_pTransform;
|
||||
Aggplus::CMatrix* m_pLastTransform;
|
||||
|
||||
NSWasm::CHLine m_oLine;
|
||||
NSWasm::CData* m_pPageMeta;
|
||||
|
||||
LONG m_nCountParagraphs;
|
||||
LONG m_nCountWords;
|
||||
LONG m_nCountSymbols;
|
||||
LONG m_nCountSpaces;
|
||||
|
||||
CHText() : m_oFontManager(), m_oLine()
|
||||
{
|
||||
m_nCountParagraphs = 0;
|
||||
m_nCountWords = 0;
|
||||
m_nCountSymbols = 0;
|
||||
m_nCountSpaces = 0;
|
||||
}
|
||||
|
||||
void ClearStatistics()
|
||||
{
|
||||
m_nCountParagraphs = 0;
|
||||
m_nCountWords = 0;
|
||||
m_nCountSymbols = 0;
|
||||
m_nCountSpaces = 0;
|
||||
}
|
||||
void ClosePage()
|
||||
{
|
||||
if (m_oLine.GetCountChars())
|
||||
DumpLine();
|
||||
}
|
||||
void CommandText(const int* pUnicodes, const int* pGids, const int& nCount, const double& x, const double& y, bool bIsDumpFont)
|
||||
{
|
||||
// 1) сначала определяем точку отсчета и направление baseline
|
||||
double _x1 = x;
|
||||
double _y1 = y;
|
||||
double _x2 = x + 1;
|
||||
double _y2 = y;
|
||||
m_pTransform->TransformPoint(_x1, _y1);
|
||||
m_pTransform->TransformPoint(_x2, _y2);
|
||||
|
||||
double _k = 0;
|
||||
double _b = 0;
|
||||
bool _isConstX = false;
|
||||
if (fabs(_x1 - _x2) < 0.001)
|
||||
{
|
||||
_isConstX = true;
|
||||
_b = _x1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_k = (_y1 - _y2) / (_x1 - _x2);
|
||||
_b = _y1 - _k * _x1;
|
||||
}
|
||||
|
||||
double dAbsVec = sqrt((_x1 - _x2) * (_x1 - _x2) + (_y1 - _y2) * (_y1 - _y2));
|
||||
if (dAbsVec == 0)
|
||||
dAbsVec = 1;
|
||||
|
||||
bool bIsNewLine = true;
|
||||
if (m_oLine.GetCountChars())
|
||||
{
|
||||
if (_isConstX && m_oLine.m_bIsConstX && fabs(_b - m_oLine.m_dB) < 0.001)
|
||||
bIsNewLine = false;
|
||||
else if (!_isConstX && !m_oLine.m_bIsConstX && fabs(_k - m_oLine.m_dK) < 0.001 && fabs(_b - m_oLine.m_dB) < 0.001)
|
||||
bIsNewLine = false;
|
||||
|
||||
if (bIsNewLine) // не совпала baseline. поэтому просто скидываем линию в поток
|
||||
DumpLine();
|
||||
}
|
||||
|
||||
// теперь нужно определить сдвиг по baseline относительно destination точки
|
||||
double dOffsetX = 0;
|
||||
LONG nCountChars = m_oLine.GetCountChars();
|
||||
if (0 == nCountChars)
|
||||
{
|
||||
m_oLine.m_bIsConstX = _isConstX;
|
||||
m_oLine.m_dK = _k;
|
||||
m_oLine.m_dB = _b;
|
||||
|
||||
m_oLine.m_dX = _x1;
|
||||
m_oLine.m_dY = _y1;
|
||||
|
||||
m_oLine.m_ex = (_x2 - _x1) / dAbsVec;
|
||||
m_oLine.m_ey = (_y2 - _y1) / dAbsVec;
|
||||
|
||||
m_oLine.m_dEndX = _x1;
|
||||
m_oLine.m_dEndY = _y1;
|
||||
}
|
||||
else
|
||||
{
|
||||
double sx = _x1 - m_oLine.m_dEndX;
|
||||
double sy = _y1 - m_oLine.m_dEndY;
|
||||
double len = sqrt(sx*sx + sy*sy);
|
||||
|
||||
if (sx * m_oLine.m_ex >= 0 && sy * m_oLine.m_ey >= 0)
|
||||
{
|
||||
// продолжаем линию
|
||||
dOffsetX = len;
|
||||
|
||||
// теперь посмотрим, может быть нужно вставить пробел??
|
||||
NSWasm::CHChar* pLastChar = m_oLine.GetTail();
|
||||
if (dOffsetX > (pLastChar->width + 0.5))
|
||||
{
|
||||
// вставляем пробел. Пробел у нас будет не совсем пробел. А специфический
|
||||
NSWasm::CHChar* pSpaceChar = m_oLine.AddTail();
|
||||
pLastChar = &m_oLine.m_pChars[m_oLine.m_lCharsTail - 2];
|
||||
pSpaceChar->x = pLastChar->width;
|
||||
pSpaceChar->width = dOffsetX - pLastChar->width;
|
||||
pSpaceChar->unicode = 0xFFFF;
|
||||
dOffsetX -= pLastChar->width;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// буква сдвинута влево относительно предыдущей буквы
|
||||
// на такую ситуацию реагируем просто - просто начинаем новую линию,
|
||||
// предварительно сбросив старую
|
||||
DumpLine();
|
||||
|
||||
m_oLine.m_bIsConstX = _isConstX;
|
||||
|
||||
m_oLine.m_dX = _x1;
|
||||
m_oLine.m_dY = _y1;
|
||||
|
||||
m_oLine.m_dK = _k;
|
||||
m_oLine.m_dB = _b;
|
||||
|
||||
m_oLine.m_ex = (_x2 - _x1) / dAbsVec;
|
||||
m_oLine.m_ey = (_y2 - _y1) / dAbsVec;
|
||||
}
|
||||
|
||||
m_oLine.m_dEndX = _x1;
|
||||
m_oLine.m_dEndY = _y1;
|
||||
}
|
||||
|
||||
if (!Aggplus::CMatrix::IsEqual(m_pLastTransform, m_pTransform, 0.001, true))
|
||||
{ // смотрим, совпадает ли главная часть матрицы
|
||||
bIsDumpFont = true;
|
||||
*m_pLastTransform = *m_pTransform;
|
||||
m_oLine.m_bIsSetUpTransform = true;
|
||||
m_oLine.m_sx = m_pTransform->sx();
|
||||
m_oLine.m_shx = m_pTransform->shx();
|
||||
m_oLine.m_shy = m_pTransform->shy();
|
||||
m_oLine.m_sy = m_pTransform->sy();
|
||||
}
|
||||
|
||||
// все, baseline установлен. теперь просто продолжаем линию
|
||||
if (bIsDumpFont)
|
||||
m_oFontManager.LoadCurrentFont();
|
||||
|
||||
double dKoef = m_oFontManager.m_pFont->Size * 25.4 / (72 * m_oFontManager.m_oCurrentInfo.m_lUnitsPerEm);
|
||||
double dAscender = m_oFontManager.m_oCurrentInfo.m_lAscent * dKoef * dAbsVec;
|
||||
double dDescender = m_oFontManager.m_oCurrentInfo.m_lDescent * dKoef * dAbsVec;
|
||||
|
||||
if (m_oLine.m_dAscent < dAscender)
|
||||
m_oLine.m_dAscent = dAscender;
|
||||
if (m_oLine.m_dDescent < dDescender)
|
||||
m_oLine.m_dDescent = dDescender;
|
||||
|
||||
const int* input = NULL;
|
||||
if (NULL != pGids)
|
||||
{
|
||||
input = pGids;
|
||||
m_oFontManager.SetStringGID(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
input = pUnicodes;
|
||||
m_oFontManager.SetStringGID(FALSE);
|
||||
}
|
||||
|
||||
double dPlusOffset = 0;
|
||||
double dPrevW = dOffsetX;
|
||||
for (int i = 0; i < nCount; ++i)
|
||||
{
|
||||
double dW = m_oFontManager.MeasureString((const unsigned int*)(input + i), 1, 0, 0);
|
||||
|
||||
NSWasm::CHChar* pChar = m_oLine.AddTail();
|
||||
pChar->unicode = pUnicodes[i];
|
||||
|
||||
pChar->x = dPrevW;
|
||||
if (i)
|
||||
dPlusOffset += dPrevW;
|
||||
dPrevW = dW;
|
||||
pChar->width = dW * dAbsVec;
|
||||
|
||||
if (i == nCount - 1)
|
||||
{
|
||||
m_oLine.m_dEndX += dPlusOffset * m_oLine.m_ex;
|
||||
m_oLine.m_dEndY += dPlusOffset * m_oLine.m_ey;
|
||||
}
|
||||
}
|
||||
}
|
||||
void DumpLine()
|
||||
{
|
||||
LONG nCount = m_oLine.GetCountChars();
|
||||
if (!nCount)
|
||||
{
|
||||
m_oLine.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_oLine.m_bIsSetUpTransform)
|
||||
{
|
||||
// выставится трансформ!!!
|
||||
// cравнивать нужно с ним!!!
|
||||
m_pLastTransform->SetElements(m_oLine.m_sx, m_oLine.m_shy, m_oLine.m_shx, m_oLine.m_sy);
|
||||
}
|
||||
|
||||
// скидываем линию в поток pMeta
|
||||
m_pPageMeta->WriteDouble(m_oLine.m_dX);
|
||||
m_pPageMeta->WriteDouble(m_oLine.m_dY);
|
||||
|
||||
bool bHorizontal = false;
|
||||
if (fabs(m_oLine.m_ex - 1.0) < 0.001 && fabs(m_oLine.m_ey) < 0.001)
|
||||
bHorizontal = true;
|
||||
m_pPageMeta->WriteBYTE(!bHorizontal ? 1 : 0);
|
||||
if (!bHorizontal)
|
||||
{
|
||||
m_pPageMeta->WriteDouble(m_oLine.m_ex);
|
||||
m_pPageMeta->WriteDouble(m_oLine.m_ey);
|
||||
}
|
||||
|
||||
m_pPageMeta->WriteDouble(m_oLine.m_dAscent);
|
||||
m_pPageMeta->WriteDouble(m_oLine.m_dDescent);
|
||||
|
||||
m_nCountParagraphs++;
|
||||
|
||||
// width
|
||||
LONG _position = m_pPageMeta->GetSize();
|
||||
m_pPageMeta->AddInt(0);
|
||||
|
||||
double dWidthLine = 0;
|
||||
double dCurrentGlyphLineOffset = 0;
|
||||
m_pPageMeta->AddInt(nCount);
|
||||
NSWasm::CHChar* pChar = NULL;
|
||||
bool bIsLastSymbol = false;
|
||||
for (LONG lIndexChar = 0; lIndexChar < nCount; ++lIndexChar)
|
||||
{
|
||||
pChar = &m_oLine.m_pChars[lIndexChar];
|
||||
|
||||
if (lIndexChar)
|
||||
{
|
||||
m_pPageMeta->WriteDouble(pChar->x);
|
||||
dCurrentGlyphLineOffset += pChar->x;
|
||||
}
|
||||
|
||||
if (pChar->unicode == 0xFFFF || pChar->unicode == 32 || pChar->unicode == 9)
|
||||
{
|
||||
m_nCountSpaces++;
|
||||
if (bIsLastSymbol)
|
||||
{
|
||||
bIsLastSymbol = false;
|
||||
m_nCountWords++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nCountSymbols++;
|
||||
bIsLastSymbol = true;
|
||||
}
|
||||
|
||||
m_pPageMeta->AddInt(pChar->unicode); // юникодное значение
|
||||
m_pPageMeta->WriteDouble(pChar->width); // ширина буквы
|
||||
}
|
||||
if (bIsLastSymbol)
|
||||
m_nCountWords++;
|
||||
|
||||
if (pChar)
|
||||
dWidthLine = dCurrentGlyphLineOffset + pChar->width;
|
||||
m_pPageMeta->AddInt((int)(dWidthLine * 10000.0), _position);
|
||||
m_oLine.Clear();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _ASC_HTMLRENDERER_TEXT_H_
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user