mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-04 09:51:46 +08:00
Compare commits
4 Commits
fix/bug706
...
feature/gr
| Author | SHA1 | Date | |
|---|---|---|---|
| c22407d445 | |||
| f80c07e275 | |||
| 748def3c76 | |||
| 7f173e2013 |
1
Common/.gitignore
vendored
1
Common/.gitignore
vendored
@ -1 +0,0 @@
|
||||
**/module.version
|
||||
@ -4,7 +4,6 @@ CORE_BOOST_LIBS = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib
|
||||
core_ios:CONFIG += disable_enum_constexpr_conversion
|
||||
core_android:CONFIG += disable_enum_constexpr_conversion
|
||||
core_mac:CONFIG += disable_enum_constexpr_conversion
|
||||
core_linux_clang:CONFIG += disable_enum_constexpr_conversion
|
||||
|
||||
core_android {
|
||||
INCLUDEPATH += $$PWD/build/android/include
|
||||
@ -26,17 +25,12 @@ bundle_xcframeworks {
|
||||
}
|
||||
}
|
||||
|
||||
core_win_arm64 {
|
||||
DEFINES += MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_CPLUSPLUS_OVERLOADS=0
|
||||
}
|
||||
|
||||
core_windows {
|
||||
VS_VERSION=140
|
||||
VS_DEBUG=
|
||||
VS_ARCH=x64
|
||||
core_debug:VS_DEBUG=gd-
|
||||
core_win_32:VS_ARCH=x32
|
||||
core_win_arm64:VS_ARCH=a64
|
||||
vs2019:VS_VERSION=142
|
||||
|
||||
BOOST_POSTFIX = -vc$${VS_VERSION}-mt-$${VS_DEBUG}$${VS_ARCH}-1_72
|
||||
|
||||
2
Common/3dParty/brotli/.gitignore
vendored
2
Common/3dParty/brotli/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
brotli/
|
||||
module.version
|
||||
@ -1,9 +0,0 @@
|
||||
SRC_DIR = $$PWD/brotli/c
|
||||
DEFINES += FT_CONFIG_OPTION_USE_BROTLI
|
||||
|
||||
INCLUDEPATH += \
|
||||
$$SRC_DIR/include
|
||||
|
||||
SOURCES += $$files($$SRC_DIR/common/*.c)
|
||||
SOURCES += $$files($$SRC_DIR/dec/*.c)
|
||||
#SOURCES += $$files($$SRC_DIR/enc/*.c)
|
||||
@ -1,20 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append("../../../../build_tools/scripts")
|
||||
import base
|
||||
|
||||
def clear_module():
|
||||
if base.is_dir("brotli"):
|
||||
base.delete_dir_with_access_error("brotli")
|
||||
return
|
||||
|
||||
base.check_module_version("1", clear_module)
|
||||
|
||||
# fetch harfbuzz
|
||||
if not base.is_dir("brotli"):
|
||||
base.cmd("git", ["clone", "https://github.com/google/brotli.git"])
|
||||
os.chdir("brotli")
|
||||
base.cmd("git", ["checkout", "a47d7475063eb223c87632eed806c0070e70da29"])
|
||||
os.chdir("../")
|
||||
@ -12,7 +12,7 @@
|
||||
#include "StaticFunctions.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#define DEFAULT_FONT_SIZE 12
|
||||
#define DEFAULT_FONT_SIZE 14
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
@ -49,8 +49,6 @@ namespace NSCSS
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
m_arParentsStyles.insert(oElement.m_arParentsStyles.begin(), oElement.m_arParentsStyles.end());
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -71,8 +69,6 @@ namespace NSCSS
|
||||
m_oDisplay = oElement.m_oDisplay;
|
||||
m_oTransform = oElement.m_oTransform;
|
||||
|
||||
m_arParentsStyles = oElement.m_arParentsStyles;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -113,8 +109,7 @@ namespace NSCSS
|
||||
bool CCompiledStyle::Empty() const
|
||||
{
|
||||
return m_oBackground.Empty() && m_oBorder.Empty() && m_oFont.Empty() &&
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() &&
|
||||
m_oDisplay.Empty() && m_oTransform.Empty();
|
||||
m_oMargin.Empty() && m_oPadding.Empty() && m_oText.Empty() && m_oDisplay.Empty();
|
||||
}
|
||||
|
||||
void CCompiledStyle::AddPropSel(const std::wstring& sProperty, const std::wstring& sValue, const unsigned int unLevel, const bool& bHardMode)
|
||||
@ -319,7 +314,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER TOP
|
||||
CASE(L"border-top"):
|
||||
CASE(L"mso-border-top-alt"):
|
||||
{
|
||||
m_oBorder.SetTopSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -341,7 +335,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER RIGHT
|
||||
CASE(L"border-right"):
|
||||
CASE(L"mso-border-right-alt"):
|
||||
{
|
||||
m_oBorder.SetRightSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -363,7 +356,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER bottom
|
||||
CASE(L"border-bottom"):
|
||||
CASE(L"mso-border-bottom-alt"):
|
||||
{
|
||||
m_oBorder.SetBottomSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -385,7 +377,6 @@ namespace NSCSS
|
||||
}
|
||||
//BORDER LEFT
|
||||
CASE(L"border-left"):
|
||||
CASE(L"mso-border-left-alt"):
|
||||
{
|
||||
m_oBorder.SetLeftSide(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
@ -444,11 +435,6 @@ namespace NSCSS
|
||||
m_oDisplay.SetVAlign(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
CASE(L"white-space"):
|
||||
{
|
||||
m_oDisplay.SetWhiteSpace(pPropertie.second, unLevel, bHardMode);
|
||||
break;
|
||||
}
|
||||
//TRANSFORM
|
||||
CASE(L"transform"):
|
||||
{
|
||||
@ -535,7 +521,7 @@ namespace NSCSS
|
||||
{
|
||||
return m_sId;
|
||||
}
|
||||
|
||||
|
||||
bool CCompiledStyle::HaveThisParent(const std::wstring &wsParentName) const
|
||||
{
|
||||
return m_arParentsStyles.end() != m_arParentsStyles.find(wsParentName);
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#ifndef CCOMPILEDSTYLE_H
|
||||
#define CCOMPILEDSTYLE_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "ConstValues.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
@ -13,9 +13,14 @@ namespace NSCSS
|
||||
delete m_pInternal;
|
||||
}
|
||||
|
||||
bool CCssCalculator::CalculateCompiledStyle(std::vector<CNode>& arSelectors) const
|
||||
CCompiledStyle CCssCalculator::GetCompiledStyle(const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->CalculateCompiledStyle(arSelectors);
|
||||
return m_pInternal->GetCompiledStyle(arSelectors);
|
||||
}
|
||||
|
||||
bool CCssCalculator::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors) const
|
||||
{
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
@ -58,11 +63,6 @@ namespace NSCSS
|
||||
return m_pInternal->GetDpi();
|
||||
}
|
||||
|
||||
bool CCssCalculator::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return m_pInternal->HaveStylesById(wsId);
|
||||
}
|
||||
|
||||
void CCssCalculator::ClearPageData()
|
||||
{
|
||||
m_pInternal->ClearPageData();
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
#define CCSSCALCULATOR_H
|
||||
|
||||
#include "CssCalculator_global.h"
|
||||
#include "StyleProperties.h"
|
||||
#include "CNode.h"
|
||||
#include "CCompiledStyle.h"
|
||||
#include "ConstValues.h"
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
namespace NSCSS
|
||||
@ -17,7 +19,8 @@ namespace NSCSS
|
||||
CCssCalculator();
|
||||
~CCssCalculator();
|
||||
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors) const;
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors) const;
|
||||
bool 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);
|
||||
@ -32,8 +35,6 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearPageData();
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
|
||||
@ -2,6 +2,8 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
@ -184,7 +186,7 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector) const
|
||||
const CElement* CStyleStorage::FindElement(const std::wstring& wsSelector)
|
||||
{
|
||||
if (wsSelector.empty())
|
||||
return nullptr;
|
||||
@ -470,7 +472,7 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const
|
||||
const CElement* CStyleStorage::FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData)
|
||||
{
|
||||
std::map<std::wstring, CElement*>::const_iterator itFound = mStyleData.find(wsSelector);
|
||||
|
||||
@ -486,95 +488,6 @@ namespace NSCSS
|
||||
{}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
bool CCssCalculator_Private::CalculateCompiledStyle(std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
if (L"#text" == arSelectors.back().m_wsName)
|
||||
{
|
||||
if (arSelectors.size() > 1 && arSelectors.back().m_pCompiledStyle->Empty())
|
||||
*arSelectors.back().m_pCompiledStyle += *(arSelectors.end() - 2)->m_pCompiledStyle;
|
||||
|
||||
if(arSelectors.crend() != std::find_if(arSelectors.crbegin(), arSelectors.crend(),
|
||||
[](const CNode& oNode){ return IsTableElement(oNode.m_wsName); }))
|
||||
{
|
||||
arSelectors.back().m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors.back().m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
arSelectors.back().SetCompiledStyle(new CCompiledStyle(oItem->second));
|
||||
return true;
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetDpi(m_nDpi);
|
||||
unsigned int unStart = 0;
|
||||
|
||||
std::vector<CNode>::const_reverse_iterator itFound = std::find_if(arSelectors.crbegin(), arSelectors.crend(), [](const CNode& oNode){ return !oNode.m_pCompiledStyle->Empty(); });
|
||||
|
||||
if (itFound != arSelectors.crend())
|
||||
unStart = itFound.base() - arSelectors.cbegin();
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < unStart; ++i)
|
||||
{
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
for (size_t i = unStart; i < arSelectors.size(); ++i)
|
||||
{
|
||||
if (0 != i)
|
||||
*arSelectors[i].m_pCompiledStyle += *arSelectors[i - 1].m_pCompiledStyle;
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oBorder.Clear();
|
||||
}
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oFont.GetLineHeight().Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oPadding.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!arSelectors.back().m_pCompiledStyle->Empty())
|
||||
m_mUsedStyles[arSelectors] = *arSelectors.back().m_pCompiledStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::SetPageData(NSProperties::CPage &oPage, const std::map<std::wstring, std::wstring> &mData, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
//TODO:: пересмотреть данный метод
|
||||
@ -592,11 +505,11 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart)
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend() - unStart; ++oNode)
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend(); ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
@ -707,16 +620,6 @@ namespace NSCSS
|
||||
FindPrevAndKindElements(pFoundName, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
const CElement* pFoundAll = m_oStyleStorage.FindElement(L"*");
|
||||
|
||||
if (nullptr != pFoundAll)
|
||||
{
|
||||
if (!pFoundAll->Empty())
|
||||
arFindedElements.push_back(pFoundAll);
|
||||
|
||||
FindPrevAndKindElements(pFoundAll, arNextNodes, arFindedElements, wsName, arClasses);
|
||||
}
|
||||
|
||||
if (arFindedElements.size() > 1)
|
||||
{
|
||||
std::sort(arFindedElements.rbegin(), arFindedElements.rend(),
|
||||
@ -728,6 +631,79 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle CCssCalculator_Private::GetCompiledStyle(const std::vector<CNode>& arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return CCompiledStyle();
|
||||
|
||||
CCompiledStyle oStyle;
|
||||
|
||||
GetCompiledStyle(oStyle, arSelectors);
|
||||
|
||||
return oStyle;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::GetCompiledStyle(CCompiledStyle &oStyle, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
oStyle.SetDpi(m_nDpi);
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
{
|
||||
oStyle.AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
if (!bInTable)
|
||||
bInTable = IsTableElement(arSelectors[i].m_wsName);
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
oStyle.m_oBackground.Clear();
|
||||
oStyle.m_oBorder.Clear();
|
||||
}
|
||||
|
||||
CCompiledStyle oTempStyle;
|
||||
|
||||
oTempStyle.AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
|
||||
for (const CElement* oElement : FindElements(arNodes, arPrevNodes))
|
||||
oTempStyle.AddStyle(oElement->GetStyle(), i + 1);
|
||||
|
||||
if (!arSelectors[i].m_wsStyle.empty())
|
||||
oTempStyle.AddStyle(arSelectors[i].m_wsStyle, i + 1, true);
|
||||
|
||||
oStyle += oTempStyle;
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (bInTable && i < arSelectors.size() - 1)
|
||||
{
|
||||
oStyle.m_oFont.GetLineHeight().Clear();
|
||||
oStyle.m_oPadding.Clear();
|
||||
oStyle.m_oMargin.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator_Private::CalculateStyleId(const CNode& oNode)
|
||||
{
|
||||
return oNode.m_wsName + ((!oNode.m_wsClass.empty()) ? L'.' + oNode.m_wsClass : L"") + ((oNode.m_wsId.empty()) ? L"" : L'#' + oNode.m_wsId) + L'-' + std::to_wstring(++m_nCountNodes);
|
||||
@ -790,11 +766,6 @@ namespace NSCSS
|
||||
return m_nDpi;
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::HaveStylesById(const std::wstring& wsId) const
|
||||
{
|
||||
return nullptr != m_oStyleStorage.FindElement(L'#' + wsId);
|
||||
}
|
||||
|
||||
void CCssCalculator_Private::ClearEmbeddedStyles()
|
||||
{
|
||||
m_oStyleStorage.ClearEmbeddedStyles();
|
||||
@ -939,11 +910,4 @@ inline static std::wstring StringifyValue(const KatanaValue* oValue)
|
||||
return str;
|
||||
}
|
||||
|
||||
inline static bool IsTableElement(const std::wstring& wsNameTag)
|
||||
{
|
||||
return L"td" == wsNameTag || L"tr" == wsNameTag || L"table" == wsNameTag ||
|
||||
L"tbody" == wsNameTag || L"thead" == wsNameTag || L"tfoot" == wsNameTag ||
|
||||
L"th" == wsNameTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
const CElement* FindElement(const std::wstring& wsSelector) const;
|
||||
const CElement* FindElement(const std::wstring& wsSelector);
|
||||
private:
|
||||
typedef struct
|
||||
{
|
||||
@ -77,7 +77,7 @@ namespace NSCSS
|
||||
|
||||
void GetOutputData(KatanaOutput* oOutput, std::map<std::wstring, CElement*>& mStyleData);
|
||||
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData) const;
|
||||
const CElement* FindSelectorFromStyleData(const std::wstring& wsSelector, const std::map<std::wstring, CElement*>& mStyleData);
|
||||
};
|
||||
|
||||
class CCssCalculator_Private
|
||||
@ -102,7 +102,8 @@ namespace NSCSS
|
||||
~CCssCalculator_Private();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
bool CalculateCompiledStyle(std::vector<CNode>& arSelectors);
|
||||
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);
|
||||
@ -110,7 +111,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0);
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors);
|
||||
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
@ -122,8 +123,6 @@ namespace NSCSS
|
||||
std::wstring GetEncoding() const;
|
||||
unsigned short int GetDpi() const;
|
||||
|
||||
bool HaveStylesById(const std::wstring& wsId) const;
|
||||
|
||||
void ClearEmbeddedStyles();
|
||||
void ClearAllowedStyleFiles();
|
||||
void ClearStylesFromFile(const std::wstring& wsFilePath);
|
||||
|
||||
@ -1,58 +1,19 @@
|
||||
#include "CNode.h"
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
#include "CCompiledStyle.h"
|
||||
#endif
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CNode::CNode()
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
: m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::CNode(const CNode& oNode)
|
||||
: m_wsName(oNode.m_wsName), m_wsClass(oNode.m_wsClass), m_wsId(oNode.m_wsId),
|
||||
m_wsStyle(oNode.m_wsStyle), m_mAttributes(oNode.m_mAttributes)
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *oNode.m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
|
||||
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
, m_pCompiledStyle(new CCompiledStyle())
|
||||
#endif
|
||||
{}
|
||||
|
||||
CNode::~CNode()
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CNode::Empty() const
|
||||
{
|
||||
return m_wsName.empty() && m_wsClass.empty() && m_wsId.empty() && m_wsStyle.empty();
|
||||
}
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void CNode::SetCompiledStyle(CCompiledStyle* pCompiledStyle)
|
||||
{
|
||||
if (nullptr != m_pCompiledStyle)
|
||||
delete m_pCompiledStyle;
|
||||
|
||||
m_pCompiledStyle = new CCompiledStyle();
|
||||
*m_pCompiledStyle = *pCompiledStyle;
|
||||
}
|
||||
#endif
|
||||
|
||||
void CNode::Clear()
|
||||
{
|
||||
m_wsName .clear();
|
||||
|
||||
@ -7,9 +7,6 @@
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
class CCompiledStyle;
|
||||
#endif
|
||||
class CNode
|
||||
{
|
||||
public:
|
||||
@ -19,21 +16,12 @@ namespace NSCSS
|
||||
std::wstring m_wsStyle; // Стиль тэга
|
||||
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle *m_pCompiledStyle;
|
||||
#endif
|
||||
public:
|
||||
CNode();
|
||||
CNode(const CNode& oNode);
|
||||
CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId);
|
||||
~CNode();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
void SetCompiledStyle(CCompiledStyle* pCompiledStyle);
|
||||
#endif
|
||||
|
||||
void Clear();
|
||||
|
||||
std::vector<std::wstring> GetData() const;
|
||||
|
||||
@ -1328,14 +1328,8 @@ namespace NSCSS
|
||||
|
||||
// DISPLAY
|
||||
CDisplay::CDisplay()
|
||||
{
|
||||
m_eWhiteSpace.SetMapping({{L"normal", EWhiteSpace::Normal },
|
||||
{L"nowrap", EWhiteSpace::Nowrap },
|
||||
{L"pre", EWhiteSpace::Pre },
|
||||
{L"pre-line", EWhiteSpace::Pre_Line},
|
||||
{L"pre-wrap", EWhiteSpace::Pre_Wrap}},
|
||||
EWhiteSpace::Normal);
|
||||
}
|
||||
: m_oDisplay(L"inline", 0)
|
||||
{}
|
||||
|
||||
void CDisplay::Equation(CDisplay &oFirstDisplay, CDisplay &oSecondDisplay)
|
||||
{
|
||||
@ -1348,8 +1342,6 @@ namespace NSCSS
|
||||
CString::Equation(oFirstDisplay.m_oHAlign, oSecondDisplay.m_oHAlign);
|
||||
|
||||
CString::Equation(oFirstDisplay.m_oDisplay, oSecondDisplay.m_oDisplay);
|
||||
|
||||
CEnum::Equation(oFirstDisplay.m_eWhiteSpace, oSecondDisplay.m_eWhiteSpace);
|
||||
}
|
||||
|
||||
bool CDisplay::SetX(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -1413,11 +1405,6 @@ namespace NSCSS
|
||||
return m_oDisplay.SetValue(wsValue, NSConstValues::DISPLAY_VALUES, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CDisplay::SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_eWhiteSpace.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
const CDigit& CDisplay::GetX() const
|
||||
{
|
||||
return m_oX;
|
||||
@ -1453,42 +1440,34 @@ namespace NSCSS
|
||||
return m_oDisplay;
|
||||
}
|
||||
|
||||
const CEnum& CDisplay::GetWhiteSpace() const
|
||||
{
|
||||
return m_eWhiteSpace;
|
||||
}
|
||||
|
||||
bool CDisplay::Empty() const
|
||||
{
|
||||
return m_oX.Empty() && m_oY.Empty() && m_oWidth.Empty() && m_oHeight.Empty() &&
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty() &&
|
||||
(m_eWhiteSpace.Empty() || m_eWhiteSpace == EWhiteSpace::Normal);
|
||||
m_oHeight.Empty() && m_oVAlign.Empty() && m_oDisplay.Empty();
|
||||
}
|
||||
|
||||
CDisplay &CDisplay::operator+=(const CDisplay &oDisplay)
|
||||
{
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
m_eWhiteSpace += oDisplay.m_eWhiteSpace;
|
||||
m_oX += oDisplay.m_oX;
|
||||
m_oY += oDisplay.m_oY;
|
||||
m_oWidth = oDisplay.m_oWidth;
|
||||
m_oHeight = oDisplay.m_oHeight;
|
||||
m_oHAlign += oDisplay.m_oHAlign;
|
||||
m_oVAlign += oDisplay.m_oVAlign;
|
||||
m_oDisplay += oDisplay.m_oDisplay;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CDisplay::operator==(const CDisplay &oDisplay) const
|
||||
{
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay &&
|
||||
m_eWhiteSpace == oDisplay.m_eWhiteSpace.ToInt();
|
||||
return m_oX == oDisplay.m_oX &&
|
||||
m_oY == oDisplay.m_oY &&
|
||||
m_oWidth == oDisplay.m_oWidth &&
|
||||
m_oHeight == oDisplay.m_oHeight &&
|
||||
m_oHAlign == oDisplay.m_oHAlign &&
|
||||
m_oVAlign == oDisplay.m_oVAlign &&
|
||||
m_oDisplay == oDisplay.m_oDisplay;
|
||||
}
|
||||
|
||||
// STROKE
|
||||
|
||||
@ -328,15 +328,6 @@ namespace NSCSS
|
||||
};
|
||||
|
||||
// PROPERTIES
|
||||
typedef enum
|
||||
{
|
||||
Normal,
|
||||
Nowrap,
|
||||
Pre,
|
||||
Pre_Line,
|
||||
Pre_Wrap
|
||||
} EWhiteSpace;
|
||||
|
||||
class CDisplay
|
||||
{
|
||||
public:
|
||||
@ -356,8 +347,6 @@ namespace NSCSS
|
||||
|
||||
bool SetDisplay(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetWhiteSpace(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetX() const;
|
||||
const CDigit& GetY() const;
|
||||
const CDigit& GetWidth() const;
|
||||
@ -368,8 +357,6 @@ namespace NSCSS
|
||||
|
||||
const CString& GetDisplay() const;
|
||||
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
@ -384,8 +371,6 @@ namespace NSCSS
|
||||
CString m_oVAlign;
|
||||
|
||||
CString m_oDisplay;
|
||||
|
||||
CEnum m_eWhiteSpace;
|
||||
};
|
||||
|
||||
class CStroke
|
||||
|
||||
@ -22,10 +22,10 @@ namespace NSCSS
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
|
||||
|
||||
std::vector<std::wstring> arCommonElements1;
|
||||
std::vector<std::wstring> arCommonElements2;
|
||||
|
||||
@ -470,6 +470,9 @@ namespace NSCSS
|
||||
|
||||
int nSpace{0};
|
||||
|
||||
if (NULL != pPadding && !pPadding->Empty() && !pPadding->Zero())
|
||||
nSpace = pPadding->ToInt(NSCSS::Point);
|
||||
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
@ -556,7 +559,7 @@ namespace NSCSS
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
|
||||
m_sStyle += oXmlElement.GetPStyle(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -68,10 +68,10 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindProperty(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindProperty(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
@ -210,7 +210,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
@ -226,18 +226,18 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindProperty(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// std::string sName = NSStringFinder::FindPropety(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// Content-Location
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -251,7 +251,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
oData = NSStringFinder::FindProperty(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
@ -265,7 +265,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindProperty(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
sCharset = NSStringFinder::FindPropety(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
@ -337,7 +337,7 @@ static std::string mhtTohtml(const std::string& sFileContent)
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
// Поиск boundary
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindProperty(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
@ -436,17 +436,17 @@ static void substitute_xml_entities_into_text(std::string& text)
|
||||
}
|
||||
|
||||
// After running through Gumbo, the values of type "" are replaced with the corresponding code '0x01'
|
||||
// Since the attribute value does not use control characters (value <= 0x09),
|
||||
// Since the attribute value does not use control characters (value <= 0x1F),
|
||||
// then just delete them, otherwise XmlUtils::CXmlLiteReader crashes on them.
|
||||
// bug#73486
|
||||
static void remove_control_symbols(std::string& text)
|
||||
{
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
std::string::iterator itFound = std::find_if(text.begin(), text.end(), [](char chValue){ return chValue <= 0x1F; });
|
||||
|
||||
while (itFound != text.end())
|
||||
{
|
||||
itFound = text.erase(itFound);
|
||||
itFound = std::find_if(itFound, text.end(), [](unsigned char chValue){ return chValue <= 0x09; });
|
||||
itFound = std::find_if(itFound, text.end(), [](char chValue){ return chValue <= 0x1F; });
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,7 +489,6 @@ static void build_doctype(GumboNode* node, NSStringUtils::CStringBuilderA& oBuil
|
||||
oBuilder.WriteString("<!DOCTYPE ");
|
||||
oBuilder.WriteString(node->v.document.name);
|
||||
std::string pi(node->v.document.public_identifier);
|
||||
remove_control_symbols(pi);
|
||||
if ((node->v.document.public_identifier != NULL) && !pi.empty())
|
||||
{
|
||||
oBuilder.WriteString(" PUBLIC \"");
|
||||
@ -510,10 +509,6 @@ static void build_attributes(const GumboVector* attribs, NSStringUtils::CStringB
|
||||
GumboAttribute* at = static_cast<GumboAttribute*>(attribs->data[i]);
|
||||
std::string sVal(at->value);
|
||||
std::string sName(at->name);
|
||||
|
||||
remove_control_symbols(sVal);
|
||||
remove_control_symbols(sName);
|
||||
|
||||
atts.WriteString(" ");
|
||||
|
||||
bool bCheck = false;
|
||||
@ -574,7 +569,6 @@ static void prettyprint_contents(GumboNode* node, NSStringUtils::CStringBuilderA
|
||||
if (child->type == GUMBO_NODE_TEXT)
|
||||
{
|
||||
std::string val(child->v.text.text);
|
||||
remove_control_symbols(val);
|
||||
substitute_xml_entities_into_text(val);
|
||||
|
||||
// Избавление от FF
|
||||
@ -614,7 +608,6 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
remove_control_symbols(tagname);
|
||||
|
||||
if (NodeIsUnprocessed(tagname))
|
||||
return;
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
import os
|
||||
import glob
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
curDirectory = os.path.dirname(os.path.realpath(__file__))
|
||||
dictionatiesDirectory = curDirectory + "/../../../../../dictionaries"
|
||||
|
||||
all_dictionaties = {}
|
||||
for dir in glob.glob(dictionatiesDirectory + "/*"):
|
||||
if not os.path.isdir(dir):
|
||||
continue
|
||||
dictionaryName = os.path.basename(dir)
|
||||
configFile = dictionatiesDirectory + "/" + dictionaryName + "/" + dictionaryName + ".json"
|
||||
if not os.path.isfile(configFile):
|
||||
continue
|
||||
isHyphen = False
|
||||
hyphenFile = dictionatiesDirectory + "/" + dictionaryName + "/hyph_" + dictionaryName + ".dic"
|
||||
if os.path.isfile(hyphenFile):
|
||||
isHyphen = True
|
||||
with open(configFile, 'r', encoding='utf-8') as file:
|
||||
data = json.loads(file.read())
|
||||
for lang in data["codes"]:
|
||||
all_dictionaties[str(lang)] = {
|
||||
"name": dictionaryName,
|
||||
"hyphen": isHyphen
|
||||
}
|
||||
|
||||
content = ""
|
||||
content += "#define DictionaryRec_count " + str(len(all_dictionaties)) + "\n"
|
||||
content += "typedef struct {\n"
|
||||
content += " const char* m_name;\n"
|
||||
content += " int m_lang;\n"
|
||||
content += "} DictionaryRec;\n\n"
|
||||
content += "static const DictionaryRec Dictionaries[DictionaryRec_count] = {\n"
|
||||
|
||||
for lang in all_dictionaties:
|
||||
info = all_dictionaties[lang]
|
||||
content += " { \"" + info["name"] + "\", " + str(lang) + " },\n"
|
||||
content += "};\n"
|
||||
|
||||
with open("./records.h", 'w', encoding='utf-8') as f:
|
||||
f.write(content)
|
||||
@ -1,73 +0,0 @@
|
||||
#define DictionaryRec_count 65
|
||||
typedef struct {
|
||||
const char* m_name;
|
||||
int m_lang;
|
||||
} DictionaryRec;
|
||||
|
||||
static const DictionaryRec Dictionaries[DictionaryRec_count] = {
|
||||
{ "ar", 1025 },
|
||||
{ "ar", 2049 },
|
||||
{ "ar", 3073 },
|
||||
{ "ar", 4097 },
|
||||
{ "ar", 5121 },
|
||||
{ "ar", 6145 },
|
||||
{ "ar", 7169 },
|
||||
{ "ar", 8193 },
|
||||
{ "ar", 9217 },
|
||||
{ "ar", 10241 },
|
||||
{ "ar", 11265 },
|
||||
{ "ar", 12289 },
|
||||
{ "ar", 13313 },
|
||||
{ "ar", 14337 },
|
||||
{ "ar", 15361 },
|
||||
{ "ar", 16385 },
|
||||
{ "az_Latn_AZ", 1068 },
|
||||
{ "bg_BG", 1026 },
|
||||
{ "ca_ES", 1027 },
|
||||
{ "ca_ES_valencia", 2051 },
|
||||
{ "cs_CZ", 1029 },
|
||||
{ "da_DK", 1030 },
|
||||
{ "de_AT", 3079 },
|
||||
{ "de_CH", 2055 },
|
||||
{ "de_DE", 1031 },
|
||||
{ "el_GR", 1032 },
|
||||
{ "en_AU", 3081 },
|
||||
{ "en_CA", 4105 },
|
||||
{ "en_GB", 2057 },
|
||||
{ "en_US", 1033 },
|
||||
{ "en_ZA", 7177 },
|
||||
{ "es_ES", 3082 },
|
||||
{ "eu_ES", 1069 },
|
||||
{ "fr_FR", 1036 },
|
||||
{ "gl_ES", 1110 },
|
||||
{ "hr_HR", 1050 },
|
||||
{ "hu_HU", 1038 },
|
||||
{ "id_ID", 1057 },
|
||||
{ "it_IT", 1040 },
|
||||
{ "kk_KZ", 1087 },
|
||||
{ "ko_KR", 1042 },
|
||||
{ "lb_LU", 1134 },
|
||||
{ "lt_LT", 1063 },
|
||||
{ "lv_LV", 1062 },
|
||||
{ "mn_MN", 1104 },
|
||||
{ "nb_NO", 1044 },
|
||||
{ "nl_NL", 1043 },
|
||||
{ "nl_NL", 2067 },
|
||||
{ "nn_NO", 2068 },
|
||||
{ "oc_FR", 1154 },
|
||||
{ "pl_PL", 1045 },
|
||||
{ "pt_BR", 1046 },
|
||||
{ "pt_PT", 2070 },
|
||||
{ "ro_RO", 1048 },
|
||||
{ "ru_RU", 1049 },
|
||||
{ "sk_SK", 1051 },
|
||||
{ "sl_SI", 1060 },
|
||||
{ "sr_Cyrl_RS", 10266 },
|
||||
{ "sr_Latn_RS", 9242 },
|
||||
{ "sv_SE", 1053 },
|
||||
{ "tr_TR", 1055 },
|
||||
{ "uk_UA", 1058 },
|
||||
{ "uz_Cyrl_UZ", 2115 },
|
||||
{ "uz_Latn_UZ", 1091 },
|
||||
{ "vi_VN", 1066 },
|
||||
};
|
||||
@ -1,4 +1,4 @@
|
||||
ICU_MAJOR_VER = 74
|
||||
ICU_MAJOR_VER = 58
|
||||
|
||||
core_windows {
|
||||
exists($$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/icu) {
|
||||
@ -20,15 +20,8 @@ core_linux {
|
||||
core_mac {
|
||||
INCLUDEPATH += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/include
|
||||
|
||||
ICU_LIBS_PATH_MAC = $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build
|
||||
bundle_dylibs {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicui18n.a
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.a
|
||||
} else {
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$ICU_LIBS_PATH_MAC/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicuuc.$${ICU_MAJOR_VER}.dylib
|
||||
LIBS += $$PWD/$$CORE_BUILDS_PLATFORM_PREFIX/build/libicudata.$${ICU_MAJOR_VER}.dylib
|
||||
}
|
||||
|
||||
core_ios {
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
ICU_VERSION="58"
|
||||
|
||||
ICU_DIR="$PWD/icu"
|
||||
|
||||
ICU_SOURCE="${ICU_DIR}/source"
|
||||
@ -45,6 +47,8 @@ defines_utypes=(
|
||||
|
||||
function prebuild() {
|
||||
|
||||
svn export http://source.icu-project.org/repos/icu/tags/release-${ICU_VERSION}/icu4c/ ${ICU_DIR} --native-eol LF
|
||||
|
||||
echo "===== REMOVING data from bundle ====="
|
||||
|
||||
#Data bundle reduction
|
||||
|
||||
4
Common/3dParty/md/.gitignore
vendored
4
Common/3dParty/md/.gitignore
vendored
@ -1,4 +0,0 @@
|
||||
# Ignore everything in this directory
|
||||
md4c
|
||||
# Except this file
|
||||
!.gitignore
|
||||
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../../build_tools/scripts')
|
||||
import config
|
||||
import base
|
||||
import os
|
||||
|
||||
base_directory = os.getcwd()
|
||||
|
||||
if not base.is_dir("md4c"):
|
||||
base.cmd("git", ["clone", "https://github.com/mity/md4c.git"])
|
||||
base.cmd_in_dir("md4c", "git", ["checkout", "481fbfbdf72daab2912380d62bb5f2187d438408"])
|
||||
@ -1,105 +0,0 @@
|
||||
#include "md2html.h"
|
||||
|
||||
#include "md4c/src/md4c-html.h"
|
||||
#include "../../../DesktopEditor/common/File.h"
|
||||
|
||||
namespace Md
|
||||
{
|
||||
void ToHtml(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
(*(std::string*)pData).append(pValue, uSize);
|
||||
}
|
||||
|
||||
std::string ConvertMdStringToHtml(const std::string& sMdString)
|
||||
{
|
||||
std::string sData;
|
||||
md_html(sMdString.c_str(), sMdString.length(), ToHtml, &sData, 0, 0);
|
||||
return sData;
|
||||
}
|
||||
|
||||
void ToHtmlFile(const MD_CHAR* pValue, MD_SIZE uSize, void* pData)
|
||||
{
|
||||
if (NULL != pData)
|
||||
((NSFile::CFileBinary*)pData)->WriteFile(pValue, uSize);
|
||||
}
|
||||
|
||||
void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
{
|
||||
oFile.WriteStringUTF8(L"<style>");
|
||||
|
||||
// Main styles
|
||||
oFile.WriteStringUTF8(L"* { font-family: Arial; color:black; white-space:pre; }");
|
||||
oFile.WriteStringUTF8(L"p { margin: 0 0 10px; display: block; }");
|
||||
oFile.WriteStringUTF8(L"a { color: #0553c1; text-decoration: underline; } a:visited { color: #954f72; text-decoration: underline; }");
|
||||
oFile.WriteStringUTF8(L"ul { margin-top: 0; margin-bottom: 10px; }");
|
||||
oFile.WriteStringUTF8(L"img { vertical-align: middle; }");
|
||||
|
||||
// Styles for tables
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group; vertical-align: middle; }");
|
||||
oFile.WriteStringUTF8(L"tr { display: table-row; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: left; display: table-cell; font-weight: bold; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"table thead tr th { vertical-align: bottom; border-bottom: 2px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table tbody tr th, table thead tr td, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table > caption + thead > tr > th, table > colgroup + thead > tr > th, table > thead > tr > th, table > caption + thead > tr > td, table > colgroup + thead > tr > td, table > thead > tr > td { border-top: 0; }");
|
||||
|
||||
// Styles for blockquote
|
||||
oFile.WriteStringUTF8(L"blockquote { border-left: 3px solid #e9e9e9; margin: 1.5em 0; padding: 0.5em 10px 0.5em 24px; font-size: 1.25rem; display: block; margin-top: 8pt; font-style: italic; color: #404040; }");
|
||||
|
||||
// Styles for code
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; border-radius: 0; background-color: #f5f5f5; color:black; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code, pre { font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; }");
|
||||
|
||||
// Styles for headings
|
||||
oFile.WriteStringUTF8(L"h1 { font-size: 20pt; color: #0f4761; margin-top: 18pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h2 { font-size: 16pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h3 { font-size: 14pt; color: #0f4761; margin-top: 8pt; margin-bottom: 4pt; }");
|
||||
oFile.WriteStringUTF8(L"h4 { font-style: italic; color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h5 { color: #0f4761; margin-top: 4pt; margin-bottom: 2pt; }");
|
||||
oFile.WriteStringUTF8(L"h6 { font-style: italic; color: #595959; margin-top: 2pt; margin-bottom: 0; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"</style>");
|
||||
}
|
||||
|
||||
bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile)
|
||||
{
|
||||
std::string sMdData;
|
||||
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(wsPathToMdFile, sMdData))
|
||||
return false;
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.CreateFile(wsPathToHtmlFile))
|
||||
return false;
|
||||
|
||||
oFile.WriteStringUTF8(L"<html><body>");
|
||||
|
||||
oFile.WriteStringUTF8(L"<head>");
|
||||
//oFile.WriteStringUTF8(L"<meta charset=\"UTF-8\">");
|
||||
oFile.WriteStringUTF8(L"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">");
|
||||
WriteBaseHtmlStyles(oFile);
|
||||
oFile.WriteStringUTF8(L"</head>");
|
||||
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM,
|
||||
0))
|
||||
bResult = false;
|
||||
|
||||
oFile.WriteStringUTF8(L"</body></html>");
|
||||
|
||||
oFile.CloseFile();
|
||||
|
||||
if (!bResult)
|
||||
NSFile::CFileBinary::Remove(wsPathToHtmlFile);
|
||||
|
||||
return bResult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,19 +0,0 @@
|
||||
#ifndef MD2HTML_H
|
||||
#define MD2HTML_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifndef MDCONVERTER_DECL_EXPORT
|
||||
#define MDCONVERTER_DECL_EXPORT
|
||||
#else
|
||||
#include "../../../DesktopEditor/common/base_export.h"
|
||||
#define MDCONVERTER_DECL_EXPORT Q_DECL_EXPORT
|
||||
#endif
|
||||
|
||||
namespace Md
|
||||
{
|
||||
std::string MDCONVERTER_DECL_EXPORT ConvertMdStringToHtml(const std::string& sMdString);
|
||||
bool MDCONVERTER_DECL_EXPORT ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring& wsPathToHtmlFile);
|
||||
}
|
||||
|
||||
#endif // MD2HTML_H
|
||||
@ -1,11 +0,0 @@
|
||||
DEFINES += MD4C_USE_UTF8
|
||||
|
||||
HEADERS += $$PWD/md4c/src/md4c.h \
|
||||
$$PWD/md4c/src/md4c-html.h \
|
||||
$$PWD/md4c/src/entity.h \
|
||||
$$PWD/md2html.h \
|
||||
|
||||
SOURCES += $$PWD/md4c/src/md4c.c \
|
||||
$$PWD/md4c/src/md4c-html.c \
|
||||
$$PWD/md4c/src/entity.c \
|
||||
$$PWD/md2html.cpp
|
||||
@ -1,16 +0,0 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/md/md2html.pri)
|
||||
|
||||
DESTDIR = $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
@ -1 +0,0 @@
|
||||
* foo **bar [link](http://example.com) baz**
|
||||
@ -1,10 +0,0 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../md2html.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::cout << (ConvertMdFileToHtml(L"YOUR_PATH", L"YOUR_PATH") ? "Good" : "Bad") << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -109,5 +109,4 @@ public:
|
||||
bool isMobiFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isFB2FormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isXpsFile(const std::wstring& fileName);
|
||||
bool isOFDFile(const std::wstring& fileName);
|
||||
};
|
||||
|
||||
@ -240,7 +240,7 @@ bool COfficeFileFormatChecker::isPdfFormatFile(unsigned char *pBuffer, int dwByt
|
||||
|
||||
documentID.clear();
|
||||
|
||||
if (dwBytes < 5 || (pBuffer[0] == 'P' && pBuffer[1] == 'K'))
|
||||
if (dwBytes < 1)
|
||||
return false;
|
||||
|
||||
pBuffer[dwBytes - 1] = '\0';
|
||||
@ -797,13 +797,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isOFDFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isMacFormatFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
@ -937,8 +930,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
}
|
||||
else if (0 == sExt.compare(L".mht") || 0 == sExt.compare(L".mhtml"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
else if (0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
else if (0 == sExt.compare(L".csv") || 0 == sExt.compare(L".xls") || 0 == sExt.compare(L".xlsx") || 0 == sExt.compare(L".xlsb"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_CSV;
|
||||
else if (0 == sExt.compare(L".html") || 0 == sExt.compare(L".htm"))
|
||||
@ -947,7 +938,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PDF;
|
||||
else if (0 == sExt.compare(L".doct")) // случай архива с html viewer
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx"))
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
else if (0 == sExt.compare(L".pages"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
@ -1601,15 +1592,12 @@ bool COfficeFileFormatChecker::isOOXFlatFormatFile(unsigned char *pBuffer, int d
|
||||
const char *xlsxPackage = "progid=\"Excel.Sheet\"";
|
||||
const char *pptxPackage = "progid=\"PowerPoint.Show\"";
|
||||
const char *packageFormatLine = "xmlns:pkg=\"http://schemas.microsoft.com/office/2006/xmlPackage\"";
|
||||
const char* workbookFormatLine = "<Workbook";
|
||||
const char* htmlFormatLine = "<html";
|
||||
|
||||
if (std::string::npos != xml_string.find(docxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX_FLAT;
|
||||
}
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine) && ( std::string::npos != xml_string.find(workbookFormatLine) ||
|
||||
std::string::npos == xml_string.find(htmlFormatLine)))
|
||||
else if (std::string::npos != xml_string.find(xlsxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX_FLAT;
|
||||
}
|
||||
@ -1670,14 +1658,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fodt";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT:
|
||||
return L".ott";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES:
|
||||
return L".pages";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP:
|
||||
return L".hwp";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX:
|
||||
return L".hwpx";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_MD:
|
||||
return L".md";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX:
|
||||
return L".pptx";
|
||||
@ -1701,8 +1681,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".otp";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG:
|
||||
return L".odg";
|
||||
case AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY:
|
||||
return L".key";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX:
|
||||
return L".xlsx";
|
||||
@ -1724,8 +1702,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".fods";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS:
|
||||
return L".ots";
|
||||
case AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS:
|
||||
return L".numbers";
|
||||
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDF:
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF:
|
||||
@ -1736,8 +1712,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".djvu";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS:
|
||||
return L".xps";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD:
|
||||
return L".ofd";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_SVG:
|
||||
return L".svg";
|
||||
case AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLR:
|
||||
@ -1855,14 +1829,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_ODT_FLAT;
|
||||
if (L".ott" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_OTT;
|
||||
if (L".pages" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES;
|
||||
if (L".hwp" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
if (L".hwpx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
if (L".md" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
|
||||
if (L".pptx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX;
|
||||
@ -1886,8 +1852,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_OTP;
|
||||
if (L".odg" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_ODG;
|
||||
if (L".key" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_PRESENTATION_KEY;
|
||||
|
||||
if (L".xlsx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLSX;
|
||||
@ -1915,8 +1879,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_OTS;
|
||||
if (L".ods" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_ODS;
|
||||
if (L".numbers" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_SPREADSHEET_NUMBERS;
|
||||
|
||||
if (L".ooxml" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_OTHER_OOXML;
|
||||
@ -1929,8 +1891,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_DJVU;
|
||||
if (L".xps" == ext || L".oxps" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_XPS;
|
||||
if (L"ofd" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
if (L".jpg" == ext || L".jpeg" == ext || L".jpe" == ext || L".jfif" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_IMAGE_JPG;
|
||||
@ -2069,26 +2029,3 @@ bool COfficeFileFormatChecker::isXpsFile(const std::wstring &fileName)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOFDFile(const std::wstring& fileName)
|
||||
{
|
||||
COfficeUtils OfficeUtils(NULL);
|
||||
|
||||
ULONG nBufferSize = 0;
|
||||
BYTE *pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = OfficeUtils.LoadFileFromArchive(fileName, L"OFD.xml", &pBuffer, nBufferSize);
|
||||
if (hresult == S_OK && pBuffer != NULL)
|
||||
{
|
||||
if (19 <= nBufferSize && NULL != strstr((char *)pBuffer, "ofd:OFD"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD;
|
||||
|
||||
delete[] pBuffer;
|
||||
pBuffer = NULL;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -58,8 +58,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0017
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001a
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0020
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
@ -104,7 +103,6 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRMenu AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0007
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_HTMLRCanvas AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0008
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_PDFA AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x0009
|
||||
#define AVS_OFFICESTUDIO_FILE_CROSSPLATFORM_OFD AVS_OFFICESTUDIO_FILE_CROSSPLATFORM + 0x000a
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE 0x0400
|
||||
#define AVS_OFFICESTUDIO_FILE_IMAGE_JPG AVS_OFFICESTUDIO_FILE_IMAGE + 0x0001
|
||||
@ -155,4 +153,4 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTX AVS_OFFICESTUDIO_FILE_DRAW + 0x0003
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSDM AVS_OFFICESTUDIO_FILE_DRAW + 0x0004
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSSM AVS_OFFICESTUDIO_FILE_DRAW + 0x0005
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
#define AVS_OFFICESTUDIO_FILE_DRAW_VSTM AVS_OFFICESTUDIO_FILE_DRAW + 0x0006
|
||||
134
Common/base.pri
134
Common/base.pri
@ -47,7 +47,7 @@ win32 {
|
||||
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
|
||||
|
||||
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
|
||||
QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved.
|
||||
QMAKE_TARGET_COPYRIGHT = Copyright (C) $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved
|
||||
|
||||
# CONFIGURATION
|
||||
CONFIG(debug, debug|release) {
|
||||
@ -91,10 +91,6 @@ isEqual(QT_MAJOR_VERSION, 5) {
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 5) {
|
||||
DEFINES += QT_VERSION_6
|
||||
|
||||
core_windows {
|
||||
QMAKE_CXXFLAGS += /permissive-
|
||||
}
|
||||
}
|
||||
|
||||
ios {
|
||||
@ -112,35 +108,6 @@ win32:contains(QMAKE_TARGET.arch, x86_64): {
|
||||
win32:!contains(QMAKE_TARGET.arch, x86_64): {
|
||||
CONFIG += core_win_32
|
||||
}
|
||||
win32:contains(QMAKE_TARGET.arch, arm64): {
|
||||
CONFIG -= core_win_32
|
||||
CONFIG += core_win_arm64
|
||||
}
|
||||
|
||||
linux-clang-libc++ {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang-libc++")
|
||||
}
|
||||
linux-clang-libc++-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang-libc++")
|
||||
}
|
||||
linux-clang {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_64
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-64-clang")
|
||||
}
|
||||
linux-clang-32 {
|
||||
CONFIG += core_linux
|
||||
CONFIG += core_linux_32
|
||||
CONFIG += core_linux_clang
|
||||
message("linux-32-clang")
|
||||
}
|
||||
|
||||
linux-g++ {
|
||||
CONFIG += core_linux
|
||||
@ -207,25 +174,6 @@ core_win_64 {
|
||||
|
||||
core_linux {
|
||||
DEFINES += LINUX _LINUX
|
||||
|
||||
QMAKE_CUSTOM_SYSROOT = $$(QMAKE_CUSTOM_SYSROOT)
|
||||
QMAKE_CUSTOM_SYSROOT_BIN = $$(QMAKE_CUSTOM_SYSROOT)/usr/bin/
|
||||
|
||||
core_linux_64 {
|
||||
!linux_arm64 { # x86_64
|
||||
QMAKE_CUSTOM_SYSROOT_LIB = $$(QMAKE_CUSTOM_SYSROOT)/usr/lib/x86_64-linux-gnu
|
||||
!isEmpty(QMAKE_CUSTOM_SYSROOT) {
|
||||
message("using custom sysroot $$QMAKE_CUSTOM_SYSROOT")
|
||||
QMAKE_CC = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "gcc")
|
||||
QMAKE_CXX = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
core_linux_host_arm64 {
|
||||
message("build on arm64")
|
||||
@ -248,10 +196,6 @@ core_mac {
|
||||
}
|
||||
}
|
||||
|
||||
core_linux_clang {
|
||||
QMAKE_CFLAGS += -Wno-implicit-function-declaration
|
||||
}
|
||||
|
||||
# PREFIXES
|
||||
core_windows {
|
||||
CONFIG -= debug_and_release debug_and_release_target
|
||||
@ -312,9 +256,6 @@ core_win_32 {
|
||||
core_win_64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_64
|
||||
}
|
||||
core_win_arm64 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = win_arm64
|
||||
}
|
||||
core_linux_32 {
|
||||
CORE_BUILDS_PLATFORM_PREFIX = linux_32
|
||||
}
|
||||
@ -341,8 +282,8 @@ linux_arm64 {
|
||||
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN){
|
||||
!isEmpty(ARM64_TOOLCHAIN_BIN_PREFIX){
|
||||
|
||||
ARM64_TOOLCHAIN_BIN_FULL = $$ARM64_TOOLCHAIN_BIN/$$ARM64_TOOLCHAIN_BIN_PREFIX
|
||||
message("using arm64 toolchain $$ARM64_TOOLCHAIN_BIN")
|
||||
|
||||
QMAKE_CC = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "gcc")
|
||||
QMAKE_CXX = $$join(ARM64_TOOLCHAIN_BIN_FULL, , , "g++")
|
||||
@ -475,12 +416,6 @@ message($$CORE_BUILDS_PLATFORM_PREFIX/$$CORE_BUILDS_CONFIGURATION_PREFIX)
|
||||
# COMPILER
|
||||
CONFIG += c++11
|
||||
|
||||
#CONFIG += enable_cpp_17
|
||||
enable_cpp_17 {
|
||||
CONFIG += c++1z
|
||||
DEFINES += _LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION
|
||||
}
|
||||
|
||||
!core_windows {
|
||||
QMAKE_CXXFLAGS += -Wno-register
|
||||
QMAKE_CFLAGS += -Wno-register
|
||||
@ -488,11 +423,7 @@ enable_cpp_17 {
|
||||
|
||||
core_linux {
|
||||
core_static_link_libstd {
|
||||
!core_linux_clang {
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
} else {
|
||||
# TODO: add libc++abi?
|
||||
}
|
||||
QMAKE_LFLAGS += -static-libstdc++ -static-libgcc
|
||||
message(core_static_link_libstd)
|
||||
}
|
||||
plugin {
|
||||
@ -602,45 +533,42 @@ core_windows {
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
}
|
||||
|
||||
core_ios|core_mac {
|
||||
CONFIG += support_bundle_dylibs
|
||||
}
|
||||
core_ios:CONFIG+=support_bundle_dylibs
|
||||
|
||||
!support_bundle_dylibs:CONFIG-=bundle_dylibs
|
||||
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
core_ios {
|
||||
bundle_dylibs {
|
||||
plugin {
|
||||
CONFIG -= plugin
|
||||
CONFIG += lib_bundle
|
||||
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @executable_path/Frameworks
|
||||
#QMAKE_LFLAGS += -Xlinker -rpath -Xlinker @loader_path/Frameworks
|
||||
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
# correct version to < 256
|
||||
VERSIONS = $$split(VERSION, ".")
|
||||
VERSION_1 = $$member(VERSIONS, 0)
|
||||
VERSION_2 = $$member(VERSIONS, 1)
|
||||
VERSION_3 = $$member(VERSIONS, 2)
|
||||
VERSION_4 = $$member(VERSIONS, 3)
|
||||
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
greaterThan(VERSION_1, 255): VERSION_1 = 255
|
||||
greaterThan(VERSION_2, 255): VERSION_2 = 255
|
||||
greaterThan(VERSION_3, 255): VERSION_3 = 255
|
||||
greaterThan(VERSION_4, 255): VERSION_4 = 255
|
||||
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
VERSION_CORRECT = $$VERSION_1
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_2)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_3)
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", ".")
|
||||
VERSION_CORRECT = $$join(VERSION_CORRECT, "", "", $$VERSION_4)
|
||||
|
||||
VERSION = $$VERSION_CORRECT
|
||||
MAJOR_VERSION = $$VERSION_1
|
||||
# set framework version as A
|
||||
QMAKE_FRAMEWORK_VERSION = A
|
||||
VERSION = $$VERSION_CORRECT
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1
Common/js/.gitignore
vendored
1
Common/js/.gitignore
vendored
@ -1,2 +1 @@
|
||||
emsdk
|
||||
__pycache__
|
||||
|
||||
@ -416,16 +416,6 @@ namespace agg
|
||||
{
|
||||
return self_type(rgba::from_wavelength(wl, gamma));
|
||||
}
|
||||
|
||||
bool operator==(const self_type& other)
|
||||
{
|
||||
return a == other.a && r == other.r && g == other.g && b == other.b;
|
||||
}
|
||||
|
||||
bool operator!=(const self_type& other)
|
||||
{
|
||||
return !operator==(other);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1465,29 +1465,7 @@ namespace agg
|
||||
}
|
||||
};
|
||||
|
||||
template<class ColorT, class Order> struct comp_op_rgba_draw_on_black
|
||||
{
|
||||
typedef ColorT color_type;
|
||||
typedef Order order_type;
|
||||
typedef typename color_type::value_type value_type;
|
||||
typedef typename color_type::calc_type calc_type;
|
||||
enum base_scale_e
|
||||
{
|
||||
base_shift = color_type::base_shift,
|
||||
base_mask = color_type::base_mask
|
||||
};
|
||||
|
||||
static AGG_INLINE void blend_pix(value_type* p,
|
||||
unsigned sr, unsigned sg, unsigned sb,
|
||||
unsigned sa, unsigned cover)
|
||||
{
|
||||
|
||||
if (0x00 != p[Order::R] || 0x00 != p[Order::G] || 0x00 != p[Order::B])
|
||||
return;
|
||||
|
||||
comp_op_rgba_src_over <ColorT,Order>::blend_pix(p, sr, sg, sb, sa, cover);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1537,9 +1515,6 @@ namespace agg
|
||||
comp_op_rgba_contrast <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert <ColorT,Order>::blend_pix,
|
||||
comp_op_rgba_invert_rgb <ColorT,Order>::blend_pix,
|
||||
|
||||
//Custom function
|
||||
comp_op_rgba_draw_on_black<ColorT,Order>::blend_pix,
|
||||
0
|
||||
};
|
||||
|
||||
@ -1576,9 +1551,6 @@ namespace agg
|
||||
comp_op_invert, //----comp_op_invert
|
||||
comp_op_invert_rgb, //----comp_op_invert_rgb
|
||||
|
||||
//Custom modes
|
||||
comp_op_draw_on_black, //----comp_op_draw_on_black
|
||||
|
||||
end_of_comp_op_e
|
||||
};
|
||||
|
||||
|
||||
@ -1000,17 +1000,7 @@ namespace agg
|
||||
{
|
||||
if (i < RES && j < RES)
|
||||
{
|
||||
if (m_oGradientInfo.luminocity)
|
||||
{
|
||||
ColorT fillC;
|
||||
fillC.r = m_oGradientInfo.shading.fill_color.r * c.r / 255 + 255 - c.r;
|
||||
fillC.g = m_oGradientInfo.shading.fill_color.g * c.g / 255 + 255 - c.g;
|
||||
fillC.b = m_oGradientInfo.shading.fill_color.b * c.b / 255 + 255 - c.b;
|
||||
fillC.a = 255;
|
||||
precalc[i][j] = fillC;
|
||||
}
|
||||
else
|
||||
precalc[i][j] = c;
|
||||
precalc[i][j] = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -506,7 +506,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
#elif MAC
|
||||
BYTE* pUtf8 = NULL;
|
||||
LONG lLen = 0;
|
||||
@ -514,7 +514,7 @@ namespace NSDirectory
|
||||
rmdir((char*)pUtf8);
|
||||
delete [] pUtf8;
|
||||
|
||||
if (deleteRoot == false)CreateDirectory(strDirectory);
|
||||
if (deleteRoot = false)CreateDirectory(strDirectory);
|
||||
#endif
|
||||
}
|
||||
std::wstring GetFolderPath(const std::wstring& wsFolderPath)
|
||||
|
||||
@ -1629,10 +1629,6 @@ namespace NSFile
|
||||
{
|
||||
wsTemp = L"";
|
||||
}
|
||||
#if defined(_WIN32) || defined (_WIN64)
|
||||
if (wsTempDir)
|
||||
free(wsTempDir);
|
||||
#endif
|
||||
wsTemp += L"x";
|
||||
int nTime = (int)time(NULL);
|
||||
for (int nIndex = 0; nIndex < 1000; ++nIndex)
|
||||
@ -1868,7 +1864,7 @@ namespace NSFile
|
||||
|
||||
namespace NSFile
|
||||
{
|
||||
bool CBase64Converter::Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags)
|
||||
bool CBase64Converter::Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags)
|
||||
{
|
||||
if (!pDataSrc || nLenSrc < 1)
|
||||
return false;
|
||||
|
||||
@ -212,7 +212,7 @@ namespace NSFile
|
||||
class KERNEL_DECL CBase64Converter
|
||||
{
|
||||
public:
|
||||
static bool Encode(const BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
|
||||
static bool Encode(BYTE* pDataSrc, int nLenSrc, char*& pDataDst, int& nLenDst, DWORD dwFlags = NSBase64::B64_BASE64_FLAG_NONE);
|
||||
static bool Decode(const char* pDataSrc, int nLenSrc, BYTE*& pDataDst, int& nLenDst);
|
||||
};
|
||||
|
||||
|
||||
@ -46,7 +46,6 @@ namespace NSProcessEnv
|
||||
static const char* gc_proxy = "proxy";
|
||||
static const char* gc_proxyUser = "proxyUser";
|
||||
static const char* gc_proxyHeader = "proxyHeader";
|
||||
static const char* gc_oformAsPdf = "oformAsPdf";
|
||||
}
|
||||
|
||||
// serialize
|
||||
|
||||
@ -319,14 +319,7 @@ namespace NSStringUtils
|
||||
{
|
||||
WriteEncodeXmlString(sString.c_str(), (int)sString.length());
|
||||
}
|
||||
void CStringBuilder::WriteEncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(std::wstring(sString.begin(), sString.end()));
|
||||
}
|
||||
void CStringBuilder::WriteUtf8EncodeXmlString(const std::string& sString)
|
||||
{
|
||||
WriteEncodeXmlString(NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)sString.c_str(), sString.size()));
|
||||
}
|
||||
|
||||
void CStringBuilder::WriteEncodeXmlString(const wchar_t* pString, int nCount)
|
||||
{
|
||||
if (sizeof(wchar_t) == 2)
|
||||
|
||||
@ -110,9 +110,6 @@ namespace NSStringUtils
|
||||
void WriteEncodeXmlString(const std::wstring& sString);
|
||||
void WriteEncodeXmlString(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
void WriteEncodeXmlString(const std::string& sString);
|
||||
void WriteUtf8EncodeXmlString(const std::string& sString);
|
||||
|
||||
void WriteEncodeXmlStringHHHH(const std::wstring& sString);
|
||||
void WriteEncodeXmlStringHHHH(const wchar_t* pString, int nCount = -1);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -59,7 +59,7 @@ namespace NSSystemUtils
|
||||
static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY";
|
||||
static const wchar_t* gc_EnvModified = L"MODIFIED";
|
||||
static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
|
||||
@ -23,30 +23,6 @@ public class NativeLibraryLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static String libPrefix;
|
||||
private static String libExtension;
|
||||
|
||||
private static boolean loadIfExist(String libPath) {
|
||||
File libFile = new File(libPath);
|
||||
if (libFile.exists()) {
|
||||
System.load(libPath);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void load(Path libDirPath, String libName) {
|
||||
String libPath = libDirPath.resolve(libPrefix + libName + libExtension).toString();
|
||||
if (OSChecker.isMac()) {
|
||||
if (!loadIfExist(libPath)) {
|
||||
// if dylib does not exist, load framework library
|
||||
System.load(libDirPath.resolve(libName + ".framework/" + libName).toString());
|
||||
}
|
||||
} else {
|
||||
System.load(libPath);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Path libDirPath = getLibPath();
|
||||
@ -55,8 +31,8 @@ public class NativeLibraryLoader {
|
||||
System.load(libDirPath.resolve("icudt58.dll").toString());
|
||||
System.load(libDirPath.resolve("icuuc58.dll").toString());
|
||||
} else if (OSChecker.isMac()) {
|
||||
loadIfExist(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
loadIfExist(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
System.load(libDirPath.resolve("libicudata.58.dylib").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.58.dylib").toString());
|
||||
} else if (OSChecker.isLinux()) {
|
||||
System.load(libDirPath.resolve("libicudata.so.58").toString());
|
||||
System.load(libDirPath.resolve("libicuuc.so.58").toString());
|
||||
@ -66,25 +42,24 @@ public class NativeLibraryLoader {
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "PdfFile", "XpsFile", "DjVuFile", "DocxRenderer", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
libPrefix = "";
|
||||
String prefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
libPrefix = "lib";
|
||||
prefix = "lib";
|
||||
}
|
||||
|
||||
libExtension = "";
|
||||
String extension = "";
|
||||
if (OSChecker.isWindows()) {
|
||||
libExtension = ".dll";
|
||||
extension = ".dll";
|
||||
} else if (OSChecker.isMac()) {
|
||||
libExtension = ".dylib";
|
||||
extension = ".dylib";
|
||||
} else {
|
||||
libExtension = ".so";
|
||||
extension = ".so";
|
||||
}
|
||||
|
||||
for (String lib : libs) {
|
||||
load(libDirPath, lib);
|
||||
System.load(libDirPath.resolve(prefix + lib + extension).toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
throw new RuntimeException("Cannot load dynamic libraries. Check if JAR file is in the same directory as all docbuilder libraries.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
deploy/
|
||||
@ -24,10 +24,6 @@ def _loadLibrary(path):
|
||||
library_name = 'libdocbuilder.c.so'
|
||||
elif 'darwin' == os_name:
|
||||
library_name = 'libdocbuilder.c.dylib'
|
||||
# if there is no dylib file, get library from framework
|
||||
if not os.path.exists(path + '/' + library_name):
|
||||
path = path + '/docbuilder.c.framework'
|
||||
library_name = 'docbuilder.c'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
@ -387,20 +383,6 @@ class CDocBuilderValue:
|
||||
def __setitem__(self, key, value):
|
||||
self.Set(key, value)
|
||||
|
||||
def __getattr__(self, name):
|
||||
def method(*args):
|
||||
return self.Call(name, *args)
|
||||
return method
|
||||
|
||||
def __len__(self):
|
||||
return self.GetLength()
|
||||
|
||||
def __iter__(self):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not iterable")
|
||||
for i in range(self.GetLength()):
|
||||
yield self.Get(i)
|
||||
|
||||
@staticmethod
|
||||
def CreateUndefined():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateUndefined()))
|
||||
@ -442,36 +424,6 @@ class CDocBuilderValue:
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
def append(self, value):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
self.Set(length, value)
|
||||
return self
|
||||
|
||||
def extend(self, iterable):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
for i, value in enumerate(iterable, start=length):
|
||||
self.Set(i, value)
|
||||
return self
|
||||
|
||||
def insert(self, i, x):
|
||||
if not self.IsArray():
|
||||
raise TypeError("Object is not an array")
|
||||
length = self.GetLength()
|
||||
if i < 0:
|
||||
if abs(i) > length:
|
||||
raise IndexError("list index out of range")
|
||||
i = max(0, length + i)
|
||||
if i >= length:
|
||||
raise IndexError("list index out of range")
|
||||
for idx in range(length, i, -1):
|
||||
self.Set(idx, self.Get(idx - 1))
|
||||
self.Set(i, x)
|
||||
|
||||
|
||||
class CDocBuilder:
|
||||
_initialized = False
|
||||
|
||||
@ -483,7 +435,7 @@ class CDocBuilder:
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilder_Destroy(self._internal)
|
||||
|
||||
def OpenFile(self, path, params=""):
|
||||
def OpenFile(self, path, params):
|
||||
return _lib.CDocBuilder_OpenFile(self._internal, ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
|
||||
def CreateFile(self, type):
|
||||
|
||||
@ -13,16 +13,16 @@ scope = context.CreateScope()
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.GetDocument()
|
||||
paragraph1 = api.CreateParagraph()
|
||||
paragraph1.SetSpacingAfter(1000, False)
|
||||
paragraph1.AddText('Hello from Python!')
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.CreateParagraph()
|
||||
paragraph2.AddText('Goodbye!')
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.InsertContent(content)
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('path_to_docbuilder')
|
||||
import docbuilder
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
scope = context.CreateScope()
|
||||
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
builder.CloseFile()
|
||||
@ -74,7 +74,6 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, cons
|
||||
global->set("native", oNativeCtrl);
|
||||
|
||||
CBuilderEmbed* pBuilderJSNative = static_cast<CBuilderEmbed*>(oBuilderJS->getNative());
|
||||
pBuilderJSNative->SetExternalize(true);
|
||||
pBuilderJSNative->m_pBuilder = pBuilder;
|
||||
}
|
||||
CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
@ -83,7 +82,7 @@ CV8RealTimeWorker::~CV8RealTimeWorker()
|
||||
m_context->Dispose();
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContextSrc)
|
||||
bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRenderer::CDocBuilderValue* retValue, const bool& isEnterContext)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -93,10 +92,6 @@ bool CV8RealTimeWorker::ExecuteCommand(const std::wstring& command, NSDoctRender
|
||||
std::string commandA = U_TO_UTF8(command);
|
||||
//commandA = "Api." + commandA;
|
||||
|
||||
bool isEnterContext = isEnterContextSrc;
|
||||
if (!isEnterContext && !m_context->IsEntered())
|
||||
isEnterContext = true;
|
||||
|
||||
if (isEnterContext)
|
||||
m_context->Enter();
|
||||
|
||||
@ -1242,13 +1237,13 @@ namespace NSDoctRenderer
|
||||
|
||||
while (true)
|
||||
{
|
||||
while (_currentPos < _commandsLen && !((_commandsPtr[_currentPos] == '\"' || _commandsPtr[_currentPos] == '\'') && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
while (_currentPos < _commandsLen && !(_commandsPtr[_currentPos] == '\"' && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
++_currentPos;
|
||||
|
||||
++_currentPos;
|
||||
size_t _start = _currentPos;
|
||||
|
||||
while (_currentPos < _commandsLen && !((_commandsPtr[_currentPos] == '\"' || _commandsPtr[_currentPos] == '\'') && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
while (_currentPos < _commandsLen && !(_commandsPtr[_currentPos] == '\"' && _commandsPtr[_currentPos - 1] != '\\'))
|
||||
++_currentPos;
|
||||
|
||||
if (_currentPos > _start)
|
||||
@ -1273,7 +1268,7 @@ namespace NSDoctRenderer
|
||||
if (m_pInternal->m_nFileType != -1 && m_pInternal->m_bIsOpenedFromSimpleJS)
|
||||
{
|
||||
m_pInternal->m_bIsOpenedFromSimpleJS = false;
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_pInternal->m_nFileType = -1;
|
||||
@ -1514,8 +1509,7 @@ namespace NSDoctRenderer
|
||||
if (nCountParameters > 2)
|
||||
sParams = _builder_params[2].c_str();
|
||||
|
||||
int nSaveError = this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
|
||||
bIsNoError = (0 == nSaveError);
|
||||
this->SaveFile(nFormat, _builder_params[1].c_str(), sParams);
|
||||
}
|
||||
else if ("WriteData" == sFuncNum)
|
||||
{
|
||||
|
||||
@ -547,7 +547,6 @@ namespace NSDoctRenderer
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_bIsUseSystemFonts = m_oParams.m_bIsSystemFonts;
|
||||
oWorker.m_arAdditionalFolders = m_oParams.m_arFontDirs;
|
||||
oWorker.m_arAdditionalFolders.push_back(NSFile::GetProcessDirectory() + L"/fonts");
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
oWorker.m_sDirectory = sDirectory;
|
||||
// это не рабочая папка, где только шрифты
|
||||
@ -928,7 +927,7 @@ namespace NSDoctRenderer
|
||||
|
||||
COfficeFileFormatChecker oChecker;
|
||||
if (!oChecker.isOfficeFile(sFileCopy))
|
||||
return 1;
|
||||
return false;
|
||||
|
||||
if (oChecker.nFileType & AVS_OFFICESTUDIO_FILE_DOCUMENT)
|
||||
m_nFileType = 0;
|
||||
|
||||
@ -171,6 +171,7 @@ public:
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
@ -283,34 +284,6 @@ public:
|
||||
return NULL;
|
||||
return m_pFile->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
BYTE* SplitPages(int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->SplitPages(arrPageIndex, nLength, data, size);
|
||||
return NULL;
|
||||
}
|
||||
bool MergePages(BYTE* data, LONG size, int nMaxID, const std::string& sPrefixForm, bool bCopy = false)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
// Память из CDrawingFileEmbed освобождается сразу после вызова функции, поэтому копируем
|
||||
if (bCopy)
|
||||
{
|
||||
BYTE* pCopy = (BYTE*)malloc(size);
|
||||
memcpy(pCopy, data, size);
|
||||
data = pCopy;
|
||||
}
|
||||
// Захватывает полученную память, будет освобождена либо в деструкторе MemStream, либо free в случае неудачи
|
||||
return ((CPdfFile*)m_pFile)->MergePages(data, size, nMaxID, sPrefixForm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool UnmergePages()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
@ -430,32 +403,22 @@ public:
|
||||
oRenderer.SetExternalImageStorage(m_pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
std::vector<std::wstring> arShapes;
|
||||
if (0 == mode)
|
||||
arShapes = oRenderer.ScanPage(m_pFile, nPageIndex);
|
||||
else
|
||||
arShapes = oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
|
||||
int nLen = (int)arShapes.size();
|
||||
|
||||
NSWasm::CData oRes;
|
||||
switch (mode)
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
{
|
||||
std::vector<std::wstring> arShapes = (0 == mode) ? oRenderer.ScanPage(m_pFile, nPageIndex) : oRenderer.ScanPagePptx(m_pFile, nPageIndex);
|
||||
int nLen = (int)arShapes.size();
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
oRes.WriteLen();
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
oRes = oRenderer.ScanPageBin(m_pFile, nPageIndex);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
|
||||
@ -166,48 +166,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::FreeWasmData(JSSmart<CJSValue> typedArray)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data)
|
||||
{
|
||||
JSSmart<CJSArray> arrPages = arrPageIndexes->toArray();
|
||||
CJSDataBuffer changes;
|
||||
if (data->isTypedArray())
|
||||
changes = data->toTypedArray()->getData();
|
||||
|
||||
int nCountPages = arrPages->getCount();
|
||||
int* pPages = NULL;
|
||||
if (0 < nCountPages)
|
||||
pPages = new int[nCountPages];
|
||||
|
||||
for (int i = 0; i < nCountPages; i++)
|
||||
pPages[i] = arrPages->get(i)->toInt32();
|
||||
|
||||
JSSmart<CJSValue> res = WasmMemoryToJS(m_pFile->SplitPages(pPages, nCountPages, changes.Data, (LONG)changes.Len));
|
||||
if (pPages)
|
||||
delete [] pPages;
|
||||
return res;
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm)
|
||||
{
|
||||
bool result = false;
|
||||
if (m_pFile)
|
||||
{
|
||||
JSSmart<CJSTypedArray> dataPtr = data->toTypedArray();
|
||||
int maxID = nMaxID->toInt32();
|
||||
std::string prefix = sPrefixForm->toStringA();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
result = m_pFile->MergePages(buffer.Data, (LONG)buffer.Len, maxID, prefix, true);
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
return CJSContext::createBool(result);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::UnmergePages()
|
||||
{
|
||||
if (m_pFile)
|
||||
return CJSContext::createBool(m_pFile->UnmergePages());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
CJSContext::Embed<CDrawingFileEmbed>(false);
|
||||
|
||||
@ -51,10 +51,6 @@ public:
|
||||
|
||||
JSSmart<CJSValue> FreeWasmData(JSSmart<CJSValue> typedArray);
|
||||
|
||||
JSSmart<CJSValue> SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data);
|
||||
JSSmart<CJSValue> MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm);
|
||||
JSSmart<CJSValue> UnmergePages();
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
|
||||
@ -196,9 +196,7 @@ JSSmart<CJSValue> CGraphicsEmbed::create(JSSmart<CJSValue> Native, JSSmart<CJSVa
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::Destroy()
|
||||
{
|
||||
// For save image bits, if needed.
|
||||
m_pInternal->Destroy();
|
||||
RELEASEOBJECT(m_pInternal);
|
||||
return NULL;
|
||||
}
|
||||
JSSmart<CJSValue> CGraphicsEmbed::EndDraw()
|
||||
|
||||
@ -45,7 +45,7 @@ public:
|
||||
|
||||
public:
|
||||
CBuilderDocumentEmbed() : m_pBuilder(NULL), m_bIsValid(false) {}
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder && !m_isExternalize) RELEASEOBJECT(m_pBuilder); }
|
||||
~CBuilderDocumentEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate(NSDoctRenderer::CDocBuilder* pBuilder) { return pBuilder->GetPrivate(); }
|
||||
|
||||
@ -88,7 +88,6 @@ JSSmart<CJSValue> CBuilderEmbed::OpenTmpFile(JSSmart<CJSValue> path, JSSmart<CJS
|
||||
JSSmart<CJSObject> oBuilderTmpDoc = CJSContext::createEmbedObject("CBuilderDocumentEmbed");
|
||||
CBuilderDocumentEmbed* pBuilderTmpDocNative = static_cast<CBuilderDocumentEmbed*>(oBuilderTmpDoc->getNative());
|
||||
pBuilderTmpDocNative->m_pBuilder = m_pBuilder;
|
||||
pBuilderTmpDocNative->SetExternalize(true);
|
||||
pBuilderTmpDocNative->_OpenFile(sPath, sParams);
|
||||
return oBuilderTmpDoc->toValue();
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
NSDoctRenderer::CDocBuilder* m_pBuilder;
|
||||
|
||||
CBuilderEmbed() : m_pBuilder(NULL) {}
|
||||
~CBuilderEmbed() { if(m_pBuilder && !m_isExternalize) RELEASEOBJECT(m_pBuilder); }
|
||||
~CBuilderEmbed() { if(m_pBuilder) RELEASEOBJECT(m_pBuilder); }
|
||||
|
||||
virtual void* getObject() { return (void*)m_pBuilder; }
|
||||
NSDoctRenderer::CDocBuilder_Private* GetPrivate() { return m_pBuilder->GetPrivate(); }
|
||||
|
||||
@ -27,9 +27,6 @@
|
||||
-(JSValue*) ScanPage : (JSValue*)nPageIndex : (JSValue*)mode;
|
||||
-(JSValue*) GetImageBase64 : (JSValue*)rId;
|
||||
-(JSValue*) FreeWasmData : (JSValue*)typedArray;
|
||||
-(JSValue*) SplitPages : (JSValue*)arrPageIndexes : (JSValue*)data;
|
||||
-(JSValue*) MergePages : (JSValue*)data : (JSValue*)nMaxID : (JSValue*)sPrefixForm;
|
||||
-(JSValue*) UnmergePages;
|
||||
@end
|
||||
|
||||
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
|
||||
@ -64,9 +61,6 @@ FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_JS_2(ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_JS_1(GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_JS_1(FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_JS_2(SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_JS_3(MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_JS_0(UnmergePages, UnmergePages)
|
||||
@end
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
|
||||
@ -30,9 +30,6 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_2(_ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_V8_1(_GetImageBase64, GetImageBase64)
|
||||
FUNCTION_WRAPPER_V8_1(_FreeWasmData, FreeWasmData)
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_V8_3(_MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -62,9 +59,6 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "ScanPage", _ScanPage);
|
||||
NSV8Objects::Template_Set(result, "GetImageBase64", _GetImageBase64);
|
||||
NSV8Objects::Template_Set(result, "FreeWasmData", _FreeWasmData);
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
NSV8Objects::Template_Set(result, "MergePages", _MergePages);
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ namespace NSGraphics
|
||||
|
||||
m_pRenderer = NSGraphics::Create();
|
||||
m_pRenderer->SetFontManager(pManager);
|
||||
RELEASEINTERFACE(pManager);
|
||||
|
||||
int nRasterW = (int)width_px;
|
||||
int nRasterH = (int)height_px;
|
||||
|
||||
@ -115,16 +115,17 @@ namespace NSGraphics
|
||||
class CGraphics
|
||||
{
|
||||
public:
|
||||
CGraphicsAppImage* m_pAppImage = nullptr;
|
||||
CGraphicsAppImage* m_pAppImage;
|
||||
CBgraFrame m_oFrame;
|
||||
|
||||
private:
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer = nullptr;
|
||||
NSGraphics::IGraphicsRenderer* m_pRenderer;
|
||||
CGrState m_oGrState;
|
||||
|
||||
public:
|
||||
CGraphics()
|
||||
{
|
||||
m_pAppImage = NULL;
|
||||
}
|
||||
~CGraphics()
|
||||
{
|
||||
|
||||
@ -31,7 +31,6 @@ namespace NSJSBase {
|
||||
{
|
||||
embed_native_internal = nullptr;
|
||||
m_pAdapter = nullptr;
|
||||
m_isExternalize = false;
|
||||
}
|
||||
|
||||
CJSEmbedObject::~CJSEmbedObject()
|
||||
@ -45,16 +44,6 @@ namespace NSJSBase {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CJSEmbedObject::SetExternalize(const bool& isExternalize)
|
||||
{
|
||||
m_isExternalize = isExternalize;
|
||||
}
|
||||
|
||||
bool CJSEmbedObject::GetExternalize()
|
||||
{
|
||||
return m_isExternalize;
|
||||
}
|
||||
|
||||
CJSEmbedObjectAdapterBase* CJSEmbedObject::getAdapter()
|
||||
{
|
||||
return nullptr;
|
||||
|
||||
@ -194,18 +194,10 @@ namespace NSJSBase
|
||||
*/
|
||||
virtual CJSEmbedObjectAdapterBase* getAdapter();
|
||||
|
||||
/**
|
||||
* Use the externalize flag if you are monitoring the object's destruction yourself.
|
||||
*/
|
||||
virtual void SetExternalize(const bool& isExternalize = true);
|
||||
virtual bool GetExternalize();
|
||||
|
||||
protected:
|
||||
CJSEmbedObjectPrivateBase* embed_native_internal;
|
||||
CJSEmbedObjectAdapterBase* m_pAdapter;
|
||||
|
||||
bool m_isExternalize;
|
||||
|
||||
friend class CJSEmbedObjectPrivateBase;
|
||||
friend class CJSEmbedObjectPrivate;
|
||||
};
|
||||
@ -491,12 +483,6 @@ namespace NSJSBase
|
||||
*/
|
||||
void Exit();
|
||||
|
||||
/**
|
||||
* Сheck if context is current.
|
||||
* This method is not safe.
|
||||
*/
|
||||
bool IsEntered();
|
||||
|
||||
/**
|
||||
* Embeds specified class in JS contexts.
|
||||
* @tparam T Embedded class name.
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
@protocol JSEmbedObjectProtocol
|
||||
-(void*) getNative;
|
||||
-(void) freeNative;
|
||||
@end
|
||||
|
||||
#if __has_feature(objc_arc)
|
||||
@ -42,10 +41,6 @@
|
||||
-(void*) getNative \
|
||||
{ \
|
||||
return m_internal; \
|
||||
} \
|
||||
-(void) freeNative \
|
||||
{ \
|
||||
RELEASEOBJECT(m_internal); \
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -34,7 +34,6 @@ namespace NSJSBase
|
||||
|
||||
// embed
|
||||
id CreateEmbedNativeObject(NSString* name);
|
||||
void FreeNativeObject(id embedded_object);
|
||||
}
|
||||
|
||||
namespace NSJSBase
|
||||
|
||||
@ -232,14 +232,10 @@ namespace NSJSBase
|
||||
{
|
||||
[m_internal->context evaluateScript:@"function jsc_toBase64(r){for(var o=[\"A\",\"B\",\"C\",\"D\",\"E\",\"F\",\"G\",\"H\",\"I\",\"J\",\"K\",\"L\",\"M\",\"N\",\"O\",\"P\",\"Q\",\"R\",\"S\",\"T\",\"U\",\"V\",\"W\",\"X\",\"Y\",\"Z\",\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\",\"h\",\"i\",\"j\",\"k\",\"l\",\"m\",\"n\",\"o\",\"p\",\"q\",\"r\",\"s\",\"t\",\"u\",\"v\",\"w\",\"x\",\"y\",\"z\",\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\",\"+\",\"/\"],a=r.length,f=4*(a/3>>0),n=f/76>>0,t=19,v=0,e=[],i=\"\",s=0;s<=n;s++){s==n&&(t=f%76/4>>0);for(var u=0;u<t;u++){for(var c=0,h=0;h<3;h++)c|=r[0+v++],c<<=8;i=\"\";for(var A=0;A<4;A++){i+=o[c>>>26&255],c<<=6,c&=4294967295}e.push(i)}}if(n=a%3!=0?a%3+1:0){for(c=0,h=0;h<3;h++)h<a%3&&(c|=r[0+v++]),c<<=8;i=\"\";for(A=0;A<n;A++){i+=o[c>>>26&255],c<<=6}t=0!=n?4-n:0;for(u=0;u<t;u++)i+=\"=\";e.push(i)}return e.join(\"\")}function jsc_fromBase64(r,o){for(var a,f=r.length,n=0,t=new Array(void 0===o?f:o),v=t,e=0,i=0;e<f;){for(var s=0,u=0,c=0;c<4&&!(f<=e);c++){var h=65<=(a=r.charCodeAt(e++))&&a<=90?a-65:97<=a&&a<=122?a-71:48<=a&&a<=57?a+4:43==a?62:47==a?63:-1;-1!=h?(s<<=6,s|=h,u+=6):c--}for(s<<=24-u,i=u>>>3,c=0;c<i;c++)v[n++]=(16711680&s)>>>16,s<<=8}return t}\n"];
|
||||
}
|
||||
// insert embed functions to global object of this context
|
||||
// insert CreateEmbedObject() function to global object of this context
|
||||
m_internal->context[@"CreateEmbedObject"] = ^(NSString* name) {
|
||||
return CreateEmbedNativeObject(name);
|
||||
};
|
||||
m_internal->context[@"FreeEmbedObject"] = ^(id embedded_object) {
|
||||
FreeNativeObject(embedded_object);
|
||||
};
|
||||
|
||||
|
||||
JSValue* global_js = [m_internal->context globalObject];
|
||||
[global_js setValue:global_js forProperty:[[NSString alloc] initWithUTF8String:"window"]];
|
||||
@ -250,8 +246,6 @@ namespace NSJSBase
|
||||
{
|
||||
CGlobalContext::GetInstance().UnregisterContextForId(*i);
|
||||
}
|
||||
// remove any exceptions pending to not prevent any JSValue deallocations
|
||||
m_internal->context.exception = nil;
|
||||
m_internal->context = nil;
|
||||
}
|
||||
|
||||
@ -445,11 +439,6 @@ namespace NSJSBase
|
||||
{
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
class CJSLocalScopePrivate
|
||||
{
|
||||
public:
|
||||
@ -509,15 +498,6 @@ namespace NSJSBase
|
||||
return pEmbedObj;
|
||||
}
|
||||
|
||||
void FreeNativeObject(id embedded_object)
|
||||
{
|
||||
// check if the object was actually embedded and do nothing if it wasn't
|
||||
if ([embedded_object conformsToProtocol:@protocol(JSEmbedObjectProtocol)])
|
||||
{
|
||||
[embedded_object freeNative];
|
||||
}
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CJSEmbedObjectAdapterJSC::Native2Value(JSValue* value)
|
||||
{
|
||||
return js_value(value);
|
||||
|
||||
@ -214,41 +214,12 @@ namespace NSJSBase
|
||||
m_internal->m_contextPersistent.Reset(isolate, v8::Context::New(isolate));
|
||||
// create temporary local handle to context
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
// insert embed functions to global object of this context
|
||||
// insert CreateEmbedObject() function to global object of this context
|
||||
m_internal->InsertToGlobal("CreateEmbedObject", CreateEmbedNativeObject);
|
||||
m_internal->InsertToGlobal("FreeEmbedObject", FreeNativeObject);
|
||||
// clear temporary local handle
|
||||
m_internal->m_context.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
class WeakHandleVisitor : public v8::PersistentHandleVisitor
|
||||
{
|
||||
private:
|
||||
WeakHandleVisitor() = default;
|
||||
|
||||
public:
|
||||
void VisitPersistentHandle(v8::Persistent<v8::Value>* value, uint16_t class_id) override
|
||||
{
|
||||
if (class_id == CJSEmbedObjectPrivate::kWeakHandleId)
|
||||
{
|
||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
||||
v8::HandleScope scope(isolate);
|
||||
v8::Local<v8::Object> handle = value->Get(isolate).As<v8::Object>();
|
||||
v8::Local<v8::External> field = v8::Local<v8::External>::Cast(handle->GetInternalField(0));
|
||||
CJSEmbedObject* native = static_cast<CJSEmbedObject*>(field->Value());
|
||||
delete native;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
static WeakHandleVisitor* getInstance()
|
||||
{
|
||||
static WeakHandleVisitor visitor;
|
||||
return &visitor;
|
||||
}
|
||||
};
|
||||
|
||||
void CJSContext::Dispose()
|
||||
{
|
||||
#ifdef V8_INSPECTOR
|
||||
@ -257,13 +228,7 @@ namespace NSJSBase
|
||||
#endif
|
||||
|
||||
m_internal->m_contextPersistent.Reset();
|
||||
// destroy native object in the weak handles before isolate disposal
|
||||
v8::Isolate* isolate = m_internal->m_isolate;
|
||||
{
|
||||
v8::Isolate::Scope scope(isolate);
|
||||
isolate->VisitHandlesWithClassIds(WeakHandleVisitor::getInstance());
|
||||
}
|
||||
isolate->Dispose();
|
||||
m_internal->m_isolate->Dispose();
|
||||
m_internal->m_isolate = NULL;
|
||||
}
|
||||
|
||||
@ -290,8 +255,6 @@ namespace NSJSBase
|
||||
m_internal->m_context = v8::Local<v8::Context>::New(isolate, m_internal->m_contextPersistent);
|
||||
if (!m_internal->m_context.IsEmpty())
|
||||
m_internal->m_context->Enter();
|
||||
|
||||
m_internal->m_entered = true;
|
||||
}
|
||||
|
||||
void CJSContext::Exit()
|
||||
@ -308,13 +271,6 @@ namespace NSJSBase
|
||||
else
|
||||
m_internal->m_context = m_internal->m_isolate->GetCurrentContext();
|
||||
m_internal->m_isolate->Exit();
|
||||
|
||||
m_internal->m_entered = false;
|
||||
}
|
||||
|
||||
bool CJSContext::IsEntered()
|
||||
{
|
||||
return m_internal->m_entered;
|
||||
}
|
||||
|
||||
CJSValue* CJSContext::createUndefined()
|
||||
@ -690,22 +646,4 @@ namespace NSJSBase
|
||||
NSJSBase::CJSEmbedObjectPrivate::CreateWeaker(obj);
|
||||
args.GetReturnValue().Set(obj);
|
||||
}
|
||||
|
||||
void FreeNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args)
|
||||
{
|
||||
v8::Isolate* isolate = args.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
|
||||
if (args.Length() != 1)
|
||||
{
|
||||
args.GetReturnValue().Set(v8::Undefined(isolate));
|
||||
return;
|
||||
}
|
||||
|
||||
v8::Local<v8::Object> obj = args[0].As<v8::Object>();
|
||||
v8::Local<v8::External> field = v8::Local<v8::External>::Cast(obj->GetInternalField(0));
|
||||
CJSEmbedObject* native = static_cast<CJSEmbedObject*>(field->Value());
|
||||
delete native;
|
||||
// weak persistent handle will be cleared and removed in CJSEmbedObjectPrivate destructor
|
||||
}
|
||||
}
|
||||
|
||||
@ -857,14 +857,12 @@ namespace NSJSBase
|
||||
v8::Local<v8::Context> m_context;
|
||||
|
||||
v8::StartupData m_startup_data;
|
||||
bool m_entered;
|
||||
|
||||
public:
|
||||
CJSContextPrivate() : m_isolate(NULL)
|
||||
{
|
||||
m_startup_data.data = NULL;
|
||||
m_startup_data.raw_size = 0;
|
||||
m_entered = false;
|
||||
}
|
||||
|
||||
void InsertToGlobal(const std::string& name, v8::FunctionCallback creator)
|
||||
@ -883,7 +881,6 @@ namespace NSJSBase
|
||||
|
||||
// embed
|
||||
void CreateEmbedNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
void FreeNativeObject(const v8::FunctionCallbackInfo<v8::Value>& args);
|
||||
|
||||
class CJSEmbedObjectAdapterV8Template : public CJSEmbedObjectAdapterBase
|
||||
{
|
||||
@ -901,8 +898,6 @@ namespace NSJSBase
|
||||
{
|
||||
public:
|
||||
v8::Persistent<v8::Object> handle;
|
||||
// contstant id for all weak native handles
|
||||
static const uint16_t kWeakHandleId = 1;
|
||||
|
||||
CJSEmbedObjectPrivate(v8::Local<v8::Object> obj)
|
||||
{
|
||||
@ -921,8 +916,6 @@ namespace NSJSBase
|
||||
|
||||
handle.Reset(CV8Worker::GetCurrent(), obj);
|
||||
handle.SetWeak(pEmbedObject, EmbedObjectWeakCallback, v8::WeakCallbackType::kParameter);
|
||||
// set class_id for being able to iterate over all these handles to destroy them on isolate disposal
|
||||
handle.SetWrapperClassId(kWeakHandleId);
|
||||
|
||||
pEmbedObject->embed_native_internal = this;
|
||||
}
|
||||
@ -936,6 +929,8 @@ namespace NSJSBase
|
||||
|
||||
static void EmbedObjectWeakCallback(const v8::WeakCallbackInfo<CJSEmbedObject>& data)
|
||||
{
|
||||
v8::Isolate* isolate = data.GetIsolate();
|
||||
v8::HandleScope scope(isolate);
|
||||
CJSEmbedObject* wrap = data.GetParameter();
|
||||
((CJSEmbedObjectPrivate*)wrap->embed_native_internal)->handle.Reset();
|
||||
delete wrap;
|
||||
|
||||
@ -1,15 +1,4 @@
|
||||
#include "Embed.h"
|
||||
#include <iostream>
|
||||
|
||||
CTestEmbed::CTestEmbed()
|
||||
{
|
||||
std::cout << "debug: CTestEmbed constructed" << std::endl;
|
||||
}
|
||||
|
||||
CTestEmbed::~CTestEmbed()
|
||||
{
|
||||
std::cout << "debug: CTestEmbed destroyed" << std::endl;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_SUM_DEL
|
||||
JSSmart<CJSValue> CTestEmbed::FunctionSum(JSSmart<CJSValue> param1, JSSmart<CJSValue> param2)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#ifndef CTESTEMBED_H_
|
||||
#define CTESTEMBED_H_
|
||||
#ifndef _BUILD_NATIVE_HASH_EMBED_H_
|
||||
#define _BUILD_NATIVE_HASH_EMBED_H_
|
||||
|
||||
#include "js_internal/js_base.h"
|
||||
|
||||
@ -10,8 +10,13 @@ using namespace NSJSBase;
|
||||
class CTestEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CTestEmbed();
|
||||
~CTestEmbed();
|
||||
CTestEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
~CTestEmbed()
|
||||
{
|
||||
}
|
||||
|
||||
virtual void* getObject() override { return NULL; }
|
||||
|
||||
@ -28,4 +33,4 @@ public:
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
#endif // CTESTEMBED_H_
|
||||
#endif // _BUILD_NATIVE_HASH_EMBED_H_
|
||||
|
||||
@ -1,14 +1,278 @@
|
||||
#include "test_functions.h"
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* 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-12 Ernesta Birznieka-Upisha
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
int main()
|
||||
#include <iostream>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
#include "Embed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// TODO: test
|
||||
#if 0
|
||||
// Primitives example
|
||||
|
||||
// testMultipleContexts();
|
||||
testEmbedExternal();
|
||||
// testEmbedInternal();
|
||||
// testHashEmbed();
|
||||
// testEmbedMixed();
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext(false);
|
||||
oContext1->Initialize();
|
||||
|
||||
JSSmart<CJSContext> oContext2 = new CJSContext;
|
||||
// oContext2->Initialize();
|
||||
|
||||
// Work with first context
|
||||
oContext1->Enter();
|
||||
|
||||
{
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSLocalScope local_scope;
|
||||
JSSmart<CJSValue> oResLocal = oContext1->runScript("function f() { return 'Local scope test'; }; f();");
|
||||
std::cout << oResLocal->toStringA() << std::endl;
|
||||
}
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSValue> oVar2 = oContext1->createString("Hel");
|
||||
oGlobal1->set("v1", oVar2.GetPointer());
|
||||
oContext1->runScript("var res = v1 + 'lo'");
|
||||
|
||||
oContext1->Exit();
|
||||
|
||||
// Work with second context with CJSContextScope usage
|
||||
{
|
||||
CJSContextScope scope(oContext2);
|
||||
|
||||
JSSmart<CJSObject> oGlobal2 = oContext2->GetGlobal();
|
||||
JSSmart<CJSValue> oVar4 = oContext2->createString("Wor");
|
||||
oGlobal2->set("v1", oVar4.GetPointer());
|
||||
oContext2->runScript("var res = v1 + 'ld!'");
|
||||
}
|
||||
|
||||
// Print result from first context
|
||||
oContext1->Enter();
|
||||
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript("function f() { return res; }; f();");
|
||||
std::string strRes1 = oRes1->toStringA();
|
||||
std::cout << strRes1 << std::endl;
|
||||
|
||||
// Print second variable
|
||||
oContext2->Enter();
|
||||
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript("function f() { return res; }; f();");
|
||||
std::string strRes2 = oRes2->toStringA();
|
||||
std::cout << strRes2 << std::endl;
|
||||
|
||||
oContext2->Exit();
|
||||
oContext1->Exit();
|
||||
|
||||
// oContext1->Dispose();
|
||||
oContext2->Dispose();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// External embed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// Embedding
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSContext::Embed<CTestEmbed>();
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed1 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
std::cout << "FunctionSum(10, 5) = " << oResTestEmbed1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed2 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSquare(4); })();");
|
||||
std::cout << "FunctionSquare(4) = " << oResTestEmbed2->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed3 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionDel(30, 3); })();");
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed4 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CZipEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
JSSmart<CJSContext> oContext2 = new CJSContext();
|
||||
|
||||
// Work with first context
|
||||
oContext1->Enter();
|
||||
CreateDefaults();
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();");
|
||||
oContext1->Exit();
|
||||
|
||||
// Work with second context
|
||||
{
|
||||
CJSContextScope scope(oContext2);
|
||||
// CreateDefaults();
|
||||
JSSmart<CJSValue> oRes2 = oContext2->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "/../embed');\n"
|
||||
"oZip.close();");
|
||||
}
|
||||
|
||||
// Print first result
|
||||
oContext1->Enter();
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSArray> oFiles1 = oGlobal1->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 1:\n";
|
||||
for (int i = 0; i < oFiles1->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// Print second result
|
||||
oContext2->Enter();
|
||||
JSSmart<CJSObject> oGlobal2 = oContext2->GetGlobal();
|
||||
JSSmart<CJSArray> oFiles2 = oGlobal2->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 2:\n";
|
||||
for (int i = 0; i < oFiles2->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles2->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
oContext2->Exit();
|
||||
oContext1->Exit();
|
||||
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// CHashEmbed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// Call hash() on first context
|
||||
CJSContextScope scope(oContext1);
|
||||
CreateDefaults();
|
||||
JSSmart<CJSValue> oRes1 = oContext1->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSObject> oGlobal1 = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal1->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Call hash2() on first context
|
||||
JSSmart<CJSValue> oRes2 = oContext1->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);");
|
||||
|
||||
// Print first result
|
||||
JSSmart<CJSTypedArray> oHash2 = oGlobal1->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < oHash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
// Mixed embed example
|
||||
|
||||
JSSmart<CJSContext> oContext1 = new CJSContext();
|
||||
|
||||
// External CTestEmbed
|
||||
CJSContextScope scope(oContext1);
|
||||
CJSContext::Embed<CTestEmbed>(false);
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed1 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
if (oResTestEmbed1->isNumber())
|
||||
std::cout << "FunctionSum(10, 5) = " << oResTestEmbed1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSObject> oTestEmbed = CJSContext::createEmbedObject("CTestEmbed");
|
||||
|
||||
// JSSmart<CJSValue> oResTestEmbed2 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSquare(4); })();");
|
||||
JSSmart<CJSValue> args2[1];
|
||||
args2[0] = CJSContext::createInt(4);
|
||||
JSSmart<CJSValue> oResTestEmbed2 = oTestEmbed->call_func("FunctionSquare", 1, args2);
|
||||
if (oResTestEmbed2->isNumber())
|
||||
std::cout << "FunctionSquare(4) = " << oResTestEmbed2->toInt32() << std::endl;
|
||||
|
||||
// JSSmart<CJSValue> oResTestEmbed3 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionDel(30, 3); })();");
|
||||
JSSmart<CJSValue> args3[2];
|
||||
args3[0] = CJSContext::createInt(30);
|
||||
args3[1] = CJSContext::createInt(3);
|
||||
JSSmart<CJSValue> oResTestEmbed3 = oTestEmbed->call_func("FunctionDel", 2, args3);
|
||||
if (oResTestEmbed3->isNumber())
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> oResTestEmbed4 = oContext1->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
if (oResTestEmbed4->isNumber())
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
|
||||
// Internal CHashEmbed
|
||||
CreateDefaults();
|
||||
oContext1->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);");
|
||||
|
||||
// Print hash
|
||||
JSSmart<CJSObject> oGlobal = oContext1->GetGlobal();
|
||||
JSSmart<CJSTypedArray> oHash = oGlobal->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < oHash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(oHash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// Internal CZipEmbed
|
||||
oContext1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();");
|
||||
|
||||
// Print files
|
||||
JSSmart<CJSArray> oFiles1 = oGlobal->get("files")->toArray();
|
||||
std::cout << "\nFILES IN CURRENT DIRECTORY:\n";
|
||||
for (int i = 0; i < oFiles1->getCount(); i++)
|
||||
{
|
||||
std::cout << oFiles1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
#include "test_functions.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
// all test functions should be called inside the `@autoreleasepool` block!
|
||||
@autoreleasepool
|
||||
{
|
||||
testEmbedExternal();
|
||||
// testHashEmbed();
|
||||
// testEmbedMixed();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -29,18 +29,10 @@ core_linux {
|
||||
LIBS += -ldl
|
||||
}
|
||||
|
||||
SOURCES += main.cpp \
|
||||
Embed.cpp
|
||||
|
||||
HEADERS += \
|
||||
Embed.h \
|
||||
test_functions.h
|
||||
|
||||
SOURCES += \
|
||||
Embed.cpp \
|
||||
test_functions.cpp
|
||||
|
||||
use_javascript_core {
|
||||
OBJECTIVE_SOURCES += main.mm
|
||||
} else {
|
||||
SOURCES += main.cpp
|
||||
}
|
||||
Embed.h
|
||||
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(Embed.h)
|
||||
|
||||
@ -1,286 +0,0 @@
|
||||
#include "test_functions.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "embed/Default.h"
|
||||
#include "js_internal/js_base.h"
|
||||
#include "Embed.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
void testMultipleContexts()
|
||||
{
|
||||
// passing `false` when creating CJSContext means that we need to initialize it manually
|
||||
JSSmart<CJSContext> context1 = new CJSContext(false);
|
||||
context1->Initialize();
|
||||
|
||||
// while creating CJSContext without any arguments will create initialized CJSContext
|
||||
JSSmart<CJSContext> context2 = new CJSContext;
|
||||
// we don't need it:
|
||||
// oContext2->Initialize();
|
||||
|
||||
// entering the first context
|
||||
context1->Enter();
|
||||
{
|
||||
// entering the first context the second time in scope creation - it's allowed and the scopes stack correctly
|
||||
CJSContextScope scope(context1);
|
||||
// allocate new local variables inside a custom local scope instead of
|
||||
// the one that is provided by CJSContextScope by default
|
||||
CJSLocalScope local_scope;
|
||||
JSSmart<CJSValue> res_local = context1->runScript("(function() { return 'Local scope test'; })();");
|
||||
std::cout << res_local->toStringA() << std::endl;
|
||||
// the first context is going to be exited at the end of the scope
|
||||
}
|
||||
// at this moment we are still inside the first context, since we have entered it twices
|
||||
JSSmart<CJSObject> global1 = context1->GetGlobal();
|
||||
JSSmart<CJSValue> var = context1->createString("Hel");
|
||||
global1->set("v1", var);
|
||||
// here `res` is set to be "Hello"
|
||||
context1->runScript("var res = v1 + 'lo'");
|
||||
// exit from the first context
|
||||
context1->Exit();
|
||||
|
||||
// now we are going to work with the second context
|
||||
{
|
||||
// enter the second context via context scope
|
||||
CJSContextScope scope(context2);
|
||||
|
||||
JSSmart<CJSObject> global2 = context2->GetGlobal();
|
||||
JSSmart<CJSValue> var = context2->createString("Wor");
|
||||
global2->set("v1", var);
|
||||
// `res` is "World!"
|
||||
context2->runScript("var res = v1 + 'ld!'");
|
||||
// the second context is going to be exited at the end of the scope
|
||||
}
|
||||
|
||||
// enter the first context
|
||||
context1->Enter();
|
||||
// print `res` variable from the first context
|
||||
JSSmart<CJSValue> res1 = context1->runScript("(function() { return res; })();");
|
||||
std::string str_res1 = res1->toStringA();
|
||||
std::cout << str_res1 << ", ";
|
||||
// make new variable `v2` in first context
|
||||
// important to note, that accessing previous `global1` object is undefined behaviour and can lead to crashes!
|
||||
// that is because when we exited from the first context, every local handle inside CJSValue and CJSObject was invalidated
|
||||
global1 = context1->GetGlobal();
|
||||
global1->set("v2", CJSContext::createInt(42));
|
||||
|
||||
// enter from the second context (notice, we haven't exited the first context before)
|
||||
context2->Enter();
|
||||
// print `res` variable from the second context
|
||||
JSSmart<CJSValue> res2 = context1->runScript("(function() { return res; })();");
|
||||
std::string str_res2 = res2->toStringA();
|
||||
std::cout << str_res2 << std::endl;
|
||||
|
||||
// exit from the second context
|
||||
context2->Exit();
|
||||
|
||||
// at this moment we are still in the first context
|
||||
// we can validate that accessing `v2` variable, which exists only in the first context
|
||||
global1 = context1->GetGlobal();
|
||||
std::cout << global1->get("v2")->toInt32() << std::endl;
|
||||
// exit from the first context
|
||||
context1->Exit();
|
||||
|
||||
// manual disposing is not necessary, since it's going to be called in CJSContext's destructor anyway
|
||||
// so we don't need to explicitly write:
|
||||
// oContext1->Dispose();
|
||||
|
||||
// but still nothing wrong will happen if we do:
|
||||
context2->Dispose();
|
||||
}
|
||||
|
||||
void testEmbedExternal()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
// Embedding
|
||||
CJSContextScope scope(context);
|
||||
CJSContext::Embed<CTestEmbed>();
|
||||
|
||||
JSSmart<CJSValue> res1 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionSum(10, 5); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionSum(10, 5) = " << res1->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res2 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionSquare(4); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionSquare(4) = " << res2->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res3 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionDel(30, 3); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionDel(30, 3) = " << res3->toInt32() << std::endl;
|
||||
|
||||
JSSmart<CJSValue> res4 = context->runScript("(function() { let value = CreateEmbedObject('CTestEmbed'); let ret = value.FunctionGet(); FreeEmbedObject(value); return ret; })();");
|
||||
std::cout << "FunctionGet() = " << res4->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
void testEmbedInternal()
|
||||
{
|
||||
// create both contexts
|
||||
JSSmart<CJSContext> context1 = new CJSContext();
|
||||
JSSmart<CJSContext> context2 = new CJSContext();
|
||||
|
||||
// work with the first context
|
||||
context1->Enter();
|
||||
// create embedding info for internally embedded objects (CZipEmbed is the one of them)
|
||||
CreateDefaults();
|
||||
context1->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
context1->Exit();
|
||||
|
||||
// work with the second context via context scope
|
||||
{
|
||||
CJSContextScope scope(context2);
|
||||
// function CJSContext::Embed() is context-independent, so we don't actually need to call it in another context
|
||||
// CreateDefaults();
|
||||
context2->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "/../../../embed');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
}
|
||||
|
||||
// print the files from the first context
|
||||
context1->Enter();
|
||||
JSSmart<CJSObject> global1 = context1->GetGlobal();
|
||||
JSSmart<CJSArray> file_list1 = global1->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 1:\n";
|
||||
for (int i = 0; i < file_list1->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list1->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// print the files from the second result (note, we haven't exited the first context before)
|
||||
context2->Enter();
|
||||
JSSmart<CJSObject> global2 = context2->GetGlobal();
|
||||
JSSmart<CJSArray> file_list2 = global2->get("files")->toArray();
|
||||
std::cout << "\nRESULT FROM CONTEXT 2:\n";
|
||||
for (int i = 0; i < file_list2->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list2->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
|
||||
// exit the contexts in reverse order
|
||||
context2->Exit();
|
||||
context1->Exit();
|
||||
}
|
||||
|
||||
void testHashEmbed()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
// test hash()
|
||||
CJSContextScope scope(context);
|
||||
CreateDefaults();
|
||||
context->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);"
|
||||
);
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
JSSmart<CJSTypedArray> res_hash = global->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < res_hash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(res_hash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
// test hash2()
|
||||
context->runScript(
|
||||
"var str2 = 'test';\n"
|
||||
"var hash2 = oHash.hash2(str2, 'yrGivlyCImiWnryRee1OJw==', 100000, 7);"
|
||||
);
|
||||
|
||||
JSSmart<CJSTypedArray> res_hash2 = global->get("hash2")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH2:\n";
|
||||
for (int i = 0; i < res_hash2->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(res_hash2->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
}
|
||||
|
||||
void testEmbedMixed()
|
||||
{
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
CJSContextScope scope(context);
|
||||
|
||||
|
||||
// --- test external embedding with CTestEmbed ---
|
||||
// embed with `false` - means we are not able to create the object directly from JavaScript.
|
||||
CJSContext::Embed<CTestEmbed>(false);
|
||||
|
||||
// example of incorrect usage:
|
||||
JSSmart<CJSValue> res1 = context->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionSum(10, 5); })();");
|
||||
if (res1->isNumber())
|
||||
{
|
||||
// this wouldn't print anything, since `res1` not a number - embedded object was not created in JS and exception was thrown.
|
||||
std::cout << "FunctionSum(10, 5) = " << res1->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// example of correct usage:
|
||||
JSSmart<CJSObject> embedded_object = CJSContext::createEmbedObject("CTestEmbed");
|
||||
JSSmart<CJSValue> args2[1];
|
||||
args2[0] = CJSContext::createInt(4);
|
||||
JSSmart<CJSValue> res2 = embedded_object->call_func("FunctionSquare", 1, args2);
|
||||
if (res2->isNumber())
|
||||
{
|
||||
// should print: "FunctionSquare(4) = 16"
|
||||
std::cout << "FunctionSquare(4) = " << res2->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// another example of correct usage:
|
||||
JSSmart<CJSValue> args3[2];
|
||||
args3[0] = CJSContext::createInt(30);
|
||||
args3[1] = CJSContext::createInt(3);
|
||||
JSSmart<CJSValue> oResTestEmbed3 = embedded_object->call_func("FunctionDel", 2, args3);
|
||||
if (oResTestEmbed3->isNumber())
|
||||
{
|
||||
// should print: "FunctionDel(30, 3) = 10"
|
||||
std::cout << "FunctionDel(30, 3) = " << oResTestEmbed3->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
// another example of incorrect usage:
|
||||
JSSmart<CJSValue> oResTestEmbed4 = context->runScript("(function() { var value = CreateEmbedObject('CTestEmbed'); return value.FunctionGet(); })();");
|
||||
if (oResTestEmbed4->isNumber())
|
||||
{
|
||||
// again, this won't be executed and nothing will be printed
|
||||
std::cout << "FunctionGet() = " << oResTestEmbed4->toInt32() << std::endl;
|
||||
}
|
||||
|
||||
|
||||
// --- test internal embedding with CHashEmbed ---
|
||||
CreateDefaults();
|
||||
context->runScript(
|
||||
"var oHash = CreateEmbedObject('CHashEmbed');\n"
|
||||
"var str = 'test';\n"
|
||||
"var hash = oHash.hash(str, str.length, 0);"
|
||||
);
|
||||
// print hash
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
JSSmart<CJSTypedArray> hash = global->get("hash")->toTypedArray();
|
||||
std::cout << "\nRESULTED HASH:\n";
|
||||
for (int i = 0; i < hash->getCount(); i++)
|
||||
{
|
||||
std::cout << std::hex << static_cast<unsigned>(hash->getData().Data[i]);
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
|
||||
// --- test internal embedding with CZipEmbed ---
|
||||
context->runScript(
|
||||
"var oZip = CreateEmbedObject('CZipEmbed');\n"
|
||||
"var files = oZip.open('" CURR_DIR "');\n"
|
||||
"oZip.close();"
|
||||
);
|
||||
|
||||
// print files
|
||||
JSSmart<CJSArray> file_list = global->get("files")->toArray();
|
||||
std::cout << "\nFILES IN CURRENT DIRECTORY:\n";
|
||||
for (int i = 0; i < file_list->getCount(); i++)
|
||||
{
|
||||
std::cout << file_list->get(i)->toStringA() << std::endl;
|
||||
}
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
#ifndef TEST_FUNCTIONS_H_
|
||||
#define TEST_FUNCTIONS_H_
|
||||
|
||||
|
||||
/**
|
||||
* NOTE: V8 ONLY!
|
||||
* The function tests the work of two CJSContexts in one thread.
|
||||
* Current working context is managed with Enter() and Exit() functions, or with CJSContextScope.
|
||||
*/
|
||||
void testMultipleContexts();
|
||||
|
||||
/**
|
||||
* The function tests external embedding functionality by embedding CTestEmbed class.
|
||||
*/
|
||||
void testEmbedExternal();
|
||||
|
||||
/**
|
||||
* NOTE: V8 ONLY!
|
||||
* The function tests internal embedding functionality by using CZipEmbed class.
|
||||
* It also shows how embedding works for two CJSContext in the same thread (similar to testMultipleContexts()).
|
||||
*/
|
||||
void testEmbedInternal();
|
||||
|
||||
/**
|
||||
* The function tests CHashEmbed class that is embedded internally.
|
||||
*/
|
||||
void testHashEmbed();
|
||||
|
||||
/**
|
||||
* The function tests both internal and external embedding in a more complicated way.
|
||||
*/
|
||||
void testEmbedMixed();
|
||||
|
||||
#endif // TEST_FUNCTIONS_H_
|
||||
@ -1853,16 +1853,6 @@ std::vector<std::wstring> CApplicationFonts::GetSetupFontFiles(const bool& bIsUs
|
||||
#if defined(_MAC) && !defined(_IOS)
|
||||
std::vector<std::wstring> _array = NSDirectory::GetFiles(L"/Library/Fonts", true);
|
||||
NSDirectory::GetFiles2(L"/System/Library/Fonts", _array, true);
|
||||
|
||||
std::set<std::wstring> installedList = GetInstalledFontsMac();
|
||||
for (const auto& sysPath : installedList) {
|
||||
if (0 == sysPath.find(L"/System/Library/Fonts/"))
|
||||
continue;
|
||||
if (0 == sysPath.find(L"/Library/Fonts/"))
|
||||
continue;
|
||||
_array.push_back(sysPath);
|
||||
}
|
||||
|
||||
return _array;
|
||||
#endif
|
||||
|
||||
@ -1968,10 +1958,6 @@ namespace NSFonts
|
||||
if (FT_Open_Face(m_internal->m_library, &oOpenArgs, nFaceIndex, &pFace))
|
||||
return;
|
||||
|
||||
bool bIsASC = false;
|
||||
if (pFace->family_name && (0 == strcmp(pFace->family_name, "ASCW3")))
|
||||
bIsASC = true;
|
||||
|
||||
for (int nCharMap = 0; nCharMap < pFace->num_charmaps; nCharMap++)
|
||||
{
|
||||
FT_Set_Charmap(pFace, pFace->charmaps[nCharMap]);
|
||||
@ -1981,8 +1967,7 @@ namespace NSFonts
|
||||
|
||||
while (indexG)
|
||||
{
|
||||
if (!bIsASC || (character < 35 || character > 255))
|
||||
pChecker->Check((int)character, indexG);
|
||||
pChecker->Check((int)character, indexG);
|
||||
character = FT_Get_Next_Char(pFace, character, &indexG);
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,6 @@
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include "FontManager.h"
|
||||
#include <set>
|
||||
|
||||
namespace NSFonts
|
||||
{
|
||||
@ -355,10 +354,6 @@ public:
|
||||
void InitFromReg();
|
||||
#endif
|
||||
|
||||
#if defined(_MAC) && !defined(_IOS)
|
||||
std::set<std::wstring> GetInstalledFontsMac();
|
||||
#endif
|
||||
|
||||
NSFonts::IFontManager* GenerateFontManager();
|
||||
|
||||
std::wstring GetFontBySymbol(int symbol);
|
||||
|
||||
@ -877,11 +877,6 @@ public:
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang SC", 36));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang TC", 37));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"PingFang HK", 38));
|
||||
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Heiti SC", 39));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Heiti TC", 40));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Songti SC", 41));
|
||||
mapFontsPriorityStandard.insert(std::pair<std::wstring, int>(L"Songti TC", 42));
|
||||
#endif
|
||||
|
||||
NSFonts::CApplicationFontsSymbols oApplicationChecker;
|
||||
@ -1609,14 +1604,6 @@ NSFonts::IApplicationFonts* CApplicationFontsWorker::Check()
|
||||
if (m_sDirectory.empty())
|
||||
return NULL;
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = m_arAdditionalFolders.begin(); i != m_arAdditionalFolders.end(); i++)
|
||||
{
|
||||
if (0 == i->find(L"./"))
|
||||
*i = NSFile::GetProcessDirectory() + L"/" + i->substr(2);
|
||||
else if (0 == i->find(L"../"))
|
||||
*i = NSFile::GetProcessDirectory() + L"/" + *i;
|
||||
}
|
||||
|
||||
std::wstring strAllFontsJSPath = m_sDirectory + L"/AllFonts.js";
|
||||
std::wstring strFontsSelectionBin = m_sDirectory + L"/font_selection.bin";
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include <vector>
|
||||
#include "../graphics/pro/Fonts.h"
|
||||
|
||||
#define ONLYOFFICE_FONTS_VERSION 14
|
||||
#define ONLYOFFICE_FONTS_VERSION 12
|
||||
#define ONLYOFFICE_ALL_FONTS_VERSION 2
|
||||
|
||||
class CApplicationFontsWorkerBreaker
|
||||
|
||||
@ -83,7 +83,6 @@
|
||||
"./../../graphics/pro/js/wasm/src/lib",
|
||||
|
||||
"./../../../Common/3dParty/harfbuzz/harfbuzz/src",
|
||||
"./../../../Common/3dParty/brotli/brotli/c/include",
|
||||
|
||||
"./../../../OfficeUtils/src",
|
||||
"./../../../OfficeUtils/src/zlib-1.2.11",
|
||||
@ -114,8 +113,6 @@
|
||||
"BUILD_ZLIB_AS_SOURCES",
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
|
||||
"FT_CONFIG_OPTION_USE_BROTLI",
|
||||
|
||||
"BUILDING_WASM_MODULE"
|
||||
],
|
||||
"compile_files_array": [
|
||||
@ -352,26 +349,6 @@
|
||||
{
|
||||
"folder": "./../../../Common/3dParty/hyphen/js/src",
|
||||
"files": ["hyphen.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "./../../../Common/3dParty/brotli/brotli/c/common",
|
||||
"files": [
|
||||
"constants.c",
|
||||
"context.c",
|
||||
"dictionary.c",
|
||||
"platform.c",
|
||||
"shared_dictionary.c",
|
||||
"transform.c"
|
||||
]
|
||||
},
|
||||
{
|
||||
"folder": "./../../../Common/3dParty/brotli/brotli/c/dec",
|
||||
"files": [
|
||||
"bit_reader.c",
|
||||
"decode.c",
|
||||
"huffman.c",
|
||||
"state.c"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -917,15 +917,15 @@ function onLoadFontsModule(window, undefined)
|
||||
this._mapToNames = AscCommon.spellcheckGetLanguages();
|
||||
|
||||
let _langKey = "" + lang;
|
||||
let _langObj = this._mapToNames[_langKey];
|
||||
if (!_langObj || !_langObj["hyphen"] || !_langObj["name"])
|
||||
let _langName = this._mapToNames[_langKey];
|
||||
if (_langName === undefined)
|
||||
{
|
||||
this._dictionaries[_langKey] = false;
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
this._loadDictionaryAttemt(_langKey, _langObj["name"], callback);
|
||||
this._loadDictionaryAttemt(_langKey, _langName, callback);
|
||||
};
|
||||
|
||||
this._loadDictionaryAttemt = function(langKey, langName, callback, currentAttempt)
|
||||
|
||||
@ -1020,39 +1020,22 @@ void CBooleanOperations::TracePaths()
|
||||
{
|
||||
size_t length = Segments1.size();
|
||||
Result.StartFigure();
|
||||
bool first_start = true;
|
||||
for (size_t i = 0; i < length + Segments2.size(); i++)
|
||||
{
|
||||
Segment s = i >= length ? Segments2[i - length] : Segments1[i];
|
||||
bool valid = s.IsValid(Op),
|
||||
start = true;
|
||||
PointD start_point;
|
||||
start = true;
|
||||
while (valid)
|
||||
{
|
||||
if (!start || (Op == Intersection && s.Inters && !GetNextSegment(s).Inters))
|
||||
SetVisited(s);
|
||||
|
||||
if (first_start)
|
||||
{
|
||||
if (start)
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
start_point = s.P;
|
||||
}
|
||||
else if (start)
|
||||
{
|
||||
double x, y;
|
||||
Result.GetLastPoint(x, y);
|
||||
if (isZero(start_point.X - x) && isZero(start_point.Y - y))
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
start_point = s.P;
|
||||
}
|
||||
else
|
||||
Result.LineTo(s.P.X, s.P.Y);
|
||||
}
|
||||
else if (s.IsCurve)
|
||||
Result.CurveTo(s.HI.X + s.P.X, s.HI.Y + s.P.Y,
|
||||
s.HO.X + s.P.X, s.HO.Y + s.P.Y,
|
||||
s.P.X, s.P.Y);
|
||||
s.HO.X + s.P.X, s.HO.Y + s.P.Y,
|
||||
s.P.X, s.P.Y);
|
||||
else
|
||||
Result.LineTo(s.P.X, s.P.Y);
|
||||
|
||||
@ -1082,9 +1065,6 @@ void CBooleanOperations::TracePaths()
|
||||
|
||||
if (start)
|
||||
start = false;
|
||||
|
||||
if (first_start)
|
||||
first_start = false;
|
||||
}
|
||||
|
||||
if (!start && AllOverlap()) break;
|
||||
@ -1665,14 +1645,12 @@ int CBooleanOperations::CheckInters(const PointD& point, const Segment& segment,
|
||||
std::vector<double> roots = curve.GetCurveLineIntersection(segment.P.X,segment.P.Y, point.X - segment.P.X, point.Y - segment.P.Y);
|
||||
Curve line(segment, Segment(point));
|
||||
|
||||
return roots.size() % 2;
|
||||
int count = 0;
|
||||
for (const auto& r : roots)
|
||||
if (line.GetTimeOf(curve.GetPoint(r)) != -1)
|
||||
count++;
|
||||
|
||||
// int count = 0;
|
||||
// for (const auto& r : roots)
|
||||
// if (line.GetTimeOf(curve.GetPoint(r)) != -1)
|
||||
// count++;
|
||||
|
||||
// return count;
|
||||
return count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -33,164 +33,22 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
CClipMask::CClipMask() : m_pixf(m_alpha_rbuf)
|
||||
{
|
||||
m_pMask = NULL;
|
||||
m_bIsClip = false;
|
||||
|
||||
m_lWidth = 0;
|
||||
m_lHeight = 0;
|
||||
}
|
||||
|
||||
CClipMask::~CClipMask()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CClipMask::Destroy()
|
||||
{
|
||||
if (NULL != m_pMask)
|
||||
delete [] m_pMask;
|
||||
}
|
||||
|
||||
void CClipMask::Reset()
|
||||
{
|
||||
m_bIsClip = false;
|
||||
}
|
||||
|
||||
void CClipMask::Create(LONG width, LONG height)
|
||||
{
|
||||
Destroy();
|
||||
m_pMask = new BYTE[width * height];
|
||||
|
||||
m_alpha_rbuf.attach(m_pMask, width, height, width);
|
||||
m_lWidth = width;
|
||||
m_lHeight = height;
|
||||
|
||||
m_pixf.attach(m_alpha_rbuf);
|
||||
m_base_renderer.attach(m_pixf);
|
||||
m_renderer.attach(m_base_renderer);
|
||||
|
||||
m_renderer.color(agg::gray8(0xFF, 0xFF));
|
||||
}
|
||||
|
||||
void CClipMask::ResetClip()
|
||||
{
|
||||
}
|
||||
|
||||
void CClipMask::GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix)
|
||||
{
|
||||
if (NULL == pPath)
|
||||
return;
|
||||
|
||||
memset(m_pMask, 0, m_lWidth * m_lHeight);
|
||||
|
||||
m_rasterizer.reset();
|
||||
|
||||
typedef agg::conv_transform<agg::path_storage> trans_type;
|
||||
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
|
||||
|
||||
typedef agg::conv_curve<trans_type> conv_crv_type;
|
||||
conv_crv_type c_c_path(trans);
|
||||
|
||||
m_rasterizer.add_path(c_c_path);
|
||||
|
||||
agg::render_scanlines(m_rasterizer, m_sl, m_renderer);
|
||||
|
||||
m_bIsClip = true;
|
||||
}
|
||||
|
||||
agg::rendering_buffer CClipMask::GetRenderingBuffer()
|
||||
{
|
||||
return m_alpha_rbuf;
|
||||
}
|
||||
BYTE* CClipMask::GetMask()
|
||||
{
|
||||
return m_pMask;
|
||||
}
|
||||
bool CClipMask::IsClip()
|
||||
{
|
||||
return m_bIsClip;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CClip::CClip() : m_pixf(m_alpha_rbuf)
|
||||
{
|
||||
m_pMask = NULL;
|
||||
m_bIsClip = false;
|
||||
|
||||
m_lWidth = 0;
|
||||
m_lHeight = 0;
|
||||
}
|
||||
|
||||
CClip::~CClip()
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
|
||||
void CClip::Destroy()
|
||||
{
|
||||
if (NULL != m_pMask)
|
||||
delete [] m_pMask;
|
||||
}
|
||||
|
||||
void CClip::Reset()
|
||||
{
|
||||
m_bIsClip = false;
|
||||
}
|
||||
|
||||
void CClip::Create(LONG width, LONG height)
|
||||
{
|
||||
}
|
||||
|
||||
void CClip::ResetClip()
|
||||
{
|
||||
}
|
||||
|
||||
void CClip::GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix)
|
||||
{
|
||||
if (NULL == pPath)
|
||||
return;
|
||||
|
||||
m_rasterizer.reset();
|
||||
|
||||
typedef agg::conv_transform<agg::path_storage> trans_type;
|
||||
trans_type trans(pPath->m_internal->m_agg_ps, pMatrix->m_internal->m_agg_mtx);
|
||||
|
||||
typedef agg::conv_curve<trans_type> conv_crv_type;
|
||||
conv_crv_type c_c_path(trans);
|
||||
|
||||
m_rasterizer.add_path(c_c_path);
|
||||
|
||||
m_bIsClip = true;
|
||||
}
|
||||
|
||||
agg::rendering_buffer CClip::GetRenderingBuffer()
|
||||
{
|
||||
return m_alpha_rbuf;
|
||||
}
|
||||
BYTE* CClip::GetMask()
|
||||
{
|
||||
return m_pMask;
|
||||
}
|
||||
bool CClip::IsClip()
|
||||
{
|
||||
return m_bIsClip;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CClipMulti::CClipMulti()
|
||||
{
|
||||
m_bIsClip = false;
|
||||
m_bIsClip2 = false;
|
||||
}
|
||||
|
||||
CClipMulti::~CClipMulti()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CClipMulti::GetRasterizer
|
||||
*
|
||||
* @return Ponter to new rasterizer if there was no
|
||||
* clip yet, otherwise - nullptr
|
||||
*/
|
||||
CClipMulti::clip_rasterizer* CClipMulti::GetRasterizer()
|
||||
{
|
||||
if (!m_bIsClip)
|
||||
@ -198,7 +56,8 @@ namespace Aggplus
|
||||
m_rasterizer.reset();
|
||||
return &m_rasterizer;
|
||||
}
|
||||
return NULL;
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CClipMulti::Create(LONG width, LONG height)
|
||||
@ -210,9 +69,16 @@ namespace Aggplus
|
||||
m_bIsClip2 = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CClipMulti::GenerateClip
|
||||
* @param pPath - vector graphics path for clip
|
||||
* @param pMatrix - transform matrix
|
||||
*
|
||||
* Create new rasterizer from path with transform maatrix and start clip.
|
||||
*/
|
||||
void CClipMulti::GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix)
|
||||
{
|
||||
if (NULL == pPath)
|
||||
if (pPath == nullptr)
|
||||
return;
|
||||
|
||||
m_rasterizer.reset();
|
||||
@ -228,6 +94,12 @@ namespace Aggplus
|
||||
GenerateClip2(pPath->m_internal->m_bEvenOdd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CClipMulti::GenerateClip2
|
||||
* @param bEvenOdd - fill mode
|
||||
*
|
||||
* Set fill mode and start clip 1.
|
||||
*/
|
||||
void CClipMulti::GenerateClip2(bool bEvenOdd)
|
||||
{
|
||||
m_rasterizer.filling_rule(bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
@ -236,6 +108,16 @@ namespace Aggplus
|
||||
m_bIsClip2 = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CClipMulti::Combine
|
||||
* @param bEvenOdd - fill mode
|
||||
* @param op - boolean operation
|
||||
* @param pRasterizer - another rasterizer for clip
|
||||
*
|
||||
* Performs the boolean operation. If there is no clip - create it.
|
||||
* If the first paart of the clip, execute it in storage. Perform
|
||||
* the second clip with storage.
|
||||
*/
|
||||
void CClipMulti::Combine(bool bEvenOdd, agg::sbool_op_e op, clip_rasterizer* pRasterizer)
|
||||
{
|
||||
if (!pRasterizer)
|
||||
@ -246,10 +128,9 @@ namespace Aggplus
|
||||
|
||||
if (!m_bIsClip2)
|
||||
{
|
||||
// смешивать надо с растерайзером
|
||||
pRasterizer->filling_rule(bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
|
||||
scanline_type sl1;
|
||||
scanline_type sl1;
|
||||
scanline_type sl2;
|
||||
scanline_type sl;
|
||||
|
||||
@ -259,36 +140,29 @@ namespace Aggplus
|
||||
}
|
||||
else
|
||||
{
|
||||
// надо смешивать со стораджем
|
||||
|
||||
pRasterizer->filling_rule(op ? agg::fill_even_odd : agg::fill_non_zero);
|
||||
|
||||
scanline_type sl1;
|
||||
scanline_type sl1;
|
||||
scanline_type sl2;
|
||||
scanline_type sl;
|
||||
scanline_type sl;
|
||||
|
||||
agg::sbool_combine_shapes_aa(op, *pRasterizer, (m_lCurStorage == 1) ? m_storage1 : m_storage2, sl1, sl2, sl,
|
||||
(m_lCurStorage == 1) ? m_storage2 : m_storage1);
|
||||
(m_lCurStorage == 1) ? m_storage2 : m_storage1);
|
||||
|
||||
if (1 == m_lCurStorage)
|
||||
{
|
||||
//m_storage1.prepare();
|
||||
m_lCurStorage = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_storage2.prepare();
|
||||
m_lCurStorage = 1;
|
||||
}
|
||||
}
|
||||
m_bIsClip2 = true;
|
||||
}
|
||||
|
||||
bool CClipMulti::IsClip()
|
||||
bool CClipMulti::IsClip() const
|
||||
{
|
||||
return m_bIsClip;
|
||||
}
|
||||
bool CClipMulti::IsClip2()
|
||||
|
||||
bool CClipMulti::IsClip2() const
|
||||
{
|
||||
return m_bIsClip2;
|
||||
}
|
||||
@ -296,10 +170,6 @@ namespace Aggplus
|
||||
void CClipMulti::Reset()
|
||||
{
|
||||
m_rasterizer.reset();
|
||||
|
||||
//m_storage1.prepare();
|
||||
//m_storage2.prepare();
|
||||
|
||||
m_bIsClip = false;
|
||||
m_bIsClip2 = false;
|
||||
}
|
||||
|
||||
@ -54,96 +54,28 @@
|
||||
namespace Aggplus
|
||||
{
|
||||
|
||||
class CClipMask
|
||||
{
|
||||
typedef agg::renderer_base<agg::pixfmt_gray8> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
|
||||
friend class CGraphicsPath;
|
||||
public:
|
||||
BYTE* m_pMask;
|
||||
LONG m_lWidth;
|
||||
LONG m_lHeight;
|
||||
|
||||
agg::rendering_buffer m_alpha_rbuf;
|
||||
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> m_rasterizer;
|
||||
|
||||
agg::pixfmt_gray8 m_pixf;
|
||||
ren_base m_base_renderer;
|
||||
renderer m_renderer;
|
||||
|
||||
agg::scanline_p8 m_sl;
|
||||
|
||||
bool m_bIsClip;
|
||||
|
||||
public:
|
||||
CClipMask();
|
||||
~CClipMask();
|
||||
|
||||
void Destroy();
|
||||
void Reset();
|
||||
|
||||
public:
|
||||
void Create(LONG width, LONG height);
|
||||
void ResetClip();
|
||||
|
||||
void GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix);
|
||||
|
||||
agg::rendering_buffer GetRenderingBuffer();
|
||||
BYTE* GetMask();
|
||||
bool IsClip();
|
||||
};
|
||||
|
||||
class CClip
|
||||
{
|
||||
typedef agg::renderer_base<agg::pixfmt_gray8> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
|
||||
friend class CGraphicsPath;
|
||||
public:
|
||||
BYTE* m_pMask;
|
||||
LONG m_lWidth;
|
||||
LONG m_lHeight;
|
||||
|
||||
agg::rendering_buffer m_alpha_rbuf;
|
||||
|
||||
agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> m_rasterizer;
|
||||
|
||||
agg::pixfmt_gray8 m_pixf;
|
||||
ren_base m_base_renderer;
|
||||
renderer m_renderer;
|
||||
|
||||
agg::scanline_p8 m_sl;
|
||||
|
||||
bool m_bIsClip;
|
||||
|
||||
public:
|
||||
CClip();
|
||||
~CClip();
|
||||
|
||||
void Destroy();
|
||||
void Reset();
|
||||
|
||||
public:
|
||||
void Create(LONG width, LONG height);
|
||||
void ResetClip();
|
||||
|
||||
void GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix);
|
||||
|
||||
agg::rendering_buffer GetRenderingBuffer();
|
||||
BYTE* GetMask();
|
||||
bool IsClip();
|
||||
};
|
||||
|
||||
/**
|
||||
* @class CClipMulti
|
||||
* @brief Class providing boolean logic
|
||||
* for a raster graphics clip.
|
||||
*
|
||||
* Boolean algebra for rasterizer scanlines, which are
|
||||
* received from CGraphicsPath.
|
||||
*/
|
||||
class CClipMulti
|
||||
{
|
||||
public:
|
||||
typedef agg::scanline_p8 scanline_type;
|
||||
typedef agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> clip_rasterizer;
|
||||
typedef agg::rasterizer_scanline_aa<agg::rasterizer_sl_clip_dbl> clip_rasterizer;
|
||||
|
||||
clip_rasterizer m_rasterizer;
|
||||
|
||||
/**
|
||||
* @brief Interfaces for implementation graphics renderer scanlines.
|
||||
*
|
||||
* Scan lines can be stored in rasterizer as in case clip1
|
||||
* or in storage otherwise(clip2).
|
||||
*/
|
||||
agg::scanline_storage_aa8 m_storage1;
|
||||
agg::scanline_storage_aa8 m_storage2;
|
||||
|
||||
@ -167,8 +99,8 @@ public:
|
||||
|
||||
void Combine(bool bEvenOdd, agg::sbool_op_e op, clip_rasterizer* pRasterizer);
|
||||
|
||||
bool IsClip();
|
||||
bool IsClip2();
|
||||
bool IsClip() const;
|
||||
bool IsClip2() const;
|
||||
|
||||
void Reset();
|
||||
};
|
||||
|
||||
@ -57,7 +57,6 @@ namespace Aggplus
|
||||
*this = paths[0];
|
||||
else
|
||||
{
|
||||
StartFigure();
|
||||
for (const auto& p : paths)
|
||||
{
|
||||
unsigned length = p.GetPointCount();
|
||||
@ -76,6 +75,7 @@ namespace Aggplus
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
//AddPath(p);
|
||||
if (p.Is_poly_closed()) CloseFigure();
|
||||
}
|
||||
}
|
||||
@ -139,11 +139,13 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::LineTo(double x, double y)
|
||||
{
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
m_internal->m_agg_ps.curve4(x1, y1, x2, y2, x3, y3);
|
||||
@ -152,17 +154,17 @@ namespace Aggplus
|
||||
|
||||
Status CGraphicsPath::AddLine(double x1, double y1, double x2, double y2)
|
||||
{
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x1, y1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_ps.line_to(x1, y1);
|
||||
}
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x1, y1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_internal->m_agg_ps.line_to(x1, y1);
|
||||
}
|
||||
|
||||
m_internal->m_agg_ps.line_to(x2, y2);
|
||||
return Ok;
|
||||
m_internal->m_agg_ps.line_to(x2, y2);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddLines(double* pPoints, int nCount)
|
||||
@ -171,22 +173,12 @@ namespace Aggplus
|
||||
{
|
||||
return InvalidParameter;
|
||||
}
|
||||
int nRet = 0;
|
||||
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
MoveTo(pPoints[0], pPoints[1]);
|
||||
}
|
||||
|
||||
/*if (Is_poly_closed())
|
||||
{
|
||||
m_agg_ps.move_to((double)pPoints[0], (double)pPoints[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_agg_ps.line_to((double)pPoints[0], (double)pPoints[1]);
|
||||
}*/
|
||||
|
||||
int n = (nCount / 2) - 1;
|
||||
|
||||
for (int i = 1; i <= n; ++i)
|
||||
@ -194,6 +186,7 @@ namespace Aggplus
|
||||
const double* points = &pPoints[i * 2];
|
||||
m_internal->m_agg_ps.line_to(points[0], points[1]);
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
@ -207,6 +200,7 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.curve4(x2, y2, x3, y3, x4, y4);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddBeziers(double* pPoints, int nCount)
|
||||
{
|
||||
if (8 > nCount)
|
||||
@ -256,22 +250,24 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.join_path(arc, 0);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddRectangle(double x, double y, double width, double height)
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddPolygon(double* pPoints, int nCount)
|
||||
{
|
||||
if (2 > nCount)
|
||||
{
|
||||
return InvalidParameter;
|
||||
}
|
||||
int nRet = 0;
|
||||
|
||||
if (Is_poly_closed())
|
||||
{
|
||||
@ -293,6 +289,7 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddPath(const CGraphicsPath& oPath)
|
||||
{
|
||||
typedef agg::conv_curve<agg::path_storage> conv_crv_type;
|
||||
@ -303,6 +300,7 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.join_path(p3, 0);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle)
|
||||
{
|
||||
if(sweepAngle >= 360.0)
|
||||
@ -470,6 +468,7 @@ namespace Aggplus
|
||||
}
|
||||
return (Ok == MoveTo(x, y));
|
||||
}
|
||||
|
||||
bool CGraphicsPath::_LineTo(double x, double y)
|
||||
{
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
@ -478,6 +477,7 @@ namespace Aggplus
|
||||
}
|
||||
return (Ok == LineTo(x, y));
|
||||
}
|
||||
|
||||
bool CGraphicsPath::_CurveTo(double x1, double y1, double x2, double y2, double x3, double y3)
|
||||
{
|
||||
if (NULL != m_internal->m_pTransform)
|
||||
@ -488,6 +488,7 @@ namespace Aggplus
|
||||
}
|
||||
return (Ok == CurveTo(x1, y1, x2, y2, x3, y3));
|
||||
}
|
||||
|
||||
bool CGraphicsPath::_Close()
|
||||
{
|
||||
return (Ok == CloseFigure());
|
||||
@ -502,6 +503,7 @@ namespace Aggplus
|
||||
pFont->LoadString1(strText, (float)x, (float)y);
|
||||
return (TRUE == pFont->GetStringPath(this)) ? Ok : InvalidParameter;
|
||||
}
|
||||
|
||||
Status CGraphicsPath::AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y)
|
||||
{
|
||||
if (NULL == pFont)
|
||||
@ -580,40 +582,40 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps = psNew;
|
||||
}
|
||||
|
||||
int CGraphicsPath::EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection)
|
||||
int CGraphicsPath::EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, bool bClockDirection)
|
||||
{
|
||||
int nRet = 0;
|
||||
|
||||
while ( fAngle1 < 0 )
|
||||
while (fAngle1 < 0)
|
||||
fAngle1 += 360;
|
||||
|
||||
while ( fAngle1 > 360 )
|
||||
while (fAngle1 > 360)
|
||||
fAngle1 -= 360;
|
||||
|
||||
while ( fAngle2 < 0 )
|
||||
while (fAngle2 < 0)
|
||||
fAngle2 += 360;
|
||||
|
||||
while ( fAngle2 >= 360 )
|
||||
while (fAngle2 >= 360)
|
||||
fAngle2 -= 360;
|
||||
|
||||
if ( !bClockDirection )
|
||||
if (!bClockDirection)
|
||||
{
|
||||
if ( fAngle1 <= fAngle2 )
|
||||
nRet = EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, fAngle2, FALSE );
|
||||
if (fAngle1 <= fAngle2)
|
||||
nRet = EllipseArc2(fX, fY, fXRad, fYRad, fAngle1, fAngle2, false);
|
||||
else
|
||||
{
|
||||
nRet += EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, 360, FALSE );
|
||||
nRet += EllipseArc2( fX, fY, fXRad, fYRad, 0, fAngle2, FALSE );
|
||||
nRet += EllipseArc2(fX, fY, fXRad, fYRad, fAngle1, 360, false);
|
||||
nRet += EllipseArc2(fX, fY, fXRad, fYRad, 0, fAngle2, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( fAngle1 >= fAngle2 )
|
||||
nRet = EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, fAngle2, TRUE );
|
||||
if (fAngle1 >= fAngle2)
|
||||
nRet = EllipseArc2(fX, fY, fXRad, fYRad, fAngle1, fAngle2, true);
|
||||
else
|
||||
{
|
||||
nRet += EllipseArc2( fX, fY, fXRad, fYRad, fAngle1, 0, TRUE );
|
||||
nRet += EllipseArc2( fX, fY, fXRad, fYRad, 360, fAngle2, TRUE );
|
||||
nRet += EllipseArc2(fX, fY, fXRad, fYRad, fAngle1, 0, true);
|
||||
nRet += EllipseArc2(fX, fY, fXRad, fYRad, 360, fAngle2, true);
|
||||
}
|
||||
}
|
||||
return nRet;
|
||||
@ -624,10 +626,10 @@ namespace Aggplus
|
||||
// Функция для перевода реального угла в параметрическое задание эллписа
|
||||
// т.е. x= a cos(t) y = b sin(t) - параметрическое задание эллписа.
|
||||
// x = r cos(p), y = r sin(p) => t = atan2( sin(p) / b, cos(p) / a );
|
||||
return atan2( sin( fAngle ) / fYRad, cos( fAngle ) / fXRad );
|
||||
return atan2(sin(fAngle) / fYRad, cos(fAngle) / fXRad);
|
||||
}
|
||||
|
||||
int CGraphicsPath::EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection)
|
||||
int CGraphicsPath::EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, bool bClockDirection)
|
||||
{
|
||||
// переведем углы в радианы
|
||||
int nRet = 0;
|
||||
@ -638,79 +640,75 @@ namespace Aggplus
|
||||
// Выясним в каких четвертях находятся начальная и конечная точки
|
||||
unsigned int nFirstPointQuard = int(fAngle1) / 90 + 1;
|
||||
unsigned int nSecondPointQuard = int(fAngle2) / 90 + 1;
|
||||
nSecondPointQuard = std::min( 4, std::max( 1, (int)nSecondPointQuard ) );
|
||||
nFirstPointQuard = std::min( 4, std::max( 1, (int)nFirstPointQuard ) );
|
||||
nSecondPointQuard = std::min(4, std::max(1, (int)nSecondPointQuard));
|
||||
nFirstPointQuard = std::min(4, std::max(1, (int)nFirstPointQuard));
|
||||
// Проведем линию в начальную точку дуги
|
||||
double fStartX = 0.0, fStartY = 0.0, fEndX = 0.0, fEndY = 0.0;
|
||||
|
||||
fStartX = fX + fXRad * cos( AngToEllPrm( dAngle1, fXRad, fYRad ) );
|
||||
fStartY = fY + fYRad * sin( AngToEllPrm( dAngle1, fXRad, fYRad ) );
|
||||
fStartX = fX + fXRad * cos(AngToEllPrm(dAngle1, fXRad, fYRad));
|
||||
fStartY = fY + fYRad * sin(AngToEllPrm(dAngle1, fXRad, fYRad));
|
||||
|
||||
LineTo(fStartX, fStartY);
|
||||
|
||||
// Дальше рисуем по четверям
|
||||
|
||||
double fCurX = fStartX, fCurY = fStartY;
|
||||
double dStartAngle = dAngle1;
|
||||
double dEndAngle = 0;
|
||||
|
||||
if ( !bClockDirection )
|
||||
if (!bClockDirection)
|
||||
{
|
||||
for( unsigned int nIndex = nFirstPointQuard; nIndex <= nSecondPointQuard; nIndex++ )
|
||||
for(unsigned int nIndex = nFirstPointQuard; nIndex <= nSecondPointQuard; nIndex++)
|
||||
{
|
||||
if ( nIndex == nSecondPointQuard )
|
||||
if (nIndex == nSecondPointQuard)
|
||||
dEndAngle = dAngle2;
|
||||
else
|
||||
dEndAngle = (90 * (nIndex ) ) * 3.141592f / 180;
|
||||
if ( !( nIndex == nFirstPointQuard ) )
|
||||
dStartAngle = (90 * (nIndex - 1 ) ) * 3.141592f / 180;
|
||||
dEndAngle = (90 * nIndex) * 3.141592f / 180;
|
||||
if (!( nIndex == nFirstPointQuard))
|
||||
dStartAngle = (90 * (nIndex - 1)) * 3.141592f / 180;
|
||||
|
||||
EllipseArc3(fX, fY, fXRad, fYRad, AngToEllPrm( dStartAngle, fXRad, fYRad ), AngToEllPrm( dEndAngle, fXRad, fYRad ), &fEndX, &fEndY, FALSE);
|
||||
EllipseArc3(fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), &fEndX, &fEndY, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( unsigned int nIndex = nFirstPointQuard; nIndex >= nSecondPointQuard; nIndex-- )
|
||||
for(unsigned int nIndex = nFirstPointQuard; nIndex >= nSecondPointQuard; nIndex--)
|
||||
{
|
||||
if ( nIndex == nFirstPointQuard )
|
||||
if (nIndex == nFirstPointQuard)
|
||||
dStartAngle = dAngle1;
|
||||
else
|
||||
dStartAngle = (90 * (nIndex ) ) * 3.141592f / 180;
|
||||
if ( !( nIndex == nSecondPointQuard ) )
|
||||
dEndAngle = (90 * (nIndex - 1 ) ) * 3.141592f / 180;
|
||||
dStartAngle = (90 * nIndex) * 3.141592f / 180;
|
||||
if (!( nIndex == nSecondPointQuard))
|
||||
dEndAngle = (90 * (nIndex - 1)) * 3.141592f / 180;
|
||||
else
|
||||
dEndAngle = dAngle2;
|
||||
|
||||
EllipseArc3(fX, fY, fXRad, fYRad, AngToEllPrm( dStartAngle, fXRad, fYRad ), AngToEllPrm( dEndAngle, fXRad, fYRad ), &fEndX, &fEndY, FALSE);
|
||||
EllipseArc3(fX, fY, fXRad, fYRad, AngToEllPrm(dStartAngle, fXRad, fYRad), AngToEllPrm(dEndAngle, fXRad, fYRad), &fEndX, &fEndY, false);
|
||||
}
|
||||
}
|
||||
|
||||
return nRet;
|
||||
}
|
||||
|
||||
int CGraphicsPath::EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, INT bClockDirection)
|
||||
int CGraphicsPath::EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double *pfXCur, double *pfYCur, bool bClockDirection)
|
||||
{
|
||||
// Рассчитаем начальную, конечную и контрольные точки
|
||||
double fX1 = 0.0, fX2 = 0.0, fY1 = 0.0, fY2 = 0.0;
|
||||
double fCX1 = 0.0, fCX2 = 0.0, fCY1 = 0.0, fCY2 = 0.0;
|
||||
|
||||
double fAlpha = sin( dAngle2 - dAngle1 ) * ( sqrt( 4.0 + 3.0 * tan( (dAngle2 - dAngle1) / 2.0 ) * tan( (dAngle2 - dAngle1) / 2.0 ) ) - 1.0 ) / 3.0;
|
||||
double fAlpha = sin(dAngle2 - dAngle1) * (sqrt( 4.0 + 3.0 * tan((dAngle2 - dAngle1) / 2.0) * tan((dAngle2 - dAngle1) / 2.0 )) - 1.0 ) / 3.0;
|
||||
|
||||
double fKoef = 1;
|
||||
fX1 = fX + fXRad * cos(dAngle1);
|
||||
fY1 = fY + fYRad * sin(dAngle1);
|
||||
|
||||
fX1 = fX + fXRad * cos( dAngle1 );
|
||||
fY1 = fY + fYRad * sin( dAngle1 );
|
||||
fX2 = fX + fXRad * cos(dAngle2);
|
||||
fY2 = fY + fYRad * sin(dAngle2);
|
||||
|
||||
fX2 = fX + fXRad * cos( dAngle2 );
|
||||
fY2 = fY + fYRad * sin( dAngle2 );
|
||||
fCX1 = fX1 - fAlpha * fXRad * sin (dAngle1);
|
||||
fCY1 = fY1 + fAlpha * fYRad * cos (dAngle1);
|
||||
|
||||
fCX1 = fX1 - fAlpha * fXRad * sin ( dAngle1 );
|
||||
fCY1 = fY1 + fAlpha * fYRad * cos ( dAngle1 );
|
||||
fCX2 = fX2 + fAlpha * fXRad * sin (dAngle2);
|
||||
fCY2 = fY2 - fAlpha * fYRad * cos (dAngle2);
|
||||
|
||||
fCX2 = fX2 + fAlpha * fXRad * sin ( dAngle2 );
|
||||
fCY2 = fY2 - fAlpha * fYRad * cos ( dAngle2 );
|
||||
|
||||
if ( !bClockDirection )
|
||||
if (!bClockDirection)
|
||||
{
|
||||
CurveTo(fCX1, fCY1, fCX2, fCY2, fX2, fY2);
|
||||
|
||||
@ -863,23 +861,21 @@ namespace Aggplus
|
||||
|
||||
double CGraphicsPath::GetArea(unsigned idx, bool isCurve) const noexcept
|
||||
{
|
||||
double area;
|
||||
float area;
|
||||
if (isCurve)
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 4);
|
||||
area = (points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y + points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3.0)
|
||||
- points[3].X * (points[2].Y + points[0].Y / 3.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = 4.0 * (points[1].Y * points[0].X - points[1].X * points[0].Y) / 3.0;
|
||||
area = 3 * ((points[3].Y - points[0].Y) * (points[1].X + points[2].X)
|
||||
- (points[3].X - points[0].X) * (points[1].Y * points[2].Y)
|
||||
+ points[1].Y * (points[0].X - points[2].X)
|
||||
- points[1].X * (points[0].Y - points[2].Y)
|
||||
+ points[3].Y * (points[2].X + points[0].X / 3)
|
||||
- points[3].X * (points[2].Y - points[0].Y / 3)) / 20;
|
||||
}
|
||||
|
||||
std::vector<PointD> points = GetPoints(idx, 2);
|
||||
area = (points[1].Y * points[0].X - points[1].X * points[0].Y) / 20;
|
||||
|
||||
return area;
|
||||
}
|
||||
|
||||
@ -1045,8 +1041,6 @@ namespace Aggplus
|
||||
return false;
|
||||
}
|
||||
|
||||
int nRet = 0;
|
||||
|
||||
if (!m_internal->m_bIsMoveTo)
|
||||
{
|
||||
_MoveTo(pData[0], pData[1]);
|
||||
@ -1375,8 +1369,6 @@ namespace Aggplus
|
||||
_LineTo(fStartX, fStartY);
|
||||
|
||||
// Дальше рисуем по четверям
|
||||
|
||||
double fCurX = fStartX, fCurY = fStartY;
|
||||
double dStartAngle = dAngle1;
|
||||
double dEndAngle = 0;
|
||||
|
||||
@ -1422,8 +1414,6 @@ namespace Aggplus
|
||||
|
||||
double fAlpha = sin( dAngle2 - dAngle1 ) * ( sqrt( 4.0 + 3.0 * tan( (dAngle2 - dAngle1) / 2.0 ) * tan( (dAngle2 - dAngle1) / 2.0 ) ) - 1.0 ) / 3.0;
|
||||
|
||||
double fKoef = 1;
|
||||
|
||||
fX1 = fX + fXRad * cos( dAngle1 );
|
||||
fY1 = fY + fYRad * sin( dAngle1 );
|
||||
|
||||
|
||||
@ -42,6 +42,11 @@
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
/**
|
||||
* @class CGraphicsPath
|
||||
*
|
||||
* A container class that implements the logic of graphic paths.
|
||||
*/
|
||||
class CGraphicsPath_private;
|
||||
class GRAPHICS_DECL CGraphicsPath : public NSFonts::ISimpleGraphicsPath
|
||||
{
|
||||
@ -57,6 +62,9 @@ namespace Aggplus
|
||||
Status Reset();
|
||||
void SetRuler(bool bEvenOdd);
|
||||
|
||||
/**
|
||||
* @brief Methods implementing basic path commands.
|
||||
*/
|
||||
Status StartFigure();
|
||||
Status CloseFigure();
|
||||
bool Is_poly_closed() const;
|
||||
@ -64,7 +72,10 @@ namespace Aggplus
|
||||
Status LineTo(double x, double y);
|
||||
Status CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
|
||||
// методы, которые просто будем сводить к трем основным
|
||||
/**
|
||||
* @brief Methods implementing additional commands for
|
||||
* more convenient creation of path.
|
||||
*/
|
||||
Status AddLine(double x1, double y1, double x2, double y2);
|
||||
Status AddLines(double* pPoints, int nCount);
|
||||
Status AddBezier(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4);
|
||||
@ -76,6 +87,9 @@ namespace Aggplus
|
||||
Status AddPath(const CGraphicsPath& oPath);
|
||||
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
|
||||
|
||||
/**
|
||||
* @brief Getter methods.
|
||||
*/
|
||||
ULONG GetPointCount() const;
|
||||
Status GetPathPoints(PointF* points, int count) const;
|
||||
Status GetLastPoint(double& x, double& y);
|
||||
@ -83,27 +97,41 @@ namespace Aggplus
|
||||
void GetBounds(double& left, double& top, double& width, double& height) const;
|
||||
void GetBoundsAccurate(double& left, double& top, double& width, double& height) const;
|
||||
|
||||
/**
|
||||
* @brief Methods implementing baasic path commands using
|
||||
* a transformation matrix to points.
|
||||
*/
|
||||
Status Transform(const CMatrix* matrix);
|
||||
virtual bool _MoveTo(double x, double y);
|
||||
virtual bool _LineTo(double x, double y);
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3);
|
||||
virtual bool _Close();
|
||||
|
||||
/**
|
||||
* @brief Methods for adding paths for text in Font manager.
|
||||
*/
|
||||
Status AddString(const std::wstring& strText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
Status AddString(const unsigned int* pGids, const unsigned int nGidsCount, NSFonts::IFontManager* pFont, double x, double y);
|
||||
Status AddStringC(const LONG& lText, NSFonts::IFontManager* pFont, double x, double y);
|
||||
void z_Stroke(const double& size);
|
||||
void Widen(const double& size, const Aggplus::LineJoin& join, const CMatrix* matrix, float flatness);
|
||||
|
||||
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
/**
|
||||
* @brief Methods implementing commands for creating arcs
|
||||
* (simple versions of Bezier curves).
|
||||
*/
|
||||
int EllipseArc(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, bool bClockDirection);
|
||||
double AngToEllPrm(double fAngle, double fXRad, double fYRad);
|
||||
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, INT bClockDirection);
|
||||
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double* pfXCur, double* pfYCur, INT bClockDirection = FALSE);
|
||||
int EllipseArc2(double fX, double fY, double fXRad, double fYRad, double fAngle1, double fAngle2, bool bClockDirection);
|
||||
int EllipseArc3(double fX, double fY, double fXRad, double fYRad, double dAngle1, double dAngle2, double* pfXCur, double* pfYCur, bool bClockDirection = false);
|
||||
int Ellipse(double fX, double fY, double fXRad, double fYRad);
|
||||
Status AddArc2(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
|
||||
bool IsPointInPath(const double& x, const double& y);
|
||||
|
||||
// Methods for Path Clip
|
||||
/**
|
||||
* @brief Methods that are used when performing Boolean operations
|
||||
* on paths.
|
||||
*/
|
||||
unsigned GetCloseCount() const noexcept;
|
||||
unsigned GetMoveCount() const noexcept;
|
||||
bool IsClockwise() const noexcept;
|
||||
|
||||
@ -214,7 +214,6 @@ int CAnnotFieldInfo::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||
int CAnnotFieldInfo::GetCopyAP() const { return m_nCopyAP; }
|
||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
{
|
||||
@ -224,7 +223,6 @@ 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::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
|
||||
const std::vector<double>& CAnnotFieldInfo::GetC() { return m_arrC; }
|
||||
|
||||
@ -361,10 +359,6 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
m_wsOUserID = pReader->ReadString();
|
||||
if (nFlags & (1 << 8))
|
||||
m_nCopyAP = pReader->ReadInt();
|
||||
if (nFlags & (1 << 9))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -683,7 +677,6 @@ int CAnnotFieldInfo::CWidgetAnnotPr::GetR() const { return m_nR; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFlags() const { return m_nFlags; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetMEOptions() const { return m_nMEOptions; }
|
||||
int CAnnotFieldInfo::CWidgetAnnotPr::GetFontStyle() const { return m_nFontStyle; }
|
||||
double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSize() const { return m_dFS; }
|
||||
double CAnnotFieldInfo::CWidgetAnnotPr::GetFontSizeAP() const { return m_dFSAP; }
|
||||
@ -693,6 +686,7 @@ const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetDV() { return m_wsDV; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetT() { return m_wsT; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontName() { return m_wsFN; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetFontKey() { return m_wsFK; }
|
||||
const std::wstring& CAnnotFieldInfo::CWidgetAnnotPr::GetOMetadata() { return m_wsOMetadata; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetTC() { return m_arrTC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBC() { return m_arrBC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CWidgetAnnotPr::GetBG() { return m_arrBG; }
|
||||
@ -893,8 +887,8 @@ void CAnnotFieldInfo::CWidgetAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
m_nParentID = pReader->ReadInt();
|
||||
if (nFlags & (1 << 18))
|
||||
m_wsT = pReader->ReadString();
|
||||
if (nFlags & (1 << 21))
|
||||
m_nMEOptions = pReader->ReadInt();
|
||||
if (nFlags & (1 << 20))
|
||||
m_wsOMetadata = pReader->ReadString();
|
||||
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
@ -991,7 +985,7 @@ void CAnnotFieldInfo::CWidgetAnnotPr::CTextWidgetPr::Read(NSOnlineOfficeBinToPdf
|
||||
m_wsV = pReader->ReadString();
|
||||
if (nFlags & (1 << 10))
|
||||
m_nMaxLen = pReader->ReadInt();
|
||||
if (nFlags & (1 << 11))
|
||||
if (nWidgetFlag & (1 << 25))
|
||||
m_wsRV = pReader->ReadString();
|
||||
if (nFlags & (1 << 12))
|
||||
m_wsAPV = pReader->ReadString();
|
||||
@ -1070,21 +1064,15 @@ CWidgetsInfo::~CWidgetsInfo()
|
||||
for (int i = 0; i < m_arrParents.size(); ++i)
|
||||
RELEASEOBJECT(m_arrParents[i]);
|
||||
}
|
||||
const std::vector< std::pair<int, int> >& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector<int>& CWidgetsInfo::GetCO() { return m_arrCO; }
|
||||
const std::vector<std::wstring>& CWidgetsInfo::GetButtonImg() { return m_arrButtonImg; }
|
||||
const std::vector<CWidgetsInfo::CParent*>& CWidgetsInfo::GetParents() { return m_arrParents; }
|
||||
void CWidgetsInfo::ChangeCO(int i, int nNum, int nGen)
|
||||
{
|
||||
if (i < 0 || i > m_arrCO.size() - 1)
|
||||
return;
|
||||
m_arrCO[i] = std::make_pair(nNum, nGen);
|
||||
}
|
||||
bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrCO.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrCO.push_back(std::make_pair(pReader->ReadInt(), -1));
|
||||
m_arrCO.push_back(pReader->ReadInt());
|
||||
|
||||
n = pReader->ReadInt();
|
||||
m_arrParents.reserve(n);
|
||||
@ -1116,40 +1104,6 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < n; ++i)
|
||||
pParent->arrV.push_back(pReader->ReadString());
|
||||
}
|
||||
if (nFlags & (1 << 6))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
pParent->arrOpt.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::wstring s1 = pReader->ReadString();
|
||||
std::wstring s2 = pReader->ReadString();
|
||||
pParent->arrOpt.push_back(std::make_pair(s1, s2));
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 7))
|
||||
pParent->nFieldFlag = pReader->ReadInt();
|
||||
if (nFlags & (1 << 8))
|
||||
{
|
||||
// Action
|
||||
int nAction = pReader->ReadInt();
|
||||
for (int i = 0; i < nAction; ++i)
|
||||
{
|
||||
std::wstring wsType = pReader->ReadString();
|
||||
CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget* pA = ReadAction(pReader);
|
||||
if (pA)
|
||||
{
|
||||
pA->wsType = wsType;
|
||||
pParent->arrAction.push_back(pA);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 9))
|
||||
pParent->nMaxLen = pReader->ReadInt();
|
||||
if (nFlags & (1 << 10))
|
||||
pParent->sTU = pReader->ReadString();
|
||||
if (nFlags & (1 << 11))
|
||||
pParent->nMEOptions = pReader->ReadInt();
|
||||
m_arrParents.push_back(pParent);
|
||||
}
|
||||
|
||||
@ -1158,10 +1112,7 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
std::string sImagePath = pReader->ReadStringA();
|
||||
std::wstring sImage = UTF8_TO_U(sImagePath);
|
||||
if (sImagePath.find("data:") != 0 && !sImagePath.empty())
|
||||
sImage = pCorrector->GetImagePath(sImage);
|
||||
m_arrButtonImg.push_back(sImage);
|
||||
m_arrButtonImg.push_back(pCorrector->GetImagePath(UTF8_TO_U(sImagePath)));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -185,7 +185,6 @@ public:
|
||||
int GetFlag() const;
|
||||
int GetFlags() const;
|
||||
int GetParentID() const;
|
||||
int GetMEOptions() const;
|
||||
int GetFontStyle() const;
|
||||
double GetFontSize() const;
|
||||
double GetFontSizeAP() const;
|
||||
@ -195,6 +194,7 @@ public:
|
||||
const std::wstring& GetT();
|
||||
const std::wstring& GetFontName();
|
||||
const std::wstring& GetFontKey();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::vector<double>& GetTC();
|
||||
const std::vector<double>& GetBC();
|
||||
const std::vector<double>& GetBG();
|
||||
@ -215,7 +215,6 @@ public:
|
||||
int m_nFlag;
|
||||
int m_nFlags;
|
||||
int m_nParentID;
|
||||
int m_nMEOptions;
|
||||
int m_nFontStyle;
|
||||
double m_dFS;
|
||||
double m_dFSAP;
|
||||
@ -225,6 +224,7 @@ public:
|
||||
std::wstring m_wsT;
|
||||
std::wstring m_wsFN;
|
||||
std::wstring m_wsFK;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::vector<double> m_arrTC;
|
||||
std::vector<double> m_arrBC;
|
||||
std::vector<double> m_arrBG;
|
||||
@ -465,13 +465,11 @@ public:
|
||||
int GetID() const;
|
||||
int GetAnnotFlag() const;
|
||||
int GetPage() const;
|
||||
int GetCopyAP() const;
|
||||
void GetBE(BYTE& nS, double& dI);
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
const std::wstring& GetLM();
|
||||
const std::wstring& GetOUserID();
|
||||
const std::wstring& GetOMetadata();
|
||||
const std::wstring& GetContents();
|
||||
const std::vector<double>& GetC();
|
||||
|
||||
@ -524,11 +522,9 @@ private:
|
||||
int m_nID;
|
||||
int m_nAnnotFlag;
|
||||
int m_nPage;
|
||||
int m_nCopyAP;
|
||||
std::wstring m_wsNM;
|
||||
std::wstring m_wsLM;
|
||||
std::wstring m_wsOUserID;
|
||||
std::wstring m_wsOMetadata;
|
||||
std::wstring m_wsContents;
|
||||
std::pair<BYTE, double> m_pBE;
|
||||
std::vector<double> m_arrC;
|
||||
@ -571,33 +567,25 @@ public:
|
||||
{
|
||||
int nID;
|
||||
int nFlags;
|
||||
int nMaxLen;
|
||||
int nParentID;
|
||||
int nMEOptions;
|
||||
int nFieldFlag;
|
||||
std::wstring sName;
|
||||
std::wstring sV;
|
||||
std::wstring sDV;
|
||||
std::wstring sTU;
|
||||
std::vector<int> arrI;
|
||||
std::vector<std::wstring> arrV;
|
||||
std::vector<CAnnotFieldInfo::CWidgetAnnotPr::CActionWidget*> arrAction;
|
||||
std::vector< std::pair<std::wstring, std::wstring> > arrOpt;
|
||||
};
|
||||
|
||||
CWidgetsInfo();
|
||||
virtual ~CWidgetsInfo();
|
||||
|
||||
const std::vector< std::pair<int, int> >& GetCO();
|
||||
const std::vector<int>& GetCO();
|
||||
const std::vector<std::wstring>& GetButtonImg();
|
||||
const std::vector<CParent*>& GetParents();
|
||||
|
||||
void ChangeCO(int i, int nNum, int nGen);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::vector< std::pair<int, int> > m_arrCO;
|
||||
std::vector<int> m_arrCO;
|
||||
std::vector<std::wstring> m_arrButtonImg;
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
@ -18,12 +18,6 @@ SOURCES += \
|
||||
$$FONT_ENGINE_PATH/FontPath.cpp \
|
||||
$$FONT_ENGINE_PATH/GlyphString.cpp
|
||||
|
||||
core_mac {
|
||||
OBJECTIVE_SOURCES += $$FONT_ENGINE_PATH/ApplicationFonts_mac.mm
|
||||
LIBS += -framework Foundation
|
||||
LIBS += -framework CoreText
|
||||
}
|
||||
|
||||
# Application fonts worker
|
||||
HEADERS += $$FONT_ENGINE_PATH/ApplicationFontsWorker.h
|
||||
SOURCES += $$FONT_ENGINE_PATH/ApplicationFontsWorker.cpp
|
||||
@ -44,10 +38,6 @@ enable_support_shaper {
|
||||
}
|
||||
# -------------------------------------------------
|
||||
|
||||
# ------------------- brotli ----------------------
|
||||
include($$PWD/../../../Common/3dParty/brotli/brotli.pri)
|
||||
# -------------------------------------------------
|
||||
|
||||
# ------------------- hyphen ----------------------
|
||||
HEADERS += $$FONT_ENGINE_PATH/languages.h
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import os
|
||||
|
||||
base.configure_common_apps()
|
||||
|
||||
base.cmd_in_dir("./../../../../../core/Common/js", sys.executable, ["make.py", "./../../DesktopEditor/graphics/pro/js/drawingfile.json"])
|
||||
base.cmd_in_dir("./../../../../../core/Common/js", "make.py", ["./../../DesktopEditor/graphics/pro/js/drawingfile.json"])
|
||||
|
||||
src_dir = "./deploy/"
|
||||
dst_dir = "./../../../../../sdkjs/pdf/src/engine/"
|
||||
|
||||
@ -51,9 +51,6 @@
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_ScanPage",
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -70,7 +67,6 @@
|
||||
"../../../../PdfFile/lib/goo", "../../../../PdfFile/lib/fofi", "../../../../PdfFile/lib/splash", "../../../../PdfFile/lib",
|
||||
"../../../raster/Jp2/openjpeg", "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2",
|
||||
"../../../../Common/3dParty/openssl/openssl/include",
|
||||
"../../../../Common/3dParty/openssl/build/linux_64/include",
|
||||
"../../../../DocxRenderer"
|
||||
],
|
||||
"define": [
|
||||
@ -90,7 +86,7 @@
|
||||
"NO_CONSOLE_IO", "USE_EXTERNAL_JPEG2000", "USE_JPIP", "OPJ_STATIC", "FONT_ENGINE_DISABLE_FILESYSTEM",
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
"USE_OPENSSL_HASH",
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM", "CRYPTOPP_DISABLE_ASM", "DISABLE_TYPE_MISMATCH"
|
||||
"DISABLE_FULL_DOCUMENT_CREATION", "DISABLE_FILESYSTEM"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
@ -139,7 +135,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "./wasm/src/",
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "HTMLRendererText.cpp"]
|
||||
"files": ["lib/wasm_jmp.cpp", "drawingfile.cpp", "metafile.cpp", "pdfwriter.cpp", "HTMLRendererText.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "freetype-2.10.4/src/",
|
||||
@ -147,7 +143,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../",
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp", "MetafileToRenderer.cpp", "MetafileToRendererReader.cpp"]
|
||||
"files": ["GraphicsRenderer.cpp", "pro/pro_Graphics.cpp", "pro/pro_Fonts.cpp", "pro/pro_Image.cpp", "Graphics.cpp", "Brush.cpp", "BaseThread.cpp", "GraphicsPath.cpp", "BooleanOperations.cpp", "Image.cpp", "Matrix.cpp", "Clip.cpp", "TemporaryCS.cpp", "AlphaMask.cpp", "GraphicsLayer.cpp", "commands/DocInfo.cpp", "commands/AnnotField.cpp", "commands/FormField.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../fontengine/",
|
||||
@ -159,16 +155,12 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
"files": ["ucnv.c", "ustr_wcs.cpp", "ucnv_err.c", "ucnv_bld.cpp", "ustrtrns.cpp", "ucnv_cb.c", "udata.cpp", "ucnv_io.cpp", "uhash.c", "udatamem.c", "cmemory.c", "ustring.cpp", "umutex.cpp", "putil.cpp", "ustr_cnv.cpp", "ucnvmbcs.cpp", "ucnvlat1.c", "ucnv_u16.c", "ucnv_u8.c", "ucnv_u32.c", "ucnv_u7.c", "ucln_cmn.cpp", "ucnv2022.cpp", "ucnv_lmb.c", "ucnvhz.c", "ucnvscsu.c", "ucnvisci.c", "ucnvbocu.cpp", "ucnv_ct.c", "ucnv_cnv.c", "stringpiece.cpp", "charstr.cpp", "umapfile.c", "ucmndata.c", "ucnv_ext.cpp", "uobject.cpp", "umath.c", "ubidi_props.c", "uchar.c", "uinvchar.c", "usprep.cpp", "unistr.cpp", "uniset_props.cpp", "loadednormalizer2impl.cpp", "filterednormalizer2.cpp", "utrie2.cpp", "normalizer2.cpp", "normalizer2impl.cpp", "utrie.cpp", "ucase.cpp", "uniset.cpp", "ruleiter.cpp", "parsepos.cpp", "util.cpp", "uprops.cpp", "uvector.cpp", "unames.cpp", "propname.cpp", "utrie2_builder.cpp", "unifunct.cpp", "bmpset.cpp", "unisetspan.cpp", "unifilt.cpp", "patternprops.cpp", "utf_impl.c", "ustrcase.cpp", "cstring.c", "bytestrie.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/cryptopp/",
|
||||
"files": ["cryptlib.cpp", "cpu.cpp", "integer.cpp", "3way.cpp", "adler32.cpp", "algebra.cpp", "algparam.cpp", "allocate.cpp", "arc4.cpp", "aria.cpp", "aria_simd.cpp", "ariatab.cpp", "asn.cpp", "authenc.cpp", "base32.cpp", "base64.cpp", "basecode.cpp", "bfinit.cpp", "blake2.cpp", "blake2s_simd.cpp", "blake2b_simd.cpp", "blowfish.cpp", "blumshub.cpp", "camellia.cpp", "cast.cpp", "casts.cpp", "cbcmac.cpp", "ccm.cpp", "chacha.cpp", "chacha_simd.cpp", "chacha_avx.cpp", "chachapoly.cpp", "cham.cpp", "cham_simd.cpp", "channels.cpp", "cmac.cpp", "crc.cpp", "crc_simd.cpp", "darn.cpp", "default.cpp", "des.cpp", "dessp.cpp", "dh.cpp", "dh2.cpp", "dll.cpp", "donna_32.cpp", "donna_64.cpp", "donna_sse.cpp", "dsa.cpp", "eax.cpp", "ec2n.cpp", "ecp.cpp", "eccrypto.cpp", "eprecomp.cpp", "elgamal.cpp", "emsa2.cpp", "eprecomp.cpp", "esign.cpp", "files.cpp", "filters.cpp", "fips140.cpp", "gcm.cpp", "gcm_simd.cpp", "gf256.cpp", "gf2_32.cpp", "gf2n.cpp", "gf2n_simd.cpp", "gfpcrypt.cpp", "gost.cpp", "gzip.cpp", "hc128.cpp", "hc256.cpp", "hex.cpp", "hight.cpp", "hmac.cpp", "hrtimer.cpp", "ida.cpp", "idea.cpp", "iterhash.cpp", "kalyna.cpp", "md5.cpp", "randpool.cpp", "osrng.cpp", "rijndael.cpp", "modes.cpp", "misc.cpp", "rdtables.cpp", "sha.cpp", "mqueue.cpp", "queue.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../OfficeUtils/src/",
|
||||
"files": ["OfficeUtils.cpp", "ZipBuffer.cpp", "ZipUtilsCP.cpp", "zlib_addon.c"]
|
||||
@ -187,23 +179,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/",
|
||||
"files": ["PdfFile.cpp", "PdfReader.cpp", "PdfWriter.cpp", "PdfEditor.cpp", "OnlineOfficeBinToPdf.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcReader/",
|
||||
"files": ["Adaptors.cpp", "GfxClip.cpp", "RendererOutputDev.cpp", "JPXStream2.cpp", "PdfAnnot.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontOTWriter.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/Resources/",
|
||||
"files": ["BaseFonts.cpp", "CMapMemory/cmap_memory.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/lib/",
|
||||
"files": ["fofi/FoFiBase.cc", "fofi/FoFiEncodings.cc", "fofi/FoFiIdentifier.cc", "fofi/FoFiTrueType.cc", "fofi/FoFiType1.cc", "fofi/FoFiType1C.cc", "goo/FixedPoint.cc", "goo/gfile.cc", "goo/GHash.cc", "goo/GList.cc", "goo/gmem.cc", "goo/gmempp.cc", "goo/GString.cc", "goo/parseargs.c", "goo/Trace.cc", "splash/Splash.cc", "splash/SplashBitmap.cc", "splash/SplashClip.cc", "splash/SplashFont.cc", "splash/SplashFontEngine.cc", "splash/SplashFontFile.cc", "splash/SplashFontFileID.cc", "splash/SplashFTFont.cc", "splash/SplashFTFontEngine.cc", "splash/SplashFTFontFile.cc", "splash/SplashPath.cc", "splash/SplashPattern.cc", "splash/SplashScreen.cc", "splash/SplashState.cc", "splash/SplashXPath.cc", "splash/SplashXPathScanner.cc", "xpdf/AcroForm.cc", "xpdf/Annot.cc", "xpdf/Array.cc", "xpdf/BuiltinFont.cc", "xpdf/BuiltinFontTables.cc", "xpdf/Catalog.cc", "xpdf/CharCodeToUnicode.cc", "xpdf/CMap.cc", "xpdf/Decrypt.cc", "xpdf/Dict.cc", "xpdf/DisplayState.cc", "xpdf/Error.cc", "xpdf/FontEncodingTables.cc", "xpdf/Function.cc", "xpdf/Gfx.cc", "xpdf/GfxFont.cc", "xpdf/GfxState.cc", "xpdf/GlobalParams.cc", "xpdf/ImageOutputDev.cc", "xpdf/JArithmeticDecoder.cc", "xpdf/JBIG2Stream.cc", "xpdf/JPXStream.cc", "xpdf/Lexer.cc", "xpdf/Link.cc", "xpdf/NameToCharCode.cc", "xpdf/Object.cc", "xpdf/OptionalContent.cc", "xpdf/Outline.cc", "xpdf/OutputDev.cc", "xpdf/Page.cc", "xpdf/Parser.cc", "xpdf/PDF417Barcode.cc", "xpdf/PDFCore.cc", "xpdf/PDFDoc.cc", "xpdf/PDFDocEncoding.cc", "xpdf/PreScanOutputDev.cc", "xpdf/PSOutputDev.cc", "xpdf/PSTokenizer.cc", "xpdf/SecurityHandler.cc", "xpdf/ShadingImage.cc", "xpdf/SplashOutputDev.cc", "xpdf/Stream.cc", "xpdf/TextOutputDev.cc", "xpdf/TextString.cc", "xpdf/TileCache.cc", "xpdf/TileCompositor.cc", "xpdf/TileMap.cc", "xpdf/UnicodeMap.cc", "xpdf/UnicodeRemapping.cc", "xpdf/UnicodeTypeTable.cc", "xpdf/UTF8.cc", "xpdf/WebFont.cc", "xpdf/XFAScanner.cc", "xpdf/XRef.cc", "xpdf/Zoox.cc"]
|
||||
"files": ["SrcReader/Adaptors.cpp", "SrcReader/GfxClip.cpp", "SrcReader/RendererOutputDev.cpp", "SrcReader/JPXStream2.cpp", "SrcReader/PdfAnnot.cpp", "Resources/BaseFonts.cpp", "Resources/CMapMemory/cmap_memory.cpp", "lib/fofi/FofiBase.cc", "lib/fofi/FofiEncodings.cc", "lib/fofi/FofiIdentifier.cc", "lib/fofi/FofiTrueType.cc", "lib/fofi/FofiType1.cc", "lib/fofi/FofiType1C.cc", "lib/goo/FixedPoint.cc", "lib/goo/gfile.cc", "lib/goo/GHash.cc", "lib/goo/GList.cc", "lib/goo/gmem.cc", "lib/goo/gmempp.cc", "lib/goo/GString.cc", "lib/goo/parseargs.c", "lib/goo/Trace.cc", "lib/splash/Splash.cc", "lib/splash/SplashBitmap.cc", "lib/splash/SplashClip.cc", "lib/splash/SplashFont.cc", "lib/splash/SplashFontEngine.cc", "lib/splash/SplashFontFile.cc", "lib/splash/SplashFontFileID.cc", "lib/splash/SplashFTFont.cc", "lib/splash/SplashFTFontEngine.cc", "lib/splash/SplashFTFontFile.cc", "lib/splash/SplashPath.cc", "lib/splash/SplashPattern.cc", "lib/splash/SplashScreen.cc", "lib/splash/SplashState.cc", "lib/splash/SplashXPath.cc", "lib/splash/SplashXPathScanner.cc", "lib/xpdf/AcroForm.cc", "lib/xpdf/Annot.cc", "lib/xpdf/Array.cc", "lib/xpdf/BuiltinFont.cc", "lib/xpdf/BuiltinFontTables.cc", "lib/xpdf/Catalog.cc", "lib/xpdf/CharCodeToUnicode.cc", "lib/xpdf/CMap.cc", "lib/xpdf/Decrypt.cc", "lib/xpdf/Dict.cc", "lib/xpdf/DisplayState.cc", "lib/xpdf/Error.cc", "lib/xpdf/FontEncodingTables.cc", "lib/xpdf/Function.cc", "lib/xpdf/Gfx.cc", "lib/xpdf/GfxFont.cc", "lib/xpdf/GfxState.cc", "lib/xpdf/GlobalParams.cc", "lib/xpdf/ImageOutputDev.cc", "lib/xpdf/JArithmeticDecoder.cc", "lib/xpdf/JBIG2Stream.cc", "lib/xpdf/JPXStream.cc", "lib/xpdf/Lexer.cc", "lib/xpdf/Link.cc", "lib/xpdf/NameToCharCode.cc", "lib/xpdf/Object.cc", "lib/xpdf/OptionalContent.cc", "lib/xpdf/Outline.cc", "lib/xpdf/OutputDev.cc", "lib/xpdf/Page.cc", "lib/xpdf/Parser.cc", "lib/xpdf/PDF417Barcode.cc", "lib/xpdf/PDFCore.cc", "lib/xpdf/PDFDoc.cc", "lib/xpdf/PDFDocEncoding.cc", "lib/xpdf/PreScanOutputDev.cc", "lib/xpdf/PSOutputDev.cc", "lib/xpdf/PSTokenizer.cc", "lib/xpdf/SecurityHandler.cc", "lib/xpdf/ShadingImage.cc", "lib/xpdf/SplashOutputDev.cc", "lib/xpdf/Stream.cc", "lib/xpdf/TextOutputDev.cc", "lib/xpdf/TextString.cc", "lib/xpdf/TileCache.cc", "lib/xpdf/TileCompositor.cc", "lib/xpdf/TileMap.cc", "lib/xpdf/UnicodeMap.cc", "lib/xpdf/UnicodeRemapping.cc", "lib/xpdf/UnicodeTypeTable.cc", "lib/xpdf/UTF8.cc", "lib/xpdf/WebFont.cc", "lib/xpdf/XFAScanner.cc", "lib/xpdf/XRef.cc", "lib/xpdf/Zoox.cc", "PdfFile.cpp", "PdfReader.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../raster/Jp2/openjpeg/openjpeg-2.4.0/src/lib/openjp2/",
|
||||
|
||||
@ -619,7 +619,10 @@ INCLUDEPATH += \
|
||||
$$PDF_ROOT_DIR/lib/splash \
|
||||
$$PDF_ROOT_DIR/lib
|
||||
|
||||
HEADERS += $$files($$PDF_ROOT_DIR/lib/*.h, true)
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/lib/aconf.h \
|
||||
$$$files($$PDF_ROOT_DIR/lib/*.h)
|
||||
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.c, true)
|
||||
SOURCES += $$files($$PDF_ROOT_DIR/lib/*.cc, true)
|
||||
|
||||
@ -641,7 +644,9 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.cpp \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/BaseFonts.cpp \
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp
|
||||
$$PDF_ROOT_DIR/Resources/CMapMemory/cmap_memory.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp
|
||||
|
||||
HEADERS +=\
|
||||
$$PDF_ROOT_DIR/Resources/Fontd050000l.h \
|
||||
@ -665,88 +670,9 @@ HEADERS +=\
|
||||
$$PDF_ROOT_DIR/SrcReader/MemoryUtils.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/GfxClip.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/FontsWasm.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h
|
||||
|
||||
DEFINES += CRYPTOPP_DISABLE_ASM
|
||||
LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lCryptoPPLib
|
||||
|
||||
# PdfWriter
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Consts.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encodings.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Types.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ICCProfile.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Annotation.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Catalog.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Destination.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Document.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Encrypt.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/EncryptDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Field.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Font14.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontCidTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTT.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontTTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/FontOTWriter.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/GState.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Image.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Info.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Objects.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Outline.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pages.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Pattern.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ResourcesDictionary.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Shading.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp
|
||||
|
||||
# PdfFile
|
||||
|
||||
HEADERS += \
|
||||
$$PDF_ROOT_DIR/PdfFile.h \
|
||||
$$PDF_ROOT_DIR/PdfWriter.h \
|
||||
$$PDF_ROOT_DIR/SrcReader/PdfAnnot.h \
|
||||
$$PDF_ROOT_DIR/PdfReader.h \
|
||||
$$PDF_ROOT_DIR/PdfEditor.h \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/PdfFile.cpp \
|
||||
$$PDF_ROOT_DIR/PdfWriter.cpp \
|
||||
$$PDF_ROOT_DIR/PdfReader.cpp \
|
||||
$$PDF_ROOT_DIR/PdfEditor.cpp \
|
||||
$$PDF_ROOT_DIR/OnlineOfficeBinToPdf.cpp
|
||||
$$PDF_ROOT_DIR/PdfFile.h
|
||||
|
||||
# DocxRenderer
|
||||
DOCX_RENDERER_ROOT_DIR = $$CORE_ROOT_DIR/DocxRenderer
|
||||
@ -803,6 +729,7 @@ HEADERS += \
|
||||
../wasm/src/Text.h
|
||||
|
||||
SOURCES += \
|
||||
../wasm/src/pdfwriter.cpp \
|
||||
../wasm/src/HTMLRendererText.cpp \
|
||||
../wasm/src/drawingfile.cpp \
|
||||
../wasm/src/drawingfile_test.cpp
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -42,19 +42,6 @@ CNativePointer.prototype.free = function()
|
||||
g_native_drawing_file["FreeWasmData"](this.ptr);
|
||||
this.ptr = null;
|
||||
};
|
||||
CNativePointer.prototype.getMemory = function(isCopy)
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
|
||||
if (!isCopy)
|
||||
return this.ptr;
|
||||
|
||||
let copyArray = new Uint8Array(this.ptr.length);
|
||||
copyArray.set(this.ptr);
|
||||
|
||||
return copyArray;
|
||||
};
|
||||
CNativePointer.prototype.getReader = function()
|
||||
{
|
||||
if (!this.ptr)
|
||||
@ -107,34 +94,6 @@ CFile.prototype._getError = function()
|
||||
return g_native_drawing_file["GetErrorCode"]();
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(pages, changes)
|
||||
{
|
||||
let dataChanges = null;
|
||||
if (changes)
|
||||
dataChanges = (undefined !== changes.byteLength) ? new Uint8Array(changes) : changes;
|
||||
g_module_pointer.ptr = g_native_drawing_file["SplitPages"](pages, dataChanges);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
if (!prefixForm)
|
||||
prefixForm = "";
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
return g_native_drawing_file["MergePages"](data, maxID, prefixForm);
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
return g_native_drawing_file["UnmergePages"]();
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@ CWasmPointer.prototype.free = function()
|
||||
Module["_free"](this.ptr);
|
||||
this.ptr = 0;
|
||||
};
|
||||
CWasmPointer.prototype.getMemory = function(isCopy)
|
||||
CWasmPointer.prototype.getReader = function()
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
@ -59,23 +59,8 @@ CWasmPointer.prototype.getMemory = function(isCopy)
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
|
||||
let noCopyArray = new Uint8Array(Module["HEAP8"].buffer, this.ptr + 4, len);
|
||||
if (!isCopy)
|
||||
return noCopyArray;
|
||||
|
||||
let copyArray = new Uint8Array(len);
|
||||
copyArray.set(noCopyArray);
|
||||
|
||||
return copyArray;
|
||||
};
|
||||
CWasmPointer.prototype.getReader = function()
|
||||
{
|
||||
let noCopyArray = this.getMemory(false);
|
||||
if (!noCopyArray)
|
||||
return null;
|
||||
|
||||
return new CBinaryReader(noCopyArray, 0, noCopyArray.length);
|
||||
let buffer = new Uint8Array(Module["HEAP8"].buffer, this.ptr + 4, len);
|
||||
return new CBinaryReader(buffer, 0, len);
|
||||
};
|
||||
|
||||
var g_module_pointer = new CWasmPointer();
|
||||
@ -127,7 +112,7 @@ CFile.prototype._closeFile = function()
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
return Module["_GetType"](this.nativeFile);
|
||||
return Module["_GetType"](this.stream, this.stream_size);
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
@ -135,63 +120,6 @@ CFile.prototype._getError = function()
|
||||
return Module["_GetErrorCode"](this.nativeFile);
|
||||
};
|
||||
|
||||
CFile.prototype._SplitPages = function(memoryBuffer, arrayBufferChanges)
|
||||
{
|
||||
let changesPtr = 0;
|
||||
let changesLen = 0;
|
||||
if (arrayBufferChanges)
|
||||
{
|
||||
let changes = new Uint8Array(arrayBufferChanges);
|
||||
changesLen = changes.length;
|
||||
changesPtr = Module["_malloc"](changesLen);
|
||||
Module["HEAP8"].set(changes, changesPtr);
|
||||
}
|
||||
|
||||
let pointer = Module["_malloc"](memoryBuffer.length * 4);
|
||||
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
|
||||
let ptr = Module["_SplitPages"](this.nativeFile, pointer, memoryBuffer.length, changesPtr, changesLen);
|
||||
Module["_free"](pointer);
|
||||
if (changesPtr)
|
||||
Module["_free"](changesPtr);
|
||||
|
||||
g_module_pointer.ptr = ptr;
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._MergePages = function(buffer, maxID, prefixForm)
|
||||
{
|
||||
if (!buffer)
|
||||
return false;
|
||||
|
||||
let data = (undefined !== buffer.byteLength) ? new Uint8Array(buffer) : buffer;
|
||||
let stream2 = Module["_malloc"](data.length);
|
||||
Module["HEAP8"].set(data, stream2);
|
||||
|
||||
if (!maxID)
|
||||
maxID = 0;
|
||||
|
||||
let prefixPtr = 0;
|
||||
if (prefixForm)
|
||||
{
|
||||
let prefixBuf = prefixForm.toUtf8();
|
||||
prefixPtr = Module["_malloc"](prefixBuf.length);
|
||||
Module["HEAP8"].set(prefixBuf, prefixPtr);
|
||||
}
|
||||
|
||||
let bRes = Module["_MergePages"](this.nativeFile, stream2, data.length, maxID, prefixPtr);
|
||||
stream2 = 0; // Success or not, stream2 is either taken or freed
|
||||
|
||||
if (prefixPtr)
|
||||
Module["_free"](prefixPtr);
|
||||
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._UndoMergePages = function()
|
||||
{
|
||||
return Module["_UnmergePages"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -42,12 +42,6 @@ CBinaryReader.prototype.readByte = function()
|
||||
this.pos += 1;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readShort = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8;
|
||||
this.pos += 2;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readInt = function()
|
||||
{
|
||||
let val = this.data[this.pos] | this.data[this.pos + 1] << 8 | this.data[this.pos + 2] << 16 | this.data[this.pos + 3] << 24;
|
||||
@ -62,10 +56,6 @@ CBinaryReader.prototype.readDouble2 = function()
|
||||
{
|
||||
return this.readInt() / 10000;
|
||||
};
|
||||
CBinaryReader.prototype.readDouble3 = function()
|
||||
{
|
||||
return this.readInt() / 100000;
|
||||
};
|
||||
CBinaryReader.prototype.readString = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
@ -73,20 +63,9 @@ CBinaryReader.prototype.readString = function()
|
||||
this.pos += len;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readString2 = function()
|
||||
{
|
||||
let len = this.readShort();
|
||||
let val = "";
|
||||
for (let i = 0; i < len; ++i)
|
||||
{
|
||||
let c = this.readShort();
|
||||
val += String.fromCharCode(c);
|
||||
}
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readData = function()
|
||||
{
|
||||
let len = this.readInt() - 4;
|
||||
let len = this.readInt();
|
||||
let val = this.data.slice(this.pos, this.pos + len);
|
||||
this.pos += len;
|
||||
return val;
|
||||
|
||||
@ -68,6 +68,25 @@ WASM_EXPORT int IsFontBinaryExist(char* path)
|
||||
return 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT int GetType(BYTE* data, LONG size)
|
||||
{
|
||||
// 0 - PDF
|
||||
// 1 - DJVU
|
||||
// 2 - XPS
|
||||
LONG nHeaderSearchSize = 1024;
|
||||
LONG nSize = size < nHeaderSearchSize ? size : nHeaderSearchSize;
|
||||
char* pData = (char*)data;
|
||||
for (int i = 0; i < nSize - 5; ++i)
|
||||
{
|
||||
int nPDF = strncmp(&pData[i], "%PDF-", 5);
|
||||
if (!nPDF)
|
||||
return 0;
|
||||
}
|
||||
if ( (8 <= size) && (0x41 == data[0] && 0x54 == data[1] && 0x26 == data[2] && 0x54 == data[3] &&
|
||||
0x46 == data[4] && 0x4f == data[5] && 0x52 == data[6] && 0x4d == data[7]))
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
{
|
||||
if (!g_applicationFonts)
|
||||
@ -83,13 +102,6 @@ WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
pFile->OpenFile(data, size, sPassword);
|
||||
return pFile;
|
||||
}
|
||||
WASM_EXPORT int GetType(CDrawingFile* pFile)
|
||||
{
|
||||
// 0 - PDF
|
||||
// 1 - DJVU
|
||||
// 2 - XPS
|
||||
return pFile->GetType();
|
||||
}
|
||||
WASM_EXPORT int GetErrorCode(CDrawingFile* pFile)
|
||||
{
|
||||
if (!pFile)
|
||||
@ -99,7 +111,6 @@ WASM_EXPORT int GetErrorCode(CDrawingFile* pFile)
|
||||
WASM_EXPORT void Close(CDrawingFile* pFile)
|
||||
{
|
||||
delete pFile;
|
||||
g_applicationFonts->GetStreams()->Clear();
|
||||
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NULL);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetInfo(CDrawingFile* pFile)
|
||||
@ -114,7 +125,7 @@ WASM_EXPORT BYTE* GetGlyphs(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetGlyphs(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetLinks(CDrawingFile* pFile, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetLinks (CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pFile->GetLinks(nPageIndex);
|
||||
}
|
||||
@ -166,18 +177,6 @@ WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
}
|
||||
WASM_EXPORT BYTE* SplitPages(CDrawingFile* pFile, int* arrPageIndex, int nLength, BYTE* data, LONG size)
|
||||
{
|
||||
return pFile->SplitPages(arrPageIndex, nLength, data, size);
|
||||
}
|
||||
WASM_EXPORT int MergePages(CDrawingFile* pFile, BYTE* data, LONG size, int nMaxID, const char* sPrefixForm)
|
||||
{
|
||||
return pFile->MergePages(data, size, nMaxID, sPrefixForm) ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int UnmergePages(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UnmergePages() ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,11 +2,8 @@
|
||||
#define _WASM_SERIALIZE_H
|
||||
|
||||
#include <vector>
|
||||
#include <stack>
|
||||
#include "../../../../../common/File.h"
|
||||
|
||||
#define CLEAR_STACK(stack) while (!(stack).empty()) (stack).pop()
|
||||
|
||||
namespace NSWasm
|
||||
{
|
||||
class CData
|
||||
@ -18,8 +15,6 @@ namespace NSWasm
|
||||
BYTE* m_pDataCur;
|
||||
size_t m_lSizeCur;
|
||||
|
||||
std::stack<size_t> m_lStack;
|
||||
|
||||
public:
|
||||
CData()
|
||||
{
|
||||
@ -29,70 +24,10 @@ namespace NSWasm
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = m_lSize;
|
||||
}
|
||||
CData(const CData& other)
|
||||
{
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = (BYTE*)malloc(m_lSize * sizeof(BYTE));
|
||||
memcpy(m_pData, other.m_pData, other.m_lSizeCur * sizeof(BYTE));
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
|
||||
m_lStack = other.m_lStack;
|
||||
}
|
||||
CData(CData&& other)
|
||||
{
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = other.m_pData;
|
||||
m_pDataCur = other.m_pDataCur;
|
||||
|
||||
m_lStack = std::move(other.m_lStack);
|
||||
|
||||
other.ClearWithoutAttack();
|
||||
}
|
||||
virtual ~CData()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
CData& operator= (const CData& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
Clear();
|
||||
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = (BYTE*)malloc(m_lSize * sizeof(BYTE));
|
||||
memcpy(m_pData, other.m_pData, other.m_lSizeCur * sizeof(BYTE));
|
||||
m_pDataCur = m_pData + m_lSizeCur;
|
||||
|
||||
m_lStack = other.m_lStack;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CData& operator= (CData&& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
Clear();
|
||||
|
||||
m_lSize = other.m_lSize;
|
||||
m_lSizeCur = other.m_lSizeCur;
|
||||
|
||||
m_pData = other.m_pData;
|
||||
m_pDataCur = other.m_pDataCur;
|
||||
|
||||
other.ClearWithoutAttack();
|
||||
|
||||
m_lStack = std::move(other.m_lStack);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void AddSize(size_t nSize)
|
||||
{
|
||||
@ -133,20 +68,6 @@ namespace NSWasm
|
||||
}
|
||||
|
||||
public:
|
||||
void StartRecord(BYTE type)
|
||||
{
|
||||
AddSize(5); // sizeof (BYTE + unsigned int)
|
||||
WriteBYTE(type);
|
||||
AddInt(0);
|
||||
m_lStack.push(m_lSizeCur);
|
||||
}
|
||||
void EndRecord()
|
||||
{
|
||||
size_t start = m_lStack.top();
|
||||
unsigned int len = m_lSizeCur - start;
|
||||
memcpy(m_pData + start - 4, &len, sizeof(unsigned int));
|
||||
m_lStack.pop();
|
||||
}
|
||||
void AddInt(unsigned int value)
|
||||
{
|
||||
AddSize(4);
|
||||
@ -154,13 +75,6 @@ namespace NSWasm
|
||||
m_pDataCur += 4;
|
||||
m_lSizeCur += 4;
|
||||
}
|
||||
void AddSInt(int value)
|
||||
{
|
||||
AddSize(4);
|
||||
memcpy(m_pDataCur, &value, sizeof(int));
|
||||
m_pDataCur += 4;
|
||||
m_lSizeCur += 4;
|
||||
}
|
||||
void AddInt(unsigned int value, size_t pos)
|
||||
{
|
||||
if (pos < m_lSizeCur)
|
||||
@ -179,10 +93,6 @@ namespace NSWasm
|
||||
m_pDataCur += sizeof(BYTE);
|
||||
m_lSizeCur += sizeof(BYTE);
|
||||
}
|
||||
void WriteBool(bool value)
|
||||
{
|
||||
WriteBYTE(value ? 1 : 0);
|
||||
}
|
||||
void WriteDouble(double value)
|
||||
{
|
||||
int nV = value * 10000;
|
||||
@ -241,37 +151,6 @@ namespace NSWasm
|
||||
WriteString(pDataUtf8, (unsigned int)lDataUtf8);
|
||||
RELEASEARRAYOBJECTS(pDataUtf8);
|
||||
}
|
||||
void WriteStringUtf16(const std::wstring& sStr, const bool& isBytes = false)
|
||||
{
|
||||
unsigned int size = static_cast<unsigned int>(sStr.length());
|
||||
|
||||
int len = 0;
|
||||
size_t posLen = m_lSizeCur;
|
||||
|
||||
// len reserve
|
||||
AddInt(0);
|
||||
|
||||
if (sizeof(wchar_t) == 4)
|
||||
{
|
||||
AddSize(4 * size + 2/*'\0'*/);
|
||||
NSFile::CUtf8Converter::GetUtf16StringFromUnicode_4bytes(sStr.c_str(), (LONG)size, m_pDataCur, len, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t bufferLen = 2 * size;
|
||||
AddSize(bufferLen);
|
||||
len = (int)(bufferLen);
|
||||
memcpy(m_pDataCur, sStr.c_str(), bufferLen);
|
||||
}
|
||||
|
||||
m_pDataCur += static_cast<unsigned int>(len);
|
||||
m_lSizeCur += static_cast<unsigned int>(len);
|
||||
|
||||
if (!isBytes)
|
||||
len /= 2;
|
||||
|
||||
AddInt((unsigned int)len, posLen);
|
||||
}
|
||||
void Write(BYTE* value, unsigned int len)
|
||||
{
|
||||
if (!value || len == 0)
|
||||
@ -286,13 +165,6 @@ namespace NSWasm
|
||||
return m_pData;
|
||||
}
|
||||
|
||||
BYTE* MoveBuffer()
|
||||
{
|
||||
BYTE* pData = m_pData;
|
||||
ClearWithoutAttack();
|
||||
return pData;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
if (m_pData)
|
||||
@ -303,8 +175,6 @@ namespace NSWasm
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
|
||||
CLEAR_STACK(m_lStack);
|
||||
}
|
||||
void ClearWithoutAttack()
|
||||
{
|
||||
@ -313,15 +183,11 @@ namespace NSWasm
|
||||
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
|
||||
CLEAR_STACK(m_lStack);
|
||||
}
|
||||
void ClearNoAttack()
|
||||
{
|
||||
m_pDataCur = m_pData;
|
||||
m_lSizeCur = 0;
|
||||
|
||||
CLEAR_STACK(m_lStack);
|
||||
}
|
||||
unsigned int GetSize()
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user