mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-03-19 06:52:10 +08:00
Compare commits
202 Commits
v8.2.0.6
...
feature/pd
| Author | SHA1 | Date | |
|---|---|---|---|
| 447e1f5ccc | |||
| 06ee659edc | |||
| fe35178e26 | |||
| 13590d4c2e | |||
| 84fc9f876e | |||
| c4530caac1 | |||
| c018d57081 | |||
| 43f49b7a9d | |||
| f8e19a7f0b | |||
| f245985bbd | |||
| 68171df991 | |||
| bbf4003ec7 | |||
| 75cc7d8457 | |||
| 7018402a58 | |||
| 6ce30ccaad | |||
| 670677c23b | |||
| 208f6efcc5 | |||
| 685165d270 | |||
| f18eb2ef5b | |||
| facdff46fe | |||
| 8843c3dd36 | |||
| 2708479152 | |||
| f3facfa8e8 | |||
| 1e26e1723a | |||
| 6d9242e1dd | |||
| e8de8dc03b | |||
| 57447f757f | |||
| 46d6eaa793 | |||
| def502c7eb | |||
| 1e5e43cbe5 | |||
| 60a888fc19 | |||
| 01ca25d798 | |||
| 6812ebaa42 | |||
| aacb2842f7 | |||
| 27a2a47cbe | |||
| 02f8178c01 | |||
| a0e2384409 | |||
| 56088e9eff | |||
| 1d6b895496 | |||
| fa4b8c8d76 | |||
| 2db2b98c8f | |||
| f45fb3c6be | |||
| 6f60d75863 | |||
| d1acdf35d8 | |||
| a1bf6a76ed | |||
| 3634d59ece | |||
| 1b21e8f136 | |||
| 554ca5ec7c | |||
| dc2e0edf80 | |||
| e38fa336d2 | |||
| 357450f242 | |||
| 4ed9925aff | |||
| 796537565b | |||
| fcf8e28ae8 | |||
| de949afbb6 | |||
| fb7bb041c1 | |||
| 8d6e15627b | |||
| 0583cbb5cc | |||
| a68bec86df | |||
| 6554185ec7 | |||
| 22bbde155d | |||
| 4a123d33ea | |||
| c7d0f27f6b | |||
| f1ddd51164 | |||
| 1d636b717f | |||
| c026f33aa7 | |||
| 29e5769d6d | |||
| 6586fc39ee | |||
| e8c7a4f670 | |||
| ead6b305b2 | |||
| 2de6a6d199 | |||
| c6ca99994b | |||
| b707510c88 | |||
| 7171dcb9f0 | |||
| 49dedc7a6d | |||
| 431fa060c4 | |||
| 0fc5133d98 | |||
| 8d5fc7d6ca | |||
| 3221d20d81 | |||
| 9fdb81554a | |||
| 95a1983e75 | |||
| c27aa4d807 | |||
| c4f8c524b5 | |||
| f7d55c08d8 | |||
| 4cfb8cc97a | |||
| a41ecb0715 | |||
| faa9e5e640 | |||
| ac2ee1b56d | |||
| b722238d21 | |||
| 83e20057f4 | |||
| 373786fca6 | |||
| 0fa1b4feec | |||
| 6a6204ae33 | |||
| f02147b97c | |||
| 88b1660735 | |||
| f5f7cb1aec | |||
| af01306997 | |||
| ef30a30e00 | |||
| 16ae48ef4e | |||
| 0eb8c93cf9 | |||
| c98285ffef | |||
| 4b99c4179b | |||
| e98dec952f | |||
| 8b2d7035c1 | |||
| 234def9cd7 | |||
| ce92766ef6 | |||
| 59c95c5039 | |||
| a23002225a | |||
| cb64a5a266 | |||
| 65483d0460 | |||
| 41758f0552 | |||
| bfd790ba11 | |||
| 81d9e3cfd7 | |||
| 2920527898 | |||
| 7013fdcb8d | |||
| 0d84e22e79 | |||
| f2acef6bb2 | |||
| 84b8850a52 | |||
| b2a3de852a | |||
| a8fa59d64d | |||
| 59b84f26ee | |||
| 5b17009fb9 | |||
| a5827f187c | |||
| 6ae25ca4c4 | |||
| 06edc93c7b | |||
| 8f9b35d94a | |||
| 14c06e4e7b | |||
| abaaa54bc2 | |||
| 7d0683e338 | |||
| f9d6b49a05 | |||
| 01916b7de6 | |||
| 666d62239e | |||
| 2e25f5dc64 | |||
| cc61536a90 | |||
| 58b5417ab4 | |||
| c056c14303 | |||
| 1b975c7048 | |||
| 3fd5b5612b | |||
| b8a8d36b8b | |||
| 6ab0d9d106 | |||
| 79309d3f02 | |||
| c8c4edf592 | |||
| 64afe55078 | |||
| 62b96623a0 | |||
| 46f30b980f | |||
| ac4f15b999 | |||
| 47961709ad | |||
| 7b8aa38c37 | |||
| 5c87955ae2 | |||
| c37aa9d9dc | |||
| d699c30bda | |||
| 9db017b9f4 | |||
| 70fe676300 | |||
| e73d4455c2 | |||
| 3158e830ff | |||
| 33daee696c | |||
| 305492ec7b | |||
| 2d213df8af | |||
| 4bb3953171 | |||
| f8e894af67 | |||
| 176290adaf | |||
| f30aba8bf1 | |||
| fb209c6c8a | |||
| d4af1308c0 | |||
| 824d9c59cf | |||
| d4f3cd3801 | |||
| c7fc2bc3a7 | |||
| a8c815d7bd | |||
| 4559d53a97 | |||
| 74d7bbca7c | |||
| 6eba82f433 | |||
| efa4433195 | |||
| 6ae6c37ef1 | |||
| 59b3862d89 | |||
| a72b42bd6d | |||
| 32464cb685 | |||
| af9a69d0f2 | |||
| 29115060b4 | |||
| f665afc1ad | |||
| e18fc06c7b | |||
| 4cd6e99531 | |||
| 56a08867db | |||
| f86548c873 | |||
| be64e3e624 | |||
| 2f6a542d02 | |||
| f69b52e232 | |||
| ce15265d5a | |||
| 370e317b79 | |||
| 3bf80a74fe | |||
| de31b16f91 | |||
| f4ec536794 | |||
| fb12bfa57f | |||
| 63c9185fd2 | |||
| 51c6fe496b | |||
| 283f21de86 | |||
| 0700038802 | |||
| 3e4c531538 | |||
| 29afb2aed9 | |||
| 86b53b7ede | |||
| 21e3293895 | |||
| cd86a8a3c7 | |||
| 9e1e641218 |
@ -34,6 +34,9 @@ namespace NSCSS
|
||||
|
||||
CCompiledStyle& CCompiledStyle::operator+= (const CCompiledStyle &oElement)
|
||||
{
|
||||
if (oElement.Empty())
|
||||
return *this;
|
||||
|
||||
m_oBackground += oElement.m_oBackground;
|
||||
m_oBorder += oElement.m_oBorder;
|
||||
m_oFont += oElement.m_oFont;
|
||||
@ -42,6 +45,9 @@ namespace NSCSS
|
||||
m_oText += oElement.m_oText;
|
||||
m_oDisplay += oElement.m_oDisplay;
|
||||
|
||||
if (!oElement.m_sId.empty())
|
||||
m_sId += L'+' + oElement.m_sId;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@ -23,6 +23,11 @@ namespace NSCSS
|
||||
return m_pInternal->GetCompiledStyle(oStyle, arSelectors, bIsSettings, unitMeasure);
|
||||
}
|
||||
|
||||
std::wstring CCssCalculator::CalculateStyleId(const CNode& oNode)
|
||||
{
|
||||
return m_pInternal->CalculateStyleId(oNode);
|
||||
}
|
||||
|
||||
bool CCssCalculator::CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
return m_pInternal->CalculatePageStyle(oPageData, arSelectors);
|
||||
|
||||
@ -22,6 +22,7 @@ namespace NSCSS
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point) const;
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
|
||||
// void AddStyle(const std::vector<std::string>& sSelectors, const std::string& sStyle);
|
||||
|
||||
@ -157,28 +157,34 @@ namespace NSCSS
|
||||
|
||||
std::vector<CElement*> CCssCalculator_Private::FindElements(std::vector<std::wstring> &arNodes, std::vector<std::wstring> &arNextNodes, bool bIsSettings)
|
||||
{
|
||||
if (arNodes.empty())
|
||||
return {};
|
||||
|
||||
std::vector<CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, wsId;
|
||||
std::vector<std::wstring> arClasses;
|
||||
|
||||
if (arNodes.back()[0] == L'#')
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'#')
|
||||
{
|
||||
wsId = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsId);
|
||||
}
|
||||
|
||||
if (arNodes.back()[0] == L'.')
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'.')
|
||||
{
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
|
||||
arNextNodes.push_back(arNodes.back());
|
||||
arNodes.pop_back();
|
||||
}
|
||||
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
if (!arNodes.empty())
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
const std::map<std::wstring, CElement*>::const_iterator oFindName = m_mData.find(wsName);
|
||||
std::map<std::wstring, CElement*>::const_iterator oFindId;
|
||||
@ -561,7 +567,7 @@ namespace NSCSS
|
||||
}
|
||||
}
|
||||
|
||||
oStyle.SetID(arSelectors.back().m_wsName + ((!arSelectors.back().m_wsClass.empty()) ? L'.' + arSelectors.back().m_wsClass : L"") + ((arSelectors.back().m_wsId.empty()) ? L"" : L'#' + arSelectors.back().m_wsId) + L'-' + std::to_wstring(++m_nCountNodes));
|
||||
oStyle.SetID(CalculateStyleId(arSelectors.back()));
|
||||
|
||||
if (!bIsSettings && !oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
@ -569,6 +575,11 @@ namespace NSCSS
|
||||
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);
|
||||
}
|
||||
|
||||
bool CCssCalculator_Private::CalculatePageStyle(NSProperties::CPage &oPageData, const std::vector<CNode> &arSelectors)
|
||||
{
|
||||
if (arSelectors.empty())
|
||||
|
||||
@ -75,6 +75,7 @@ namespace NSCSS
|
||||
CCompiledStyle GetCompiledStyle(const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
|
||||
bool GetCompiledStyle(CCompiledStyle& oStyle, const std::vector<CNode> &arSelectors, const bool& bIsSettings = false, const UnitMeasure& unitMeasure = Point);
|
||||
|
||||
std::wstring CalculateStyleId(const CNode& oNode);
|
||||
bool CalculatePageStyle(NSProperties::CPage& oPageData, const std::vector<CNode> &arSelectors);
|
||||
#endif
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@ namespace NSCSS
|
||||
CNode::CNode()
|
||||
{}
|
||||
|
||||
CNode::CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId)
|
||||
CNode::CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId)
|
||||
: m_wsName(wsName), m_wsClass(wsClass), m_wsId(wsId)
|
||||
{}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ namespace NSCSS
|
||||
|
||||
public:
|
||||
CNode();
|
||||
CNode(std::wstring wsName, std::wstring wsClass, std::wstring wsId);
|
||||
CNode(const std::wstring& wsName, const std::wstring& wsClass, const std::wstring& wsId);
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
|
||||
@ -141,7 +141,9 @@ namespace NS_STATIC_FUNCTIONS
|
||||
|
||||
while (std::wstring::npos != unEnd)
|
||||
{
|
||||
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
|
||||
if (unStart != unEnd)
|
||||
arWords.emplace_back(wsLine.data() + unStart, unEnd - unStart + ((bWithSigns) ? 1 : 0));
|
||||
|
||||
unStart = wsLine.find_first_not_of(wsDelimiters, unEnd);
|
||||
unEnd = wsLine.find_first_of(wsDelimiters, unStart);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -13,6 +13,8 @@ namespace NSCSS
|
||||
{
|
||||
namespace NSProperties
|
||||
{
|
||||
#define NEXT_LEVEL UINT_MAX, true
|
||||
|
||||
template<typename T>
|
||||
class CValue
|
||||
{
|
||||
@ -21,6 +23,7 @@ namespace NSCSS
|
||||
friend class CDigit;
|
||||
friend class CColor;
|
||||
friend class CEnum;
|
||||
friend class CURL;
|
||||
|
||||
T m_oValue;
|
||||
unsigned int m_unLevel;
|
||||
@ -74,13 +77,13 @@ namespace NSCSS
|
||||
return *this;
|
||||
}
|
||||
|
||||
CValue& operator =(const T& oValue)
|
||||
virtual CValue& operator =(const T& oValue)
|
||||
{
|
||||
//m_oValue = oValue.m_oValue;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CValue& operator+=(const CValue& oValue)
|
||||
virtual CValue& operator+=(const CValue& oValue)
|
||||
{
|
||||
if (m_unLevel > oValue.m_unLevel || (m_bImportant && !oValue.m_bImportant) || oValue.Empty())
|
||||
return *this;
|
||||
@ -92,10 +95,15 @@ namespace NSCSS
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const CValue& oValue) const
|
||||
virtual bool operator==(const CValue& oValue) const
|
||||
{
|
||||
return m_oValue == oValue.m_oValue;
|
||||
}
|
||||
|
||||
virtual bool operator!=(const CValue& oValue) const
|
||||
{
|
||||
return m_oValue != oValue.m_oValue;
|
||||
}
|
||||
};
|
||||
|
||||
class CString : public CValue<std::wstring>
|
||||
@ -130,6 +138,7 @@ namespace NSCSS
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
|
||||
bool SetValue(const CDigit& oValue);
|
||||
bool SetValue(const double& dValue, unsigned int unLevel, bool bHardMode);
|
||||
|
||||
bool Empty() const override;
|
||||
bool Zero() const;
|
||||
@ -178,8 +187,28 @@ namespace NSCSS
|
||||
bool Empty() const;
|
||||
|
||||
bool operator==(const TRGB& oRGB) const;
|
||||
bool operator!=(const TRGB& oRGB) const;
|
||||
};
|
||||
|
||||
class CURL
|
||||
{
|
||||
public:
|
||||
CURL();
|
||||
|
||||
bool Empty() const;
|
||||
bool LinkToId() const;
|
||||
|
||||
void Clear();
|
||||
|
||||
bool SetValue(const std::wstring& wsValue);
|
||||
std::wstring GetValue() const;
|
||||
|
||||
bool operator==(const CURL& oValue) const;
|
||||
bool operator!=(const CURL& oValue) const;
|
||||
private:
|
||||
std::wstring m_wsValue;
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ColorEmpty,
|
||||
@ -189,39 +218,8 @@ namespace NSCSS
|
||||
ColorUrl
|
||||
} ColorType;
|
||||
|
||||
class Q_DECL_EXPORT CColorValue
|
||||
class CColor : public CValue<void*>
|
||||
{
|
||||
public:
|
||||
CColorValue();
|
||||
CColorValue(const CColorValue& oColorValue);
|
||||
~CColorValue();
|
||||
|
||||
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
|
||||
void SetRGB(const TRGB& oRGB);
|
||||
void SetHEX(const std::wstring& wsValue);
|
||||
void SetUrl(const std::wstring& wsValue);
|
||||
void SetNone();
|
||||
|
||||
void Clear();
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
ColorType m_enType;
|
||||
void* m_pColor = NULL;
|
||||
|
||||
std::wstring GetColor() const;
|
||||
|
||||
bool operator==(const CColorValue& oColorValue) const;
|
||||
CColorValue& operator= (const CColorValue& oColorValue);
|
||||
};
|
||||
|
||||
class CColor : public CValue<CColorValue>
|
||||
{
|
||||
CDigit m_oOpacity;
|
||||
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
|
||||
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
|
||||
static std::wstring CutURL(const std::wstring& wsValue);
|
||||
void SetEmpty(unsigned int unLevel = 0);
|
||||
public:
|
||||
CColor();
|
||||
|
||||
@ -242,6 +240,25 @@ namespace NSCSS
|
||||
std::wstring ToWString() const override;
|
||||
std::wstring EquateToColor(const std::vector<std::pair<TRGB, std::wstring>>& arColors) const;
|
||||
TRGB ToRGB() const;
|
||||
|
||||
static TRGB ConvertHEXtoRGB(const std::wstring& wsValue);
|
||||
static std::wstring ConvertRGBtoHEX(const TRGB& oValue);
|
||||
|
||||
bool operator==(const CColor& oColor) const;
|
||||
bool operator!=(const CColor& oColor) const;
|
||||
|
||||
CColor& operator =(const CColor& oColor);
|
||||
CColor& operator+=(const CColor& oColor);
|
||||
private:
|
||||
CDigit m_oOpacity;
|
||||
ColorType m_enType;
|
||||
|
||||
void SetEmpty(unsigned int unLevel = 0);
|
||||
void SetRGB(unsigned char uchR, unsigned char uchG, unsigned char uchB);
|
||||
void SetRGB(const TRGB& oRGB);
|
||||
void SetHEX(const std::wstring& wsValue);
|
||||
void SetUrl(const std::wstring& wsValue);
|
||||
void SetNone();
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@ -427,6 +444,7 @@ namespace NSCSS
|
||||
{
|
||||
public:
|
||||
CBorderSide();
|
||||
CBorderSide(const CBorderSide& oBorderSide);
|
||||
|
||||
void Clear();
|
||||
|
||||
@ -434,9 +452,12 @@ namespace NSCSS
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void SetNone(unsigned int unLevel, bool bHardMode);
|
||||
|
||||
void Block();
|
||||
void Unblock();
|
||||
|
||||
@ -452,6 +473,7 @@ namespace NSCSS
|
||||
|
||||
CBorderSide& operator+=(const CBorderSide& oBorderSide);
|
||||
bool operator==(const CBorderSide& oBorderSide) const;
|
||||
bool operator!=(const CBorderSide& oBorderSide) const;
|
||||
CBorderSide& operator =(const CBorderSide& oBorderSide);
|
||||
private:
|
||||
CDigit m_oWidth;
|
||||
@ -473,39 +495,50 @@ namespace NSCSS
|
||||
CBorder();
|
||||
|
||||
void Clear();
|
||||
void ClearLeftSide();
|
||||
void ClearTopSide();
|
||||
void ClearRightSide();
|
||||
void ClearBottomSide();
|
||||
|
||||
static void Equation(CBorder &oFirstBorder, CBorder &oSecondBorder);
|
||||
|
||||
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetCollapse(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Left Side
|
||||
bool SetLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Top Side
|
||||
bool SetTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Right Side
|
||||
bool SetRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Bottom Side
|
||||
bool SetBottomSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void SetNone(unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void Block();
|
||||
void Unblock();
|
||||
|
||||
@ -522,7 +555,7 @@ namespace NSCSS
|
||||
|
||||
CBorder& operator+=(const CBorder& oBorder);
|
||||
bool operator==(const CBorder& oBorder) const;
|
||||
|
||||
bool operator!=(const CBorder& oBorder) const;
|
||||
CBorder& operator =(const CBorder& oBorder);
|
||||
private:
|
||||
CBorderSide m_oLeft;
|
||||
@ -574,11 +607,13 @@ namespace NSCSS
|
||||
bool SetAlign (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetDecoration(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHighlight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetIndent() const;
|
||||
const CString& GetAlign() const;
|
||||
const TTextDecoration& GetDecoration() const;
|
||||
const CColor& GetColor() const;
|
||||
const CColor& GetHighlight() const;
|
||||
|
||||
bool Empty() const;
|
||||
|
||||
@ -593,6 +628,7 @@ namespace NSCSS
|
||||
CDigit m_oIndent;
|
||||
CString m_oAlign;
|
||||
CColor m_oColor;
|
||||
CColor m_oHighlight;
|
||||
};
|
||||
|
||||
class CIndent
|
||||
@ -610,9 +646,13 @@ namespace NSCSS
|
||||
|
||||
bool SetValues (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateAll (double dFontSize);
|
||||
void UpdateTop (double dFontSize);
|
||||
@ -652,6 +692,7 @@ namespace NSCSS
|
||||
|
||||
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
@ -341,12 +341,14 @@ namespace NSCSS
|
||||
sSpacingValue.reserve(128);
|
||||
|
||||
if (!oStyle.m_oMargin.GetTop().Empty() && !oStyle.m_oMargin.GetTop().Zero())
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"0\" ";
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"0\"";
|
||||
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
|
||||
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"0\"";
|
||||
|
||||
if (!oStyle.m_oMargin.GetBottom().Empty() && !oStyle.m_oMargin.GetBottom().Zero())
|
||||
sSpacingValue += L"w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"0\" ";
|
||||
sSpacingValue += L" w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"0\"";
|
||||
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
|
||||
sSpacingValue += L"w:after=\"0\" ";
|
||||
sSpacingValue += L" w:after=\"0\" w:afterAutospacing=\"0\"";
|
||||
|
||||
if (!oStyle.m_oFont.GetLineHeight().Empty() && !oStyle.m_oFont.GetLineHeight().Zero())
|
||||
{
|
||||
@ -356,7 +358,7 @@ namespace NSCSS
|
||||
sSpacingValue += L" w:line=\"" + wsLine + L"\" w:lineRule=\"" + wsLineRule + L"\"";
|
||||
}
|
||||
else if (oStyle.m_oFont.GetLineHeight().Zero() || bInTable)
|
||||
sSpacingValue += L"w:lineRule=\"auto\" w:line=\"240\"";
|
||||
sSpacingValue += L" w:lineRule=\"auto\" w:line=\"240\"";
|
||||
|
||||
if (!sSpacingValue.empty())
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Spacing, sSpacingValue);
|
||||
@ -491,17 +493,15 @@ namespace NSCSS
|
||||
if (!oStyle.m_oBackground.GetColor().Empty() && !oStyle.m_oBackground.GetColor().None() && !oStyle.m_oBackground.GetColor().Url())
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Shd, oStyle.m_oBackground.GetColor().ToWString());
|
||||
|
||||
/*
|
||||
const std::wstring wsHighlight{oStyle.m_oBackground.GetColor().EquateToColor({{{0, 0, 0}, L"black"}, {{0, 0, 255}, L"blue"}, {{0, 255, 255}, L"cyan"},
|
||||
{{0, 255, 0}, L"green"}, {{255, 0, 255}, L"magenta"}, {{255, 0, 0}, L"red"},
|
||||
{{255, 255, 0}, L"yellow"}, {{255, 255, 255}, L"white"}, {{0, 0, 139}, L"darkBlue"},
|
||||
{{0, 139, 139}, L"darkCyan"}, {{0, 100, 0}, L"darkGreen"}, {{139, 0, 139}, L"darkMagenta"},
|
||||
{{139, 0, 0}, L"darkRed"}, {{128, 128, 0}, L"darkYellow"},{{169, 169, 169}, L"darkGray"},
|
||||
{{211, 211, 211}, L"lightGray"}})};
|
||||
const std::wstring wsHighlight{oStyle.m_oText.GetHighlight().EquateToColor({{{0, 0, 0}, L"black"}, {{0, 0, 255}, L"blue"}, {{0, 255, 255}, L"cyan"},
|
||||
{{0, 255, 0}, L"green"}, {{255, 0, 255}, L"magenta"}, {{255, 0, 0}, L"red"},
|
||||
{{255, 255, 0}, L"yellow"}, {{255, 255, 255}, L"white"}, {{0, 0, 139}, L"darkBlue"},
|
||||
{{0, 139, 139}, L"darkCyan"}, {{0, 100, 0}, L"darkGreen"}, {{139, 0, 139}, L"darkMagenta"},
|
||||
{{139, 0, 0}, L"darkRed"}, {{128, 128, 0}, L"darkYellow"},{{169, 169, 169}, L"darkGray"},
|
||||
{{211, 211, 211}, L"lightGray"}})};
|
||||
|
||||
if (L"none" != wsHighlight)
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Highlight, wsHighlight);
|
||||
*/
|
||||
|
||||
oXmlElement.AddPropertiesInR(RProperties::R_Color, oStyle.m_oText.GetColor().ToWString());
|
||||
|
||||
@ -523,10 +523,7 @@ namespace NSCSS
|
||||
Clear();
|
||||
|
||||
if(oStyle.GetId().empty())
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return false;
|
||||
}
|
||||
|
||||
CStyleUsed structStyle(oStyle, false);
|
||||
|
||||
@ -589,10 +586,7 @@ namespace NSCSS
|
||||
Clear();
|
||||
|
||||
if(oStyle.GetId().empty())
|
||||
{
|
||||
m_sId = L"normal";
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
CStyleUsed structStyle(oStyle, true);
|
||||
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
|
||||
@ -27,7 +27,7 @@ CXmlElement::CXmlElement(const std::wstring& sNameDefaultElement)
|
||||
|
||||
bool CXmlElement::Empty() const
|
||||
{
|
||||
return m_mPStyleValues.empty() && m_mRStyleValues.empty() && m_mBasicValues.find(CSSProperties::BasicProperties::B_BasedOn) == m_mBasicValues.end();
|
||||
return m_mPStyleValues.empty() && m_mRStyleValues.empty() && GetBasedOn().empty();
|
||||
}
|
||||
|
||||
void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
@ -35,7 +35,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
if (!Empty())
|
||||
Clear();
|
||||
|
||||
if (sNameDefaultElement == L"p")
|
||||
/* if (sNameDefaultElement == L"p")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"p");
|
||||
@ -47,7 +47,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"li")
|
||||
else */if (sNameDefaultElement == L"li")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"li");
|
||||
@ -203,7 +203,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_Sz, L"15");
|
||||
AddPropertiesInR(CSSProperties::RunnerProperties::R_B, L"bold");
|
||||
}
|
||||
else if (sNameDefaultElement == L"div-c")
|
||||
/*else if (sNameDefaultElement == L"div-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_StyleId, L"div-c");
|
||||
@ -219,7 +219,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Name, L"Div paragraph");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_BasedOn, L"normal");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"div-c");
|
||||
}
|
||||
}*/
|
||||
else if (sNameDefaultElement == L"a-c")
|
||||
{
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Type, L"character");
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
#include "../../../../Common/3dParty/hunspell/hunspell/src/hunspell/hunspell.h"
|
||||
#include "../../../../DesktopEditor/common/StringExt.h"
|
||||
#include "../../../../DesktopEditor/common/Directory.h"
|
||||
#include <iostream>
|
||||
|
||||
bool CheckCaret(std::vector<std::wstring>& words)
|
||||
{
|
||||
@ -85,11 +86,36 @@ std::wstring CheckWord(Hunhandle* pDic, const std::wstring& sWord, const bool& b
|
||||
return sResult;
|
||||
}
|
||||
|
||||
#if defined(_WIN32) || defined(_WIN64)
|
||||
#define USE_WCHAR_ARGC
|
||||
#endif
|
||||
|
||||
#ifdef USE_WCHAR_ARGC
|
||||
std::wstring GetParam(wchar_t* arg)
|
||||
{
|
||||
return std::wstring(arg);
|
||||
}
|
||||
#else
|
||||
std::wstring GetParam(char* arg)
|
||||
{
|
||||
return NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE *)arg, (LONG)strlen(arg));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_WCHAR_ARGC
|
||||
int wmain(int argc, wchar_t *argv[])
|
||||
#else
|
||||
int main(int argc, char *argv[])
|
||||
#endif
|
||||
{
|
||||
std::wstring sSrcDir = NSFile::GetProcessDirectory() + L"/../src";
|
||||
std::wstring sDstDir = NSFile::GetProcessDirectory() + L"/../dst";
|
||||
std::wstring sDictionariesDir = NSFile::GetProcessDirectory() + L"/../../../../../../dictionaries";
|
||||
|
||||
if (argc > 1) sSrcDir = GetParam(argv[1]);
|
||||
if (argc > 2) sDstDir = GetParam(argv[2]);
|
||||
if (argc > 3) sDictionariesDir = GetParam(argv[3]);
|
||||
|
||||
std::vector<std::wstring> arSrcFiles = NSDirectory::GetFiles(sSrcDir);
|
||||
|
||||
for (int i = 0, len = (int)arSrcFiles.size(); i < len; ++i)
|
||||
@ -125,6 +151,8 @@ int main(int argc, char *argv[])
|
||||
Hunspell_destroy(pDictionary);
|
||||
|
||||
NSFile::CFileBinary::SaveToFile(sFileDst, sResult, true);
|
||||
|
||||
std::cout << "[" << (i + 1) << " of " << (int)arSrcFiles.size() << "] " << U_TO_UTF8(sName) << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
QT -= core gui
|
||||
|
||||
TARGET = test
|
||||
TARGET = dictionariestester
|
||||
CONFIG += console
|
||||
CONFIG -= app_bundle
|
||||
|
||||
@ -22,8 +22,7 @@ include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
ADD_DEPENDENCY(UnicodeConverter kernel hunspell)
|
||||
|
||||
core_windows:LIBS += -lgdi32 -ladvapi32 -luser32 -lshell32
|
||||
core_linux:LIBS += -lz
|
||||
|
||||
SOURCES += main.cpp
|
||||
|
||||
DESTDIR = $$PWD/build
|
||||
DESTDIR = $$CORE_BUILDS_BINARY_PATH
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
<<<<<<<
|
||||
m_packet_mgr.set_encode_callback(std::bind(&client_impl::on_encode,this,_1,_2));
|
||||
=======
|
||||
m_packet_mgr.set_encode_callback(std::bind(&client_impl::on_encode,this,_1,_2));
|
||||
|
||||
m_client.set_close_handshake_timeout(1);
|
||||
>>>>>>>
|
||||
22
Common/3dParty/socketio/patches/sio_client_impl_fail.patch
Normal file
22
Common/3dParty/socketio/patches/sio_client_impl_fail.patch
Normal file
@ -0,0 +1,22 @@
|
||||
<<<<<<<
|
||||
if (m_con_state == con_closing) {
|
||||
LOG("Connection failed while closing." << endl);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
|
||||
m_con.reset();
|
||||
m_con_state = con_closed;
|
||||
this->sockets_invoke_void(&sio_no_tls::socket::on_disconnect);
|
||||
=======
|
||||
con_state con_state_old = m_con_state;
|
||||
m_con.reset();
|
||||
m_con_state = con_closed;
|
||||
this->sockets_invoke_void(&sio::socket::on_disconnect);
|
||||
|
||||
if (con_state_old == con_closing) {
|
||||
LOG("Connection failed while closing." << endl);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
>>>>>>>
|
||||
24
Common/3dParty/socketio/patches/sio_client_impl_open.patch
Normal file
24
Common/3dParty/socketio/patches/sio_client_impl_open.patch
Normal file
@ -0,0 +1,24 @@
|
||||
<<<<<<<
|
||||
if (m_con_state == con_closing) {
|
||||
LOG("Connection opened while closing." << endl);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
|
||||
LOG("Connected." << endl);
|
||||
m_con_state = con_opened;
|
||||
m_con = con;
|
||||
m_reconn_made = 0;
|
||||
=======
|
||||
con_state con_state_old = m_con_state;
|
||||
LOG("Connected." << endl);
|
||||
m_con_state = con_opened;
|
||||
m_con = con;
|
||||
m_reconn_made = 0;
|
||||
|
||||
if (con_state_old == con_closing) {
|
||||
LOG("Connection opened while closing." << endl);
|
||||
this->close();
|
||||
return;
|
||||
}
|
||||
>>>>>>>
|
||||
40
Common/3dParty/socketio/patches/websocketpp.patch
Normal file
40
Common/3dParty/socketio/patches/websocketpp.patch
Normal file
@ -0,0 +1,40 @@
|
||||
<<<<<<<
|
||||
template <typename config>
|
||||
void connection<config>::handle_terminate(terminate_status tstat,
|
||||
lib::error_code const & ec)
|
||||
{
|
||||
if (m_alog->static_test(log::alevel::devel)) {
|
||||
m_alog->write(log::alevel::devel,"connection handle_terminate");
|
||||
}
|
||||
|
||||
if (ec) {
|
||||
// there was an error actually shutting down the connection
|
||||
log_err(log::elevel::devel,"handle_terminate",ec);
|
||||
}
|
||||
=======
|
||||
template <typename config>
|
||||
void connection<config>::handle_terminate(terminate_status tstat,
|
||||
lib::error_code const & ec)
|
||||
{
|
||||
if (m_alog->static_test(log::alevel::devel)) {
|
||||
m_alog->write(log::alevel::devel,"connection handle_terminate");
|
||||
}
|
||||
|
||||
if (ec) {
|
||||
// there was an error actually shutting down the connection
|
||||
log_err(log::elevel::devel,"handle_terminate",ec);
|
||||
}
|
||||
|
||||
// Even with all workarounds and bug fixes in socket-io master branch, still running into
|
||||
// cases like https://github.com/socketio/socket.io-client-cpp/issues/254.
|
||||
//
|
||||
// After much investigation and debugging, seems like the socket is remaining
|
||||
// open and preventing the network thread from ending. Perhaps this is specific to the
|
||||
// environment where this code is run by Solink. The only solution seems to be manually
|
||||
// closing the socket as described here: https://github.com/zaphoyd/websocketpp/issues/805
|
||||
|
||||
bool isSocketOpen = transport_con_type::get_raw_socket().is_open();
|
||||
if (isSocketOpen) {
|
||||
transport_con_type::get_raw_socket().close();
|
||||
}
|
||||
>>>>>>>
|
||||
@ -5,6 +5,7 @@ v8_version_89 {
|
||||
CONFIG += c++14
|
||||
CONFIG += use_v8_monolith
|
||||
DEFINES += V8_VERSION_89_PLUS
|
||||
DEFINES += V8_SUPPORT_SNAPSHOTS
|
||||
|
||||
core_win_32:CONFIG += build_platform_32
|
||||
core_linux_32:CONFIG += build_platform_32
|
||||
|
||||
@ -32,8 +32,8 @@
|
||||
|
||||
#include <list>
|
||||
#include "./../include/manager.h"
|
||||
#include "./../../../core/DesktopEditor/graphics/TemporaryCS.h"
|
||||
#include "./../../../core/DesktopEditor/graphics/BaseThread.h"
|
||||
#include "./../../../../DesktopEditor/graphics/TemporaryCS.h"
|
||||
#include "./../../../../DesktopEditor/graphics/BaseThread.h"
|
||||
|
||||
namespace ASC
|
||||
{
|
||||
|
||||
@ -88,6 +88,17 @@ namespace NSNetwork
|
||||
m_base->listener->onError("");
|
||||
}
|
||||
|
||||
void event_onReconnecting()
|
||||
{
|
||||
CTemporaryCS oCS(&m_oCS_Events);
|
||||
m_connecting_in_process = true;
|
||||
}
|
||||
void event_onReconnect(unsigned, unsigned)
|
||||
{
|
||||
CTemporaryCS oCS(&m_oCS_Events);
|
||||
m_connecting_in_process = false;
|
||||
}
|
||||
|
||||
public:
|
||||
virtual void open(const std::map<std::string, std::string>& query) override
|
||||
{
|
||||
@ -96,6 +107,10 @@ namespace NSNetwork
|
||||
m_socket->set_close_listener(std::bind(&CIOWebSocket_private_tls::event_onClose, this, std::placeholders::_1));
|
||||
m_socket->set_fail_listener (std::bind(&CIOWebSocket_private_tls::event_onFail, this));
|
||||
|
||||
m_socket->set_reconnect_listener(std::bind(&CIOWebSocket_private_tls::event_onReconnect, this,
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
m_socket->set_reconnecting_listener(std::bind(&CIOWebSocket_private_tls::event_onReconnecting, this));
|
||||
|
||||
sio::message::ptr objAuth = sio::object_message::create();
|
||||
//std::string sAuth;
|
||||
|
||||
|
||||
@ -113,6 +113,11 @@ def exec_wasm(data, work, compiler_flags, wasm):
|
||||
if not wasm:
|
||||
engine_js_content = engine_js_content.replace("//polyfill", polyfill_js_content)
|
||||
|
||||
if "replaces" in data:
|
||||
for item in data["replaces"]:
|
||||
replace_file_content = base.readFile(data["replaces"][item])
|
||||
engine_js_content = engine_js_content.replace("//" + item, replace_file_content)
|
||||
|
||||
# write new version
|
||||
base.writeFile(data["res_folder"] + "/" + data["name"] + ("" if wasm else "_ie") + ".js", engine_js_content)
|
||||
base.copy_file("./" + data["name"] + (".wasm" if wasm else ".js.mem"), data["res_folder"] + "/" + data["name"] + (".wasm" if wasm else ".js.mem"))
|
||||
|
||||
@ -31,12 +31,6 @@ namespace agg
|
||||
static unsigned calculate(const int8u* p) { return *p; }
|
||||
};
|
||||
|
||||
//===================================================four_component_mask_u8
|
||||
struct four_component_mask_u8
|
||||
{
|
||||
static unsigned calculate(const int8u* p) { return p[3]; }
|
||||
};
|
||||
|
||||
|
||||
//=====================================================rgb_to_gray_mask_u8
|
||||
template<unsigned R, unsigned G, unsigned B>
|
||||
|
||||
@ -30,125 +30,148 @@
|
||||
*
|
||||
*/
|
||||
#include "StringUTF32.h"
|
||||
#include "StringExt.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace NSStringUtils;
|
||||
|
||||
CStringUTF32::CStringUTF32() {}
|
||||
CStringUTF32::CStringUTF32(const CStringUTF32 &other): m_vec(other.m_vec) {}
|
||||
CStringUTF32::CStringUTF32(const wchar_t *other) { *this = other; }
|
||||
CStringUTF32::CStringUTF32(const wstring &other) { *this = other; }
|
||||
CStringUTF32::CStringUTF32(const vector<uint32_t> &other): m_vec(other) {}
|
||||
CStringUTF32::CStringUTF32()
|
||||
{
|
||||
}
|
||||
CStringUTF32::CStringUTF32(const CStringUTF32& other) : m_vec(other.m_vec)
|
||||
{
|
||||
}
|
||||
CStringUTF32::CStringUTF32(const wchar_t* other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
CStringUTF32::CStringUTF32(const wstring& other)
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
CStringUTF32::CStringUTF32(const vector<uint32_t>& other) : m_vec(other)
|
||||
{
|
||||
}
|
||||
|
||||
CStringUTF32::CStringUTF32(const uint32_t* data, const size_t& len)
|
||||
{
|
||||
m_vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
this->m_vec.push_back(data[i]);
|
||||
m_vec.reserve(len);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
this->m_vec.push_back(data[i]);
|
||||
}
|
||||
|
||||
CStringUTF32::~CStringUTF32() {}
|
||||
CStringUTF32::~CStringUTF32()
|
||||
{
|
||||
}
|
||||
|
||||
bool CStringUTF32::empty() const
|
||||
{
|
||||
return this->m_vec.empty();
|
||||
return this->m_vec.empty();
|
||||
}
|
||||
|
||||
size_t CStringUTF32::length() const
|
||||
{
|
||||
return this->m_vec.size();
|
||||
return this->m_vec.size();
|
||||
}
|
||||
|
||||
wstring CStringUTF32::ToStdWString() const
|
||||
{
|
||||
if (0 == length())
|
||||
return L"";
|
||||
return NSStringExt::CConverter::GetUnicodeFromUTF32(&this->m_vec[0], static_cast<long>(this->length()));
|
||||
if (0 == length())
|
||||
return L"";
|
||||
return NSStringExt::CConverter::GetUnicodeFromUTF32(&this->m_vec[0], static_cast<long>(this->length()));
|
||||
}
|
||||
|
||||
bool CStringUTF32::operator == (const CStringUTF32 &right) const
|
||||
bool CStringUTF32::operator==(const CStringUTF32& right) const
|
||||
{
|
||||
return this->m_vec == right.m_vec;
|
||||
return this->m_vec == right.m_vec;
|
||||
}
|
||||
|
||||
bool CStringUTF32::operator != (const CStringUTF32 &right) const
|
||||
bool CStringUTF32::operator!=(const CStringUTF32& right) const
|
||||
{
|
||||
return !(this->m_vec == right.m_vec);
|
||||
return !(this->m_vec == right.m_vec);
|
||||
}
|
||||
|
||||
uint32_t& CStringUTF32::operator [] (size_t index)
|
||||
uint32_t& CStringUTF32::operator[](size_t index)
|
||||
{
|
||||
return this->m_vec[index];
|
||||
return this->m_vec[index];
|
||||
}
|
||||
|
||||
CStringUTF32& CStringUTF32::operator = (const CStringUTF32 &right)
|
||||
CStringUTF32& CStringUTF32::operator=(const CStringUTF32& right)
|
||||
{
|
||||
this->m_vec = right.m_vec;
|
||||
return *this;
|
||||
this->m_vec = right.m_vec;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CStringUTF32& CStringUTF32::operator = (const wchar_t *right)
|
||||
CStringUTF32& CStringUTF32::operator=(const wchar_t* right)
|
||||
{
|
||||
if (!right)
|
||||
{
|
||||
m_vec.clear();
|
||||
return *this;
|
||||
}
|
||||
if (!right)
|
||||
{
|
||||
m_vec.clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
return (*this = std::wstring(right));
|
||||
return (*this = std::wstring(right));
|
||||
}
|
||||
|
||||
CStringUTF32& CStringUTF32::operator = (const wstring &right)
|
||||
CStringUTF32& CStringUTF32::operator=(const wstring& right)
|
||||
{
|
||||
if (right.empty())
|
||||
{
|
||||
m_vec.clear();
|
||||
return *this;
|
||||
}
|
||||
if (right.empty())
|
||||
{
|
||||
m_vec.clear();
|
||||
return *this;
|
||||
}
|
||||
|
||||
unsigned int utf32_len = 0;
|
||||
unsigned int* utf32 = NSStringExt::CConverter::GetUtf32FromUnicode(right, utf32_len);
|
||||
this->m_vec.clear();
|
||||
this->m_vec.reserve(utf32_len);
|
||||
for (size_t i = 0; i < utf32_len; ++i)
|
||||
this->m_vec.push_back(utf32[i]);
|
||||
unsigned int utf32_len = 0;
|
||||
unsigned int* utf32 = NSStringExt::CConverter::GetUtf32FromUnicode(right, utf32_len);
|
||||
this->m_vec.clear();
|
||||
this->m_vec.reserve(utf32_len);
|
||||
for (size_t i = 0; i < utf32_len; ++i)
|
||||
this->m_vec.push_back(utf32[i]);
|
||||
|
||||
delete [] utf32;
|
||||
return *this;
|
||||
delete[] utf32;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CStringUTF32& CStringUTF32::operator = (const std::vector<uint32_t> &right)
|
||||
CStringUTF32& CStringUTF32::operator=(const std::vector<uint32_t>& right)
|
||||
{
|
||||
this->m_vec = right;
|
||||
return *this;
|
||||
this->m_vec = right;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CStringUTF32 CStringUTF32::operator + (const CStringUTF32 &right) const
|
||||
CStringUTF32 CStringUTF32::operator+(const CStringUTF32& right) const
|
||||
{
|
||||
CStringUTF32 result;
|
||||
result.m_vec.reserve(this->length() + right.length());
|
||||
result.m_vec.insert(result.m_vec.end(), m_vec.begin(), m_vec.end());
|
||||
result.m_vec.insert(result.m_vec.end(), right.m_vec.begin(), right.m_vec.end());
|
||||
return result;
|
||||
CStringUTF32 result;
|
||||
result.m_vec.reserve(this->length() + right.length());
|
||||
result.m_vec.insert(result.m_vec.end(), m_vec.begin(), m_vec.end());
|
||||
result.m_vec.insert(result.m_vec.end(), right.m_vec.begin(), right.m_vec.end());
|
||||
return result;
|
||||
}
|
||||
|
||||
CStringUTF32& CStringUTF32::operator += (const CStringUTF32 &right)
|
||||
CStringUTF32& CStringUTF32::operator+=(const CStringUTF32& right)
|
||||
{
|
||||
m_vec.insert(m_vec.end(), right.m_vec.begin(), right.m_vec.end());
|
||||
return *this;
|
||||
m_vec.insert(m_vec.end(), right.m_vec.begin(), right.m_vec.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
CStringUTF32& CStringUTF32::operator += (const uint32_t& symbol)
|
||||
CStringUTF32& CStringUTF32::operator+=(const uint32_t& symbol)
|
||||
{
|
||||
m_vec.push_back(symbol);
|
||||
return *this;
|
||||
m_vec.push_back(symbol);
|
||||
return *this;
|
||||
}
|
||||
|
||||
CStringUTF32 CStringUTF32::substr(size_t start, size_t count) const
|
||||
{
|
||||
CStringUTF32 result;
|
||||
result.m_vec.reserve(count);
|
||||
result.m_vec.insert(result.m_vec.end(), m_vec.begin() + start, m_vec.begin() + start + count);
|
||||
return result;
|
||||
CStringUTF32 result;
|
||||
result.m_vec.reserve(count);
|
||||
result.m_vec.insert(result.m_vec.end(), m_vec.begin() + start, m_vec.begin() + start + count);
|
||||
return result;
|
||||
}
|
||||
|
||||
const uint32_t& CStringUTF32::at(size_t index) const
|
||||
{
|
||||
return this->m_vec.at(index);
|
||||
}
|
||||
uint32_t& CStringUTF32::at(size_t index)
|
||||
{
|
||||
return this->m_vec.at(index);
|
||||
}
|
||||
|
||||
@ -32,45 +32,49 @@
|
||||
#ifndef STRINGUTF32_HPP
|
||||
#define STRINGUTF32_HPP
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "StringExt.h"
|
||||
#include "../../Common/kernel_config.h"
|
||||
|
||||
namespace NSStringUtils
|
||||
{
|
||||
class KERNEL_DECL CStringUTF32
|
||||
{
|
||||
std::vector<uint32_t> m_vec;
|
||||
public:
|
||||
CStringUTF32();
|
||||
CStringUTF32(const CStringUTF32 &other);
|
||||
CStringUTF32(const wchar_t *other);
|
||||
CStringUTF32(const std::wstring &other);
|
||||
CStringUTF32(const std::vector<uint32_t> &other);
|
||||
CStringUTF32(const uint32_t* data, const size_t& count);
|
||||
virtual ~CStringUTF32();
|
||||
class KERNEL_DECL CStringUTF32
|
||||
{
|
||||
std::vector<uint32_t> m_vec;
|
||||
|
||||
bool empty() const;
|
||||
size_t length() const;
|
||||
public:
|
||||
CStringUTF32();
|
||||
CStringUTF32(const CStringUTF32 &other);
|
||||
CStringUTF32(const wchar_t *other);
|
||||
CStringUTF32(const std::wstring &other);
|
||||
CStringUTF32(const std::vector<uint32_t> &other);
|
||||
CStringUTF32(const uint32_t *data, const size_t &count);
|
||||
virtual ~CStringUTF32();
|
||||
|
||||
std::wstring ToStdWString() const;
|
||||
bool empty() const;
|
||||
size_t length() const;
|
||||
|
||||
bool operator == (const CStringUTF32 &right) const;
|
||||
bool operator != (const CStringUTF32 &right) const;
|
||||
uint32_t &operator [] (size_t index);
|
||||
std::wstring ToStdWString() const;
|
||||
|
||||
CStringUTF32 &operator = (const CStringUTF32 &right);
|
||||
CStringUTF32 &operator = (const wchar_t *right);
|
||||
CStringUTF32 &operator = (const std::wstring &right);
|
||||
CStringUTF32 &operator = (const std::vector<uint32_t> &right);
|
||||
bool operator==(const CStringUTF32 &right) const;
|
||||
bool operator!=(const CStringUTF32 &right) const;
|
||||
uint32_t &operator[](size_t index);
|
||||
|
||||
CStringUTF32 operator + (const CStringUTF32 &right) const;
|
||||
CStringUTF32 &operator += (const CStringUTF32 &right);
|
||||
CStringUTF32 &operator += (const uint32_t& symbol);
|
||||
CStringUTF32 &operator=(const CStringUTF32 &right);
|
||||
CStringUTF32 &operator=(const wchar_t *right);
|
||||
CStringUTF32 &operator=(const std::wstring &right);
|
||||
CStringUTF32 &operator=(const std::vector<uint32_t> &right);
|
||||
|
||||
CStringUTF32 substr(size_t start, size_t count) const;
|
||||
};
|
||||
}
|
||||
CStringUTF32 operator+(const CStringUTF32 &right) const;
|
||||
CStringUTF32 &operator+=(const CStringUTF32 &right);
|
||||
CStringUTF32 &operator+=(const uint32_t &symbol);
|
||||
|
||||
CStringUTF32 substr(size_t start, size_t count) const;
|
||||
|
||||
const uint32_t &at(size_t index) const;
|
||||
uint32_t &at(size_t index);
|
||||
};
|
||||
} // namespace NSStringUtils
|
||||
|
||||
#endif // STRINGUTF32_HPP
|
||||
|
||||
@ -147,6 +147,7 @@ int main(int argc, char *argv[])
|
||||
std::wstring sBuildFile = UTF8_TO_U(sBuildFileA);
|
||||
#endif
|
||||
|
||||
bool bResult = true;
|
||||
if (true)
|
||||
{
|
||||
NSDoctRenderer::CDocBuilder oBuilder;
|
||||
@ -159,9 +160,9 @@ int main(int argc, char *argv[])
|
||||
|
||||
parse_args(&oBuilder, argc - 1, argv);
|
||||
|
||||
oBuilder.Run(sBuildFile.c_str());
|
||||
bResult = oBuilder.Run(sBuildFile.c_str());
|
||||
}
|
||||
|
||||
NSDoctRenderer::CDocBuilder::Dispose();
|
||||
return 0;
|
||||
return bResult ? 0 : 1;
|
||||
}
|
||||
|
||||
@ -40,24 +40,53 @@
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CAdditionalData
|
||||
{
|
||||
public:
|
||||
CAdditionalData() {}
|
||||
virtual ~CAdditionalData() {}
|
||||
virtual std::string getParam(const std::wstring& name) { return ""; }
|
||||
};
|
||||
|
||||
class CDocBuilderParams
|
||||
{
|
||||
public:
|
||||
CDocBuilderParams() :
|
||||
m_bCheckFonts(false),
|
||||
m_sWorkDir(L""),
|
||||
m_bSaveWithDoctrendererMode(false),
|
||||
m_sArgumentJSON(""),
|
||||
m_bIsSystemFonts(true)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
bool m_bCheckFonts;
|
||||
std::wstring m_sWorkDir;
|
||||
bool m_bSaveWithDoctrendererMode;
|
||||
std::string m_sArgumentJSON;
|
||||
|
||||
bool m_bIsSystemFonts;
|
||||
std::vector<std::wstring> m_arFontDirs;
|
||||
};
|
||||
|
||||
class CDoctRendererConfig
|
||||
{
|
||||
public:
|
||||
std::vector<std::wstring> m_arrFiles;
|
||||
std::wstring m_strSdkPath;
|
||||
|
||||
std::vector<std::wstring> m_arDoctSDK;
|
||||
std::vector<std::wstring> m_arPpttSDK;
|
||||
std::vector<std::wstring> m_arXlstSDK;
|
||||
std::vector<std::wstring> m_arVsdtSDK;
|
||||
std::vector<std::wstring> m_arrFiles;
|
||||
|
||||
std::wstring m_strAllFonts;
|
||||
bool m_bIsNotUseConfigAllFontsDir;
|
||||
|
||||
bool m_bIsUseCache;
|
||||
|
||||
std::wstring m_sConsoleLogFile;
|
||||
std::wstring m_sErrorsLogFile;
|
||||
|
||||
public:
|
||||
CDoctRendererConfig() : m_bIsNotUseConfigAllFontsDir(false)
|
||||
CDoctRendererConfig() : m_bIsNotUseConfigAllFontsDir(false), m_bIsUseCache(true)
|
||||
{
|
||||
}
|
||||
|
||||
@ -92,10 +121,6 @@ namespace NSDoctRenderer
|
||||
void Parse(const std::wstring& sWorkDir)
|
||||
{
|
||||
m_arrFiles.clear();
|
||||
m_arDoctSDK.clear();
|
||||
m_arPpttSDK.clear();
|
||||
m_arXlstSDK.clear();
|
||||
m_arVsdtSDK.clear();
|
||||
|
||||
std::wstring sConfigDir = sWorkDir + L"/";
|
||||
std::wstring sConfigPath = sConfigDir + L"DoctRenderer.config";
|
||||
@ -149,40 +174,16 @@ namespace NSDoctRenderer
|
||||
}
|
||||
}
|
||||
}
|
||||
m_arrFiles.push_back(bIsAbsoluteFontsPath ? m_strAllFonts : private_GetFile(sConfigDir, m_strAllFonts));
|
||||
|
||||
if (!bIsAbsoluteFontsPath)
|
||||
m_strAllFonts = private_GetFile(sConfigDir, m_strAllFonts);
|
||||
}
|
||||
|
||||
std::wstring sSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!sSdkPath.empty())
|
||||
m_strSdkPath = oNode.ReadNodeText(L"sdkjs");
|
||||
if (!m_strSdkPath.empty())
|
||||
{
|
||||
if (!NSDirectory::Exists(sSdkPath))
|
||||
sSdkPath = sConfigDir + sSdkPath;
|
||||
|
||||
std::wstring sFontsPath = sSdkPath + L"/common/libfont/engine";
|
||||
if (!sFontsPath.empty())
|
||||
{
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
sFontsPath += L"/fonts_native.js";
|
||||
#else
|
||||
sFontsPath += L"/fonts_ie.js";
|
||||
#endif
|
||||
}
|
||||
|
||||
m_arDoctSDK.push_back(sSdkPath + L"/word/sdk-all-min.js");
|
||||
m_arDoctSDK.push_back(sFontsPath);
|
||||
m_arDoctSDK.push_back(sSdkPath + L"/word/sdk-all.js");
|
||||
|
||||
m_arPpttSDK.push_back(sSdkPath + L"/slide/sdk-all-min.js");
|
||||
m_arPpttSDK.push_back(sFontsPath);
|
||||
m_arPpttSDK.push_back(sSdkPath + L"/slide/sdk-all.js");
|
||||
|
||||
m_arXlstSDK.push_back(sSdkPath + L"/cell/sdk-all-min.js");
|
||||
m_arXlstSDK.push_back(sFontsPath);
|
||||
m_arXlstSDK.push_back(sSdkPath + L"/cell/sdk-all.js");
|
||||
|
||||
m_arVsdtSDK.push_back(sSdkPath + L"/draw/sdk-all-min.js");
|
||||
m_arVsdtSDK.push_back(sFontsPath);
|
||||
m_arVsdtSDK.push_back(sSdkPath + L"/draw/sdk-all.js");
|
||||
if (!NSDirectory::Exists(m_strSdkPath))
|
||||
m_strSdkPath = sConfigDir + m_strSdkPath;
|
||||
}
|
||||
|
||||
m_sConsoleLogFile = oNode.ReadNodeText(L"LogFileConsoleLog");
|
||||
@ -193,7 +194,35 @@ namespace NSDoctRenderer
|
||||
if (!m_sErrorsLogFile.empty())
|
||||
m_sErrorsLogFile = private_GetFile(sConfigDir, m_sErrorsLogFile);
|
||||
}
|
||||
|
||||
char* GetVersion()
|
||||
{
|
||||
std::wstring sFile = m_strSdkPath + L"/word/sdk-all-min.js";
|
||||
|
||||
std::string sData;
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(sFile, sData))
|
||||
return NULL;
|
||||
|
||||
std::string::size_type startPos = sData.find("Version:");
|
||||
if (std::string::npos == startPos)
|
||||
return NULL;
|
||||
|
||||
startPos += 8;
|
||||
|
||||
std::string::size_type endPos = sData.find(')', startPos);
|
||||
if (std::string::npos == endPos)
|
||||
return NULL;
|
||||
|
||||
size_t sSrcLen = endPos - startPos + 1;
|
||||
if (sSrcLen == 0)
|
||||
return NULL;
|
||||
|
||||
char* sRet = new char[sSrcLen + 1];
|
||||
memcpy(sRet, sData.c_str() + startPos, sSrcLen);
|
||||
sRet[sSrcLen] = '\0';
|
||||
return sRet;
|
||||
}
|
||||
};
|
||||
} // namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
#endif // DOC_BUILDER_CONFIG
|
||||
|
||||
3
DesktopEditor/doctrenderer/docbuilder.java/.gitignore
vendored
Normal file
3
DesktopEditor/doctrenderer/docbuilder.java/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
result.docx
|
||||
*.class
|
||||
*.jar
|
||||
108
DesktopEditor/doctrenderer/docbuilder.java/make.py
Normal file
108
DesktopEditor/doctrenderer/docbuilder.java/make.py
Normal file
@ -0,0 +1,108 @@
|
||||
import os
|
||||
import argparse
|
||||
import platform
|
||||
import subprocess
|
||||
import re
|
||||
|
||||
# NOTE: In JDK 8 and earlier, `javac` does not create the directories specified in the -d option if they do not already exist
|
||||
# So we need to create them manually
|
||||
def makedirs(dir):
|
||||
if not os.path.exists(dir):
|
||||
os.makedirs(dir)
|
||||
return
|
||||
|
||||
def is_javac_available(javac):
|
||||
try:
|
||||
process = subprocess.Popen([javac, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
ret = process.wait()
|
||||
return ret == 0
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def get_jdk_version(javac):
|
||||
try:
|
||||
process = subprocess.Popen([javac, '-version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
output = stdout if stdout else stderr
|
||||
if not output:
|
||||
return 0
|
||||
|
||||
javac_version_str = output.decode('utf-8').strip()
|
||||
match = re.search('(\d+)(?:\.(\d+))?', javac_version_str)
|
||||
if not match:
|
||||
return 0
|
||||
|
||||
major_version = int(match.group(1))
|
||||
minor_version = int(match.group(2)) if match.group(2) else 0
|
||||
|
||||
# for JDK 9 and earlier command `javac -version` would give '1.x.xx'
|
||||
if major_version == 1:
|
||||
return minor_version
|
||||
return major_version
|
||||
|
||||
except Exception:
|
||||
return 0
|
||||
|
||||
# return all files with extension `ext` in directory `dir` as string
|
||||
def getFilesInDir(dir, ext):
|
||||
files = [];
|
||||
for file in os.listdir(dir):
|
||||
if file.endswith(ext):
|
||||
files.append(os.path.join(dir, file))
|
||||
|
||||
return files
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Build Java wrapper for docbuilder library')
|
||||
parser.add_argument('-H', '--headers', action='store_true', help='Generate C++ JNI header files')
|
||||
parser.add_argument('-n', '--no-jar', dest='no_jar', action='store_true', help='Build only classes without JAR archive')
|
||||
args = parser.parse_args()
|
||||
|
||||
file_dir = os.path.dirname(os.path.realpath(__file__));
|
||||
os.chdir(file_dir + '/src/java')
|
||||
|
||||
java_files = getFilesInDir('docbuilder', '.java')
|
||||
java_files += getFilesInDir('docbuilder/utils', '.java')
|
||||
|
||||
# INITIALIZE JDK TOOLS
|
||||
javac = 'javac'
|
||||
jar = 'jar'
|
||||
ext = '.exe' if platform.system().lower() == 'windows' else ''
|
||||
java_home = os.environ.get('JAVA_HOME')
|
||||
if java_home:
|
||||
javac = os.path.join(java_home, 'bin', 'javac' + ext)
|
||||
if not os.path.exists(javac):
|
||||
print('Error: Cannot find: ' + javac)
|
||||
exit()
|
||||
jar = os.path.join(java_home, 'bin', 'jar' + ext)
|
||||
else:
|
||||
print('Warning: environment variable JAVA_HOME wasn\'t set. Default Java compiler will be used (if any).')
|
||||
|
||||
if not is_javac_available(javac):
|
||||
print('Error: javac is not available')
|
||||
exit()
|
||||
|
||||
# CHECK JDK VERSION
|
||||
jdk_version = get_jdk_version(javac)
|
||||
if jdk_version < 8:
|
||||
print('Error: javac version is not supported')
|
||||
exit()
|
||||
|
||||
release_flags = []
|
||||
if jdk_version > 8:
|
||||
release_flags = ['--release', '8']
|
||||
|
||||
# BUILD
|
||||
classes_dir = file_dir + '/build/classes'
|
||||
makedirs(classes_dir + '/docbuilder/utils')
|
||||
headers_dir = file_dir + '/src/jni'
|
||||
# build all Java classes
|
||||
subprocess.call([javac, '-d', classes_dir] + release_flags + java_files, cwd=os.getcwd(), stderr=subprocess.STDOUT)
|
||||
|
||||
# PACKING TO JAR
|
||||
if not args.no_jar:
|
||||
os.chdir(classes_dir)
|
||||
class_files = getFilesInDir('docbuilder', '.class')
|
||||
class_files += getFilesInDir('docbuilder/utils', '.class')
|
||||
makedirs('../libs')
|
||||
subprocess.call([jar, '-cvf', '../libs/docbuilder.jar'] + class_files, cwd=os.getcwd(), stderr=subprocess.STDOUT)
|
||||
@ -0,0 +1,142 @@
|
||||
package docbuilder;
|
||||
|
||||
import docbuilder.utils.NativeLibraryLoader;
|
||||
|
||||
public class CDocBuilder {
|
||||
public CDocBuilder() {
|
||||
c_internal = c_Create();
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
c_Destroy(c_internal);
|
||||
}
|
||||
|
||||
public int openFile(String path, String params) {
|
||||
return c_OpenFile(c_internal, path, params);
|
||||
}
|
||||
|
||||
public boolean createFile(int type) {
|
||||
return c_CreateFileByType(c_internal, type);
|
||||
}
|
||||
|
||||
public boolean createFile(String extension) {
|
||||
return c_CreateFileByExtension(c_internal, extension);
|
||||
}
|
||||
|
||||
public void setTmpFolder(String folder) {
|
||||
c_SetTmpFolder(c_internal, folder);
|
||||
}
|
||||
|
||||
public int saveFile(int type, String path) {
|
||||
return c_SaveFileByType(c_internal, type, path);
|
||||
}
|
||||
|
||||
public int saveFile(int type, String path, String params) {
|
||||
return c_SaveFileByTypeWithParams(c_internal, type, path, params);
|
||||
}
|
||||
|
||||
public int saveFile(String extension, String path) {
|
||||
return c_SaveFileByExtension(c_internal, extension, path);
|
||||
}
|
||||
|
||||
public int saveFile(String extension, String path, String params) {
|
||||
return c_SaveFileByExtensionWithParams(c_internal, extension, path, params);
|
||||
}
|
||||
|
||||
public void closeFile() {
|
||||
c_CloseFile(c_internal);
|
||||
}
|
||||
|
||||
public boolean executeCommand(String command) {
|
||||
return c_ExecuteCommand(c_internal, command);
|
||||
}
|
||||
|
||||
public boolean executeCommand(String command, CDocBuilderValue retValue) {
|
||||
return c_ExecuteCommandWithRetValue(c_internal, command, retValue.c_internal);
|
||||
}
|
||||
|
||||
public boolean run(String path) {
|
||||
return c_Run(c_internal, path);
|
||||
}
|
||||
|
||||
public boolean runText(String commands) {
|
||||
return c_RunText(c_internal, commands);
|
||||
}
|
||||
|
||||
public void setProperty(String param, String value) {
|
||||
c_SetProperty(c_internal, param, value);
|
||||
}
|
||||
|
||||
public void writeData(String path, String value, boolean append) {
|
||||
c_WriteData(c_internal, path, value, append);
|
||||
}
|
||||
|
||||
public boolean isSaveWithDoctrendererMode() {
|
||||
return c_IsSaveWithDoctrendererMode(c_internal);
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return c_GetVersion(c_internal);
|
||||
}
|
||||
|
||||
public CDocBuilderContext getContext() {
|
||||
return new CDocBuilderContext(c_GetContext(c_internal));
|
||||
}
|
||||
|
||||
public static void initialize() {
|
||||
c_Initialize();
|
||||
}
|
||||
|
||||
public static void initialize(String directory) {
|
||||
if (directory.isEmpty())
|
||||
directory = NativeLibraryLoader.getLibPath().toString();
|
||||
c_InitializeWithDirectory(directory);
|
||||
}
|
||||
|
||||
public static void dispose() {
|
||||
c_Dispose();
|
||||
}
|
||||
|
||||
// Native code
|
||||
static {
|
||||
docbuilder.utils.NativeLibraryLoader.loadLibraries();
|
||||
}
|
||||
|
||||
long c_internal = 0;
|
||||
|
||||
private static native long c_Create();
|
||||
private static native void c_Destroy(long self);
|
||||
|
||||
private static native int c_OpenFile(long self, String path, String params);
|
||||
private static native boolean c_CreateFileByType(long self, int type);
|
||||
private static native boolean c_CreateFileByExtension(long self, String extension);
|
||||
|
||||
private static native void c_SetTmpFolder(long self, String folder);
|
||||
|
||||
private static native int c_SaveFileByType(long self, int type, String path);
|
||||
private static native int c_SaveFileByTypeWithParams(long self, int type, String path, String params);
|
||||
private static native int c_SaveFileByExtension(long self, String extension, String path);
|
||||
private static native int c_SaveFileByExtensionWithParams(long self, String extension, String path, String params);
|
||||
|
||||
private static native void c_CloseFile(long self);
|
||||
|
||||
private static native boolean c_ExecuteCommand(long self, String command);
|
||||
private static native boolean c_ExecuteCommandWithRetValue(long self, String command, long retValue);
|
||||
|
||||
private static native boolean c_Run(long self, String path);
|
||||
private static native boolean c_RunText(long self, String commands);
|
||||
|
||||
private static native void c_SetProperty(long self, String param, String value);
|
||||
|
||||
private static native void c_WriteData(long self, String path, String value, boolean append);
|
||||
|
||||
private static native boolean c_IsSaveWithDoctrendererMode(long self);
|
||||
|
||||
private static native String c_GetVersion(long self);
|
||||
|
||||
private static native long c_GetContext(long self);
|
||||
|
||||
private static native void c_Initialize();
|
||||
private static native void c_InitializeWithDirectory(String directory);
|
||||
private static native void c_Dispose();
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package docbuilder;
|
||||
|
||||
public class CDocBuilderContext {
|
||||
public CDocBuilderContext() {
|
||||
c_internal = c_Create();
|
||||
}
|
||||
|
||||
CDocBuilderContext(long internal) {
|
||||
c_internal = internal;
|
||||
}
|
||||
|
||||
public CDocBuilderContext(CDocBuilderContext other) {
|
||||
c_internal = c_Copy(other.c_internal);
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
c_Destroy(c_internal);
|
||||
}
|
||||
|
||||
public CDocBuilderValue createUndefined() {
|
||||
return new CDocBuilderValue(c_CreateUndefined(c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue createNull() {
|
||||
return new CDocBuilderValue(c_CreateNull(c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue createObject() {
|
||||
return new CDocBuilderValue(c_CreateObject(c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue createArray(int length) {
|
||||
return new CDocBuilderValue(c_CreateArray(c_internal, length));
|
||||
}
|
||||
|
||||
public CDocBuilderValue getGlobal() {
|
||||
return new CDocBuilderValue(c_GetGlobal(c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderContextScope createScope() {
|
||||
return new CDocBuilderContextScope(c_CreateScope(c_internal));
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return c_IsError(c_internal);
|
||||
}
|
||||
|
||||
// Native code
|
||||
static {
|
||||
docbuilder.utils.NativeLibraryLoader.loadLibraries();
|
||||
}
|
||||
|
||||
long c_internal = 0;
|
||||
|
||||
private static native long c_Create();
|
||||
private static native long c_Copy(long other);
|
||||
private static native void c_Destroy(long self);
|
||||
|
||||
private static native long c_CreateUndefined(long self);
|
||||
private static native long c_CreateNull(long self);
|
||||
private static native long c_CreateObject(long self);
|
||||
private static native long c_CreateArray(long self, int length);
|
||||
|
||||
private static native long c_GetGlobal(long self);
|
||||
|
||||
private static native long c_CreateScope(long self);
|
||||
|
||||
private static native boolean c_IsError(long self);
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
package docbuilder;
|
||||
|
||||
public class CDocBuilderContextScope {
|
||||
public CDocBuilderContextScope() {
|
||||
c_internal = c_Create();
|
||||
}
|
||||
|
||||
CDocBuilderContextScope(long internal) {
|
||||
c_internal = internal;
|
||||
}
|
||||
|
||||
public CDocBuilderContextScope(CDocBuilderContextScope other) {
|
||||
c_internal = c_Copy(other.c_internal);
|
||||
}
|
||||
|
||||
protected void finalize() {
|
||||
c_Destroy(c_internal);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
c_Close(c_internal);
|
||||
}
|
||||
|
||||
// Native code
|
||||
static {
|
||||
docbuilder.utils.NativeLibraryLoader.loadLibraries();
|
||||
}
|
||||
|
||||
long c_internal = 0;
|
||||
|
||||
private static native long c_Create();
|
||||
private static native long c_Copy(long other);
|
||||
private static native void c_Destroy(long self);
|
||||
|
||||
private static native void c_Close(long self);
|
||||
}
|
||||
@ -0,0 +1,278 @@
|
||||
package docbuilder;
|
||||
|
||||
public class CDocBuilderValue {
|
||||
public CDocBuilderValue() {
|
||||
c_internal = c_Create();
|
||||
}
|
||||
|
||||
CDocBuilderValue(long internal) {
|
||||
c_internal = internal;
|
||||
}
|
||||
|
||||
public CDocBuilderValue(CDocBuilderValue other) {
|
||||
c_internal = c_Copy(other.c_internal);
|
||||
}
|
||||
|
||||
protected void finalize()
|
||||
{
|
||||
c_Destroy(c_internal);
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return c_IsEmpty(c_internal);
|
||||
}
|
||||
|
||||
public void clear()
|
||||
{
|
||||
c_Clear(c_internal);
|
||||
}
|
||||
|
||||
public boolean isNull()
|
||||
{
|
||||
return c_IsNull(c_internal);
|
||||
}
|
||||
|
||||
public boolean isUndefined()
|
||||
{
|
||||
return c_IsUndefined(c_internal);
|
||||
}
|
||||
|
||||
public boolean isInt()
|
||||
{
|
||||
return c_IsInt(c_internal);
|
||||
}
|
||||
|
||||
public boolean isDouble()
|
||||
{
|
||||
return c_IsDouble(c_internal);
|
||||
}
|
||||
|
||||
public boolean isString()
|
||||
{
|
||||
return c_IsString(c_internal);
|
||||
}
|
||||
|
||||
public boolean isFunction()
|
||||
{
|
||||
return c_IsFunction(c_internal);
|
||||
}
|
||||
|
||||
public boolean isObject()
|
||||
{
|
||||
return c_IsObject(c_internal);
|
||||
}
|
||||
|
||||
public boolean isArray()
|
||||
{
|
||||
return c_IsArray(c_internal);
|
||||
}
|
||||
|
||||
public int getLength()
|
||||
{
|
||||
return c_GetLength(c_internal);
|
||||
}
|
||||
|
||||
public boolean toBool()
|
||||
{
|
||||
return c_ToBool(c_internal);
|
||||
}
|
||||
|
||||
public int toInt()
|
||||
{
|
||||
return c_ToInt(c_internal);
|
||||
}
|
||||
|
||||
public double toDouble()
|
||||
{
|
||||
return c_ToDouble(c_internal);
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return c_ToString(c_internal);
|
||||
}
|
||||
|
||||
public CDocBuilderValue getProperty(String name) {
|
||||
return new CDocBuilderValue(c_GetProperty(c_internal, name));
|
||||
}
|
||||
|
||||
public CDocBuilderValue get(String name) {
|
||||
return new CDocBuilderValue(c_GetProperty(c_internal, name));
|
||||
}
|
||||
|
||||
public CDocBuilderValue get(int index) {
|
||||
return new CDocBuilderValue(c_GetByIndex(c_internal, index));
|
||||
}
|
||||
|
||||
public void setProperty(String name, Object value) {
|
||||
CDocBuilderValue docBuilderValue = getValueFromObject(value);
|
||||
c_SetProperty(c_internal, name, docBuilderValue.c_internal);
|
||||
}
|
||||
|
||||
public void set(String name, Object value) {
|
||||
CDocBuilderValue docBuilderValue = getValueFromObject(value);
|
||||
c_SetProperty(c_internal, name, docBuilderValue.c_internal);
|
||||
}
|
||||
|
||||
public void set(int index, Object value) {
|
||||
CDocBuilderValue docBuilderValue = getValueFromObject(value);
|
||||
c_SetByIndex(c_internal, index, docBuilderValue.c_internal);
|
||||
}
|
||||
|
||||
public CDocBuilderValue(boolean value) {
|
||||
c_internal = c_CreateWithBool(value);
|
||||
}
|
||||
|
||||
public CDocBuilderValue(int value) {
|
||||
c_internal = c_CreateWithInt(value);
|
||||
}
|
||||
|
||||
public CDocBuilderValue(double value) {
|
||||
c_internal = c_CreateWithDouble(value);
|
||||
}
|
||||
|
||||
public CDocBuilderValue(String value) {
|
||||
c_internal = c_CreateWithString(value);
|
||||
}
|
||||
|
||||
public CDocBuilderValue(Object[] values) {
|
||||
int length = values.length;
|
||||
c_internal = c_CreateArray(length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
this.set(i, getValueFromObject(values[i]));
|
||||
}
|
||||
}
|
||||
|
||||
static CDocBuilderValue getValueFromObject(Object obj) {
|
||||
if (obj instanceof CDocBuilderValue) {
|
||||
return (CDocBuilderValue)obj;
|
||||
} else if (obj instanceof Boolean) {
|
||||
return new CDocBuilderValue((Boolean)obj);
|
||||
} else if (obj instanceof Integer) {
|
||||
return new CDocBuilderValue((Integer)obj);
|
||||
} else if (obj instanceof Double) {
|
||||
return new CDocBuilderValue((Double)obj);
|
||||
} else if (obj instanceof String) {
|
||||
return new CDocBuilderValue((String)obj);
|
||||
} else if (obj instanceof Object[]) {
|
||||
return new CDocBuilderValue((Object[])obj);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unsupported type for CDocBuilderValue");
|
||||
}
|
||||
}
|
||||
|
||||
public static CDocBuilderValue createUndefined() {
|
||||
return new CDocBuilderValue(c_CreateUndefined());
|
||||
}
|
||||
|
||||
public static CDocBuilderValue createNull() {
|
||||
return new CDocBuilderValue(c_CreateNull());
|
||||
}
|
||||
|
||||
public static CDocBuilderValue createArray(int length) {
|
||||
return new CDocBuilderValue(c_CreateArray(length));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name) {
|
||||
return new CDocBuilderValue(c_Call0(c_internal, name));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name, Object p1) {
|
||||
CDocBuilderValue pValue1 = getValueFromObject(p1);
|
||||
return new CDocBuilderValue(c_Call1(c_internal, name, pValue1.c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name, Object p1, Object p2) {
|
||||
CDocBuilderValue pValue1 = getValueFromObject(p1);
|
||||
CDocBuilderValue pValue2 = getValueFromObject(p2);
|
||||
return new CDocBuilderValue(c_Call2(c_internal, name, pValue1.c_internal, pValue2.c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name, Object p1, Object p2, Object p3) {
|
||||
CDocBuilderValue pValue1 = getValueFromObject(p1);
|
||||
CDocBuilderValue pValue2 = getValueFromObject(p2);
|
||||
CDocBuilderValue pValue3 = getValueFromObject(p3);
|
||||
return new CDocBuilderValue(c_Call3(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name, Object p1, Object p2, Object p3, Object p4) {
|
||||
CDocBuilderValue pValue1 = getValueFromObject(p1);
|
||||
CDocBuilderValue pValue2 = getValueFromObject(p2);
|
||||
CDocBuilderValue pValue3 = getValueFromObject(p3);
|
||||
CDocBuilderValue pValue4 = getValueFromObject(p4);
|
||||
return new CDocBuilderValue(c_Call4(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal, pValue4.c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name, Object p1, Object p2, Object p3, Object p4, Object p5) {
|
||||
CDocBuilderValue pValue1 = getValueFromObject(p1);
|
||||
CDocBuilderValue pValue2 = getValueFromObject(p2);
|
||||
CDocBuilderValue pValue3 = getValueFromObject(p3);
|
||||
CDocBuilderValue pValue4 = getValueFromObject(p4);
|
||||
CDocBuilderValue pValue5 = getValueFromObject(p5);
|
||||
return new CDocBuilderValue(c_Call5(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal, pValue4.c_internal, pValue5.c_internal));
|
||||
}
|
||||
|
||||
public CDocBuilderValue call(String name, Object p1, Object p2, Object p3, Object p4, Object p5, Object p6) {
|
||||
CDocBuilderValue pValue1 = getValueFromObject(p1);
|
||||
CDocBuilderValue pValue2 = getValueFromObject(p2);
|
||||
CDocBuilderValue pValue3 = getValueFromObject(p3);
|
||||
CDocBuilderValue pValue4 = getValueFromObject(p4);
|
||||
CDocBuilderValue pValue5 = getValueFromObject(p5);
|
||||
CDocBuilderValue pValue6 = getValueFromObject(p6);
|
||||
return new CDocBuilderValue(c_Call6(c_internal, name, pValue1.c_internal, pValue2.c_internal, pValue3.c_internal, pValue4.c_internal, pValue5.c_internal, pValue6.c_internal));
|
||||
}
|
||||
|
||||
// Native code
|
||||
static {
|
||||
docbuilder.utils.NativeLibraryLoader.loadLibraries();
|
||||
}
|
||||
|
||||
long c_internal = 0;
|
||||
|
||||
private static native long c_Create();
|
||||
private static native long c_Copy(long other);
|
||||
private static native void c_Destroy(long self);
|
||||
|
||||
private static native boolean c_IsEmpty(long self);
|
||||
private static native void c_Clear(long self);
|
||||
|
||||
private static native boolean c_IsNull(long self);
|
||||
private static native boolean c_IsUndefined(long self);
|
||||
private static native boolean c_IsInt(long self);
|
||||
private static native boolean c_IsDouble(long self);
|
||||
private static native boolean c_IsString(long self);
|
||||
private static native boolean c_IsFunction(long self);
|
||||
private static native boolean c_IsObject(long self);
|
||||
private static native boolean c_IsArray(long self);
|
||||
|
||||
private static native int c_GetLength(long self);
|
||||
|
||||
private static native boolean c_ToBool(long self);
|
||||
private static native int c_ToInt(long self);
|
||||
private static native double c_ToDouble(long self);
|
||||
private static native String c_ToString(long self);
|
||||
|
||||
private static native long c_GetProperty(long self, String name);
|
||||
private static native long c_GetByIndex(long self, int index);
|
||||
|
||||
private static native void c_SetProperty(long self, String name, long value);
|
||||
private static native void c_SetByIndex(long self, int index, long value);
|
||||
|
||||
private static native long c_CreateWithBool(boolean value);
|
||||
private static native long c_CreateWithInt(int value);
|
||||
private static native long c_CreateWithDouble(double value);
|
||||
private static native long c_CreateWithString(String value);
|
||||
|
||||
private static native long c_CreateUndefined();
|
||||
private static native long c_CreateNull();
|
||||
private static native long c_CreateArray(int length);
|
||||
|
||||
private static native long c_Call0(long self, String name);
|
||||
private static native long c_Call1(long self, String name, long p1);
|
||||
private static native long c_Call2(long self, String name, long p1, long p2);
|
||||
private static native long c_Call3(long self, String name, long p1, long p2, long p3);
|
||||
private static native long c_Call4(long self, String name, long p1, long p2, long p3, long p4);
|
||||
private static native long c_Call5(long self, String name, long p1, long p2, long p3, long p4, long p5);
|
||||
private static native long c_Call6(long self, String name, long p1, long p2, long p3, long p4, long p5, long p6);
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package docbuilder;
|
||||
|
||||
public class FileTypes {
|
||||
public class Document {
|
||||
private static final int MASK = 0x0040;
|
||||
public static final int DOCX = MASK + 0x0001;
|
||||
public static final int DOC = MASK + 0x0002;
|
||||
public static final int ODT = MASK + 0x0003;
|
||||
public static final int RTF = MASK + 0x0004;
|
||||
public static final int TXT = MASK + 0x0005;
|
||||
public static final int DOTX = MASK + 0x000c;
|
||||
public static final int OTT = MASK + 0x000f;
|
||||
public static final int HTML = MASK + 0x0012;
|
||||
public static final int OFORM_PDF = MASK + 0x0017;
|
||||
}
|
||||
|
||||
public class Presentation {
|
||||
private static final int MASK = 0x0080;
|
||||
public static final int PPTX = MASK + 0x0001;
|
||||
public static final int PPT = MASK + 0x0002;
|
||||
public static final int ODP = MASK + 0x0003;
|
||||
public static final int PPSX = MASK + 0x0004;
|
||||
public static final int POTX = MASK + 0x0007;
|
||||
public static final int OTP = MASK + 0x000a;
|
||||
}
|
||||
|
||||
public class Spreadsheet {
|
||||
private static final int MASK = 0x0100;
|
||||
public static final int XLSX = MASK + 0x0001;
|
||||
public static final int XLS = MASK + 0x0002;
|
||||
public static final int ODS = MASK + 0x0003;
|
||||
public static final int CSV = MASK + 0x0004;
|
||||
public static final int XLTX = MASK + 0x0006;
|
||||
public static final int OTS = MASK + 0x0009;
|
||||
}
|
||||
|
||||
public class Graphics {
|
||||
private static final int PDF_MASK = 0x0200;
|
||||
public static final int PDF = PDF_MASK + 0x0001;
|
||||
public static final int PDFA = PDF_MASK + 0x0009;
|
||||
|
||||
private static final int IMAGE_MASK = 0x0400;
|
||||
public static final int JPG = IMAGE_MASK + 0x0001;
|
||||
public static final int PNG = IMAGE_MASK + 0x0005;
|
||||
public static final int BMP = IMAGE_MASK + 0x0008;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
package docbuilder.utils;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class NativeLibraryLoader {
|
||||
// helper class for retrieving information about current OS
|
||||
public static class OSChecker {
|
||||
private static String osName = System.getProperty("os.name").toLowerCase();
|
||||
|
||||
public static boolean isWindows() {
|
||||
return (osName.indexOf("win") >= 0);
|
||||
}
|
||||
|
||||
public static boolean isMac() {
|
||||
return (osName.indexOf("mac") >= 0);
|
||||
}
|
||||
|
||||
public static boolean isLinux() {
|
||||
return (osName.indexOf("nix") >= 0 || osName.indexOf("nux") >= 0 || osName.indexOf("aix") > 0);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
Path libDirPath = getLibPath();
|
||||
// load icu libraries
|
||||
if (OSChecker.isWindows()) {
|
||||
System.load(libDirPath.resolve("icudt58.dll").toString());
|
||||
System.load(libDirPath.resolve("icuuc58.dll").toString());
|
||||
} else if (OSChecker.isMac()) {
|
||||
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());
|
||||
} else {
|
||||
throw new RuntimeException("Unsupported OS");
|
||||
}
|
||||
|
||||
String[] libs = {"UnicodeConverter", "kernel", "kernel_network", "graphics", "doctrenderer", "docbuilder.jni"};
|
||||
|
||||
String prefix = "";
|
||||
if (OSChecker.isMac() || OSChecker.isLinux()) {
|
||||
prefix = "lib";
|
||||
}
|
||||
|
||||
String extension = "";
|
||||
if (OSChecker.isWindows()) {
|
||||
extension = ".dll";
|
||||
} else if (OSChecker.isMac()) {
|
||||
extension = ".dylib";
|
||||
} else {
|
||||
extension = ".so";
|
||||
}
|
||||
|
||||
for (String lib : libs) {
|
||||
System.load(libDirPath.resolve(prefix + lib + extension).toString());
|
||||
}
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
throw new RuntimeException("Cannot load dynamic libraries. Check if JAR file is in the same directory as all docbuilder libraries.");
|
||||
}
|
||||
}
|
||||
|
||||
// Returns path to the directory containing current JAR
|
||||
public static Path getLibPath()
|
||||
{
|
||||
URL url = NativeLibraryLoader.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
try {
|
||||
File jarFile = new File(url.toURI());
|
||||
Path jarPath = jarFile.toPath();
|
||||
Path libDirPath = jarPath.getParent();
|
||||
|
||||
return libDirPath;
|
||||
} catch (URISyntaxException exception) {
|
||||
// Very unlikely to be happened
|
||||
throw new RuntimeException("Cannot convert URI of the NativeLibraryLoader.class to URL");
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadLibraries() {
|
||||
// No-op, just to force the class loading
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,179 @@
|
||||
#include "docbuilder_CDocBuilder.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "docbuilder.h"
|
||||
// for wchar_t <=> char conversion
|
||||
#include "../../../../common/File.h"
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
static std::wstring wstringFromJavaString(JNIEnv* env, jstring jstr)
|
||||
{
|
||||
const char* strUtf = env->GetStringUTFChars(jstr, nullptr);
|
||||
std::wstring wstr = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)strUtf, (LONG)strlen(strUtf));
|
||||
env->ReleaseStringUTFChars(jstr, strUtf);
|
||||
return wstr;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilder());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1OpenFile(JNIEnv* env, jclass cls, jlong self, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
std::wstring strParams = wstringFromJavaString(env, params);
|
||||
return (jint)pSelf->OpenFile(strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByType(JNIEnv* env, jclass cls, jlong self, jint type)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->CreateFile((int)type);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1CreateFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
return (jboolean)pSelf->CreateFile(strExtension.c_str());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1SetTmpFolder(JNIEnv* env, jclass cls, jlong self, jstring folder)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strFolder = wstringFromJavaString(env, folder);
|
||||
pSelf->SetTmpFolder(strFolder.c_str());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByType(JNIEnv* env, jclass cls, jlong self, jint type, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams(JNIEnv* env, jclass cls, jlong self, jint type, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
std::wstring strParams = wstringFromJavaString(env, params);
|
||||
return (jint)pSelf->SaveFile((int)type, strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtension(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str());
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams(JNIEnv* env, jclass cls, jlong self, jstring extension, jstring path, jstring params)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strExtension = wstringFromJavaString(env, extension);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
std::wstring strParams = wstringFromJavaString(env, params);
|
||||
return (jint)pSelf->SaveFile(strExtension.c_str(), strPath.c_str(), strParams.c_str());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1CloseFile(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
pSelf->CloseFile();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommand(JNIEnv* env, jclass cls, jlong self, jstring command)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue(JNIEnv* env, jclass cls, jlong self, jstring command, jlong retValue)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strCommand = wstringFromJavaString(env, command);
|
||||
CDocBuilderValue* pRetValue = reinterpret_cast<CDocBuilderValue*>(retValue);
|
||||
return (jboolean)pSelf->ExecuteCommand(strCommand.c_str(), pRetValue);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1Run(JNIEnv* env, jclass cls, jlong self, jstring path)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
return (jboolean)pSelf->Run(strPath.c_str());
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1RunText(JNIEnv* env, jclass cls, jlong self, jstring commands)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfCommands = env->GetStringUTFChars(commands, nullptr);
|
||||
jboolean result = (jboolean)pSelf->RunTextA(strUtfCommands);
|
||||
env->ReleaseStringUTFChars(commands, strUtfCommands);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring param, jstring value)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
const char* strUtfParam = env->GetStringUTFChars(param, nullptr);
|
||||
std::wstring strValue = wstringFromJavaString(env, value);
|
||||
pSelf->SetProperty(strUtfParam, strValue.c_str());
|
||||
env->ReleaseStringUTFChars(param, strUtfParam);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1WriteData(JNIEnv* env, jclass cls, jlong self, jstring path, jstring data, jboolean append)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
std::wstring strPath = wstringFromJavaString(env, path);
|
||||
std::wstring strData = wstringFromJavaString(env, data);
|
||||
pSelf->WriteData(strPath.c_str(), strData.c_str(), (bool)append);
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return (jboolean)pSelf->IsSaveWithDoctrendererMode();
|
||||
}
|
||||
|
||||
jstring Java_docbuilder_CDocBuilder_c_1GetVersion(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
char* strUtfVersion = pSelf->GetVersion();
|
||||
jstring jstrVersion = env->NewStringUTF(strUtfVersion);
|
||||
delete[] strUtfVersion;
|
||||
return jstrVersion;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilder_c_1GetContext(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilder* pSelf = reinterpret_cast<CDocBuilder*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(pSelf->GetContext()));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Initialize(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory(JNIEnv* env, jclass cls, jstring directory)
|
||||
{
|
||||
std::wstring strDirectory = wstringFromJavaString(env, directory);
|
||||
CDocBuilder::Initialize(strDirectory.c_str());
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilder_c_1Dispose(JNIEnv* env, jclass cls)
|
||||
{
|
||||
CDocBuilder::Dispose();
|
||||
}
|
||||
@ -0,0 +1,197 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class docbuilder_CDocBuilder */
|
||||
|
||||
#ifndef _Included_docbuilder_CDocBuilder
|
||||
#define _Included_docbuilder_CDocBuilder
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Create
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1Create
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Destroy
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Destroy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_OpenFile
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1OpenFile
|
||||
(JNIEnv *, jclass, jlong, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_CreateFileByType
|
||||
* Signature: (JI)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByType
|
||||
(JNIEnv *, jclass, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_CreateFileByExtension
|
||||
* Signature: (JLjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1CreateFileByExtension
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_SetTmpFolder
|
||||
* Signature: (JLjava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetTmpFolder
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_SaveFileByType
|
||||
* Signature: (JILjava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByType
|
||||
(JNIEnv *, jclass, jlong, jint, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_SaveFileByTypeWithParams
|
||||
* Signature: (JILjava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByTypeWithParams
|
||||
(JNIEnv *, jclass, jlong, jint, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_SaveFileByExtension
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtension
|
||||
(JNIEnv *, jclass, jlong, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_SaveFileByExtensionWithParams
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilder_c_1SaveFileByExtensionWithParams
|
||||
(JNIEnv *, jclass, jlong, jstring, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_CloseFile
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1CloseFile
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_ExecuteCommand
|
||||
* Signature: (JLjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommand
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_ExecuteCommandWithRetValue
|
||||
* Signature: (JLjava/lang/String;J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1ExecuteCommandWithRetValue
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Run
|
||||
* Signature: (JLjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1Run
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_RunText
|
||||
* Signature: (JLjava/lang/String;)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1RunText
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_SetProperty
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1SetProperty
|
||||
(JNIEnv *, jclass, jlong, jstring, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_WriteData
|
||||
* Signature: (JLjava/lang/String;Ljava/lang/String;Z)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1WriteData
|
||||
(JNIEnv *, jclass, jlong, jstring, jstring, jboolean);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_IsSaveWithDoctrendererMode
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilder_c_1IsSaveWithDoctrendererMode
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_GetVersion
|
||||
* Signature: (J)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilder_c_1GetVersion
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_GetContext
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilder_c_1GetContext
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Initialize
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Initialize
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_InitializeWithDirectory
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1InitializeWithDirectory
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilder
|
||||
* Method: c_Dispose
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilder_c_1Dispose
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,64 @@
|
||||
#include "docbuilder_CDocBuilderContext.h"
|
||||
|
||||
#include "docbuilder.h"
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContext* pOther = reinterpret_cast<CDocBuilderContext*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContext(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContext_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateUndefined()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateNull()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateObject()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateArray(JNIEnv* env, jclass cls, jlong self, jint length)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->CreateArray((int)length)));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1GetGlobal(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(pSelf->GetGlobal()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContext_c_1CreateScope(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(pSelf->CreateScope()));
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderContext_c_1IsError(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContext* pSelf = reinterpret_cast<CDocBuilderContext*>(self);
|
||||
return (jboolean)pSelf->IsError();
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class docbuilder_CDocBuilderContext */
|
||||
|
||||
#ifndef _Included_docbuilder_CDocBuilderContext
|
||||
#define _Included_docbuilder_CDocBuilderContext
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_Create
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Create
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_Copy
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1Copy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_Destroy
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContext_c_1Destroy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_CreateUndefined
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateUndefined
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_CreateNull
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateNull
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_CreateObject
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateObject
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_CreateArray
|
||||
* Signature: (JI)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateArray
|
||||
(JNIEnv *, jclass, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_GetGlobal
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1GetGlobal
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_CreateScope
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContext_c_1CreateScope
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContext
|
||||
* Method: c_IsError
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderContext_c_1IsError
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,28 @@
|
||||
#include "docbuilder_CDocBuilderContextScope.h"
|
||||
|
||||
#include "docbuilder.h"
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderContextScope_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderContextScope* pOther = reinterpret_cast<CDocBuilderContextScope*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderContextScope(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderContextScope_c_1Close(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderContextScope* pSelf = reinterpret_cast<CDocBuilderContextScope*>(self);
|
||||
pSelf->Close();
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class docbuilder_CDocBuilderContextScope */
|
||||
|
||||
#ifndef _Included_docbuilder_CDocBuilderContextScope
|
||||
#define _Included_docbuilder_CDocBuilderContextScope
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContextScope
|
||||
* Method: c_Create
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Create
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContextScope
|
||||
* Method: c_Copy
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Copy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContextScope
|
||||
* Method: c_Destroy
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Destroy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderContextScope
|
||||
* Method: c_Close
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderContextScope_c_1Close
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,273 @@
|
||||
#include "docbuilder_CDocBuilderValue.h"
|
||||
|
||||
#include <wchar.h>
|
||||
|
||||
#include "docbuilder.h"
|
||||
// for wchar_t <=> char conversion
|
||||
#include "../../../../common/File.h"
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Create(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Copy(JNIEnv* env, jclass cls, jlong other)
|
||||
{
|
||||
CDocBuilderValue* pOther = reinterpret_cast<CDocBuilderValue*>(other);
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(*pOther));
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Destroy(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
delete pSelf;
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsEmpty(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsEmpty();
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1Clear(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
pSelf->Clear();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsNull(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsNull();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsUndefined(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsUndefined();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsInt();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsDouble();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsString();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsFunction(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsFunction();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsObject(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsObject();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1IsArray(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->IsArray();
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1GetLength(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->GetLength();
|
||||
}
|
||||
|
||||
jboolean Java_docbuilder_CDocBuilderValue_c_1ToBool(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jboolean)pSelf->ToBool();
|
||||
}
|
||||
|
||||
jint Java_docbuilder_CDocBuilderValue_c_1ToInt(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jint)pSelf->ToInt();
|
||||
}
|
||||
|
||||
jdouble Java_docbuilder_CDocBuilderValue_c_1ToDouble(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
return (jdouble)pSelf->ToDouble();
|
||||
}
|
||||
|
||||
jstring Java_docbuilder_CDocBuilderValue_c_1ToString(JNIEnv* env, jclass cls, jlong self)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CString strValue = pSelf->ToString();
|
||||
std::string strUtfData = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(strValue.c_str(), (LONG)wcslen(strValue.c_str()));
|
||||
return env->NewStringUTF(strUtfData.c_str());
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetProperty(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get(strUtfName));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1GetByIndex(JNIEnv* env, jclass cls, jlong self, jint index)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(pSelf->Get((int)index));
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetProperty(JNIEnv* env, jclass cls, jlong self, jstring name, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
std::wstring strName = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)strUtfName, (LONG)strlen(strUtfName));
|
||||
pSelf->Set(strName.c_str(), *pValue);
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
}
|
||||
|
||||
void Java_docbuilder_CDocBuilderValue_c_1SetByIndex(JNIEnv* env, jclass cls, jlong self, jint index, jlong value)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pValue = reinterpret_cast<CDocBuilderValue*>(value);
|
||||
pSelf->Set((int)index, *pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithBool(JNIEnv* env, jclass cls, jboolean value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((bool)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithInt(JNIEnv* env, jclass cls, jint value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((int)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble(JNIEnv* env, jclass cls, jdouble value)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue((double)value));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateWithString(JNIEnv* env, jclass cls, jstring str)
|
||||
{
|
||||
const char* strUtf = env->GetStringUTFChars(str, nullptr);
|
||||
CDocBuilderValue* pValue = new CDocBuilderValue(strUtf);
|
||||
env->ReleaseStringUTFChars(str, strUtf);
|
||||
return reinterpret_cast<jlong>(pValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateUndefined(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateUndefined()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateNull(JNIEnv* env, jclass cls)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateNull()));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1CreateArray(JNIEnv* env, jclass cls, jint length)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new CDocBuilderValue(CDocBuilderValue::CreateArray((int)length)));
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call0(JNIEnv* env, jclass cls, jlong self, jstring name)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call1(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call2(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
CDocBuilderValue* pParam2 = reinterpret_cast<CDocBuilderValue*>(p2);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call3(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
CDocBuilderValue* pParam2 = reinterpret_cast<CDocBuilderValue*>(p2);
|
||||
CDocBuilderValue* pParam3 = reinterpret_cast<CDocBuilderValue*>(p3);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call4(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
CDocBuilderValue* pParam2 = reinterpret_cast<CDocBuilderValue*>(p2);
|
||||
CDocBuilderValue* pParam3 = reinterpret_cast<CDocBuilderValue*>(p3);
|
||||
CDocBuilderValue* pParam4 = reinterpret_cast<CDocBuilderValue*>(p4);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3, *pParam4));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call5(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
CDocBuilderValue* pParam2 = reinterpret_cast<CDocBuilderValue*>(p2);
|
||||
CDocBuilderValue* pParam3 = reinterpret_cast<CDocBuilderValue*>(p3);
|
||||
CDocBuilderValue* pParam4 = reinterpret_cast<CDocBuilderValue*>(p4);
|
||||
CDocBuilderValue* pParam5 = reinterpret_cast<CDocBuilderValue*>(p5);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3, *pParam4, *pParam5));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
|
||||
jlong Java_docbuilder_CDocBuilderValue_c_1Call6(JNIEnv* env, jclass cls, jlong self, jstring name, jlong p1, jlong p2, jlong p3, jlong p4, jlong p5, jlong p6)
|
||||
{
|
||||
CDocBuilderValue* pSelf = reinterpret_cast<CDocBuilderValue*>(self);
|
||||
CDocBuilderValue* pParam1 = reinterpret_cast<CDocBuilderValue*>(p1);
|
||||
CDocBuilderValue* pParam2 = reinterpret_cast<CDocBuilderValue*>(p2);
|
||||
CDocBuilderValue* pParam3 = reinterpret_cast<CDocBuilderValue*>(p3);
|
||||
CDocBuilderValue* pParam4 = reinterpret_cast<CDocBuilderValue*>(p4);
|
||||
CDocBuilderValue* pParam5 = reinterpret_cast<CDocBuilderValue*>(p5);
|
||||
CDocBuilderValue* pParam6 = reinterpret_cast<CDocBuilderValue*>(p6);
|
||||
const char* strUtfName = env->GetStringUTFChars(name, nullptr);
|
||||
CDocBuilderValue* pReturnValue = new CDocBuilderValue(pSelf->Call(strUtfName, *pParam1, *pParam2, *pParam3, *pParam4, *pParam5, *pParam6));
|
||||
env->ReleaseStringUTFChars(name, strUtfName);
|
||||
return reinterpret_cast<jlong>(pReturnValue);
|
||||
}
|
||||
@ -0,0 +1,301 @@
|
||||
/* DO NOT EDIT THIS FILE - it is machine generated */
|
||||
#include <jni.h>
|
||||
/* Header for class docbuilder_CDocBuilderValue */
|
||||
|
||||
#ifndef _Included_docbuilder_CDocBuilderValue
|
||||
#define _Included_docbuilder_CDocBuilderValue
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Create
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Create
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Copy
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Copy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Destroy
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Destroy
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsEmpty
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsEmpty
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Clear
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1Clear
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsNull
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsNull
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsUndefined
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsUndefined
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsInt
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsInt
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsDouble
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsDouble
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsString
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsString
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsFunction
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsFunction
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsObject
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsObject
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_IsArray
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1IsArray
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_GetLength
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1GetLength
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_ToBool
|
||||
* Signature: (J)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_docbuilder_CDocBuilderValue_c_1ToBool
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_ToInt
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_docbuilder_CDocBuilderValue_c_1ToInt
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_ToDouble
|
||||
* Signature: (J)D
|
||||
*/
|
||||
JNIEXPORT jdouble JNICALL Java_docbuilder_CDocBuilderValue_c_1ToDouble
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_ToString
|
||||
* Signature: (J)Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_docbuilder_CDocBuilderValue_c_1ToString
|
||||
(JNIEnv *, jclass, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_GetProperty
|
||||
* Signature: (JLjava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetProperty
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_GetByIndex
|
||||
* Signature: (JI)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1GetByIndex
|
||||
(JNIEnv *, jclass, jlong, jint);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_SetProperty
|
||||
* Signature: (JLjava/lang/String;J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetProperty
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_SetByIndex
|
||||
* Signature: (JIJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_docbuilder_CDocBuilderValue_c_1SetByIndex
|
||||
(JNIEnv *, jclass, jlong, jint, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateWithBool
|
||||
* Signature: (Z)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithBool
|
||||
(JNIEnv *, jclass, jboolean);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateWithInt
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithInt
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateWithDouble
|
||||
* Signature: (D)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithDouble
|
||||
(JNIEnv *, jclass, jdouble);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateWithString
|
||||
* Signature: (Ljava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateWithString
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateUndefined
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateUndefined
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateNull
|
||||
* Signature: ()J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateNull
|
||||
(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_CreateArray
|
||||
* Signature: (I)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1CreateArray
|
||||
(JNIEnv *, jclass, jint);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call0
|
||||
* Signature: (JLjava/lang/String;)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call0
|
||||
(JNIEnv *, jclass, jlong, jstring);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call1
|
||||
* Signature: (JLjava/lang/String;J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call1
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call2
|
||||
* Signature: (JLjava/lang/String;JJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call2
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call3
|
||||
* Signature: (JLjava/lang/String;JJJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call3
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call4
|
||||
* Signature: (JLjava/lang/String;JJJJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call4
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call5
|
||||
* Signature: (JLjava/lang/String;JJJJJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call5
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong, jlong);
|
||||
|
||||
/*
|
||||
* Class: docbuilder_CDocBuilderValue
|
||||
* Method: c_Call6
|
||||
* Signature: (JLjava/lang/String;JJJJJJ)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_docbuilder_CDocBuilderValue_c_1Call6
|
||||
(JNIEnv *, jclass, jlong, jstring, jlong, jlong, jlong, jlong, jlong, jlong);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -0,0 +1,47 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = docbuilder.jni
|
||||
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += shared
|
||||
CONFIG += plugin
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
include($$CORE_ROOT_DIR/Common/3dParty/icu/icu.pri)
|
||||
|
||||
ADD_DEPENDENCY(graphics, kernel, kernel_network, UnicodeConverter, doctrenderer)
|
||||
|
||||
INCLUDEPATH += ../../..
|
||||
|
||||
# get path to JDK from environment variable JAVA_HOME (preferable way) or take the default one
|
||||
JDK_PATH = $$(JAVA_HOME)
|
||||
isEmpty(JDK_PATH) {
|
||||
core_windows:JDK_PATH = "C:/Program Files/Java/jdk1.8.0_202"
|
||||
core_linux:JDK_PATH = "/usr/lib/jvm/java-8-openjdk-amd64"
|
||||
core_mac:JDK_PATH = "/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home"
|
||||
}
|
||||
|
||||
INCLUDEPATH += $$JDK_PATH/include
|
||||
|
||||
core_windows:JAVA_ARCH = win32
|
||||
core_linux:JAVA_ARCH = linux
|
||||
core_mac:JAVA_ARCH = darwin
|
||||
|
||||
INCLUDEPATH += $$JDK_PATH/include/$$JAVA_ARCH
|
||||
|
||||
SOURCES += \
|
||||
docbuilder_CDocBuilderValue.cpp \
|
||||
docbuilder_CDocBuilder.cpp \
|
||||
docbuilder_CDocBuilderContextScope.cpp \
|
||||
docbuilder_CDocBuilderContext.cpp
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_CDocBuilderValue.h \
|
||||
docbuilder_CDocBuilder.h \
|
||||
docbuilder_CDocBuilderContextScope.h \
|
||||
docbuilder_CDocBuilderContext.h
|
||||
44
DesktopEditor/doctrenderer/docbuilder.java/test/Program.java
Normal file
44
DesktopEditor/doctrenderer/docbuilder.java/test/Program.java
Normal file
@ -0,0 +1,44 @@
|
||||
import docbuilder.*;
|
||||
|
||||
public class Program {
|
||||
public static void main(String[] args) {
|
||||
String resultPath = "result.docx";
|
||||
|
||||
test(resultPath);
|
||||
|
||||
// Need to explicitly call System.gc() because finalizers might not automatically get called
|
||||
// Note: Even System.gc() can not guarantee that finalizers will be actually called. Possible memory leaks!
|
||||
System.gc();
|
||||
}
|
||||
|
||||
public static void test(String resultPath) {
|
||||
CDocBuilder.initialize("");
|
||||
CDocBuilder builder = new CDocBuilder();
|
||||
builder.createFile(FileTypes.Document.DOCX);
|
||||
|
||||
CDocBuilderContext context = builder.getContext();
|
||||
CDocBuilderContextScope scope = context.createScope();
|
||||
|
||||
CDocBuilderValue global = context.getGlobal();
|
||||
|
||||
CDocBuilderValue api = global.get("Api");
|
||||
CDocBuilderValue document = api.call("GetDocument");
|
||||
CDocBuilderValue paragraph1 = api.call("CreateParagraph");
|
||||
|
||||
paragraph1.call("SetSpacingAfter", 1000, false);
|
||||
paragraph1.call("AddText", "Hello from Java!");
|
||||
|
||||
CDocBuilderValue paragraph2 = api.call("CreateParagraph");
|
||||
paragraph2.call("AddText", "Goodbye!");
|
||||
|
||||
CDocBuilderValue[] paragraphs = { paragraph1, paragraph2 };
|
||||
CDocBuilderValue content = new CDocBuilderValue(paragraphs);
|
||||
|
||||
document.call("InsertContent", content);
|
||||
|
||||
builder.saveFile(FileTypes.Document.DOCX, resultPath);
|
||||
builder.closeFile();
|
||||
|
||||
CDocBuilder.dispose();
|
||||
}
|
||||
}
|
||||
45
DesktopEditor/doctrenderer/docbuilder.java/test/make_test.py
Normal file
45
DesktopEditor/doctrenderer/docbuilder.java/test/make_test.py
Normal file
@ -0,0 +1,45 @@
|
||||
import os
|
||||
import argparse
|
||||
import subprocess
|
||||
import platform
|
||||
|
||||
# NOTE: In JDK 8 and earlier, `javac` does not create the directories specified in the -d option if they do not already exist
|
||||
# So we need to create them manually
|
||||
def makedirs(dir):
|
||||
if not os.path.exists(dir):
|
||||
os.makedirs(dir)
|
||||
return
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description='Build and run the test example for docbuilder Java wrapper')
|
||||
parser.add_argument('-r', '--run', dest='builder_dir', metavar='<directory>', help='Run the test example with specified docbuilder directory')
|
||||
args = parser.parse_args()
|
||||
|
||||
file_dir = os.path.dirname(os.path.realpath(__file__));
|
||||
os.chdir(file_dir)
|
||||
|
||||
java_file = 'Program.java'
|
||||
|
||||
# INITIALIZE JAVA TOOLS
|
||||
javac = 'javac'
|
||||
java = 'java'
|
||||
ext = '.exe' if platform.system().lower() == 'windows' else ''
|
||||
java_home = os.environ.get('JAVA_HOME')
|
||||
if java_home:
|
||||
javac = os.path.join(java_home, 'bin', 'javac' + ext)
|
||||
if not os.path.exists(javac):
|
||||
print('Error: Cannot find: ' + javac)
|
||||
exit()
|
||||
java = os.path.join(java_home, 'bin', 'java' + ext)
|
||||
else:
|
||||
print('Warning: environment variable JAVA_HOME wasn\'t set. Default Java compiler will be used (if any).')
|
||||
|
||||
if args.builder_dir:
|
||||
builder_dir = args.builder_dir
|
||||
subprocess.call([java, '-cp', os.path.join(builder_dir, 'docbuilder.jar') + os.pathsep + 'build/classes', 'Program'], cwd=os.getcwd(), stderr=subprocess.STDOUT)
|
||||
else:
|
||||
makedirs('build/classes')
|
||||
subprocess.call([javac, '-d', 'build/classes', '-cp', '../build/libs/docbuilder.jar', java_file], cwd=os.getcwd(), stderr=subprocess.STDOUT)
|
||||
print('Program was built successfully')
|
||||
print('Run it with: java -cp \"/path/to/docbuilder/docbuilder.jar' + os.pathsep + 'build/classes\" Program')
|
||||
print('Or just run: python make_test.py --run \"/path/to/docbuilder\"')
|
||||
@ -95,7 +95,7 @@ const wchar_t* CDocBuilderValue_ToString(CDocBuilderValue* self)
|
||||
CString strValue = self->ToString();
|
||||
size_t len = wcslen(strValue.c_str());
|
||||
wchar_t* strRes = new wchar_t[len + 1];
|
||||
memcpy(strRes, strValue.c_str(), (len + 1) + sizeof(wchar_t));
|
||||
memcpy(strRes, strValue.c_str(), (len + 1) * sizeof(wchar_t));
|
||||
return strRes;
|
||||
}
|
||||
|
||||
|
||||
@ -44,11 +44,15 @@ void CV8RealTimeWorker::_LOGGING_ERROR_(const std::wstring& strType, const std::
|
||||
|
||||
using namespace NSJSBase;
|
||||
|
||||
CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder)
|
||||
CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, const NSDoctRenderer::DoctRendererEditorType& type, NSDoctRenderer::CDoctRendererConfig* config)
|
||||
{
|
||||
m_nFileType = -1;
|
||||
|
||||
m_context = new CJSContext();
|
||||
if (NSDoctRenderer::DoctRendererEditorType::INVALID == type)
|
||||
m_context = new CJSContext();
|
||||
else
|
||||
m_context = NSDoctRenderer::CreateEditorContext(type, config);
|
||||
|
||||
CJSContextScope scope(m_context);
|
||||
|
||||
CJSContext::Embed<CNativeControlEmbed>(false);
|
||||
@ -62,6 +66,7 @@ CV8RealTimeWorker::CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder)
|
||||
|
||||
JSSmart<CJSObject> global = m_context->GetGlobal();
|
||||
global->set("window", global);
|
||||
global->set("self", global);
|
||||
|
||||
JSSmart<CJSObject> oBuilderJS = CJSContext::createEmbedObject("CBuilderEmbed");
|
||||
global->set("builderJS", oBuilderJS);
|
||||
@ -239,7 +244,7 @@ bool CV8RealTimeWorker::InitVariables()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams)
|
||||
bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams)
|
||||
{
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
@ -248,7 +253,8 @@ bool CV8RealTimeWorker::OpenFile(const std::wstring& sBasePath, const std::wstri
|
||||
|
||||
LOGGER_SPEED_LAP("compile");
|
||||
|
||||
m_context->runScript(sString, try_catch, sCachePath);
|
||||
if (!m_context->isSnapshotUsed())
|
||||
NSDoctRenderer::RunEditor(editorType, m_context, try_catch, config);
|
||||
if(try_catch->Check())
|
||||
return false;
|
||||
|
||||
@ -1249,45 +1255,7 @@ namespace NSDoctRenderer
|
||||
char* CDocBuilder::GetVersion()
|
||||
{
|
||||
m_pInternal->Init();
|
||||
|
||||
if (0 == m_pInternal->m_arDoctSDK.size())
|
||||
return NULL;
|
||||
|
||||
std::wstring sFile;
|
||||
for (std::vector<std::wstring>::iterator i = m_pInternal->m_arDoctSDK.begin(); i != m_pInternal->m_arDoctSDK.end(); i++)
|
||||
{
|
||||
if (std::wstring::npos != i->find(L"sdk-all-min.js"))
|
||||
{
|
||||
sFile = *i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sFile.empty())
|
||||
return NULL;
|
||||
|
||||
std::string sData;
|
||||
if (!NSFile::CFileBinary::ReadAllTextUtf8A(sFile, sData))
|
||||
return NULL;
|
||||
|
||||
std::string::size_type startPos = sData.find("Version:");
|
||||
if (std::string::npos == startPos)
|
||||
return NULL;
|
||||
|
||||
startPos += 8;
|
||||
|
||||
std::string::size_type endPos = sData.find(')', startPos);
|
||||
if (std::string::npos == endPos)
|
||||
return NULL;
|
||||
|
||||
size_t sSrcLen = endPos - startPos + 1;
|
||||
if (sSrcLen == 0)
|
||||
return NULL;
|
||||
|
||||
char* sRet = new char[sSrcLen + 1];
|
||||
memcpy(sRet, sData.c_str() + startPos, sSrcLen);
|
||||
sRet[sSrcLen] = '\0';
|
||||
return sRet;
|
||||
return m_pInternal->GetVersion();
|
||||
}
|
||||
|
||||
bool CDocBuilder::Run(const wchar_t* path)
|
||||
@ -1338,7 +1306,7 @@ namespace NSDoctRenderer
|
||||
while (_start2 < _currentPos && (commands[_start2] == '\t' || commands[_start2] == ' '))
|
||||
++_start2;
|
||||
|
||||
if (_currentPos > _start2 && (commands[_start2] != '#' && commands[_start2] != '/'))
|
||||
if (_currentPos > _start2 && (commands[_start2] != '#'))
|
||||
{
|
||||
_commands.push_back(std::string(commands + _start2, _currentPos - _start2));
|
||||
// DEBUG
|
||||
@ -1521,7 +1489,7 @@ namespace NSDoctRenderer
|
||||
else if (sParam == "--work-directory")
|
||||
m_pInternal->m_oParams.m_sWorkDir = std::wstring(value);
|
||||
else if (sParam == "--cache-scripts")
|
||||
m_pInternal->m_bIsCacheScript = (std::wstring(value) == L"true");
|
||||
m_pInternal->m_bIsUseCache = (std::wstring(value) == L"true");
|
||||
else if (sParam == "--save-use-only-names")
|
||||
{
|
||||
m_pInternal->m_bIsServerSafeVersion = true;
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
#ifndef DOC_BUILDER_PRIVATE
|
||||
#define DOC_BUILDER_PRIVATE
|
||||
|
||||
#include "./config.h"
|
||||
#include "./editors.h"
|
||||
#include "docbuilder.h"
|
||||
#include "doctrenderer.h"
|
||||
|
||||
@ -415,7 +415,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder);
|
||||
CV8RealTimeWorker(NSDoctRenderer::CDocBuilder* pBuilder, const NSDoctRenderer::DoctRendererEditorType& type, NSDoctRenderer::CDoctRendererConfig* config);
|
||||
~CV8RealTimeWorker();
|
||||
|
||||
public:
|
||||
@ -427,36 +427,13 @@ public:
|
||||
std::string GetGlobalVariable();
|
||||
std::wstring GetJSVariable(std::wstring sParam);
|
||||
|
||||
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const std::string& sString, const std::wstring& sCachePath, CV8Params* pParams = NULL);
|
||||
bool OpenFile(const std::wstring& sBasePath, const std::wstring& path, const NSDoctRenderer::DoctRendererEditorType& editorType, NSDoctRenderer::CDoctRendererConfig* config, CV8Params* pParams = NULL);
|
||||
bool SaveFileWithChanges(int type, const std::wstring& _path, const std::wstring& sJsonParams = L"");
|
||||
bool InitVariables();
|
||||
};
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
class CAdditionalData
|
||||
{
|
||||
public:
|
||||
CAdditionalData() {}
|
||||
virtual ~CAdditionalData() {}
|
||||
virtual std::string getParam(const std::wstring& name) { return ""; }
|
||||
};
|
||||
|
||||
class CDocBuilderParams
|
||||
{
|
||||
public:
|
||||
CDocBuilderParams() : m_bCheckFonts(false), m_sWorkDir(L""), m_bSaveWithDoctrendererMode(false), m_sArgumentJSON(""), m_bIsSystemFonts(true) {}
|
||||
|
||||
public:
|
||||
bool m_bCheckFonts;
|
||||
std::wstring m_sWorkDir;
|
||||
bool m_bSaveWithDoctrendererMode;
|
||||
std::string m_sArgumentJSON;
|
||||
|
||||
bool m_bIsSystemFonts;
|
||||
std::vector<std::wstring> m_arFontDirs;
|
||||
};
|
||||
|
||||
class CDocBuilder_Private : public CDoctRendererConfig
|
||||
{
|
||||
public:
|
||||
@ -477,8 +454,6 @@ namespace NSDoctRenderer
|
||||
CDocBuilderParams m_oParams;
|
||||
bool m_bIsInit;
|
||||
|
||||
bool m_bIsCacheScript;
|
||||
|
||||
bool m_bIsServerSafeVersion;
|
||||
std::wstring m_sFolderForSaveOnlyUseNames;
|
||||
|
||||
@ -490,7 +465,7 @@ namespace NSDoctRenderer
|
||||
static std::wstring m_sExternalDirectory;
|
||||
public:
|
||||
CDocBuilder_Private() : CDoctRendererConfig(), m_sTmpFolder(NSFile::CFileBinary::GetTempPath()), m_nFileType(-1),
|
||||
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsCacheScript(true), m_bIsServerSafeVersion(false),
|
||||
m_pWorker(NULL), m_pAdditionalData(NULL), m_bIsInit(false), m_bIsServerSafeVersion(false),
|
||||
m_sGlobalVariable(""), m_bIsGlobalVariableUse(false), m_pParent(NULL), m_bJavascriptBeforeEditor(false)
|
||||
{
|
||||
}
|
||||
@ -1251,7 +1226,7 @@ namespace NSDoctRenderer
|
||||
{
|
||||
if (NULL == m_pWorker)
|
||||
{
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent);
|
||||
m_pWorker = new CV8RealTimeWorker(m_pParent, GetEditorType(), this);
|
||||
m_pWorker->m_sUtf8ArgumentJSON = m_oParams.m_sArgumentJSON;
|
||||
m_pWorker->m_sGlobalVariable = m_sGlobalVariable;
|
||||
|
||||
@ -1273,15 +1248,12 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
m_bJavascriptBeforeEditor = false;
|
||||
std::wstring sCachePath = L"";
|
||||
if (m_bIsCacheScript)
|
||||
sCachePath = GetScriptCache();
|
||||
|
||||
CV8Params oParams;
|
||||
oParams.IsServerSaveVersion = m_bIsServerSafeVersion;
|
||||
oParams.DocumentDirectory = m_sFileDir;
|
||||
|
||||
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetScript(), sCachePath, &oParams);
|
||||
return m_pWorker->OpenFile(m_sX2tPath, m_sFileDir, GetEditorType(), this, &oParams);
|
||||
}
|
||||
|
||||
int SaveFile(const std::wstring& ext, const std::wstring& path, const wchar_t* params = NULL)
|
||||
@ -1316,119 +1288,22 @@ namespace NSDoctRenderer
|
||||
return ctx;
|
||||
}
|
||||
|
||||
std::string GetScript()
|
||||
NSDoctRenderer::DoctRendererEditorType GetEditorType()
|
||||
{
|
||||
std::vector<std::wstring>* arSdkFiles = NULL;
|
||||
|
||||
switch (m_nFileType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
arSdkFiles = &m_arDoctSDK;
|
||||
break;
|
||||
}
|
||||
return NSDoctRenderer::DoctRendererEditorType::WORD;
|
||||
case 1:
|
||||
{
|
||||
arSdkFiles = &m_arPpttSDK;
|
||||
break;
|
||||
}
|
||||
return NSDoctRenderer::DoctRendererEditorType::SLIDE;
|
||||
case 2:
|
||||
{
|
||||
arSdkFiles = &m_arXlstSDK;
|
||||
break;
|
||||
}
|
||||
return NSDoctRenderer::DoctRendererEditorType::CELL;
|
||||
case 7:
|
||||
{
|
||||
arSdkFiles = &m_arVsdtSDK;
|
||||
break;
|
||||
}
|
||||
return NSDoctRenderer::DoctRendererEditorType::VISIO;
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string strScript = "";
|
||||
for (size_t i = 0; i < m_arrFiles.size(); ++i)
|
||||
{
|
||||
strScript += ReadScriptFile(m_arrFiles[i]);
|
||||
strScript += "\n\n";
|
||||
}
|
||||
|
||||
if (NULL != arSdkFiles)
|
||||
{
|
||||
for (const std::wstring& i : *arSdkFiles)
|
||||
{
|
||||
strScript += ReadScriptFile(i);
|
||||
strScript += "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_nFileType == 2)
|
||||
strScript += "\n$.ready();";
|
||||
|
||||
return strScript;
|
||||
}
|
||||
|
||||
std::wstring GetScriptCache()
|
||||
{
|
||||
std::vector<std::wstring>* arSdkFiles = NULL;
|
||||
switch (m_nFileType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
arSdkFiles = &m_arDoctSDK;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
arSdkFiles = &m_arPpttSDK;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
arSdkFiles = &m_arXlstSDK;
|
||||
break;
|
||||
}
|
||||
case 7:
|
||||
{
|
||||
arSdkFiles = &m_arVsdtSDK;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return L"";
|
||||
}
|
||||
|
||||
if (0 < arSdkFiles->size())
|
||||
{
|
||||
return NSFile::GetDirectoryName(*arSdkFiles->begin()) + L"/sdk-all.cache";
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
std::string ReadScriptFile(const std::wstring& strFile)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.OpenFile(strFile))
|
||||
return "";
|
||||
|
||||
int nSize = (int)oFile.GetFileSize();
|
||||
if (nSize < 3)
|
||||
return "";
|
||||
|
||||
BYTE* pData = new BYTE[nSize];
|
||||
DWORD dwReadSize = 0;
|
||||
oFile.ReadFile(pData, (DWORD)nSize, dwReadSize);
|
||||
|
||||
int nOffset = 0;
|
||||
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xBF)
|
||||
{
|
||||
nOffset = 3;
|
||||
}
|
||||
|
||||
std::string sReturn((char*)(pData + nOffset), nSize - nOffset);
|
||||
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
return sReturn;
|
||||
return NSDoctRenderer::DoctRendererEditorType::INVALID;
|
||||
}
|
||||
|
||||
void WriteData(const wchar_t* path, const wchar_t* value, const bool& append)
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#include "embed/NativeControlEmbed.h"
|
||||
#include "embed/GraphicsEmbed.h"
|
||||
|
||||
#include "./config.h"
|
||||
#include "./editors.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace NSDoctRenderer
|
||||
@ -99,9 +99,8 @@ namespace NSDoctRenderer
|
||||
std::wstring m_sJsonParams;
|
||||
int m_nLcid;
|
||||
|
||||
std::wstring m_sScriptsCacheDirectory;
|
||||
|
||||
std::vector<int> m_arThemesThumbnailsParams;
|
||||
|
||||
public:
|
||||
CExecuteParams() : m_arChanges()
|
||||
{
|
||||
@ -123,7 +122,6 @@ namespace NSDoctRenderer
|
||||
m_nMailMergeIndexEnd = -1;
|
||||
|
||||
m_nLcid = -1;
|
||||
m_sScriptsCacheDirectory = L"";
|
||||
}
|
||||
~CExecuteParams()
|
||||
{
|
||||
@ -152,13 +150,13 @@ namespace NSDoctRenderer
|
||||
{
|
||||
m_nCountChangesItems = oNodeChanges.ReadAttributeInt(L"TopItem", -1);
|
||||
|
||||
std::vector<XmlUtils::CXmlNode> oNodes;
|
||||
std::vector<XmlUtils::CXmlNode> oNodes;
|
||||
oNodeChanges.GetNodes(L"Change", oNodes);
|
||||
|
||||
size_t nCount = oNodes.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
size_t nCount = oNodes.size();
|
||||
for (size_t i = 0; i < nCount; ++i)
|
||||
{
|
||||
XmlUtils::CXmlNode & _node = oNodes[i];
|
||||
XmlUtils::CXmlNode& _node = oNodes[i];
|
||||
m_arChanges.push_back(_node.GetText());
|
||||
}
|
||||
}
|
||||
@ -175,8 +173,6 @@ namespace NSDoctRenderer
|
||||
m_nLcid = oNode.ReadValueInt(L"Lcid", -1);
|
||||
m_sJsonParams = oNode.ReadValueString(L"JsonParams");
|
||||
|
||||
m_sScriptsCacheDirectory = oNode.ReadValueString(L"ScriptsCacheDirectory", L"");
|
||||
|
||||
m_arThemesThumbnailsParams.clear();
|
||||
std::wstring sThemesThumbnailsParams = oNode.ReadValueString(L"ThemesThumbnailsParams");
|
||||
if (!sThemesThumbnailsParams.empty())
|
||||
@ -190,21 +186,21 @@ namespace NSDoctRenderer
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace NSDoctRenderer
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
std::wstring string_replaceAll(std::wstring str, const std::wstring& from, const std::wstring& to)
|
||||
{
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = str.find(from, start_pos)) != std::wstring::npos)
|
||||
while ((start_pos = str.find(from, start_pos)) != std::wstring::npos)
|
||||
{
|
||||
str.replace(start_pos, from.length(), to);
|
||||
start_pos += to.length();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
} // namespace NSDoctRenderer
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
@ -243,7 +239,6 @@ namespace NSDoctRenderer
|
||||
}
|
||||
~CDoctRenderer_Private()
|
||||
{
|
||||
|
||||
}
|
||||
void LoadConfig(const std::wstring& sConfigDir, const std::wstring& sAllFontsPath = L"")
|
||||
{
|
||||
@ -256,7 +251,6 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
static void _LOGGING_ERROR_(const std::wstring& strType, const std::wstring& strError)
|
||||
{
|
||||
#if 0
|
||||
@ -280,16 +274,12 @@ namespace NSDoctRenderer
|
||||
std::cerr << sT << ": " << sE << std::endl;
|
||||
}
|
||||
|
||||
static bool Doct_renderer_SaveFile(CExecuteParams* pParams,
|
||||
NSNativeControl::CNativeControl* pNative,
|
||||
JSSmart<CJSContext> context,
|
||||
JSSmart<CJSValue>* args,
|
||||
std::wstring& strError,
|
||||
JSSmart<CJSObject>& api_js_maybe_null,
|
||||
bool bIsPdfBase64 = false)
|
||||
static bool Doct_renderer_SaveFile(
|
||||
CExecuteParams* pParams, NSNativeControl::CNativeControl* pNative, JSSmart<CJSContext> context, JSSmart<CJSValue>* args, std::wstring& strError, JSSmart<CJSObject>& api_js_maybe_null,
|
||||
bool bIsPdfBase64 = false)
|
||||
{
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
JSSmart<CJSObject> global_js = context->GetGlobal();
|
||||
JSSmart<CJSObject> global_js = context->GetGlobal();
|
||||
|
||||
JSSmart<CJSObject> js_objectApi = api_js_maybe_null;
|
||||
if (!js_objectApi.IsInit() || js_objectApi->isUndefined())
|
||||
@ -313,7 +303,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::XLST:
|
||||
{
|
||||
JSSmart<CJSValue> js_result2 = js_objectApi->call_func("asc_nativeGetFileData", 1, args);
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"save\"";
|
||||
bIsBreak = true;
|
||||
@ -362,14 +352,14 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> js_result1 = js_objectApi->call_func("asc_nativeCalculateFile", 1, args);
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"calculate\"";
|
||||
bIsBreak = true;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> js_result2 = js_objectApi->call_func("asc_nativeGetHtml", 1, args);
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"save\"";
|
||||
bIsBreak = true;
|
||||
@ -401,7 +391,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> js_result2 = js_objectApi->call_func("asc_nativeCalculateFile", 1, args);
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"calculate\"";
|
||||
bIsBreak = true;
|
||||
@ -412,7 +402,7 @@ namespace NSDoctRenderer
|
||||
if (!bIsBreak)
|
||||
{
|
||||
JSSmart<CJSValue> js_result1 = js_objectApi->call_func("asc_nativePrintPagesCount", 1, args);
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"calculate\"";
|
||||
bIsBreak = true;
|
||||
@ -422,8 +412,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
// RENDER
|
||||
if (!bIsBreak &&
|
||||
(DoctRendererFormat::PDF == pParams->m_eDstFormat || DoctRendererFormat::IMAGE == pParams->m_eDstFormat))
|
||||
if (!bIsBreak && (DoctRendererFormat::PDF == pParams->m_eDstFormat || DoctRendererFormat::IMAGE == pParams->m_eDstFormat))
|
||||
{
|
||||
if (pParams->m_sJsonParams.empty())
|
||||
{
|
||||
@ -447,7 +436,7 @@ namespace NSDoctRenderer
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> js_result2 = js_objectApi->call_func("asc_nativeGetPDF", 1, args);
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"save\"";
|
||||
bIsBreak = true;
|
||||
@ -500,7 +489,7 @@ namespace NSDoctRenderer
|
||||
js_result2 = js_objectApi->call_func("asc_nativeGetThemeThumbnail", 1, args);
|
||||
}
|
||||
|
||||
if(try_catch->Check())
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"save\"";
|
||||
bIsBreak = true;
|
||||
@ -582,14 +571,12 @@ namespace NSDoctRenderer
|
||||
return bIsBreak;
|
||||
}
|
||||
|
||||
bool ExecuteScript(const std::string& strScript, const std::wstring& sCachePath, std::wstring& strError, std::wstring& strReturnParams)
|
||||
bool ExecuteScript(NSDoctRenderer::DoctRendererEditorType& editorType, std::wstring& strError, std::wstring& strReturnParams)
|
||||
{
|
||||
if (strScript.empty() && sCachePath.empty()) return true;
|
||||
|
||||
LOGGER_SPEED_START();
|
||||
|
||||
bool bIsBreak = false;
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
JSSmart<CJSContext> context = NSDoctRenderer::CreateEditorContext(editorType, this);
|
||||
|
||||
if (true)
|
||||
{
|
||||
@ -598,10 +585,11 @@ namespace NSDoctRenderer
|
||||
CJSContext::Embed<CGraphicsEmbed>();
|
||||
NSJSBase::CreateDefaults();
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
|
||||
JSSmart<CJSObject> global_js = context->GetGlobal();
|
||||
global_js->set("window", global_js);
|
||||
global_js->set("self", global_js);
|
||||
|
||||
JSSmart<CJSObject> oNativeCtrl = CJSContext::createEmbedObject("CNativeControlEmbed");
|
||||
global_js->set("native", oNativeCtrl);
|
||||
@ -611,8 +599,10 @@ namespace NSDoctRenderer
|
||||
|
||||
LOGGER_SPEED_LAP("compile");
|
||||
|
||||
JSSmart<CJSValue> res = context->runScript(strScript, try_catch, sCachePath);
|
||||
if(try_catch->Check())
|
||||
if (!context->isSnapshotUsed())
|
||||
NSDoctRenderer::RunEditor(editorType, context, try_catch, this);
|
||||
|
||||
if (try_catch->Check())
|
||||
{
|
||||
strError = L"code=\"run\"";
|
||||
bIsBreak = true;
|
||||
@ -748,8 +738,7 @@ namespace NSDoctRenderer
|
||||
// images in changes
|
||||
if (NULL != pNative)
|
||||
{
|
||||
for (std::map<std::wstring, bool>::const_iterator iter = pNative->m_mapImagesInChanges.begin();
|
||||
iter != pNative->m_mapImagesInChanges.end(); iter++)
|
||||
for (std::map<std::wstring, bool>::const_iterator iter = pNative->m_mapImagesInChanges.begin(); iter != pNative->m_mapImagesInChanges.end(); iter++)
|
||||
{
|
||||
m_arImagesInChanges.push_back(iter->first);
|
||||
}
|
||||
@ -760,9 +749,7 @@ namespace NSDoctRenderer
|
||||
LOGGER_SPEED_LAP("changes");
|
||||
|
||||
bool bIsMailMerge = false;
|
||||
if (!m_oParams.m_strMailMergeDatabasePath.empty() &&
|
||||
m_oParams.m_nMailMergeIndexEnd >= m_oParams.m_nMailMergeIndexStart &&
|
||||
m_oParams.m_nMailMergeIndexEnd >= 0)
|
||||
if (!m_oParams.m_strMailMergeDatabasePath.empty() && m_oParams.m_nMailMergeIndexEnd >= m_oParams.m_nMailMergeIndexStart && m_oParams.m_nMailMergeIndexEnd >= 0)
|
||||
{
|
||||
bIsMailMerge = true;
|
||||
}
|
||||
@ -819,11 +806,10 @@ namespace NSDoctRenderer
|
||||
|
||||
if (!bIsBreak)
|
||||
{
|
||||
std::string sFieldUtf8 = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oParams.m_strMailMergeField.c_str(),
|
||||
(LONG)m_oParams.m_strMailMergeField.length());
|
||||
std::string sFieldUtf8 = NSFile::CUtf8Converter::GetUtf8StringFromUnicode2(m_oParams.m_strMailMergeField.c_str(), (LONG)m_oParams.m_strMailMergeField.length());
|
||||
|
||||
strReturnParams += L"<MailMergeFields>";
|
||||
for (int nIndexMM = m_oParams.m_nMailMergeIndexStart; nIndexMM <= m_oParams.m_nMailMergeIndexEnd && !bIsBreak; ++nIndexMM)
|
||||
for (int nIndexMM = m_oParams.m_nMailMergeIndexStart; nIndexMM <= m_oParams.m_nMailMergeIndexEnd && !bIsBreak; ++nIndexMM)
|
||||
{
|
||||
JSSmart<CJSValue> args_changes[1];
|
||||
args_changes[0] = CJSContext::createInt(nIndexMM);
|
||||
@ -935,7 +921,7 @@ namespace NSDoctRenderer
|
||||
m_pInternal->m_oParams.FromXml(strXml);
|
||||
m_pInternal->m_arImagesInChanges.clear();
|
||||
|
||||
std::vector<std::wstring>* arSdkFiles = NULL;
|
||||
NSDoctRenderer::DoctRendererEditorType editorType = NSDoctRenderer::DoctRendererEditorType::INVALID;
|
||||
switch (m_pInternal->m_oParams.m_eSrcFormat)
|
||||
{
|
||||
case DoctRendererFormat::DOCT:
|
||||
@ -948,7 +934,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::HTML:
|
||||
case DoctRendererFormat::WATERMARK:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arDoctSDK;
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::WORD;
|
||||
m_pInternal->m_strEditorType = L"document";
|
||||
break;
|
||||
}
|
||||
@ -966,7 +952,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::IMAGE:
|
||||
case DoctRendererFormat::PPTX_THEME_THUMBNAIL:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arPpttSDK;
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::SLIDE;
|
||||
m_pInternal->m_strEditorType = L"presentation";
|
||||
break;
|
||||
}
|
||||
@ -983,7 +969,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arXlstSDK;
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::CELL;
|
||||
m_pInternal->m_strEditorType = L"spreadsheet";
|
||||
break;
|
||||
}
|
||||
@ -1000,7 +986,7 @@ namespace NSDoctRenderer
|
||||
case DoctRendererFormat::PDF:
|
||||
case DoctRendererFormat::IMAGE:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arVsdtSDK;
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::VISIO;
|
||||
m_pInternal->m_strEditorType = L"draw";
|
||||
break;
|
||||
}
|
||||
@ -1009,6 +995,21 @@ namespace NSDoctRenderer
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DoctRendererFormat::PDF:
|
||||
{
|
||||
switch (m_pInternal->m_oParams.m_eDstFormat)
|
||||
{
|
||||
case DoctRendererFormat::PDF:
|
||||
{
|
||||
editorType = NSDoctRenderer::DoctRendererEditorType::PDF;
|
||||
m_pInternal->m_strEditorType = L"pdf";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
@ -1026,50 +1027,8 @@ namespace NSDoctRenderer
|
||||
|
||||
m_pInternal->m_strFilePath = strFileName;
|
||||
|
||||
std::string strScript = "";
|
||||
for (size_t i = 0; i < m_pInternal->m_arrFiles.size(); ++i)
|
||||
{
|
||||
strScript += m_pInternal->ReadScriptFile(m_pInternal->m_arrFiles[i]);
|
||||
strScript += "\n\n";
|
||||
}
|
||||
|
||||
std::wstring sCachePath = L"";
|
||||
if (arSdkFiles && (0 < arSdkFiles->size()))
|
||||
{
|
||||
if (m_pInternal->m_oParams.m_sScriptsCacheDirectory.empty())
|
||||
{
|
||||
sCachePath = NSFile::GetDirectoryName(*arSdkFiles->begin()) + L"/sdk-all.cache";
|
||||
}
|
||||
else if (m_pInternal->m_oParams.m_sScriptsCacheDirectory != L"empty")
|
||||
{
|
||||
sCachePath = m_pInternal->m_oParams.m_sScriptsCacheDirectory;
|
||||
wchar_t lastSymbol = sCachePath.back();
|
||||
if (lastSymbol != '\\' && lastSymbol != '/')
|
||||
sCachePath += L"/";
|
||||
|
||||
wchar_t editorFirst = m_pInternal->m_strEditorType.at(0);
|
||||
if (editorFirst == 'd' && L"document" == m_pInternal->m_strEditorType)
|
||||
sCachePath += L"word";
|
||||
else if (editorFirst == 'p')
|
||||
sCachePath += L"slide";
|
||||
else if (editorFirst == 'd')
|
||||
sCachePath += L"draw";
|
||||
else
|
||||
sCachePath += L"cell";
|
||||
}
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = arSdkFiles->begin(); i != arSdkFiles->end(); i++)
|
||||
{
|
||||
strScript += m_pInternal->ReadScriptFile(*i);
|
||||
strScript += "\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pInternal->m_strEditorType == L"spreadsheet")
|
||||
strScript += "\n$.ready();";
|
||||
|
||||
std::wstring sReturnParams = L"";
|
||||
bool bResult = m_pInternal->ExecuteScript(strScript, sCachePath, strError, sReturnParams);
|
||||
bool bResult = m_pInternal->ExecuteScript(editorType, strError, sReturnParams);
|
||||
|
||||
if (strError.length() != 0)
|
||||
{
|
||||
@ -1093,76 +1052,15 @@ namespace NSDoctRenderer
|
||||
#ifndef JS_ENGINE_JAVASCRIPTCORE
|
||||
LoadConfig(NSFile::GetProcessDirectory(), sAllFontsPath);
|
||||
|
||||
std::wstring sCacheDirectory = sCacheDir;
|
||||
if (sCacheDirectory.empty() && m_pInternal->m_arDoctSDK.size() > 0)
|
||||
std::vector<NSDoctRenderer::DoctRendererEditorType> editors;
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::WORD);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::SLIDE);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::CELL);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::VISIO);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::PDF);
|
||||
|
||||
for (std::vector<NSDoctRenderer::DoctRendererEditorType>::const_iterator i = editors.begin(); i != editors.end(); i++)
|
||||
{
|
||||
sCacheDirectory = NSFile::GetDirectoryName(m_pInternal->m_arDoctSDK[0]);
|
||||
sCacheDirectory = NSFile::GetDirectoryName(sCacheDirectory);
|
||||
}
|
||||
|
||||
if (sCacheDirectory.empty())
|
||||
return;
|
||||
|
||||
std::string strScriptAll = "";
|
||||
for (size_t i = 0; i < m_pInternal->m_arrFiles.size(); ++i)
|
||||
{
|
||||
strScriptAll += m_pInternal->ReadScriptFile(m_pInternal->m_arrFiles[i]);
|
||||
strScriptAll += "\n\n";
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
std::string strScript = strScriptAll;
|
||||
std::wstring sCachePath = sCacheDirectory;
|
||||
|
||||
std::vector<std::wstring>* arSdkFiles = NULL;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arDoctSDK;
|
||||
sCachePath += L"/word/sdk-all.cache";
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arPpttSDK;
|
||||
sCachePath += L"/slide/sdk-all.cache";
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arXlstSDK;
|
||||
sCachePath += L"/cell/sdk-all.cache";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
arSdkFiles = &m_pInternal->m_arVsdtSDK;
|
||||
sCachePath += L"/draw/sdk-all.cache";
|
||||
if (0 < arSdkFiles->size() && !NSFile::CFileBinary::Exists(*arSdkFiles->begin()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (NSFile::CFileBinary::Exists(sCachePath))
|
||||
NSFile::CFileBinary::Remove(sCachePath);
|
||||
|
||||
for (std::vector<std::wstring>::iterator i = arSdkFiles->begin(); i != arSdkFiles->end(); i++)
|
||||
{
|
||||
strScript += m_pInternal->ReadScriptFile(*i);
|
||||
strScript += "\n\n";
|
||||
}
|
||||
|
||||
if (2 == i)
|
||||
strScript += "\n$.ready();";
|
||||
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
if (true)
|
||||
@ -1174,24 +1072,42 @@ namespace NSDoctRenderer
|
||||
|
||||
JSSmart<CJSObject> global = context->GetGlobal();
|
||||
global->set("window", global);
|
||||
global->set("self", global);
|
||||
global->set("native", CJSContext::createEmbedObject("CNativeControlEmbed"));
|
||||
|
||||
JSSmart<CJSTryCatch> try_catch = context->GetExceptions();
|
||||
|
||||
context->runScript(strScript, try_catch, sCachePath);
|
||||
NSDoctRenderer::RunEditor(*i, context, try_catch, m_pInternal);
|
||||
}
|
||||
|
||||
context->Dispose();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
bool Doct_renderer_SaveFile_ForBuilder(int nFormat, const std::wstring& strDstFile,
|
||||
NSNativeControl::CNativeControl* pNative,
|
||||
JSSmart<CJSContext> context,
|
||||
JSSmart<CJSValue>* args,
|
||||
std::wstring& strError, const std::wstring& jsonParams)
|
||||
void CDoctrenderer::CreateSnapshots()
|
||||
{
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
std::vector<NSDoctRenderer::DoctRendererEditorType> editors;
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::WORD);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::SLIDE);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::CELL);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::VISIO);
|
||||
editors.push_back(NSDoctRenderer::DoctRendererEditorType::PDF);
|
||||
|
||||
// initialize v8
|
||||
JSSmart<CJSContext> context = new CJSContext();
|
||||
|
||||
for (std::vector<NSDoctRenderer::DoctRendererEditorType>::const_iterator i = editors.begin(); i != editors.end(); i++)
|
||||
{
|
||||
NSDoctRenderer::GenerateEditorSnapshot(*i, m_pInternal);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} // namespace NSDoctRenderer
|
||||
|
||||
bool Doct_renderer_SaveFile_ForBuilder(
|
||||
int nFormat, const std::wstring& strDstFile, NSNativeControl::CNativeControl* pNative, JSSmart<CJSContext> context, JSSmart<CJSValue>* args, std::wstring& strError, const std::wstring& jsonParams)
|
||||
{
|
||||
NSDoctRenderer::CExecuteParams oParams;
|
||||
oParams.m_eDstFormat = (NSDoctRenderer::DoctRendererFormat::FormatFile)nFormat;
|
||||
@ -1199,6 +1115,5 @@ bool Doct_renderer_SaveFile_ForBuilder(int nFormat, const std::wstring& strDstFi
|
||||
oParams.m_sJsonParams = jsonParams;
|
||||
|
||||
JSSmart<CJSObject> js_objectApi; // empty
|
||||
return NSDoctRenderer::CDoctRenderer_Private::Doct_renderer_SaveFile(&oParams,
|
||||
pNative, context, args, strError, js_objectApi, false);
|
||||
return NSDoctRenderer::CDoctRenderer_Private::Doct_renderer_SaveFile(&oParams, pNative, context, args, strError, js_objectApi, false);
|
||||
}
|
||||
|
||||
@ -71,6 +71,7 @@ namespace NSDoctRenderer
|
||||
bool Execute(const std::wstring& strXml, std::wstring& strError);
|
||||
std::vector<std::wstring> GetImagesInChanges();
|
||||
void CreateCache(const std::wstring& sAllFontsPath, const std::wstring& sCacheDir);
|
||||
void CreateSnapshots();
|
||||
|
||||
private:
|
||||
CDoctRenderer_Private* m_pInternal;
|
||||
|
||||
@ -16,12 +16,18 @@ DEFINES += DOCTRENDERER_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
DEFINES += JSBASE_USE_DYNAMIC_LIBRARY_BUILDING
|
||||
ADD_DEPENDENCY(graphics, kernel, UnicodeConverter, kernel_network)
|
||||
|
||||
# drawingfile support
|
||||
DEFINES += WASM_SERIALIZER_USE_ALLOCATOR
|
||||
ADD_DEPENDENCY(PdfFile, XpsFile, DjVuFile, DocxRenderer)
|
||||
SOURCES += ../../HtmlRenderer/src/HTMLRendererText.cpp
|
||||
|
||||
#CONFIG += build_xp
|
||||
#CONFIG += v8_version_60
|
||||
core_android:DEFINES += DISABLE_MEMORY_LIMITATION
|
||||
|
||||
HEADERS += \
|
||||
config.h \
|
||||
editors.h \
|
||||
doctrenderer.h \
|
||||
docbuilder.h
|
||||
|
||||
@ -43,7 +49,8 @@ HEADERS += \
|
||||
nativecontrol.h \
|
||||
graphics.h \
|
||||
hash.h \
|
||||
server.h
|
||||
server.h \
|
||||
drawingfile.h
|
||||
|
||||
HEADERS += \
|
||||
embed/PointerEmbed.h \
|
||||
@ -56,6 +63,7 @@ HEADERS += \
|
||||
embed/TextMeasurerEmbed.h \
|
||||
embed/HashEmbed.h \
|
||||
embed/Default.h \
|
||||
embed/DrawingFileEmbed.h \
|
||||
js_internal/js_base.h
|
||||
|
||||
SOURCES += \
|
||||
@ -68,7 +76,8 @@ SOURCES += \
|
||||
embed/NativeBuilderDocumentEmbed.cpp \
|
||||
embed/TextMeasurerEmbed.cpp \
|
||||
embed/HashEmbed.cpp \
|
||||
embed/Default.cpp
|
||||
embed/Default.cpp \
|
||||
embed/DrawingFileEmbed.cpp
|
||||
|
||||
# Serialize objects to JS
|
||||
HEADERS += \
|
||||
@ -101,6 +110,7 @@ ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/NativeControlEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/PointerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/TextMeasurerEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/ZipEmbed.h)
|
||||
ADD_FILES_FOR_EMBEDDED_CLASS_HEADER(embed/DrawingFileEmbed.h)
|
||||
|
||||
include(../graphics/pro/textshaper.pri)
|
||||
include(../../Common/3dParty/openssl/openssl.pri)
|
||||
|
||||
493
DesktopEditor/doctrenderer/drawingfile.h
Normal file
493
DesktopEditor/doctrenderer/drawingfile.h
Normal file
@ -0,0 +1,493 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef DRAWINGFILE_H
|
||||
#define DRAWINGFILE_H
|
||||
|
||||
#include "./common.h"
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../../PdfFile/PdfFile.h"
|
||||
#include "../../XpsFile/XpsFile.h"
|
||||
#include "../../DjVuFile/DjVu.h"
|
||||
#include "../../DesktopEditor/graphics/pro/js/wasm/src/serialize.h"
|
||||
#include "../../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "../../DocxRenderer/DocxRenderer.h"
|
||||
|
||||
class CDrawingFile
|
||||
{
|
||||
private:
|
||||
NSFonts::IApplicationFonts* m_pApplicationFonts;
|
||||
NSFonts::IFontManager* m_pFontManager;
|
||||
NSHtmlRenderer::CHTMLRendererText* m_pTextRenderer;
|
||||
NSDocxRenderer::IImageStorage* m_pImageStorage;
|
||||
|
||||
IOfficeDrawingFile* m_pFile;
|
||||
int m_nType = -1;
|
||||
|
||||
public:
|
||||
CDrawingFile(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
m_pApplicationFonts = pFonts;
|
||||
ADDREFINTERFACE(m_pApplicationFonts);
|
||||
|
||||
m_pFontManager = m_pApplicationFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||
pFontCache->SetStreams(m_pApplicationFonts->GetStreams());
|
||||
pFontCache->SetCacheSize(8);
|
||||
m_pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
m_pTextRenderer = NULL;
|
||||
m_pImageStorage = NULL;
|
||||
|
||||
m_pFile = NULL;
|
||||
}
|
||||
~CDrawingFile()
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
RELEASEOBJECT(m_pTextRenderer);
|
||||
RELEASEOBJECT(m_pFontManager);
|
||||
RELEASEINTERFACE(m_pApplicationFonts);
|
||||
RELEASEOBJECT(m_pImageStorage);
|
||||
}
|
||||
|
||||
public:
|
||||
static void InitFontsGlobalStorage()
|
||||
{
|
||||
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NSFonts::NSApplicationFontStream::CreateDefaultGlobalMemoryStorage());
|
||||
}
|
||||
|
||||
static NSFonts::IFontsMemoryStorage* GetFontsStorage()
|
||||
{
|
||||
return NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
|
||||
}
|
||||
|
||||
public:
|
||||
bool OpenFile(const std::wstring& sFile, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CXpsFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 2;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CDjVuFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromFile(sFile, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 1;
|
||||
}
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
bool OpenFile(BYTE* data, LONG size, const std::wstring& sPassword)
|
||||
{
|
||||
CloseFile();
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CPdfFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 0;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CXpsFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 2;
|
||||
}
|
||||
|
||||
if (NULL == m_pFile)
|
||||
{
|
||||
m_pFile = new CDjVuFile(m_pApplicationFonts);
|
||||
if (!m_pFile->LoadFromMemory(data, size, L"", sPassword, sPassword))
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
else
|
||||
m_nType = 1;
|
||||
}
|
||||
|
||||
return m_pFile ? true : false;
|
||||
}
|
||||
|
||||
void CloseFile()
|
||||
{
|
||||
if (m_pFile)
|
||||
RELEASEOBJECT(m_pFile);
|
||||
|
||||
m_nType = -1;
|
||||
}
|
||||
|
||||
int GetType()
|
||||
{
|
||||
return m_nType;
|
||||
}
|
||||
|
||||
int GetErrorCode()
|
||||
{
|
||||
if (!m_pFile)
|
||||
return -1;
|
||||
|
||||
if (0 == m_nType)
|
||||
return ((CPdfFile*)m_pFile)->GetError();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
BYTE* GetInfo()
|
||||
{
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
|
||||
oRes.AddInt(GetMaxRefID());
|
||||
|
||||
int pages_count = GetPagesCount();
|
||||
oRes.AddInt(pages_count);
|
||||
for (int page = 0; page < pages_count; ++page)
|
||||
{
|
||||
int nW = 0;
|
||||
int nH = 0;
|
||||
int nDpi = 0;
|
||||
int nRotate = 0;
|
||||
GetPageInfo(page, nW, nH, nDpi, nRotate);
|
||||
oRes.AddInt(nW);
|
||||
oRes.AddInt(nH);
|
||||
oRes.AddInt(nDpi);
|
||||
oRes.AddInt(nRotate);
|
||||
}
|
||||
std::wstring wsInfo = m_pFile->GetInfo();
|
||||
std::string sInfo = U_TO_UTF8(wsInfo);
|
||||
oRes.WriteString((BYTE*)sInfo.c_str(), sInfo.length());
|
||||
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
}
|
||||
|
||||
BYTE* GetPixmap(int nPageIndex, int nRasterW, int nRasterH, int nBackgroundColor)
|
||||
{
|
||||
if (!m_pFile)
|
||||
return NULL;
|
||||
return m_pFile->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, m_pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
if (NULL == m_pTextRenderer)
|
||||
m_pTextRenderer = new NSHtmlRenderer::CHTMLRendererText();
|
||||
|
||||
m_pTextRenderer->Init(m_pFile, 8);
|
||||
m_pFile->DrawPageOnRenderer(m_pTextRenderer, nPageIndex, NULL);
|
||||
|
||||
return m_pTextRenderer->GetBuffer();
|
||||
}
|
||||
BYTE* GetLinks(int nPageIndex)
|
||||
{
|
||||
return m_pFile->GetLinks(nPageIndex);
|
||||
}
|
||||
BYTE* GetStructure()
|
||||
{
|
||||
return m_pFile->GetStructure();
|
||||
}
|
||||
BYTE* GetInteractiveFormsInfo()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->GetWidgets();
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetInteractiveFormsFonts(int nTypeFonts)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
if (nTypeFonts == 1)
|
||||
return ((CPdfFile*)m_pFile)->GetAnnotEmbeddedFonts();
|
||||
if (nTypeFonts == 2)
|
||||
return ((CPdfFile*)m_pFile)->GetAnnotStandardFonts();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BYTE* GetInteractiveFormsAP(int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nWidget, int nView, int nButtonView)
|
||||
{
|
||||
if (0 != m_nType)
|
||||
return NULL;
|
||||
|
||||
const char* sView = NULL;
|
||||
if (nView == 0)
|
||||
sView = "N";
|
||||
else if (nView == 1)
|
||||
sView = "D";
|
||||
else if (nView == 2)
|
||||
sView = "R";
|
||||
|
||||
const char* sButtonView = NULL;
|
||||
if (nButtonView == 0)
|
||||
sButtonView = "Off";
|
||||
else if (nButtonView == 1)
|
||||
sButtonView = "Yes";
|
||||
|
||||
return ((CPdfFile*)m_pFile)->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sButtonView);
|
||||
}
|
||||
BYTE* GetButtonIcons(int nBackgroundColor, int nPageIndex, int bBase64, int nButtonWidget, int nIconView)
|
||||
{
|
||||
if (0 != m_nType)
|
||||
return NULL;
|
||||
|
||||
const char* sIconView = NULL;
|
||||
if (nIconView == 0)
|
||||
sIconView = "I";
|
||||
else if (nIconView == 1)
|
||||
sIconView = "RI";
|
||||
else if (nIconView == 2)
|
||||
sIconView = "IX";
|
||||
|
||||
return ((CPdfFile*)m_pFile)->GetButtonIcon(nBackgroundColor, nPageIndex, bBase64 ? true : false, nButtonWidget, sIconView);
|
||||
}
|
||||
BYTE* GetAnnotationsInfo(int nPageIndex)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->GetAnnots(nPageIndex);
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetAnnotationsAP(int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nAnnot, int nView)
|
||||
{
|
||||
if (m_nType != 0)
|
||||
return NULL;
|
||||
|
||||
const char* sView = NULL;
|
||||
if (nView == 0)
|
||||
sView = "N";
|
||||
else if (nView == 1)
|
||||
sView = "D";
|
||||
else if (nView == 2)
|
||||
sView = "R";
|
||||
|
||||
return ((CPdfFile*)m_pFile)->GetAPAnnots(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nAnnot, sView);
|
||||
}
|
||||
|
||||
void DestroyTextInfo()
|
||||
{
|
||||
RELEASEOBJECT(m_pTextRenderer);
|
||||
}
|
||||
bool IsNeedCMap()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->IsNeedCMap();
|
||||
return false;
|
||||
}
|
||||
void SetCMapData(BYTE* data, int size)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
((CPdfFile*)m_pFile)->SetCMapMemory(data, size);
|
||||
}
|
||||
BYTE* ScanPage(int nPageIndex, int mode)
|
||||
{
|
||||
if (NULL == m_pImageStorage)
|
||||
m_pImageStorage = NSDocxRenderer::CreateWasmImageStorage();
|
||||
|
||||
CDocxRenderer oRenderer(m_pApplicationFonts);
|
||||
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;
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
|
||||
void* GetImageBase64(int rId)
|
||||
{
|
||||
if (NULL == m_pImageStorage)
|
||||
return NULL;
|
||||
return m_pImageStorage->GetBase64(rId);
|
||||
}
|
||||
int GetImageBase64Len(std::string* p)
|
||||
{
|
||||
return (int)p->length();
|
||||
}
|
||||
char* GetImageBase64Ptr(std::string* p)
|
||||
{
|
||||
return (char*)p->c_str();
|
||||
}
|
||||
void GetImageBase64Free(std::string* p)
|
||||
{
|
||||
*p = "";
|
||||
}
|
||||
|
||||
void SetFontBinary(char* path, BYTE* data, int size)
|
||||
{
|
||||
NSFonts::IFontsMemoryStorage* pStorage = NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
|
||||
if (pStorage)
|
||||
{
|
||||
std::string sPathA(path);
|
||||
pStorage->Add(UTF8_TO_U(sPathA), data, size, true);
|
||||
}
|
||||
}
|
||||
int IsFontBinaryExist(char* path)
|
||||
{
|
||||
NSFonts::IFontsMemoryStorage* pStorage = NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
|
||||
if (pStorage)
|
||||
{
|
||||
std::string sPathA(path);
|
||||
NSFonts::IFontStream* pStream = pStorage->Get(UTF8_TO_U(sPathA));
|
||||
if (pStream)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
BYTE* GetFontBinary(const std::string& sPathA)
|
||||
{
|
||||
std::wstring sFontName = UTF8_TO_U(sPathA);
|
||||
|
||||
std::wstring sFontFile;
|
||||
if (m_nType == 0)
|
||||
sFontFile = ((CPdfFile*)m_pFile)->GetFontPath(sFontName);
|
||||
|
||||
if (sFontFile.empty())
|
||||
sFontFile = sFontName;
|
||||
|
||||
NSFonts::IFontsMemoryStorage* pStorage = GetFontsStorage();
|
||||
if (pStorage)
|
||||
{
|
||||
NSFonts::IFontStream* pStream = pStorage->Get(sFontFile);
|
||||
if (pStream)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
LONG lLength = 0;
|
||||
pStream->GetMemory(pData, lLength);
|
||||
|
||||
if (pData)
|
||||
{
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
|
||||
oRes.AddInt(lLength);
|
||||
|
||||
unsigned long long npSubMatrix = (unsigned long long)pData;
|
||||
unsigned int npSubMatrix1 = npSubMatrix & 0xFFFFFFFF;
|
||||
oRes.AddInt(npSubMatrix1);
|
||||
oRes.AddInt(npSubMatrix >> 32);
|
||||
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
private:
|
||||
int GetPagesCount()
|
||||
{
|
||||
return m_pFile->GetPagesCount();
|
||||
}
|
||||
int GetMaxRefID()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->GetMaxRefID();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetPageInfo(int nPageIndex, int& nWidth, int& nHeight, int& nPageDpiX, int& nRotate)
|
||||
{
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
m_pFile->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
if (m_nType == 2)
|
||||
{
|
||||
dWidth = dWidth / 25.4 * 96.0;
|
||||
dHeight = dHeight / 25.4 * 96.0;
|
||||
dPageDpiX = dPageDpiX / 25.4 * 96.0;
|
||||
}
|
||||
if (m_nType == 0)
|
||||
nRotate = ((CPdfFile*)m_pFile)->GetRotate(nPageIndex);
|
||||
nWidth = dWidth;
|
||||
nHeight = dHeight;
|
||||
nPageDpiX = dPageDpiX;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // DRAWINGFILE_H
|
||||
306
DesktopEditor/doctrenderer/editors.h
Normal file
306
DesktopEditor/doctrenderer/editors.h
Normal file
@ -0,0 +1,306 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#ifndef DOC_BUILDER_EDITORS_CONFIG
|
||||
#define DOC_BUILDER_EDITORS_CONFIG
|
||||
|
||||
#include "./config.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../common/StringBuilder.h"
|
||||
|
||||
#ifdef CreateFile
|
||||
#undef CreateFile
|
||||
#endif
|
||||
|
||||
namespace NSDoctRenderer
|
||||
{
|
||||
enum class DoctRendererEditorType
|
||||
{
|
||||
WORD = 0,
|
||||
CELL = 1,
|
||||
SLIDE = 2,
|
||||
VISIO = 3,
|
||||
PDF = 4,
|
||||
|
||||
INVALID = 255
|
||||
};
|
||||
|
||||
static void AppendScript(NSStringUtils::CStringBuilderA* builder, const std::wstring& path)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.OpenFile(path))
|
||||
return;
|
||||
|
||||
int size = (int)oFile.GetFileSize();
|
||||
if (size < 3)
|
||||
return;
|
||||
|
||||
BYTE* pData = new BYTE[size];
|
||||
DWORD dwReadSize = 0;
|
||||
oFile.ReadFile(pData, (DWORD)size, dwReadSize);
|
||||
oFile.CloseFile();
|
||||
|
||||
int nOffset = 0;
|
||||
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xBF)
|
||||
nOffset = 3;
|
||||
|
||||
builder->WriteString((char*)(pData + nOffset), size - nOffset);
|
||||
builder->WriteString("\n\n");
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
}
|
||||
|
||||
static bool RunScript(JSSmart<NSJSBase::CJSContext>& context, JSSmart<NSJSBase::CJSTryCatch>& try_catch, const std::wstring& path)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
|
||||
if (!oFile.OpenFile(path))
|
||||
return false;
|
||||
|
||||
int size = (int)oFile.GetFileSize();
|
||||
if (size < 3)
|
||||
return false;
|
||||
|
||||
BYTE* pData = new BYTE[size];
|
||||
DWORD dwReadSize = 0;
|
||||
oFile.ReadFile(pData, (DWORD)size, dwReadSize);
|
||||
oFile.CloseFile();
|
||||
|
||||
int nOffset = 0;
|
||||
if (pData[0] == 0xEF && pData[1] == 0xBB && pData[2] == 0xBF)
|
||||
nOffset = 3;
|
||||
|
||||
context->runScript(std::string((char*)(pData + nOffset), size - nOffset), try_catch);
|
||||
RELEASEARRAYOBJECTS(pData);
|
||||
|
||||
return !try_catch->Check();
|
||||
}
|
||||
|
||||
static std::wstring GetAllScript(NSStringUtils::CStringBuilderA* builder, const DoctRendererEditorType& type, CDoctRendererConfig* config, const bool& isSnapshot = false)
|
||||
{
|
||||
for (std::vector<std::wstring>::const_iterator i = config->m_arrFiles.cbegin(); i != config->m_arrFiles.cend(); i++)
|
||||
AppendScript(builder, *i);
|
||||
|
||||
std::wstring sFontsPath = config->m_strSdkPath + L"/common/libfont/engine";
|
||||
#ifdef SUPPORT_HARFBUZZ_SHAPER
|
||||
sFontsPath += L"/fonts_native.js";
|
||||
#else
|
||||
sFontsPath += L"/fonts_ie.js";
|
||||
#endif
|
||||
|
||||
std::wstring sCachePath = L"";
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DoctRendererEditorType::WORD:
|
||||
{
|
||||
AppendScript(builder, config->m_strSdkPath + L"/word/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/word/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/word/sdk-all";
|
||||
break;
|
||||
}
|
||||
case DoctRendererEditorType::SLIDE:
|
||||
{
|
||||
AppendScript(builder, config->m_strSdkPath + L"/slide/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/slide/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/slide/sdk-all";
|
||||
break;
|
||||
}
|
||||
case DoctRendererEditorType::CELL:
|
||||
{
|
||||
AppendScript(builder, config->m_strSdkPath + L"/cell/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/cell/sdk-all.js");
|
||||
builder->WriteString("\n$.ready();", 11);
|
||||
sCachePath = config->m_strSdkPath + L"/cell/sdk-all";
|
||||
break;
|
||||
}
|
||||
case DoctRendererEditorType::VISIO:
|
||||
{
|
||||
if (!NSFile::CFileBinary::Exists(config->m_strSdkPath + L"/draw/sdk-all-min.js"))
|
||||
return L"";
|
||||
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/draw/sdk-all.js");
|
||||
sCachePath = config->m_strSdkPath + L"/draw/sdk-all";
|
||||
break;
|
||||
}
|
||||
case DoctRendererEditorType::PDF:
|
||||
{
|
||||
AppendScript(builder, config->m_strSdkPath + L"/word/sdk-all-min.js");
|
||||
AppendScript(builder, sFontsPath);
|
||||
AppendScript(builder, config->m_strSdkPath + L"/word/sdk-all.js");
|
||||
AppendScript(builder, config->m_strSdkPath + L"/pdf/src/engine/drawingfile_native.js");
|
||||
sCachePath = config->m_strSdkPath + L"/pdf/sdk-all";
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!sCachePath.empty())
|
||||
sCachePath += (isSnapshot ? L".bin" : L".cache");
|
||||
|
||||
return sCachePath;
|
||||
}
|
||||
|
||||
static std::wstring GetSnapshotPath(const DoctRendererEditorType& type, CDoctRendererConfig* config)
|
||||
{
|
||||
std::wstring sCachePath = L"";
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DoctRendererEditorType::WORD:
|
||||
{
|
||||
return config->m_strSdkPath + L"/word/sdk-all.bin";
|
||||
}
|
||||
case DoctRendererEditorType::SLIDE:
|
||||
{
|
||||
return config->m_strSdkPath + L"/slide/sdk-all.bin";
|
||||
}
|
||||
case DoctRendererEditorType::CELL:
|
||||
{
|
||||
return config->m_strSdkPath + L"/cell/sdk-all.bin";
|
||||
}
|
||||
case DoctRendererEditorType::VISIO:
|
||||
{
|
||||
return config->m_strSdkPath + L"/draw/sdk-all.bin";
|
||||
}
|
||||
case DoctRendererEditorType::PDF:
|
||||
{
|
||||
return config->m_strSdkPath + L"/pdf/sdk-all.bin";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return L"";
|
||||
}
|
||||
|
||||
static bool RunEditorFooter(JSSmart<NSJSBase::CJSContext>& context, JSSmart<NSJSBase::CJSTryCatch>& try_catch, CDoctRendererConfig* config)
|
||||
{
|
||||
if (!RunScript(context, try_catch, config->m_strAllFonts))
|
||||
return false;
|
||||
|
||||
std::string sFooter = "\
|
||||
window.InitNativeObject();\
|
||||
window.InitNativeTextMeasurer();\
|
||||
window.InitNativeZLib();\
|
||||
AscFonts.checkAllFonts();\n";
|
||||
|
||||
if (context->isSnapshotUsed())
|
||||
{
|
||||
sFooter += "\
|
||||
if (undefined === String.prototype.replaceAll)\
|
||||
{\
|
||||
String.prototype.replaceAll = function(str, newStr)\
|
||||
{\
|
||||
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]')\
|
||||
return this.replace(str, newStr);\
|
||||
return this.split(str).join(newStr);\
|
||||
};\
|
||||
}\n";
|
||||
}
|
||||
|
||||
context->runScript(sFooter, try_catch);
|
||||
return !try_catch->Check();
|
||||
}
|
||||
|
||||
static bool RunEditor(const DoctRendererEditorType& type, JSSmart<NSJSBase::CJSContext>& context, JSSmart<NSJSBase::CJSTryCatch>& try_catch, CDoctRendererConfig* config)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA builder;
|
||||
builder.AddSize(10 * 1024 * 1024);
|
||||
std::wstring sCachePath = GetAllScript(&builder, type, config);
|
||||
|
||||
if (!sCachePath.empty())
|
||||
{
|
||||
context->runScript(builder.GetData(), try_catch, config->m_bIsUseCache ? sCachePath : L"");
|
||||
RunEditorFooter(context, try_catch, config);
|
||||
}
|
||||
|
||||
return !try_catch->Check();
|
||||
}
|
||||
|
||||
static bool GenerateEditorSnapshot(const DoctRendererEditorType& type, CDoctRendererConfig* config)
|
||||
{
|
||||
NSStringUtils::CStringBuilderA builder;
|
||||
builder.AddSize(10 * 1024 * 1024);
|
||||
std::wstring sCachePath = GetAllScript(&builder, type, config, true);
|
||||
|
||||
builder.WriteString("delete String.prototype.replaceAll;");
|
||||
|
||||
if (sCachePath.empty())
|
||||
return false;
|
||||
|
||||
return NSJSBase::CJSContext::generateSnapshot(builder.GetData(), sCachePath);
|
||||
}
|
||||
|
||||
static JSSmart<NSJSBase::CJSContext> RunEditorWithSnapshot(const DoctRendererEditorType& type, CDoctRendererConfig* config)
|
||||
{
|
||||
#ifndef V8_VERSION_89_PLUS
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
#ifndef V8_SUPPORT_SNAPSHOTS
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
std::wstring sCachePath = GetSnapshotPath(type, config);
|
||||
if (!NSFile::CFileBinary::Exists(sCachePath))
|
||||
return NULL;
|
||||
|
||||
if (sCachePath.empty())
|
||||
return NULL;
|
||||
|
||||
JSSmart<NSJSBase::CJSContext> context = new NSJSBase::CJSContext(false);
|
||||
context->Initialize(sCachePath);
|
||||
|
||||
NSJSBase::CJSContextScope scope(context);
|
||||
|
||||
JSSmart<NSJSBase::CJSTryCatch> try_catch = context->GetExceptions();
|
||||
|
||||
if (!RunEditorFooter(context, try_catch, config))
|
||||
return NULL;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static JSSmart<NSJSBase::CJSContext> CreateEditorContext(const DoctRendererEditorType& type, CDoctRendererConfig* config)
|
||||
{
|
||||
JSSmart<NSJSBase::CJSContext> context = RunEditorWithSnapshot(type, config);
|
||||
if (context.is_init())
|
||||
return context;
|
||||
return new NSJSBase::CJSContext();
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DOC_BUILDER_EDITORS_CONFIG
|
||||
@ -1,7 +1,7 @@
|
||||
#ifndef _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
#define _BUILD_NATIVE_DEFAULT_EMBED_H_
|
||||
|
||||
#include "../js_internal/js_base.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
namespace NSJSBase
|
||||
{
|
||||
|
||||
119
DesktopEditor/doctrenderer/embed/DrawingFileEmbed.cpp
Normal file
119
DesktopEditor/doctrenderer/embed/DrawingFileEmbed.cpp
Normal file
@ -0,0 +1,119 @@
|
||||
#include "DrawingFileEmbed.h"
|
||||
|
||||
JSSmart<CJSValue> MoveMemoryToJS(BYTE* pWasmData)
|
||||
{
|
||||
if (NULL == pWasmData)
|
||||
return CJSContext::createNull();
|
||||
|
||||
int nLen = 0;
|
||||
memcpy(&nLen, pWasmData, sizeof(int));
|
||||
if (4 >= nLen)
|
||||
return CJSContext::createNull();
|
||||
|
||||
size_t nBufferSize = (size_t)(nLen - 4);
|
||||
BYTE* pMemory = NSJSBase::NSAllocator::Alloc(nBufferSize);
|
||||
memcpy(pMemory, pWasmData + 4, nBufferSize);
|
||||
free(pWasmData);
|
||||
|
||||
return NSJSBase::CJSContext::createUint8Array(pMemory, (int)nBufferSize, false);
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::OpenFile(JSSmart<CJSValue> sFile, JSSmart<CJSValue> sPassword)
|
||||
{
|
||||
bool bResult = m_pFile->OpenFile(sFile->toStringW(), sPassword->isString() ? sPassword->toStringW() : L"");
|
||||
return CJSContext::createBool(bResult);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::CloseFile()
|
||||
{
|
||||
m_pFile->CloseFile();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetType()
|
||||
{
|
||||
return CJSContext::createInt(m_pFile->GetType());
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetErrorCode()
|
||||
{
|
||||
return CJSContext::createInt(m_pFile->GetErrorCode());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetInfo()
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetInfo());
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetPixmap(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetPixmap(nPageIndex->toInt32(), nRasterW->toInt32(), nRasterH->toInt32(), nBackgroundColor->toInt32()));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetGlyphs(JSSmart<CJSValue> nPageIndex)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetGlyphs(nPageIndex->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetLinks(JSSmart<CJSValue> nPageIndex)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetLinks(nPageIndex->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetStructure()
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetStructure());
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetInteractiveFormsInfo()
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetInteractiveFormsInfo());
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetInteractiveFormsFonts(JSSmart<CJSValue> nTypeFonts)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetInteractiveFormsFonts(nTypeFonts->toInt32()));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetInteractiveFormsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor,
|
||||
JSSmart<CJSValue> nPageIndex,
|
||||
JSSmart<CJSValue> nWidget, JSSmart<CJSValue> nView, JSSmart<CJSValue> nButtonView)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetInteractiveFormsAP(nRasterW->toInt32(), nRasterH->toInt32(), nBackgroundColor->toInt32(),
|
||||
nPageIndex->toInt32(),
|
||||
nWidget->toInt32(), nView->toInt32(), nButtonView->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetButtonIcons(JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> bBase64,
|
||||
JSSmart<CJSValue> nButtonWidget, JSSmart<CJSValue> nIconView)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetButtonIcons(nBackgroundColor->toInt32(), nPageIndex->toInt32(), bBase64->toInt32(),
|
||||
nButtonWidget->toInt32(), nIconView->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetAnnotationsInfo(JSSmart<CJSValue> nPageIndex)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetAnnotationsInfo(nPageIndex->toInt32()));
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetAnnotationsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor,
|
||||
JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nAnnot, JSSmart<CJSValue> nView)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->GetAnnotationsAP(nRasterW->toInt32(), nRasterH->toInt32(), nBackgroundColor->toInt32(),
|
||||
nPageIndex->toInt32(), nAnnot->toInt32(), nView->toInt32()));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::DestroyTextInfo()
|
||||
{
|
||||
m_pFile->DestroyTextInfo();
|
||||
return CJSContext::createUndefined();
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::IsNeedCMap()
|
||||
{
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::ScanPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> mode)
|
||||
{
|
||||
return MoveMemoryToJS(m_pFile->ScanPage(nPageIndex->toInt32(), mode->toInt32()));
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::GetImageBase64(JSSmart<CJSValue> rId)
|
||||
{
|
||||
std::string* pData = (std::string*)m_pFile->GetImageBase64(rId->toInt32());
|
||||
if (!pData)
|
||||
return CJSContext::createNull();
|
||||
JSSmart<CJSValue> ret = CJSContext::createString(*pData);
|
||||
*pData = "";
|
||||
return ret;
|
||||
}
|
||||
56
DesktopEditor/doctrenderer/embed/DrawingFileEmbed.h
Normal file
56
DesktopEditor/doctrenderer/embed/DrawingFileEmbed.h
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef _BUILD_DRAWING_EMBED_H_
|
||||
#define _BUILD_DRAWING_EMBED_H_
|
||||
|
||||
#include "../drawingfile.h"
|
||||
#include "../js_internal/js_base.h"
|
||||
|
||||
using namespace NSJSBase;
|
||||
class JS_DECL CDrawingFileEmbed : public CJSEmbedObject
|
||||
{
|
||||
public:
|
||||
CDrawingFile* m_pFile;
|
||||
|
||||
public:
|
||||
CDrawingFileEmbed()
|
||||
{
|
||||
m_pFile = NULL;
|
||||
}
|
||||
~CDrawingFileEmbed()
|
||||
{
|
||||
RELEASEOBJECT(m_pFile);
|
||||
}
|
||||
|
||||
virtual void* getObject() override { return (void*)m_pFile; }
|
||||
|
||||
public:
|
||||
JSSmart<CJSValue> OpenFile(JSSmart<CJSValue> sFile, JSSmart<CJSValue> sPassword);
|
||||
JSSmart<CJSValue> CloseFile();
|
||||
|
||||
JSSmart<CJSValue> GetType();
|
||||
JSSmart<CJSValue> GetErrorCode();
|
||||
|
||||
JSSmart<CJSValue> GetInfo();
|
||||
|
||||
JSSmart<CJSValue> GetPixmap(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor);
|
||||
|
||||
JSSmart<CJSValue> GetGlyphs(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> GetLinks(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> GetStructure();
|
||||
JSSmart<CJSValue> GetInteractiveFormsInfo();
|
||||
JSSmart<CJSValue> GetInteractiveFormsFonts(JSSmart<CJSValue> nTypeFonts);
|
||||
|
||||
JSSmart<CJSValue> GetInteractiveFormsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nWidget, JSSmart<CJSValue> nView, JSSmart<CJSValue> nButtonView);
|
||||
JSSmart<CJSValue> GetButtonIcons(JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> bBase64, JSSmart<CJSValue> nButtonWidget, JSSmart<CJSValue> nIconView);
|
||||
JSSmart<CJSValue> GetAnnotationsInfo(JSSmart<CJSValue> nPageIndex);
|
||||
JSSmart<CJSValue> GetAnnotationsAP(JSSmart<CJSValue> nRasterW, JSSmart<CJSValue> nRasterH, JSSmart<CJSValue> nBackgroundColor, JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> nAnnot, JSSmart<CJSValue> nView);
|
||||
|
||||
JSSmart<CJSValue> DestroyTextInfo();
|
||||
JSSmart<CJSValue> IsNeedCMap();
|
||||
JSSmart<CJSValue> ScanPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> mode);
|
||||
|
||||
JSSmart<CJSValue> GetImageBase64(JSSmart<CJSValue> rId);
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
#endif // _BUILD_NATIVE_ZIP_EMBED_H_
|
||||
81
DesktopEditor/doctrenderer/embed/jsc/jsc_DrawingFileEmbed.mm
Normal file
81
DesktopEditor/doctrenderer/embed/jsc/jsc_DrawingFileEmbed.mm
Normal file
@ -0,0 +1,81 @@
|
||||
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
|
||||
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
|
||||
|
||||
#include "../DrawingFileEmbed.h"
|
||||
#include "../../js_internal/jsc/jsc_base.h"
|
||||
|
||||
@protocol IJSCDrawingFileEmbed <JSExport>
|
||||
-(JSValue*) OpenFile : (JSValue*)sFile : (JSValue*)sPassword;
|
||||
-(JSValue*) CloseFile;
|
||||
-(JSValue*) GetType;
|
||||
-(JSValue*) GetErrorCode;
|
||||
-(JSValue*) GetInfo;
|
||||
-(JSValue*) GetPixmap : (JSValue*)nPageIndex : (JSValue*)nRasterW : (JSValue*)nRasterH : (JSValue*)nBackgroundColor;
|
||||
-(JSValue*) GetGlyphs : (JSValue*)nPageIndex;
|
||||
-(JSValue*) GetLinks : (JSValue*)nPageIndex;
|
||||
-(JSValue*) GetStructure;
|
||||
-(JSValue*) GetInteractiveFormsInfo;
|
||||
-(JSValue*) GetInteractiveFormsFonts : (JSValue*)nTypeFonts;
|
||||
-(JSValue*) GetInteractiveFormsAP : (JSValue*)nRasterW : (JSValue*)nRasterH : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)nWidget : (JSValue*)nView : (JSValue*)nButtonView;
|
||||
-(JSValue*) GetButtonIcons : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)bBase64 : (JSValue*)nButtonWidget : (JSValue*)nIconView;
|
||||
-(JSValue*) GetAnnotationsInfo : (JSValue*)nPageIndex;
|
||||
-(JSValue*) GetAnnotationsAP : (JSValue*)nRasterW : (JSValue*)nRasterH : (JSValue*)nBackgroundColor : (JSValue*)nPageIndex : (JSValue*)nAnnot : (JSValue*)nView;
|
||||
-(JSValue*) DestroyTextInfo;
|
||||
-(JSValue*) IsNeedCMap;
|
||||
-(JSValue*) ScanPage : (JSValue*)nPageIndex : (JSValue*)mode;
|
||||
-(JSValue*) GetImageBase64 : (JSValue*)rId;
|
||||
@end
|
||||
|
||||
@interface CJSCDrawingFileEmbed : NSObject<IJSCDrawingFileEmbed, JSEmbedObjectProtocol>
|
||||
{
|
||||
@public
|
||||
CDrawingFileEmbed* m_internal;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CJSCDrawingFileEmbed
|
||||
EMBED_OBJECT_WRAPPER_METHODS(CDrawingFileEmbed);
|
||||
|
||||
FUNCTION_WRAPPER_JS_2(OpenFile, OpenFile)
|
||||
FUNCTION_WRAPPER_JS_0(CloseFile, CloseFile)
|
||||
FUNCTION_WRAPPER_JS_0(GetType, GetType)
|
||||
FUNCTION_WRAPPER_JS_0(GetErrorCode, GetErrorCode)
|
||||
FUNCTION_WRAPPER_JS_0(GetInfo, GetInfo)
|
||||
FUNCTION_WRAPPER_JS_4(GetPixmap, GetPixmap)
|
||||
FUNCTION_WRAPPER_JS_1(GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_JS_1(GetLinks, GetLinks)
|
||||
FUNCTION_WRAPPER_JS_0(GetStructure, GetStructure)
|
||||
FUNCTION_WRAPPER_JS_0(GetInteractiveFormsInfo, GetInteractiveFormsInfo)
|
||||
FUNCTION_WRAPPER_JS_1(GetInteractiveFormsFonts, GetInteractiveFormsFonts)
|
||||
FUNCTION_WRAPPER_JS_7(GetInteractiveFormsAP, GetInteractiveFormsAP)
|
||||
FUNCTION_WRAPPER_JS_5(GetButtonIcons, GetButtonIcons)
|
||||
FUNCTION_WRAPPER_JS_1(GetAnnotationsInfo, GetAnnotationsInfo)
|
||||
FUNCTION_WRAPPER_JS_6(GetAnnotationsAP, GetAnnotationsAP)
|
||||
FUNCTION_WRAPPER_JS_0(DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_JS_0(IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_JS_2(ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_JS_1(GetImageBase64, GetImageBase64)
|
||||
@end
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterJSC
|
||||
{
|
||||
public:
|
||||
virtual id getExportedObject(CJSEmbedObject* pNative) override
|
||||
{
|
||||
return [[CJSCDrawingFileEmbed alloc] init:(CDrawingFileEmbed*)pNative];
|
||||
}
|
||||
};
|
||||
|
||||
CJSEmbedObjectAdapterBase* CDrawingFileEmbed::getAdapter()
|
||||
{
|
||||
if (m_pAdapter == nullptr)
|
||||
m_pAdapter = new CDrawingFileEmbedAdapter();
|
||||
return m_pAdapter;
|
||||
}
|
||||
|
||||
std::string CDrawingFileEmbed::getName() { return "CDrawingFileEmbed"; }
|
||||
|
||||
CJSEmbedObject* CDrawingFileEmbed::getCreator()
|
||||
{
|
||||
return new CDrawingFileEmbed();
|
||||
}
|
||||
84
DesktopEditor/doctrenderer/embed/v8/v8_DrawingFileEmbed.cpp
Normal file
84
DesktopEditor/doctrenderer/embed/v8/v8_DrawingFileEmbed.cpp
Normal file
@ -0,0 +1,84 @@
|
||||
// THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT CHANGE IT!
|
||||
// IF YOU NEED TO UPDATE THIS CODE, JUST RERUN PYTHON SCRIPT WITH "--internal" OPTION.
|
||||
|
||||
#include "../DrawingFileEmbed.h"
|
||||
#include "../../js_internal/v8/v8_base.h"
|
||||
|
||||
namespace NSDrawingFileEmbed
|
||||
{
|
||||
#define CURRENTWRAPPER CDrawingFileEmbed
|
||||
|
||||
FUNCTION_WRAPPER_V8_2(_OpenFile, OpenFile)
|
||||
FUNCTION_WRAPPER_V8_0(_CloseFile, CloseFile)
|
||||
FUNCTION_WRAPPER_V8_0(_GetType, GetType)
|
||||
FUNCTION_WRAPPER_V8_0(_GetErrorCode, GetErrorCode)
|
||||
FUNCTION_WRAPPER_V8_0(_GetInfo, GetInfo)
|
||||
FUNCTION_WRAPPER_V8_4(_GetPixmap, GetPixmap)
|
||||
FUNCTION_WRAPPER_V8_1(_GetGlyphs, GetGlyphs)
|
||||
FUNCTION_WRAPPER_V8_1(_GetLinks, GetLinks)
|
||||
FUNCTION_WRAPPER_V8_0(_GetStructure, GetStructure)
|
||||
FUNCTION_WRAPPER_V8_0(_GetInteractiveFormsInfo, GetInteractiveFormsInfo)
|
||||
FUNCTION_WRAPPER_V8_1(_GetInteractiveFormsFonts, GetInteractiveFormsFonts)
|
||||
FUNCTION_WRAPPER_V8_7(_GetInteractiveFormsAP, GetInteractiveFormsAP)
|
||||
FUNCTION_WRAPPER_V8_5(_GetButtonIcons, GetButtonIcons)
|
||||
FUNCTION_WRAPPER_V8_1(_GetAnnotationsInfo, GetAnnotationsInfo)
|
||||
FUNCTION_WRAPPER_V8_6(_GetAnnotationsAP, GetAnnotationsAP)
|
||||
FUNCTION_WRAPPER_V8_0(_DestroyTextInfo, DestroyTextInfo)
|
||||
FUNCTION_WRAPPER_V8_0(_IsNeedCMap, IsNeedCMap)
|
||||
FUNCTION_WRAPPER_V8_2(_ScanPage, ScanPage)
|
||||
FUNCTION_WRAPPER_V8_1(_GetImageBase64, GetImageBase64)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> result = v8::ObjectTemplate::New(isolate);
|
||||
result->SetInternalFieldCount(1);
|
||||
|
||||
NSV8Objects::Template_Set(result, "OpenFile", _OpenFile);
|
||||
NSV8Objects::Template_Set(result, "CloseFile", _CloseFile);
|
||||
NSV8Objects::Template_Set(result, "GetType", _GetType);
|
||||
NSV8Objects::Template_Set(result, "GetErrorCode", _GetErrorCode);
|
||||
NSV8Objects::Template_Set(result, "GetInfo", _GetInfo);
|
||||
NSV8Objects::Template_Set(result, "GetPixmap", _GetPixmap);
|
||||
NSV8Objects::Template_Set(result, "GetGlyphs", _GetGlyphs);
|
||||
NSV8Objects::Template_Set(result, "GetLinks", _GetLinks);
|
||||
NSV8Objects::Template_Set(result, "GetStructure", _GetStructure);
|
||||
NSV8Objects::Template_Set(result, "GetInteractiveFormsInfo", _GetInteractiveFormsInfo);
|
||||
NSV8Objects::Template_Set(result, "GetInteractiveFormsFonts", _GetInteractiveFormsFonts);
|
||||
NSV8Objects::Template_Set(result, "GetInteractiveFormsAP", _GetInteractiveFormsAP);
|
||||
NSV8Objects::Template_Set(result, "GetButtonIcons", _GetButtonIcons);
|
||||
NSV8Objects::Template_Set(result, "GetAnnotationsInfo", _GetAnnotationsInfo);
|
||||
NSV8Objects::Template_Set(result, "GetAnnotationsAP", _GetAnnotationsAP);
|
||||
NSV8Objects::Template_Set(result, "DestroyTextInfo", _DestroyTextInfo);
|
||||
NSV8Objects::Template_Set(result, "IsNeedCMap", _IsNeedCMap);
|
||||
NSV8Objects::Template_Set(result, "ScanPage", _ScanPage);
|
||||
NSV8Objects::Template_Set(result, "GetImageBase64", _GetImageBase64);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
}
|
||||
|
||||
class CDrawingFileEmbedAdapter : public CJSEmbedObjectAdapterV8Template
|
||||
{
|
||||
public:
|
||||
virtual v8::Local<v8::ObjectTemplate> getTemplate(v8::Isolate* isolate) override
|
||||
{
|
||||
v8::EscapableHandleScope handle_scope(isolate);
|
||||
v8::Local<v8::ObjectTemplate> templ = NSDrawingFileEmbed::CreateTemplate(isolate);
|
||||
return handle_scope.Escape(templ);
|
||||
}
|
||||
};
|
||||
|
||||
CJSEmbedObjectAdapterBase* CDrawingFileEmbed::getAdapter()
|
||||
{
|
||||
if (m_pAdapter == nullptr)
|
||||
m_pAdapter = new CDrawingFileEmbedAdapter();
|
||||
return m_pAdapter;
|
||||
}
|
||||
|
||||
std::string CDrawingFileEmbed::getName() { return "CDrawingFileEmbed"; }
|
||||
|
||||
CJSEmbedObject* CDrawingFileEmbed::getCreator()
|
||||
{
|
||||
return new CDrawingFileEmbed();
|
||||
}
|
||||
@ -440,14 +440,21 @@ namespace NSJSBase
|
||||
/**
|
||||
* Initializes the JS context.
|
||||
* By default it happens automatically when creating a CJSConext instance.
|
||||
* @param snapshotPath Path to snapshot file.
|
||||
*/
|
||||
void Initialize();
|
||||
void Initialize(const std::wstring& snapshotPath = L"");
|
||||
/**
|
||||
* Releases any resources taken by the JS context.
|
||||
* Generally there is no need to call it manually, cause this method called when CJSConext is being destructed.
|
||||
*/
|
||||
void Dispose();
|
||||
|
||||
/**
|
||||
* Get information about snapshot
|
||||
* @return Returns true if snapshot was used on Initialize method
|
||||
*/
|
||||
bool isSnapshotUsed();
|
||||
|
||||
/**
|
||||
* Creates and returns the pointer to an object for tracking exceptions during code execution in current JS context.
|
||||
*/
|
||||
@ -480,6 +487,15 @@ namespace NSJSBase
|
||||
AddEmbedCreator(T::getName(), T::getCreator, isAllowedInJS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate snapshot by script.
|
||||
* @param script The script to be executed.
|
||||
* @param exception The object for handling exceptions.
|
||||
* @param snapshotPath The path to the snapshot
|
||||
* @return Returns true whether a snapshot has been created.
|
||||
*/
|
||||
static bool generateSnapshot(const std::string& script, const std::wstring& snapshotPath);
|
||||
|
||||
/**
|
||||
* Run the script in the current JS context.
|
||||
* @param script The script to be executed.
|
||||
|
||||
@ -215,7 +215,7 @@ namespace NSJSBase
|
||||
return new CJSCTryCatch();
|
||||
}
|
||||
|
||||
void CJSContext::Initialize()
|
||||
void CJSContext::Initialize(const std::wstring& snapshotPath)
|
||||
{
|
||||
m_internal->context = [[JSContext alloc] init];
|
||||
|
||||
@ -249,6 +249,11 @@ namespace NSJSBase
|
||||
m_internal->context = nil;
|
||||
}
|
||||
|
||||
bool CJSContext::isSnapshotUsed()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
JSSmart<CJSObject> CJSContext::GetGlobal()
|
||||
{
|
||||
CJSObjectJSC* ret = new CJSObjectJSC();
|
||||
@ -346,6 +351,11 @@ namespace NSJSBase
|
||||
return _value;
|
||||
}
|
||||
|
||||
bool CJSContext::generateSnapshot(const std::string& script, const std::wstring& snapshotPath)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
JSSmart<CJSValue> CJSContext::runScript(const std::string& script, JSSmart<CJSTryCatch> exception, const std::wstring& scriptPath)
|
||||
{
|
||||
CJSValueJSC* _value = new CJSValueJSC();
|
||||
|
||||
@ -98,12 +98,8 @@ namespace NSJSBase
|
||||
if (pCacheData)
|
||||
{
|
||||
// save cache to file
|
||||
NSFile::CFileBinary oFileTest;
|
||||
if (oFileTest.CreateFileW(Path))
|
||||
{
|
||||
oFileTest.WriteFile(pCacheData->data, (DWORD)pCacheData->length);
|
||||
oFileTest.CloseFile();
|
||||
}
|
||||
oFileTest.WriteFile(pCacheData->data, (DWORD)pCacheData->length);
|
||||
oFileTest.CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,12 +188,25 @@ namespace NSJSBase
|
||||
return new CV8TryCatch();
|
||||
}
|
||||
|
||||
void CJSContext::Initialize()
|
||||
void CJSContext::Initialize(const std::wstring& snapshotPath)
|
||||
{
|
||||
if (m_internal->m_isolate == NULL)
|
||||
{
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
if (!snapshotPath.empty())
|
||||
{
|
||||
BYTE* data = NULL;
|
||||
DWORD dataLength = 0;
|
||||
if (NSFile::CFileBinary::ReadAllBytes(snapshotPath, &data, dataLength))
|
||||
{
|
||||
m_internal->m_startup_data.data = reinterpret_cast<const char*>(data);
|
||||
m_internal->m_startup_data.raw_size = (int)dataLength;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// get new isolate
|
||||
v8::Isolate* isolate = CV8Worker::getInitializer().CreateNew();
|
||||
v8::Isolate* isolate = CV8Worker::getInitializer().CreateNew(m_internal->m_startup_data.data ? &m_internal->m_startup_data : nullptr);
|
||||
m_internal->m_isolate = isolate;
|
||||
// get new context
|
||||
v8::Isolate::Scope iscope(isolate);
|
||||
@ -223,6 +232,11 @@ namespace NSJSBase
|
||||
m_internal->m_isolate = NULL;
|
||||
}
|
||||
|
||||
bool CJSContext::isSnapshotUsed()
|
||||
{
|
||||
return m_internal->m_startup_data.data != NULL;
|
||||
}
|
||||
|
||||
JSSmart<CJSObject> CJSContext::GetGlobal()
|
||||
{
|
||||
CJSObjectV8* ret = new CJSObjectV8();
|
||||
@ -395,6 +409,51 @@ namespace NSJSBase
|
||||
return _return;
|
||||
}
|
||||
|
||||
bool CJSContext::generateSnapshot(const std::string& script, const std::wstring& snapshotPath)
|
||||
{
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
bool result = false;
|
||||
// snapshot creator should be in its own scope, because it handles entering, exiting and disposing the isolate
|
||||
v8::SnapshotCreator snapshotCreator;
|
||||
v8::Isolate* isolate = snapshotCreator.GetIsolate();
|
||||
{
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
// Create a new context
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
v8::Context::Scope context_scope(context);
|
||||
|
||||
// Trying to handle compile & run errors:
|
||||
// window
|
||||
v8::Local<v8::Object> global = context->Global();
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "window"), global).Check();
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "self"), global).Check();
|
||||
global->Set(context, v8::String::NewFromUtf8Literal(isolate, "native"), v8::Undefined(isolate)).Check();
|
||||
|
||||
// Compile and run
|
||||
v8::Local<v8::String> source = v8::String::NewFromUtf8(isolate, script.c_str()).ToLocalChecked();
|
||||
v8::Local<v8::Script> script = v8::Script::Compile(context, source).ToLocalChecked();
|
||||
|
||||
bool isEmpty = script->Run(context).IsEmpty();
|
||||
snapshotCreator.SetDefaultContext(context);
|
||||
}
|
||||
v8::StartupData data = snapshotCreator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);
|
||||
|
||||
NSFile::CFileBinary snapshotFile;
|
||||
if (data.data && snapshotFile.CreateFile(snapshotPath))
|
||||
{
|
||||
snapshotFile.WriteFile(data.data, (DWORD)data.raw_size);
|
||||
snapshotFile.CloseFile();
|
||||
result = true;
|
||||
}
|
||||
|
||||
delete[] data.data;
|
||||
|
||||
return result;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
JSSmart<CJSContext> CJSContext::GetCurrent()
|
||||
{
|
||||
CJSContext* ret = new CJSContext(false);
|
||||
|
||||
@ -180,7 +180,7 @@ public:
|
||||
return m_pAllocator;
|
||||
}
|
||||
|
||||
v8::Isolate* CreateNew()
|
||||
v8::Isolate* CreateNew(v8::StartupData* startupData = nullptr)
|
||||
{
|
||||
v8::Isolate::CreateParams create_params;
|
||||
#ifndef V8_OS_XP
|
||||
@ -200,6 +200,10 @@ public:
|
||||
nMaxVirtualMemory);
|
||||
#endif
|
||||
|
||||
#ifdef V8_VERSION_89_PLUS
|
||||
create_params.snapshot_blob = startupData;
|
||||
#endif
|
||||
|
||||
return v8::Isolate::New(create_params);
|
||||
}
|
||||
};
|
||||
@ -839,9 +843,13 @@ namespace NSJSBase
|
||||
v8::Persistent<v8::Context> m_contextPersistent;
|
||||
v8::Local<v8::Context> m_context;
|
||||
|
||||
v8::StartupData m_startup_data;
|
||||
|
||||
public:
|
||||
CJSContextPrivate() : m_isolate(NULL)
|
||||
{
|
||||
m_startup_data.data = NULL;
|
||||
m_startup_data.raw_size = 0;
|
||||
}
|
||||
|
||||
void InsertToGlobal(const std::string& name, v8::FunctionCallback creator)
|
||||
@ -850,6 +858,12 @@ namespace NSJSBase
|
||||
v8::MaybeLocal<v8::Function> oFuncMaybeLocal = templ->GetFunction(m_context);
|
||||
m_context->Global()->Set(m_context, CreateV8String(m_isolate, name.c_str()), oFuncMaybeLocal.ToLocalChecked());
|
||||
}
|
||||
|
||||
~CJSContextPrivate()
|
||||
{
|
||||
if (m_startup_data.data)
|
||||
delete [] m_startup_data.data;
|
||||
}
|
||||
};
|
||||
|
||||
// embed
|
||||
|
||||
@ -1039,108 +1039,6 @@ public:
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#if 0
|
||||
class CSnapshotScript
|
||||
{
|
||||
public:
|
||||
bool m_bIsExist;
|
||||
v8::StartupData m_oStartupData;
|
||||
|
||||
CSnapshotScript(const std::wstring& sDir = L"")
|
||||
{
|
||||
m_bIsExist = false;
|
||||
m_oStartupData.data = NULL;
|
||||
m_oStartupData.raw_size = 0;
|
||||
|
||||
std::wstring sFile = sDir + L"/heap_snapshot.bin";
|
||||
if (NSFile::CFileBinary::Exists(sFile))
|
||||
{
|
||||
m_bIsExist = true;
|
||||
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.OpenFile(sFile);
|
||||
m_oStartupData.raw_size = (int)oFile.GetFileSize();
|
||||
m_oStartupData.data = new char[m_oStartupData.raw_size];
|
||||
|
||||
DWORD dwRead = 0;
|
||||
oFile.ReadFile((BYTE*)m_oStartupData.data, (DWORD)m_oStartupData.raw_size, dwRead);
|
||||
oFile.CloseFile();
|
||||
}
|
||||
}
|
||||
|
||||
bool Generate(const std::string& sScript)
|
||||
{
|
||||
m_oStartupData = {NULL, 0};
|
||||
{
|
||||
v8::SnapshotCreator snapshot_creator;
|
||||
// Obtain an isolate provided by SnapshotCreator.
|
||||
v8::Isolate* isolate = snapshot_creator.GetIsolate();
|
||||
{
|
||||
v8::HandleScope scope(isolate);
|
||||
// Create a new context and optionally run some script.
|
||||
v8::Local<v8::Context> context = v8::Context::New(isolate);
|
||||
//v8::Context::Scope context_scope(context);
|
||||
|
||||
if (!RunExtraCode(isolate, context, sScript.c_str(), "<embedded>"))
|
||||
return false;
|
||||
|
||||
// Add the possibly customized context to the SnapshotCreator.
|
||||
snapshot_creator.SetDefaultContext(context);
|
||||
}
|
||||
// Use the SnapshotCreator to create the snapshot blob.
|
||||
m_oStartupData = snapshot_creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kClear);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Save(const std::wstring& sDir)
|
||||
{
|
||||
if (m_oStartupData.data == NULL)
|
||||
return;
|
||||
|
||||
std::wstring sFile = sDir + L"/heap_snapshot.bin";
|
||||
NSFile::CFileBinary oFile;
|
||||
oFile.CreateFile(sFile);
|
||||
oFile.WriteFile((BYTE*)m_oStartupData.data, (DWORD)m_oStartupData.raw_size);
|
||||
oFile.CloseFile();
|
||||
}
|
||||
|
||||
bool RunExtraCode(v8::Isolate* isolate, v8::Local<v8::Context> context, const char* utf8_source, const char* name)
|
||||
{
|
||||
// Run custom script if provided.
|
||||
v8::TryCatch try_catch(isolate);
|
||||
|
||||
v8::Local<v8::String> source_string;
|
||||
if (!v8::String::NewFromUtf8(isolate, utf8_source, v8::NewStringType::kNormal).ToLocal(&source_string))
|
||||
return false;
|
||||
|
||||
v8::Local<v8::String> resource_name = v8::String::NewFromUtf8(isolate, name, v8::NewStringType::kNormal).ToLocalChecked();
|
||||
|
||||
v8::ScriptOrigin origin(resource_name);
|
||||
v8::ScriptCompiler::Source source(source_string, origin);
|
||||
v8::Local<v8::Script> script;
|
||||
|
||||
bool bRet = v8::ScriptCompiler::Compile(context, &source).ToLocal(&script);
|
||||
|
||||
if (try_catch.HasCaught())
|
||||
{
|
||||
std::string strCode = to_cstringA(try_catch.Message()->GetSourceLine());
|
||||
std::string strException = to_cstringA(try_catch.Message()->Get());
|
||||
return false;
|
||||
}
|
||||
|
||||
script->Run();
|
||||
|
||||
if (try_catch.HasCaught())
|
||||
{
|
||||
std::string strCode = to_cstringA(try_catch.Message()->GetSourceLine());
|
||||
std::string strException = to_cstringA(try_catch.Message()->Get());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
bool Doct_renderer_SaveFile_ForBuilder(int nFormat, const std::wstring& strDstFile,
|
||||
NSNativeControl::CNativeControl* pNative,
|
||||
|
||||
@ -37,11 +37,6 @@ namespace Aggplus
|
||||
}
|
||||
}
|
||||
|
||||
void CAlphaMask::SetDataType(EMaskDataType oType)
|
||||
{
|
||||
m_enDataType = oType;
|
||||
}
|
||||
|
||||
Status CAlphaMask::Create(UINT unWidth, UINT unHeight, EMaskDataType eDataType)
|
||||
{
|
||||
if (0 == unWidth || 0 == unHeight)
|
||||
@ -69,4 +64,131 @@ namespace Aggplus
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
|
||||
|
||||
CSoftMask::CSoftMask() : m_unWidth(0), m_unHeight(0), m_pImageData(NULL), m_pAlphaBufferData(NULL) {}
|
||||
CSoftMask::CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip) : m_pImageData(NULL), m_pAlphaBufferData(NULL)
|
||||
{
|
||||
LoadFromBuffer(pBuffer, unWidth, unHeight, enDataType, bExternalBuffer, bFlip);
|
||||
}
|
||||
CSoftMask::~CSoftMask()
|
||||
{
|
||||
BYTE* pBuffer = m_oRenderingBuffer.buf();
|
||||
if (NULL != pBuffer)
|
||||
{
|
||||
if (!m_bExternalBuffer)
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
m_oRenderingBuffer.attach(NULL, 0, 0, 0);
|
||||
}
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
}
|
||||
|
||||
EMaskDataType CSoftMask::GetDataType() const { return m_enDataType; }
|
||||
unsigned int CSoftMask::GetStep() const
|
||||
{
|
||||
switch(m_enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer: return 4;
|
||||
case EMaskDataType::AlphaBuffer: return 1;
|
||||
case EMaskDataType::Alpha4Buffer: return 4;
|
||||
}
|
||||
}
|
||||
unsigned int CSoftMask::GetWidth() const { return m_unWidth; }
|
||||
unsigned int CSoftMask::GetHeight() const { return m_unHeight; }
|
||||
|
||||
void CSoftMask::SetType(EMaskDataType enDataType)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
|
||||
RELEASEOBJECT(m_pImageData);
|
||||
RELEASEOBJECT(m_pAlphaBufferData);
|
||||
|
||||
switch (enDataType)
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
m_pImageData = new AMaskFromImage(m_oRenderingBuffer);
|
||||
m_pImageData->m_oRendererBase.attach(m_pImageData->m_oPixfmt);
|
||||
m_pImageData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
m_pAlphaBufferData = new AMaskFromABuffer(m_oRenderingBuffer);
|
||||
m_pAlphaBufferData->m_oRendererBase.attach(m_pAlphaBufferData->m_oPixfmt);
|
||||
m_pAlphaBufferData->m_oAlphaMask.attach(m_oRenderingBuffer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Status CSoftMask::Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType)
|
||||
{
|
||||
if (0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = false;
|
||||
|
||||
UINT unSize = unWidth * unHeight * GetStep();
|
||||
BYTE* pAlphaBufffer = new BYTE[unSize];
|
||||
if (!pAlphaBufffer)
|
||||
return OutOfMemory;
|
||||
|
||||
memset(pAlphaBufffer, 0x00, unSize);
|
||||
|
||||
Set(pAlphaBufffer, unWidth, unHeight, enDataType);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CSoftMask::LoadFromBuffer(BYTE *pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer, bool bFlip)
|
||||
{
|
||||
if (NULL == pBuffer || 0 == unWidth || 0 == unHeight)
|
||||
return InvalidParameter;
|
||||
|
||||
m_bExternalBuffer = bExternalBuffer;
|
||||
|
||||
Set(pBuffer, unWidth, unHeight, enDataType, bFlip);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
RenBaseBGRA32& CSoftMask::GetRendererBaseImage()
|
||||
{
|
||||
return m_pImageData->m_oRendererBase;
|
||||
}
|
||||
|
||||
ScanlineBGRA32Gray& CSoftMask::GetScanlineImage()
|
||||
{
|
||||
return m_pImageData->m_oScanLine;
|
||||
}
|
||||
|
||||
ScanlineBGRA32A& CSoftMask::GetScanlineABuffer()
|
||||
{
|
||||
return m_pAlphaBufferData->m_oScanLine;
|
||||
}
|
||||
|
||||
BYTE* CSoftMask::GetBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer.buf();
|
||||
}
|
||||
|
||||
agg::rendering_buffer& CSoftMask::GetRenderingBuffer()
|
||||
{
|
||||
return m_oRenderingBuffer;
|
||||
}
|
||||
|
||||
void CSoftMask::Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip)
|
||||
{
|
||||
m_enDataType = enDataType;
|
||||
m_unWidth = unWidth;
|
||||
m_unHeight = unHeight;
|
||||
m_oRenderingBuffer.attach(pBuffer, unWidth, unHeight, (bFlip ? -1 : 1) * GetStep() * unWidth);
|
||||
|
||||
SetType(enDataType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,11 @@
|
||||
#include "../common/IGrObject.h"
|
||||
#include "./config.h"
|
||||
|
||||
#include "../agg-2.4/include/agg_renderer_base.h"
|
||||
#include "../agg-2.4/include/agg_pixfmt_rgba.h"
|
||||
#include "../agg-2.4/include/agg_scanline_u.h"
|
||||
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
|
||||
|
||||
namespace Aggplus
|
||||
{
|
||||
enum class EMaskDataType
|
||||
@ -26,7 +31,6 @@ namespace Aggplus
|
||||
EMaskDataType GetDataType() const;
|
||||
UINT GetStep() const;
|
||||
|
||||
void SetDataType(EMaskDataType oType);
|
||||
Status Create(UINT unWidth, UINT unHeight, EMaskDataType eDataType);
|
||||
Status LoadFromBuffer(BYTE* pBuffer, EMaskDataType eDataType, bool bExternalBuffer = true);
|
||||
private:
|
||||
@ -34,6 +38,58 @@ namespace Aggplus
|
||||
EMaskDataType m_enDataType;
|
||||
bool m_bExternalBuffer;
|
||||
};
|
||||
|
||||
template <class PixelFormat, class AlphaMask>
|
||||
struct TAlphaMaskData
|
||||
{
|
||||
TAlphaMaskData(agg::rendering_buffer& oRenderingBuffer) : m_oPixfmt(oRenderingBuffer), m_oScanLine(m_oAlphaMask) {};
|
||||
|
||||
PixelFormat m_oPixfmt;
|
||||
agg::renderer_base<PixelFormat> m_oRendererBase;
|
||||
AlphaMask m_oAlphaMask;
|
||||
agg::scanline_u8_am<AlphaMask> m_oScanLine;
|
||||
};
|
||||
|
||||
typedef agg::renderer_base<agg::pixfmt_bgra32> RenBaseBGRA32;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32gray> ScanlineBGRA32Gray;
|
||||
typedef agg::scanline_u8_am<agg::alpha_mask_bgra32a> ScanlineBGRA32A;
|
||||
|
||||
class GRAPHICS_DECL CSoftMask : public IGrObject
|
||||
{
|
||||
public:
|
||||
CSoftMask();
|
||||
CSoftMask(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
virtual ~CSoftMask();
|
||||
|
||||
EMaskDataType GetDataType() const;
|
||||
unsigned int GetStep() const;
|
||||
unsigned int GetWidth() const;
|
||||
unsigned int GetHeight() const;
|
||||
|
||||
void SetType(EMaskDataType enDataType);
|
||||
Status Create(UINT unWidth, UINT unHeight, EMaskDataType enDataType);
|
||||
Status LoadFromBuffer(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bExternalBuffer = true, bool bFlip = false);
|
||||
|
||||
agg::rendering_buffer& GetRenderingBuffer();
|
||||
RenBaseBGRA32& GetRendererBaseImage();
|
||||
ScanlineBGRA32Gray& GetScanlineImage();
|
||||
ScanlineBGRA32A& GetScanlineABuffer();
|
||||
BYTE* GetBuffer();
|
||||
private:
|
||||
void Set(BYTE* pBuffer, UINT unWidth, UINT unHeight, EMaskDataType enDataType, bool bFlip = false);
|
||||
|
||||
agg::rendering_buffer m_oRenderingBuffer;
|
||||
EMaskDataType m_enDataType;
|
||||
bool m_bExternalBuffer;
|
||||
unsigned int m_unWidth;
|
||||
unsigned int m_unHeight;
|
||||
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32gray> AMaskFromImage;
|
||||
typedef TAlphaMaskData<agg::pixfmt_bgra32, agg::alpha_mask_bgra32a> AMaskFromABuffer;
|
||||
|
||||
AMaskFromImage* m_pImageData;
|
||||
AMaskFromABuffer* m_pAlphaBufferData;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _BUILD_ALPHAMASK_H_
|
||||
|
||||
@ -68,6 +68,7 @@ namespace Aggplus
|
||||
m_dDpiTile = -1;
|
||||
|
||||
m_pAlphaMask = NULL;
|
||||
m_pSoftMask = NULL;
|
||||
|
||||
m_nTextRenderMode = FT_RENDER_MODE_NORMAL;
|
||||
m_nBlendMode = agg::comp_op_src_over;
|
||||
@ -106,6 +107,7 @@ namespace Aggplus
|
||||
m_dDpiTile = -1;
|
||||
|
||||
m_pAlphaMask = NULL;
|
||||
m_pSoftMask = NULL;
|
||||
|
||||
m_nTextRenderMode = FT_RENDER_MODE_NORMAL;
|
||||
m_nBlendMode = agg::comp_op_src_over;
|
||||
@ -149,6 +151,7 @@ namespace Aggplus
|
||||
m_dDpiTile = -1;
|
||||
|
||||
m_pAlphaMask = NULL;
|
||||
m_pSoftMask = NULL;
|
||||
|
||||
m_nTextRenderMode = FT_RENDER_MODE_NORMAL;
|
||||
m_nBlendMode = agg::comp_op_src_over;
|
||||
@ -164,6 +167,7 @@ namespace Aggplus
|
||||
#endif
|
||||
|
||||
RELEASEINTERFACE(m_pAlphaMask);
|
||||
RELEASEINTERFACE(m_pSoftMask);
|
||||
|
||||
while (!m_arLayers.empty())
|
||||
{
|
||||
@ -1236,9 +1240,7 @@ namespace Aggplus
|
||||
if (m_pAlphaMask)
|
||||
m_pAlphaMask->AddRef();
|
||||
|
||||
return Ok;
|
||||
|
||||
//return CreateLayer();
|
||||
return CreateLayer();
|
||||
}
|
||||
|
||||
Status CGraphics::StartCreatingAlphaMask()
|
||||
@ -1275,6 +1277,54 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
CSoftMask* CGraphics::CreateSoftMask(bool bAlpha)
|
||||
{
|
||||
if (m_arLayers.empty())
|
||||
return NULL;
|
||||
|
||||
CGraphicsLayer *pCurrentGraphicsLayer = m_arLayers.top();
|
||||
m_arLayers.pop();
|
||||
|
||||
if (pCurrentGraphicsLayer->Empty())
|
||||
{
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BYTE* pBuffer = pCurrentGraphicsLayer->GetBuffer();
|
||||
pCurrentGraphicsLayer->ClearBuffer(false);
|
||||
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
RELEASEINTERFACE(m_pSoftMask);
|
||||
|
||||
m_pSoftMask = new CSoftMask(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), bAlpha ? EMaskDataType::Alpha4Buffer : EMaskDataType::ImageBuffer, false, m_frame_buffer.ren_buf().stride() < 0);
|
||||
|
||||
pBuffer = m_arLayers.empty() ? m_pPixels : m_arLayers.top()->GetBuffer();
|
||||
if (!pBuffer)
|
||||
{
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), m_frame_buffer.ren_buf().stride());
|
||||
|
||||
return m_pSoftMask;
|
||||
}
|
||||
|
||||
Status CGraphics::SetSoftMask(CSoftMask* pSoftMask)
|
||||
{
|
||||
if (m_pSoftMask == pSoftMask)
|
||||
return Ok;
|
||||
|
||||
RELEASEINTERFACE(m_pSoftMask);
|
||||
m_pSoftMask = pSoftMask;
|
||||
|
||||
if (m_pSoftMask)
|
||||
m_pSoftMask->AddRef();
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphics::AddLayer(CGraphicsLayer *pGraphicsLayer)
|
||||
{
|
||||
if (NULL == pGraphicsLayer || pGraphicsLayer->Empty())
|
||||
@ -1287,7 +1337,7 @@ namespace Aggplus
|
||||
const unsigned int unWidth = m_frame_buffer.ren_buf().width();
|
||||
const unsigned int unHeight = m_frame_buffer.ren_buf().height();
|
||||
|
||||
m_frame_buffer.create(unWidth, unHeight, false, nStride, pGraphicsLayer->GetBuffer());
|
||||
m_frame_buffer.create(unWidth, unHeight, nStride < 0, nStride, pGraphicsLayer->GetBuffer());
|
||||
|
||||
return Ok;
|
||||
}
|
||||
@ -1304,7 +1354,7 @@ namespace Aggplus
|
||||
|
||||
memset(pBuffer, 0x00, unSize);
|
||||
|
||||
m_frame_buffer.create(unWidth, unHeight, false, nStride, pBuffer);
|
||||
m_frame_buffer.create(unWidth, unHeight, nStride < 0, nStride, pBuffer);
|
||||
|
||||
m_arLayers.push(new CGraphicsLayer(pBuffer, false));
|
||||
return Ok;
|
||||
@ -1333,9 +1383,41 @@ namespace Aggplus
|
||||
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), m_frame_buffer.ren_buf().stride());
|
||||
|
||||
if (NULL == m_pAlphaMask)
|
||||
if (m_pAlphaMask)
|
||||
{
|
||||
if (m_nBlendMode != agg::comp_op_src_over)// && m_nBlendMode != agg::comp_op_multiply && m_nBlendMode != agg::comp_op_screen && m_nBlendMode != agg::comp_op_darken)
|
||||
switch(m_pAlphaMask->GetDataType())
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<2, 1, 0>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pAlphaMask->GetBuffer(), m_pAlphaMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::AlphaBuffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::one_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pAlphaMask->GetBuffer(), m_pAlphaMask->GetStep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_pSoftMask)
|
||||
{
|
||||
switch(m_pSoftMask->GetDataType())
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<2, 1, 0>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer(), m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::one_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pSoftMask->GetBuffer() + 3, m_pSoftMask->GetStep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_nBlendMode != agg::comp_op_src_over)
|
||||
{
|
||||
pixfmt_type_comp pixfmt(m_frame_buffer.ren_buf(), m_nBlendMode);
|
||||
Aggplus::BlendTo(pCurrentGraphicsLayer, pixfmt, m_nBlendMode);
|
||||
@ -1343,27 +1425,6 @@ namespace Aggplus
|
||||
else
|
||||
Aggplus::BlendTo(pCurrentGraphicsLayer, m_frame_buffer.pixfmt());
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(m_pAlphaMask->GetDataType())
|
||||
{
|
||||
case EMaskDataType::ImageBuffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::rgb_to_gray_mask_u8<2, 1, 0>>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pAlphaMask->GetBuffer(), m_pAlphaMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::AlphaBuffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::one_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pAlphaMask->GetBuffer(), m_pAlphaMask->GetStep());
|
||||
break;
|
||||
}
|
||||
case EMaskDataType::Alpha4Buffer:
|
||||
{
|
||||
Aggplus::BlendTo<agg::four_component_mask_u8>(pCurrentGraphicsLayer, m_frame_buffer.pixfmt(), m_pAlphaMask->GetBuffer(), m_pAlphaMask->GetStep());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
return Ok;
|
||||
@ -1377,6 +1438,21 @@ namespace Aggplus
|
||||
CGraphicsLayer *pCurrentGraphicsLayer = m_arLayers.top();
|
||||
m_arLayers.pop();
|
||||
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
if (!m_arLayers.empty())
|
||||
pBuffer = m_arLayers.top()->GetBuffer();
|
||||
else
|
||||
pBuffer = m_pPixels;
|
||||
|
||||
if (NULL == pBuffer)
|
||||
{
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
return WrongState;
|
||||
}
|
||||
|
||||
m_frame_buffer.ren_buf().attach(pBuffer, m_frame_buffer.ren_buf().width(), m_frame_buffer.ren_buf().height(), m_frame_buffer.ren_buf().stride());
|
||||
|
||||
RELEASEINTERFACE(pCurrentGraphicsLayer);
|
||||
return Ok;
|
||||
}
|
||||
@ -1404,54 +1480,6 @@ namespace Aggplus
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphics::SetLayerIsolated(bool bIsolated)
|
||||
{
|
||||
if (m_arLayers.empty())
|
||||
return WrongState;
|
||||
|
||||
UINT unSize = m_frame_buffer.ren_buf().width() * m_frame_buffer.ren_buf().height() * m_frame_buffer.pix_size;
|
||||
if (bIsolated)
|
||||
memset(m_arLayers.top()->GetBuffer(), 0x00, unSize);
|
||||
else
|
||||
memcpy(m_arLayers.top()->GetBuffer(), m_pPixels, unSize);
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphics::SetAlphaMaskIsolated(bool bIsolated)
|
||||
{
|
||||
if (m_arLayers.empty())
|
||||
return WrongState;
|
||||
|
||||
UINT unSize = m_frame_buffer.ren_buf().width() * m_frame_buffer.ren_buf().height() * m_frame_buffer.pix_size;
|
||||
if (bIsolated)
|
||||
{
|
||||
memset(m_arLayers.top()->GetBuffer(), 0x00, unSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE* pBuffer = m_arLayers.top()->GetBuffer();
|
||||
for (unsigned int i = 0; i < unSize; i = i + 4)
|
||||
{
|
||||
pBuffer[i + 0] = 0x00;
|
||||
pBuffer[i + 1] = 0x00;
|
||||
pBuffer[i + 2] = 0x00;
|
||||
pBuffer[i + 3] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
return Ok;
|
||||
}
|
||||
|
||||
Status CGraphics::SetAlphaMaskType(EMaskDataType oType)
|
||||
{
|
||||
if (!m_pAlphaMask)
|
||||
return WrongState;
|
||||
|
||||
m_pAlphaMask->SetDataType(oType);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
void CGraphics::CalculateFullTransform()
|
||||
{
|
||||
m_oFullTransform = m_oCoordTransform;
|
||||
@ -1463,52 +1491,43 @@ namespace Aggplus
|
||||
return m_oClip.IsClip();
|
||||
}
|
||||
|
||||
unsigned int CGraphics::GetLayerW()
|
||||
{
|
||||
return m_frame_buffer.ren_buf().width();
|
||||
}
|
||||
|
||||
unsigned int CGraphics::GetLayerH()
|
||||
{
|
||||
return m_frame_buffer.ren_buf().height();
|
||||
}
|
||||
|
||||
template<class Renderer>
|
||||
void CGraphics::render_scanlines(Renderer& ren)
|
||||
template<class Rasterizer, class Renderer, class Scanline>
|
||||
void CGraphics::render_scanlines_3(Rasterizer& ras, Renderer& ren, Scanline& sl)
|
||||
{
|
||||
if (!m_oClip.IsClip())
|
||||
{
|
||||
agg::render_scanlines(m_rasterizer.get_rasterizer(), m_rasterizer.get_scanline(), ren);
|
||||
agg::render_scanlines(ras, sl, ren);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_oClip.IsClip2())
|
||||
{
|
||||
typedef agg::scanline_p8 sbool_scanline_type;
|
||||
typedef agg::scanline_p8 sbool_scanline_type;
|
||||
|
||||
sbool_scanline_type sl_result;
|
||||
sbool_scanline_type sl1;
|
||||
sbool_scanline_type sl2;
|
||||
|
||||
agg::sbool_combine_shapes_aa(agg::sbool_and, m_rasterizer.get_rasterizer(), m_oClip.m_rasterizer,
|
||||
sl1, sl2, sl_result, ren);
|
||||
agg::sbool_combine_shapes_aa(agg::sbool_and, ras, m_oClip.m_rasterizer, sl1, sl2, sl, ren);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef agg::scanline_p8 sbool_scanline_type;
|
||||
|
||||
sbool_scanline_type sl_result;
|
||||
typedef agg::scanline_p8 sbool_scanline_type;
|
||||
|
||||
sbool_scanline_type sl1;
|
||||
sbool_scanline_type sl2;
|
||||
|
||||
sbool_scanline_type sl;
|
||||
|
||||
agg::sbool_combine_shapes_aa(agg::sbool_and, m_rasterizer.get_rasterizer(),
|
||||
(1 == m_oClip.m_lCurStorage) ? m_oClip.m_storage1 : m_oClip.m_storage2, sl1, sl2, sl_result, ren);
|
||||
agg::sbool_combine_shapes_aa(agg::sbool_and, ras, (1 == m_oClip.m_lCurStorage) ? m_oClip.m_storage1 : m_oClip.m_storage2, sl1, sl2, sl, ren);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Renderer>
|
||||
void CGraphics::render_scanlines(Renderer& ren)
|
||||
{
|
||||
render_scanlines_2(m_rasterizer.get_rasterizer(), ren);
|
||||
}
|
||||
|
||||
template<class Renderer>
|
||||
void CGraphics::render_scanlines_alpha(Renderer& ren, BYTE Alpha)
|
||||
{
|
||||
@ -1526,47 +1545,16 @@ namespace Aggplus
|
||||
}
|
||||
|
||||
template<class Rasterizer, class Renderer>
|
||||
void CGraphics::render_scanlines(Rasterizer& ras, Renderer& ren)
|
||||
void CGraphics::render_scanlines_2(Rasterizer& ras, Renderer& ren)
|
||||
{
|
||||
if (!m_oClip.IsClip())
|
||||
if (m_pSoftMask)
|
||||
{
|
||||
// if (m_pAlphaMask && ApplyingAlphaMask == m_pAlphaMask->GetStatus())
|
||||
// {
|
||||
// if (ImageBuffer == m_pAlphaMask->GetDataType())
|
||||
// return agg::render_scanlines(ras, m_pAlphaMask->m_internal->GetScanlineImage(), ren);
|
||||
// else if (AlphaBuffer == m_pAlphaMask->GetDataType())
|
||||
// return agg::render_scanlines(ras, m_pAlphaMask->m_internal->GetScanlineABuffer(), ren);
|
||||
// }
|
||||
|
||||
return agg::render_scanlines(ras, m_rasterizer.get_scanline(), ren);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_oClip.IsClip2())
|
||||
{
|
||||
typedef agg::scanline_p8 sbool_scanline_type;
|
||||
|
||||
sbool_scanline_type sl_result;
|
||||
sbool_scanline_type sl1;
|
||||
sbool_scanline_type sl2;
|
||||
|
||||
agg::sbool_combine_shapes_aa(agg::sbool_and, ras, m_oClip.m_rasterizer,
|
||||
sl1, sl2, sl_result, ren);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef agg::scanline_p8 sbool_scanline_type;
|
||||
|
||||
sbool_scanline_type sl_result;
|
||||
sbool_scanline_type sl1;
|
||||
sbool_scanline_type sl2;
|
||||
|
||||
sbool_scanline_type sl;
|
||||
|
||||
agg::sbool_combine_shapes_aa(agg::sbool_and, ras,
|
||||
(1 == m_oClip.m_lCurStorage) ? m_oClip.m_storage1 : m_oClip.m_storage2, sl1, sl2, sl_result, ren);
|
||||
}
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::ImageBuffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineImage());
|
||||
if (m_pSoftMask->GetDataType() == EMaskDataType::Alpha4Buffer)
|
||||
return render_scanlines_3(ras, ren, m_pSoftMask->GetScanlineABuffer());
|
||||
}
|
||||
render_scanlines_3(ras, ren, m_rasterizer.get_scanline());
|
||||
}
|
||||
|
||||
void CGraphics::DoFillPathSolid(CColor dwColor)
|
||||
@ -2304,7 +2292,7 @@ namespace Aggplus
|
||||
ren_fine.color(clr.GetAggColor());
|
||||
|
||||
//agg::render_scanlines(storage, m_rasterizer.get_scanline(), ren_fine);
|
||||
render_scanlines(storage, ren_fine);
|
||||
render_scanlines_2(storage, ren_fine);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@ -282,6 +282,7 @@ protected:
|
||||
CClipMulti m_oClip;
|
||||
|
||||
CAlphaMask* m_pAlphaMask;
|
||||
CSoftMask* m_pSoftMask;
|
||||
|
||||
std::stack<CGraphicsLayer*> m_arLayers;
|
||||
|
||||
@ -402,11 +403,13 @@ public:
|
||||
|
||||
//Работа с альфа-маской
|
||||
Status SetAlphaMask(CAlphaMask* pAlphaMask);
|
||||
inline CAlphaMask* GetAlphaMask() { return m_pAlphaMask; }
|
||||
Status StartCreatingAlphaMask();
|
||||
Status EndCreatingAlphaMask();
|
||||
Status ResetAlphaMask();
|
||||
|
||||
CSoftMask* CreateSoftMask(bool bAlpha);
|
||||
Status SetSoftMask(CSoftMask* pSoftMask);
|
||||
|
||||
//Работа со слоями
|
||||
Status AddLayer(CGraphicsLayer* pGraphicsLayer);
|
||||
Status CreateLayer();
|
||||
@ -415,9 +418,6 @@ public:
|
||||
|
||||
Status SetLayerSettings(const TGraphicsLayerSettings& oSettings);
|
||||
Status SetLayerOpacity(double dOpacity);
|
||||
Status SetLayerIsolated(bool bIsolated);
|
||||
Status SetAlphaMaskIsolated(bool bIsolated);
|
||||
Status SetAlphaMaskType(EMaskDataType oType);
|
||||
|
||||
void CalculateFullTransform();
|
||||
bool IsClip();
|
||||
@ -427,17 +427,17 @@ public:
|
||||
|
||||
inline double GetPixW() { return m_dWidthPix; }
|
||||
inline double GetPixH() { return m_dHeightPix; }
|
||||
unsigned int GetLayerW();
|
||||
unsigned int GetLayerH();
|
||||
|
||||
protected:
|
||||
|
||||
template<class Renderer>
|
||||
void render_scanlines(Renderer& ren);
|
||||
template<class Rasterizer, class Renderer>
|
||||
void render_scanlines(Rasterizer& ras, Renderer& ren);
|
||||
void render_scanlines_2(Rasterizer& ras, Renderer& ren);
|
||||
template<class Renderer>
|
||||
void render_scanlines_alpha(Renderer& ren, BYTE Alpha);
|
||||
template<class Rasterizer, class Renderer, class Scanline>
|
||||
void render_scanlines_3(Rasterizer& ras, Renderer& ren, Scanline& sl);
|
||||
|
||||
void DoFillPathSolid(CColor dwColor);
|
||||
void DoFillPathGradient(CBrushLinearGradient *pBrush);
|
||||
|
||||
@ -23,11 +23,11 @@ namespace Aggplus
|
||||
unsigned int unSrcH = oSrc.height();
|
||||
|
||||
BYTE nOpacity = pLayer->GetSettings().m_uchOpacity;
|
||||
bool bStride = oSrc.stride() < 0;
|
||||
bool bFlip = oSrc.stride() < 0;
|
||||
|
||||
for (unsigned int unY = 0; unY < unSrcH; ++unY)
|
||||
{
|
||||
pDstBuffer = oSrc.row_ptr(bStride ? unSrcH - unY - 1: unY);
|
||||
pDstBuffer = oSrc.row_ptr(bFlip ? unSrcH - 1 - unY : unY);
|
||||
for (unsigned int unX = 0; unX < unSrcW; ++unX)
|
||||
{
|
||||
uchAlpha = (SrcPixelFormatRenderer::base_mask + nOpacity * pSrcBuffer[order_type::A]) >> 8;
|
||||
@ -70,11 +70,11 @@ namespace Aggplus
|
||||
unsigned int unSrcH = oSrc.height();
|
||||
|
||||
BYTE nOpacity = pLayer->GetSettings().m_uchOpacity;
|
||||
bool bStride = oSrc.stride() < 0;
|
||||
bool bFlip = oSrc.stride() < 0;
|
||||
|
||||
for (unsigned int unY = 0; unY < unSrcH; ++unY)
|
||||
{
|
||||
pDstBuffer = oSrc.row_ptr(bStride ? unSrcH - unY - 1: unY);
|
||||
pDstBuffer = oSrc.row_ptr(bFlip ? unSrcH - 1 - unY : unY);
|
||||
for (unsigned int unX = 0; unX < unSrcW; ++unX)
|
||||
{
|
||||
uchAlpha = (SrcPixelFormatRenderer::base_mask + nOpacity * pSrcBuffer[order_type::A]) >> 8;
|
||||
@ -108,11 +108,11 @@ namespace Aggplus
|
||||
unsigned int unSrcH = oSrc.height();
|
||||
|
||||
BYTE nOpacity = pLayer->GetSettings().m_uchOpacity;
|
||||
bool bStride = oSrc.stride() < 0;
|
||||
bool bFlip = oSrc.stride() < 0;
|
||||
|
||||
for (unsigned int unY = 0; unY < unSrcH; ++unY)
|
||||
{
|
||||
pDstBuffer = oSrc.row_ptr(bStride ? unSrcH - unY - 1: unY);
|
||||
pDstBuffer = oSrc.row_ptr(bFlip ? unSrcH - 1 - unY : unY);
|
||||
for (unsigned int unX = 0; unX < unSrcW; ++unX)
|
||||
{
|
||||
uchAlpha = ((SrcPixelFormatRenderer::base_mask + nOpacity * pSrcBuffer[order_type::A] * AlphaMaskFunction::calculate(pSrcAlphaMaskBuffer)) >> 16);
|
||||
|
||||
@ -1416,9 +1416,14 @@ void CGraphicsRenderer::SetAlphaMask(Aggplus::CAlphaMask *pAlphaMask)
|
||||
m_pRenderer->SetAlphaMask(pAlphaMask);
|
||||
}
|
||||
|
||||
Aggplus::CAlphaMask* CGraphicsRenderer::GetAlphaMask()
|
||||
Aggplus::CSoftMask* CGraphicsRenderer::CreateSoftMask(bool bAlpha)
|
||||
{
|
||||
return m_pRenderer->GetAlphaMask();
|
||||
return m_pRenderer->CreateSoftMask(bAlpha);
|
||||
}
|
||||
|
||||
void CGraphicsRenderer::SetSoftMask(Aggplus::CSoftMask* pSoftMask)
|
||||
{
|
||||
m_pRenderer->SetSoftMask(pSoftMask);
|
||||
}
|
||||
|
||||
HRESULT CGraphicsRenderer::put_LayerOpacity(double dValue)
|
||||
@ -1426,21 +1431,6 @@ HRESULT CGraphicsRenderer::put_LayerOpacity(double dValue)
|
||||
return m_pRenderer->SetLayerOpacity(dValue);
|
||||
}
|
||||
|
||||
HRESULT CGraphicsRenderer::put_LayerIsolated(bool bIsolated)
|
||||
{
|
||||
return m_pRenderer->SetLayerIsolated(bIsolated);
|
||||
}
|
||||
|
||||
HRESULT CGraphicsRenderer::put_AlphaMaskIsolated(bool bIsolated)
|
||||
{
|
||||
return m_pRenderer->SetAlphaMaskIsolated(bIsolated);
|
||||
}
|
||||
|
||||
void CGraphicsRenderer::put_AlphaMaskType(Aggplus::EMaskDataType oType)
|
||||
{
|
||||
m_pRenderer->SetAlphaMaskType(oType);
|
||||
}
|
||||
|
||||
void CGraphicsRenderer::put_GlobalAlphaEnabled(const bool& bEnabled, const double& dVal)
|
||||
{
|
||||
m_bGlobalAlphaEnabled = bEnabled;
|
||||
@ -1493,6 +1483,7 @@ public:
|
||||
double m_dGlobalAlpha;
|
||||
bool m_bGlobalAlphaEnabled;
|
||||
bool m_bIntegerGrid;
|
||||
unsigned int m_nBlendMode;
|
||||
|
||||
Aggplus::CGraphics_ClipState m_oClipState;
|
||||
};
|
||||
@ -1513,6 +1504,7 @@ void CGraphicsRenderer::Save()
|
||||
pState->m_bGlobalAlphaEnabled = m_bGlobalAlphaEnabled;
|
||||
|
||||
pState->m_bIntegerGrid = m_pRenderer->m_bIntegerGrid;
|
||||
pState->m_nBlendMode = m_pRenderer->m_nBlendMode;
|
||||
|
||||
m_arStates.push_back(pState);
|
||||
}
|
||||
@ -1534,6 +1526,7 @@ void CGraphicsRenderer::Restore()
|
||||
ApplyTransform(&pState->m_oTransform);
|
||||
this->put_IntegerGrid(pState->m_bIntegerGrid);
|
||||
this->put_GlobalAlphaEnabled(pState->m_bGlobalAlphaEnabled, pState->m_dGlobalAlpha);
|
||||
this->put_BlendMode(pState->m_nBlendMode);
|
||||
|
||||
m_pRenderer->ResetClip();
|
||||
for (std::vector<Aggplus::CGraphics_ClipStateRecord*>::iterator i = pState->m_oClipState.Records.begin(); i != pState->m_oClipState.Records.end(); i++)
|
||||
|
||||
@ -124,8 +124,8 @@ public:
|
||||
virtual void SetSwapRGB(bool bValue){ if (m_pRenderer) m_pRenderer->m_bSwapRGB = bValue; }
|
||||
virtual void SetTileImageDpi(const double& dDpi) { if (m_pRenderer) m_pRenderer->m_dDpiTile = dDpi; }
|
||||
|
||||
void Save();
|
||||
void Restore();
|
||||
virtual void Save();
|
||||
virtual void Restore();
|
||||
|
||||
public:
|
||||
// тип рендерера-----------------------------------------------------------------------------
|
||||
@ -348,18 +348,14 @@ public:
|
||||
|
||||
inline double GetPixW() { return m_pRenderer->GetPixW(); }
|
||||
inline double GetPixH() { return m_pRenderer->GetPixH(); }
|
||||
inline unsigned int GetLayerW() override { return m_pRenderer->GetLayerW(); }
|
||||
inline unsigned int GetLayerH() override { return m_pRenderer->GetLayerH(); }
|
||||
|
||||
// alpha mask methods
|
||||
void SetAlphaMask(Aggplus::CAlphaMask* pAlphaMask);
|
||||
Aggplus::CAlphaMask* GetAlphaMask();
|
||||
virtual Aggplus::CSoftMask* CreateSoftMask(bool bAlpha) override;
|
||||
virtual void SetSoftMask(Aggplus::CSoftMask* pSoftMask) override;
|
||||
|
||||
// layer methods
|
||||
virtual HRESULT put_LayerOpacity(double dValue) override;
|
||||
virtual HRESULT put_LayerIsolated(bool bIsolated) override;
|
||||
virtual HRESULT put_AlphaMaskIsolated(bool bIsolated) override;
|
||||
virtual void put_AlphaMaskType(Aggplus::EMaskDataType oType) override;
|
||||
|
||||
// smart methods
|
||||
void drawHorLine(BYTE align, double y, double x, double r, double penW)
|
||||
|
||||
@ -403,16 +403,6 @@ public:
|
||||
UNUSED_VARIABLE(dValue);
|
||||
return S_FALSE;
|
||||
}
|
||||
virtual HRESULT put_LayerIsolated(bool bIsolated)
|
||||
{
|
||||
UNUSED_VARIABLE(bIsolated);
|
||||
return S_FALSE;
|
||||
}
|
||||
virtual HRESULT put_AlphaMaskIsolated(bool bIsolated)
|
||||
{
|
||||
UNUSED_VARIABLE(bIsolated);
|
||||
return S_FALSE;
|
||||
}
|
||||
};
|
||||
|
||||
#define PROPERTY_RENDERER(NameBase, Name, Type) \
|
||||
|
||||
@ -214,6 +214,11 @@ int CAnnotFieldInfo::GetID() const { return m_nID; }
|
||||
int CAnnotFieldInfo::GetAnnotFlag() const { return m_nAnnotFlag; }
|
||||
int CAnnotFieldInfo::GetPage() const { return m_nPage; }
|
||||
void CAnnotFieldInfo::GetBE(BYTE& nS, double& dI) { nS = m_pBE.first; dI = m_pBE.second; }
|
||||
BYTE* CAnnotFieldInfo::GetRender(LONG& nLen)
|
||||
{
|
||||
nLen = m_nRenderLen;
|
||||
return m_pRender;
|
||||
}
|
||||
const std::wstring& CAnnotFieldInfo::GetNM() { return m_wsNM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetLM() { return m_wsLM; }
|
||||
const std::wstring& CAnnotFieldInfo::GetContents() { return m_wsContents; }
|
||||
@ -337,6 +342,12 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
}
|
||||
if (nFlags & (1 << 5))
|
||||
m_wsLM = pReader->ReadString();
|
||||
if (nFlags & (1 << 6))
|
||||
{
|
||||
m_nRenderLen = pReader->ReadInt() - 4;
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
|
||||
if (IsMarkup())
|
||||
{
|
||||
@ -567,11 +578,6 @@ const std::wstring& CAnnotFieldInfo::CFreeTextAnnotPr::GetDS() { return m_wsDS;
|
||||
void CAnnotFieldInfo::CFreeTextAnnotPr::GetRD(double& dRD1, double& dRD2, double& dRD3, double& dRD4) { dRD1 = m_dRD[0]; dRD2 = m_dRD[1]; dRD3 = m_dRD[2]; dRD4 = m_dRD[3]; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CFreeTextAnnotPr::GetCL() { return m_arrCL; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CFreeTextAnnotPr::GetIC() { return m_arrIC; }
|
||||
BYTE* CAnnotFieldInfo::CFreeTextAnnotPr::GetRender(LONG& nLen)
|
||||
{
|
||||
nLen = m_nRenderLen;
|
||||
return m_pRender;
|
||||
}
|
||||
void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
m_nQ = pReader->ReadByte();
|
||||
@ -601,12 +607,6 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
if (nFlags & (1 << 22))
|
||||
{
|
||||
m_nRenderLen = pReader->ReadInt() - 4;
|
||||
m_pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(m_nRenderLen);
|
||||
}
|
||||
}
|
||||
|
||||
BYTE CAnnotFieldInfo::CCaretAnnotPr::GetSy() const { return m_nSy; }
|
||||
|
||||
@ -372,7 +372,6 @@ public:
|
||||
void GetRD(double& dRD1, double& dRD2, double& dRD3, double& dRD4);
|
||||
const std::vector<double>& GetCL();
|
||||
const std::vector<double>& GetIC();
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
@ -385,8 +384,6 @@ public:
|
||||
double m_dRD[4]{};
|
||||
std::vector<double> m_arrCL;
|
||||
std::vector<double> m_arrIC;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CCaretAnnotPr
|
||||
@ -414,6 +411,7 @@ public:
|
||||
int GetAnnotFlag() const;
|
||||
int GetPage() const;
|
||||
void GetBE(BYTE& nS, double& dI);
|
||||
BYTE* GetRender(LONG& nLen);
|
||||
const std::wstring& GetNM();
|
||||
const std::wstring& GetLM();
|
||||
const std::wstring& GetContents();
|
||||
@ -472,6 +470,8 @@ private:
|
||||
std::pair<BYTE, double> m_pBE;
|
||||
std::vector<double> m_arrC;
|
||||
CBorder m_oBorder;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
|
||||
CMarkupAnnotPr* m_pMarkupPr;
|
||||
CTextAnnotPr* m_pTextPr;
|
||||
|
||||
@ -164,24 +164,57 @@ bool CPageRotate::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafile
|
||||
return true;
|
||||
}
|
||||
|
||||
CHeadings::CHeading::CHeading()
|
||||
{
|
||||
nPage = 0;
|
||||
dX = 0.0;
|
||||
dY = 0.0;
|
||||
pParent = NULL;
|
||||
}
|
||||
CHeadings::CHeading::~CHeading()
|
||||
{
|
||||
for (int i = 0; i < arrHeading.size(); ++i)
|
||||
RELEASEOBJECT(arrHeading[i]);
|
||||
}
|
||||
|
||||
CHeadings::CHeadings() : IAdvancedCommand(AdvancedCommandType::Headings) {}
|
||||
const std::vector<CHeadings::CHeading>& CHeadings::GetHeading() { return m_arrHeading; }
|
||||
CHeadings::~CHeadings()
|
||||
{
|
||||
for (int i = 0; i < m_arrHeading.size(); ++i)
|
||||
RELEASEOBJECT(m_arrHeading[i]);
|
||||
}
|
||||
const std::vector<CHeadings::CHeading*>& CHeadings::GetHeading() { return m_arrHeading; }
|
||||
bool CHeadings::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int nPredLevel = 0, nHeaderLevel = 0;
|
||||
std::vector<CHeading*>* arrHeading = &m_arrHeading;
|
||||
CHeading* pParent = NULL;
|
||||
int nHeadings = pReader->ReadInt();
|
||||
for (int i = 0; i < nHeadings; ++i)
|
||||
m_arrHeading.push_back(ReadHeading(pReader));
|
||||
{
|
||||
int nLevel = pReader->ReadInt();
|
||||
if (nLevel > nPredLevel && i > 0)
|
||||
{
|
||||
nHeaderLevel = nPredLevel;
|
||||
pParent = arrHeading->back();
|
||||
arrHeading = &pParent->arrHeading;
|
||||
}
|
||||
else if (nLevel < nPredLevel && nLevel <= nHeaderLevel)
|
||||
{
|
||||
nHeaderLevel = nLevel;
|
||||
pParent = pParent ? pParent->pParent : NULL;
|
||||
arrHeading = pParent ? &pParent->arrHeading : &m_arrHeading;
|
||||
}
|
||||
nPredLevel = nLevel;
|
||||
|
||||
CHeading* pHeading = new CHeading();
|
||||
pHeading->nPage = pReader->ReadInt();
|
||||
pHeading->dX = pReader->ReadDouble();
|
||||
pHeading->dY = pReader->ReadDouble();
|
||||
pHeading->wsTitle = pReader->ReadString();
|
||||
pHeading->pParent = pParent;
|
||||
|
||||
arrHeading->push_back(pHeading);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
CHeadings::CHeading CHeadings::ReadHeading(NSOnlineOfficeBinToPdf::CBufferReader* pReader)
|
||||
{
|
||||
CHeading oHeading;
|
||||
oHeading.wsTitle = pReader->ReadString();
|
||||
oHeading.nPage = pReader->ReadInt();
|
||||
oHeading.dX = pReader->ReadDouble();
|
||||
oHeading.dY = pReader->ReadDouble();
|
||||
int nHeadings = pReader->ReadInt();
|
||||
for (int i = 0; i < nHeadings; ++i)
|
||||
oHeading.arrHeading.push_back(ReadHeading(pReader));
|
||||
return oHeading;
|
||||
}
|
||||
|
||||
@ -179,19 +179,22 @@ public:
|
||||
int nPage;
|
||||
double dX;
|
||||
double dY;
|
||||
std::vector<CHeading> arrHeading;
|
||||
CHeading* pParent;
|
||||
std::vector<CHeading*> arrHeading;
|
||||
|
||||
CHeading();
|
||||
~CHeading();
|
||||
};
|
||||
|
||||
CHeadings();
|
||||
~CHeadings();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
const std::vector<CHeading>& GetHeading();
|
||||
const std::vector<CHeading*>& GetHeading();
|
||||
|
||||
private:
|
||||
std::vector<CHeading> m_arrHeading;
|
||||
|
||||
CHeading ReadHeading(NSOnlineOfficeBinToPdf::CBufferReader* pReader);
|
||||
std::vector<CHeading*> m_arrHeading;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -88,6 +88,8 @@ namespace NSGraphics
|
||||
|
||||
virtual void SetSwapRGB(bool bValue) = 0;
|
||||
virtual void SetTileImageDpi(const double& dDpi) = 0;
|
||||
virtual void Save() = 0;
|
||||
virtual void Restore() = 0;
|
||||
|
||||
public:
|
||||
virtual void CreateFromBgraFrame(CBgraFrame* pFrame) = 0;
|
||||
@ -117,13 +119,11 @@ namespace NSGraphics
|
||||
virtual void Stroke() = 0;
|
||||
virtual double GetPixW() = 0;
|
||||
virtual double GetPixH() = 0;
|
||||
virtual unsigned int GetLayerW() = 0;
|
||||
virtual unsigned int GetLayerH() = 0;
|
||||
|
||||
//alpha mask methods
|
||||
virtual void SetAlphaMask(Aggplus::CAlphaMask* pAlphaMask) = 0;
|
||||
virtual Aggplus::CAlphaMask* GetAlphaMask() = 0;
|
||||
virtual void put_AlphaMaskType(Aggplus::EMaskDataType oType) = 0;
|
||||
virtual Aggplus::CSoftMask* CreateSoftMask(bool bAlpha) = 0;
|
||||
virtual void SetSoftMask(Aggplus::CSoftMask* pSoftMask) = 0;
|
||||
|
||||
// smart methods
|
||||
virtual void drawHorLine(BYTE align, double y, double x, double r, double penW) = 0;
|
||||
|
||||
@ -121,7 +121,6 @@ namespace MetaFile
|
||||
IMetaFile(NSFonts::IApplicationFonts *pAppFonts) {}
|
||||
virtual ~IMetaFile() {}
|
||||
|
||||
virtual void SetImageSize(int nWidth, int nHeight) = 0;
|
||||
virtual bool LoadFromFile(const wchar_t* wsFilePath) = 0;
|
||||
virtual bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize) = 0;
|
||||
virtual bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight) = 0;
|
||||
|
||||
@ -21,5 +21,18 @@ base.replaceInFile("./deploy/drawingfile_ie.js", "\"drawingfile.js.mem\"", "getM
|
||||
base.cmd_in_dir("../../../../Common/js", "python", ["./min.py", "./../../DesktopEditor/graphics/pro/js/deploy/drawingfile.js", "WHITESPACE_ONLY"])
|
||||
base.cmd_in_dir("../../../../Common/js", "python", ["./min.py", "./../../DesktopEditor/graphics/pro/js/deploy/drawingfile_ie.js", "WHITESPACE_ONLY"])
|
||||
|
||||
content_native_files = [
|
||||
"./wasm/js/stream.js",
|
||||
"./wasm/js/drawingfile.js"
|
||||
]
|
||||
|
||||
content_native = "(function(window, undefined) {\n"
|
||||
for item in content_native_files:
|
||||
content_native += base.readFile(item)
|
||||
content_native += "\n})(window, undefined);"
|
||||
content_native = content_native.replace("//file_internal", base.readFile("./wasm/js/drawingfile_native.js"))
|
||||
base.writeFile("./deploy/drawingfile_native.js", content_native)
|
||||
base.cmd_in_dir("../../../../Common/js", "python", ["./min.py", "./../../DesktopEditor/graphics/pro/js/deploy/drawingfile_native.js", "WHITESPACE_ONLY"])
|
||||
|
||||
# base.delete_dir("./xml")
|
||||
# base.delete_dir("./freetype-2.10.4")
|
||||
|
||||
@ -19,3 +19,4 @@ base.delete_file(dst_dir + "drawingfile_ie.js")
|
||||
base.copy_file(src_dir + "drawingfile.js", dst_dir + "drawingfile.js")
|
||||
base.copy_file(src_dir + "drawingfile.wasm", dst_dir + "drawingfile.wasm")
|
||||
base.copy_file(src_dir + "drawingfile_ie.js", dst_dir + "drawingfile_ie.js")
|
||||
base.copy_file(src_dir + "drawingfile_native.js", dst_dir + "drawingfile_native.js")
|
||||
|
||||
@ -7,6 +7,11 @@
|
||||
"run_before": "before.py",
|
||||
"run_after": "after.py",
|
||||
"base_js_content": "./wasm/js/drawingfile_base.js",
|
||||
"replaces" : {
|
||||
"stream" : "./wasm/js/stream.js",
|
||||
"file" : "./wasm/js/drawingfile.js",
|
||||
"file_internal" : "./wasm/js/drawingfile_wasm.js"
|
||||
},
|
||||
|
||||
"compiler_flags": [
|
||||
"-O3",
|
||||
@ -222,7 +227,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../DocxRenderer/src/logic/elements",
|
||||
"files": ["BaseItem.cpp", "ContText.cpp", "DropCap.cpp", "Image.cpp", "Paragraph.cpp", "Shape.cpp", "TextLine.cpp"]
|
||||
"files": ["BaseItem.cpp", "ContText.cpp", "DropCap.cpp", "Paragraph.cpp", "Shape.cpp", "TextLine.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../common",
|
||||
|
||||
@ -677,7 +677,6 @@ HEADERS += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/BaseItem.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Image.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.h \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.h \
|
||||
@ -702,7 +701,6 @@ SOURCES += \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/BaseItem.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/ContText.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/DropCap.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Image.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Paragraph.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/Shape.cpp \
|
||||
$$DOCX_RENDERER_ROOT_DIR/src/logic/elements/TextLine.cpp \
|
||||
|
||||
1453
DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js
Normal file
1453
DesktopEditor/graphics/pro/js/wasm/js/drawingfile.js
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
184
DesktopEditor/graphics/pro/js/wasm/js/drawingfile_native.js
Normal file
184
DesktopEditor/graphics/pro/js/wasm/js/drawingfile_native.js
Normal file
@ -0,0 +1,184 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
function CNativePointer()
|
||||
{
|
||||
this.ptr = null;
|
||||
}
|
||||
CNativePointer.prototype.free = function()
|
||||
{
|
||||
this.ptr = null;
|
||||
};
|
||||
CNativePointer.prototype.getReader = function()
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
|
||||
return new CBinaryReader(this.ptr, 0, this.ptr.length);
|
||||
};
|
||||
|
||||
var g_module_pointer = new CNativePointer();
|
||||
|
||||
// js interface
|
||||
CFile.prototype._free = function(ptr)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
CFile.prototype._getUint8Array = function(ptr, len)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
CFile.prototype._getUint8ClampedArray = function(ptr, len)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// FILE
|
||||
CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._closeFile = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._setCMap = function(memoryBuffer)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getFontByID = function(ID)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// INFO DOCUMENT
|
||||
CFile.prototype._getInfo = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getStructure = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getLinks = function(pageIndex)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// WIDGETS & ANNOTATIONS
|
||||
CFile.prototype._getInteractiveFormsInfo = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getAnnotationsInfo = function(pageIndex)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getButtonIcons = function(backgroundColor, pageIndex, isBase64, nWidget, nView)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getAnnotationsAP = function(width, height, backgroundColor, pageIndex, nAnnot, nView)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor, pageIndex, nWidget, nView, nButtonView)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype._scanPage = function(page, mode)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._getImageBase64 = function(rId)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// TEXT
|
||||
CFile.prototype._getGlyphs = function(pageIndex)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
CFile.prototype._destroyTextInfo = function()
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// RASTER
|
||||
CFile.prototype._getPixmap = function(pageIndex, width, height, backgroundColor)
|
||||
{
|
||||
// TODO:
|
||||
};
|
||||
|
||||
// STATIC FUNCTIONS
|
||||
CFile.prototype._InitializeFonts = function(basePath)
|
||||
{
|
||||
};
|
||||
|
||||
CFile.prototype._CheckStreamId = function(data, status)
|
||||
{
|
||||
};
|
||||
430
DesktopEditor/graphics/pro/js/wasm/js/drawingfile_wasm.js
Normal file
430
DesktopEditor/graphics/pro/js/wasm/js/drawingfile_wasm.js
Normal file
@ -0,0 +1,430 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
function CWasmPointer()
|
||||
{
|
||||
this.ptr = 0;
|
||||
}
|
||||
CWasmPointer.prototype.free = function()
|
||||
{
|
||||
Module["_free"](this.ptr);
|
||||
this.ptr = 0;
|
||||
};
|
||||
CWasmPointer.prototype.getReader = function()
|
||||
{
|
||||
if (!this.ptr)
|
||||
return null;
|
||||
|
||||
let lenArr = new Int32Array(Module["HEAP8"].buffer, this.ptr, 1);
|
||||
if (!lenArr)
|
||||
{
|
||||
this.free();
|
||||
return null;
|
||||
}
|
||||
|
||||
let len = lenArr[0];
|
||||
if (len <= 4)
|
||||
{
|
||||
this.free();
|
||||
return null;
|
||||
}
|
||||
|
||||
len -= 4;
|
||||
let buffer = new Uint8Array(Module["HEAP8"].buffer, this.ptr + 4, len);
|
||||
return new CBinaryReader(buffer, 0, len);
|
||||
};
|
||||
|
||||
var g_module_pointer = new CWasmPointer();
|
||||
|
||||
// js interface
|
||||
CFile.prototype._free = function(ptr)
|
||||
{
|
||||
Module["_free"](ptr);
|
||||
};
|
||||
CFile.prototype._getUint8Array = function(ptr, len)
|
||||
{
|
||||
return new Uint8Array(Module["HEAP8"].buffer, ptr, len);
|
||||
};
|
||||
CFile.prototype._getUint8ClampedArray = function(ptr, len)
|
||||
{
|
||||
return new Uint8ClampedArray(Module["HEAP8"].buffer, ptr, len);
|
||||
};
|
||||
|
||||
// FILE
|
||||
CFile.prototype._openFile = function(buffer, password)
|
||||
{
|
||||
if (this.stream && buffer)
|
||||
{
|
||||
let data = new Uint8Array(buffer);
|
||||
this.stream_size = data.length;
|
||||
this.stream = Module["_malloc"](this.stream_size);
|
||||
Module["HEAP8"].set(data, this.stream);
|
||||
}
|
||||
|
||||
let passwordPtr = 0;
|
||||
if (password)
|
||||
{
|
||||
let passwordBuf = password.toUtf8();
|
||||
let passwordPtr = Module["_malloc"](passwordBuf.length);
|
||||
Module["HEAP8"].set(passwordBuf, passwordPtr);
|
||||
}
|
||||
|
||||
this.nativeFile = Module["_Open"](this.stream, this.stream_size, passwordPtr);
|
||||
|
||||
if (passwordPtr)
|
||||
Module["_free"](passwordPtr);
|
||||
return this.nativeFile > 0 ? true : false;
|
||||
};
|
||||
|
||||
CFile.prototype._closeFile = function()
|
||||
{
|
||||
Module["_Close"](this.nativeFile);
|
||||
};
|
||||
|
||||
CFile.prototype._getType = function()
|
||||
{
|
||||
return Module["_GetType"](this.stream, this.stream_size);
|
||||
};
|
||||
|
||||
CFile.prototype._getError = function()
|
||||
{
|
||||
return Module["_GetErrorCode"](this.nativeFile);
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
let isNeed = Module["_IsNeedCMap"](this.nativeFile);
|
||||
return (isNeed === 1) ? true : false;
|
||||
};
|
||||
|
||||
CFile.prototype._setCMap = function(memoryBuffer)
|
||||
{
|
||||
let pointer = Module["_malloc"](memoryBuffer.length);
|
||||
Module.HEAP8.set(memoryBuffer, pointer);
|
||||
Module["_SetCMapData"](this.nativeFile, pointer, memoryBuffer.length);
|
||||
};
|
||||
|
||||
CFile.prototype._getFontByID = function(ID)
|
||||
{
|
||||
if (ID === undefined)
|
||||
return null;
|
||||
|
||||
let idBuffer = ID.toUtf8();
|
||||
let idPointer = Module["_malloc"](idBuffer.length);
|
||||
Module["HEAP8"].set(idBuffer, idPointer);
|
||||
g_module_pointer.ptr = Module["_GetFontBinary"](this.nativeFile, idPointer);
|
||||
Module["_free"](idPointer);
|
||||
|
||||
let reader = g_module_pointer.getReader();
|
||||
if (!reader)
|
||||
return null;
|
||||
|
||||
let nFontLength = reader.readInt();
|
||||
let np1 = reader.readInt();
|
||||
let np2 = reader.readInt();
|
||||
let pFontPointer = np2 << 32 | np1;
|
||||
|
||||
let res = new Uint8Array(Module["HEAP8"].buffer, pFontPointer, nFontLength);
|
||||
g_module_pointer.free();
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype._getInteractiveFormsFonts = function(type)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetInteractiveFormsFonts"](this.nativeFile, type);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
// INFO DOCUMENT
|
||||
CFile.prototype._getInfo = function()
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetInfo"](this.nativeFile);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getStructure = function()
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetStructure"](this.nativeFile);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getLinks = function(pageIndex)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetLinks"](this.nativeFile, pageIndex);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
// WIDGETS & ANNOTATIONS
|
||||
CFile.prototype._getInteractiveFormsInfo = function()
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetInteractiveFormsInfo"](this.nativeFile);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getAnnotationsInfo = function(pageIndex)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetAnnotationsInfo"](this.nativeFile, pageIndex === undefined ? -1 : pageIndex);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getButtonIcons = function(backgroundColor, pageIndex, isBase64, nWidget, nView)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetButtonIcons"](this.nativeFile,
|
||||
backgroundColor === undefined ? 0xFFFFFF : backgroundColor,
|
||||
pageIndex,
|
||||
isBase64 ? 1 : 0,
|
||||
nWidget === undefined ? -1 : nWidget,
|
||||
nView);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getAnnotationsAP = function(width, height, backgroundColor, pageIndex, nAnnot, nView)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetAnnotationsAP"](this.nativeFile,
|
||||
width,
|
||||
height,
|
||||
backgroundColor === undefined ? 0xFFFFFF : backgroundColor,
|
||||
pageIndex,
|
||||
nAnnot === undefined ? -1 : nAnnot,
|
||||
nView);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getInteractiveFormsAP = function(width, height, backgroundColor, pageIndex, nWidget, nView, nButtonView)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_GetInteractiveFormsAP"](this.nativeFile,
|
||||
width,
|
||||
height,
|
||||
backgroundColor === undefined ? 0xFFFFFF : backgroundColor,
|
||||
pageIndex,
|
||||
nWidget === undefined ? -1 : nWidget,
|
||||
nView, nButtonView);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
// SCAN PAGES
|
||||
CFile.prototype._scanPage = function(page, mode)
|
||||
{
|
||||
g_module_pointer.ptr = Module["_ScanPage"](this.nativeFile, page, (mode === undefined) ? 0 : mode);
|
||||
return g_module_pointer;
|
||||
};
|
||||
|
||||
CFile.prototype._getImageBase64 = function(rId)
|
||||
{
|
||||
let strPtr = Module["_GetImageBase64"](this.nativeFile, rId);
|
||||
if (0 == strPtr)
|
||||
return "error";
|
||||
let len = Module["_GetImageBase64Len"](strPtr);
|
||||
let ptr = Module["_GetImageBase64Ptr"](strPtr);
|
||||
|
||||
var buffer = new Uint8Array(Module["HEAP8"].buffer, ptr, len);
|
||||
let result = String.prototype.fromUtf8(buffer, 0, len);
|
||||
Module["_GetImageBase64Free"](strPtr);
|
||||
return result;
|
||||
};
|
||||
|
||||
// TEXT
|
||||
CFile.prototype._getGlyphs = function(pageIndex)
|
||||
{
|
||||
let ptr = Module["_GetGlyphs"](this.nativeFile, pageIndex);
|
||||
if (!ptr)
|
||||
return null;
|
||||
|
||||
let ptrArray = new Int32Array(Module["HEAP8"].buffer, ptr, 5);
|
||||
let len = ptrArray[0];
|
||||
len -= 20;
|
||||
|
||||
let res = {};
|
||||
res.info = [ptrArray[1], ptrArray[2], ptrArray[3], ptrArray[4]];
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
let textCommandsSrc = new Uint8Array(Module["HEAP8"].buffer, ptr + 20, len);
|
||||
res.result = new Uint8Array(len);
|
||||
res.result.set(textCommandsSrc);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype._destroyTextInfo = function()
|
||||
{
|
||||
Module["_DestroyTextInfo"]();
|
||||
};
|
||||
|
||||
// RASTER
|
||||
CFile.prototype._getPixmap = function(pageIndex, width, height, backgroundColor)
|
||||
{
|
||||
return Module["_GetPixmap"](this.nativeFile, pageIndex, width, height, backgroundColor === undefined ? 0xFFFFFF : backgroundColor);
|
||||
};
|
||||
|
||||
// STATIC FUNCTIONS
|
||||
CFile.prototype._InitializeFonts = function(basePath)
|
||||
{
|
||||
if (undefined !== basePath && "" !== basePath)
|
||||
baseFontsPath = basePath;
|
||||
if (!window["g_fonts_selection_bin"])
|
||||
return;
|
||||
let memoryBuffer = window["g_fonts_selection_bin"].toUtf8();
|
||||
let pointer = Module["_malloc"](memoryBuffer.length);
|
||||
Module.HEAP8.set(memoryBuffer, pointer);
|
||||
Module["_InitializeFontsBase64"](pointer, memoryBuffer.length);
|
||||
Module["_free"](pointer);
|
||||
delete window["g_fonts_selection_bin"];
|
||||
|
||||
// ranges
|
||||
let rangesBuffer = new CBinaryWriter();
|
||||
let ranges = AscFonts.getSymbolRanges();
|
||||
|
||||
let rangesCount = ranges.length;
|
||||
rangesBuffer.writeUint(rangesCount);
|
||||
for (let i = 0; i < rangesCount; i++)
|
||||
{
|
||||
rangesBuffer.writeString(ranges[i].getName());
|
||||
rangesBuffer.writeUint(ranges[i].getStart());
|
||||
rangesBuffer.writeUint(ranges[i].getEnd());
|
||||
}
|
||||
|
||||
let rangesFinalLen = rangesBuffer.dataSize;
|
||||
let rangesFinal = new Uint8Array(rangesBuffer.buffer.buffer, 0, rangesFinalLen);
|
||||
pointer = Module["_malloc"](rangesFinalLen);
|
||||
Module.HEAP8.set(rangesFinal, pointer);
|
||||
Module["_InitializeFontsRanges"](pointer, rangesFinalLen);
|
||||
Module["_free"](pointer);
|
||||
};
|
||||
|
||||
CFile.prototype._CheckStreamId = function(data, status)
|
||||
{
|
||||
let drawingFile = self.drawingFile;
|
||||
if (!drawingFile)
|
||||
return;
|
||||
|
||||
let lenArray = new Int32Array(Module["HEAP8"].buffer, data, 4);
|
||||
let len = lenArray[0];
|
||||
len -= 4;
|
||||
|
||||
let buffer = new Uint8Array(Module["HEAP8"].buffer, data + 4, len);
|
||||
let reader = new CBinaryReader(buffer, 0, len);
|
||||
|
||||
let name = reader.readString();
|
||||
let style = 0;
|
||||
if (reader.readInt() != 0)
|
||||
style |= 1;//AscFonts.FontStyle.FontStyleBold;
|
||||
if (reader.readInt() != 0)
|
||||
style |= 2;//AscFonts.FontStyle.FontStyleItalic;
|
||||
|
||||
let file = AscFonts.pickFont(name, style);
|
||||
let fileId = file.GetID();
|
||||
let fileStatus = file.GetStatus();
|
||||
|
||||
if (fileStatus === 0)
|
||||
{
|
||||
// font was loaded
|
||||
fontToMemory(file, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
drawingFile.fontStreams[fileId] = drawingFile.fontStreams[fileId] || {};
|
||||
drawingFile.fontStreams[fileId].pages = drawingFile.fontStreams[fileId].pages || [];
|
||||
addToArrayAsDictionary(drawingFile.fontStreams[fileId].pages, drawingFile.fontPageIndex);
|
||||
addToArrayAsDictionary(drawingFile.pages[drawingFile.fontPageIndex].fonts, fileId);
|
||||
|
||||
drawingFile.pages[drawingFile.fontPageIndex].fontsUpdateType |= drawingFile.fontPageUpdateType;
|
||||
|
||||
// font can be loading in editor
|
||||
if (undefined === file.externalCallback)
|
||||
{
|
||||
let _t = file;
|
||||
file.externalCallback = function() {
|
||||
fontToMemory(_t, true);
|
||||
|
||||
let pages = drawingFile.fontStreams[fileId].pages;
|
||||
delete drawingFile.fontStreams[fileId];
|
||||
|
||||
let pagesRepaint_Page = [];
|
||||
let pagesRepaint_Annotation = [];
|
||||
let pagesRepaint_Forms = [];
|
||||
|
||||
for (let i = 0, len = pages.length; i < len; i++)
|
||||
{
|
||||
let pageNum = pages[i];
|
||||
let pageObj = drawingFile.pages[pageNum];
|
||||
let fonts = pageObj.fonts;
|
||||
|
||||
for (let j = 0, len_fonts = fonts.length; j < len_fonts; j++)
|
||||
{
|
||||
if (fonts[j] == fileId)
|
||||
{
|
||||
fonts.splice(j, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == fonts.length)
|
||||
{
|
||||
if (pageObj.fontsUpdateType & UpdateFontsSource.Page)
|
||||
pagesRepaint_Page.push(pageNum);
|
||||
|
||||
if (pageObj.fontsUpdateType & UpdateFontsSource.Annotation)
|
||||
pagesRepaint_Annotation.push(pageNum);
|
||||
|
||||
if (pageObj.fontsUpdateType & UpdateFontsSource.Forms)
|
||||
pagesRepaint_Forms.push(pageNum);
|
||||
|
||||
pageObj.fontsUpdateType = UpdateFontsSource.Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if (pagesRepaint_Page.length > 0 && drawingFile.onRepaintPages)
|
||||
drawingFile.onRepaintPages(pagesRepaint_Page);
|
||||
|
||||
if (pagesRepaint_Annotation.length > 0 && drawingFile.onRepaintAnnotations)
|
||||
drawingFile.onRepaintAnnotations(pagesRepaint_Annotation);
|
||||
|
||||
if (pagesRepaint_Forms.length > 0 && drawingFile.onRepaintForms)
|
||||
drawingFile.onRepaintForms(pagesRepaint_Forms);
|
||||
|
||||
delete _t.externalCallback;
|
||||
};
|
||||
|
||||
if (2 !== file.LoadFontAsync)
|
||||
file.LoadFontAsync(baseFontsPath, null);
|
||||
}
|
||||
}
|
||||
|
||||
let memoryBuffer = fileId.toUtf8();
|
||||
let pointer = Module["_malloc"](memoryBuffer.length);
|
||||
Module.HEAP8.set(memoryBuffer, pointer);
|
||||
Module["HEAP8"][status] = (fileStatus == 0) ? 1 : 0;
|
||||
return pointer;
|
||||
};
|
||||
115
DesktopEditor/graphics/pro/js/wasm/js/stream.js
Normal file
115
DesktopEditor/graphics/pro/js/wasm/js/stream.js
Normal file
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2023
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
function CBinaryReader(data, start, size)
|
||||
{
|
||||
this.data = data;
|
||||
this.pos = start;
|
||||
this.limit = start + size;
|
||||
}
|
||||
CBinaryReader.prototype.readByte = function()
|
||||
{
|
||||
let val = this.data[this.pos];
|
||||
this.pos += 1;
|
||||
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;
|
||||
this.pos += 4;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readDouble = function()
|
||||
{
|
||||
return this.readInt() / 100;
|
||||
};
|
||||
CBinaryReader.prototype.readDouble2 = function()
|
||||
{
|
||||
return this.readInt() / 10000;
|
||||
};
|
||||
CBinaryReader.prototype.readString = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
let val = String.prototype.fromUtf8(this.data, this.pos, len);
|
||||
this.pos += len;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.readData = function()
|
||||
{
|
||||
let len = this.readInt();
|
||||
let val = this.data.slice(this.pos, this.pos + len);
|
||||
this.pos += len;
|
||||
return val;
|
||||
};
|
||||
CBinaryReader.prototype.isValid = function()
|
||||
{
|
||||
return (this.pos < this.limit) ? true : false;
|
||||
};
|
||||
CBinaryReader.prototype.Skip = function(nPos)
|
||||
{
|
||||
this.pos += nPos;
|
||||
};
|
||||
|
||||
function CBinaryWriter()
|
||||
{
|
||||
this.size = 100000;
|
||||
this.dataSize = 0;
|
||||
this.buffer = new Uint8Array(this.size);
|
||||
}
|
||||
CBinaryWriter.prototype.checkAlloc = function(addition)
|
||||
{
|
||||
if ((this.dataSize + addition) <= this.size)
|
||||
return;
|
||||
|
||||
let newSize = Math.max(this.size * 2, this.size + addition);
|
||||
let newBuffer = new Uint8Array(newSize);
|
||||
newBuffer.set(this.buffer, 0);
|
||||
|
||||
this.size = newSize;
|
||||
this.buffer = newBuffer;
|
||||
};
|
||||
CBinaryWriter.prototype.writeUint = function(value)
|
||||
{
|
||||
this.checkAlloc(4);
|
||||
let val = (value>2147483647)?value-4294967296:value;
|
||||
this.buffer[this.dataSize++] = (val) & 0xFF;
|
||||
this.buffer[this.dataSize++] = (val >>> 8) & 0xFF;
|
||||
this.buffer[this.dataSize++] = (val >>> 16) & 0xFF;
|
||||
this.buffer[this.dataSize++] = (val >>> 24) & 0xFF;
|
||||
};
|
||||
CBinaryWriter.prototype.writeString = function(value)
|
||||
{
|
||||
let valueUtf8 = value.toUtf8();
|
||||
this.checkAlloc(valueUtf8.length);
|
||||
this.buffer.set(valueUtf8, this.dataSize);
|
||||
this.dataSize += valueUtf8.length;
|
||||
};
|
||||
@ -1,8 +1,7 @@
|
||||
#include <malloc.h>
|
||||
|
||||
#include "../../../../../common/Base64.h"
|
||||
|
||||
#include "drawingfile.h"
|
||||
#include "../../../../../doctrenderer/drawingfile.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WASM_EXPORT __declspec(dllexport)
|
||||
@ -49,7 +48,7 @@ WASM_EXPORT void InitializeFontsRanges(BYTE* pDataSrc)
|
||||
}
|
||||
WASM_EXPORT void SetFontBinary(char* path, BYTE* data, int size)
|
||||
{
|
||||
NSFonts::IFontsMemoryStorage* pStorage = NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
|
||||
NSFonts::IFontsMemoryStorage* pStorage = CDrawingFile::GetFontsStorage();
|
||||
if (pStorage)
|
||||
{
|
||||
std::string sPathA(path);
|
||||
@ -58,7 +57,7 @@ WASM_EXPORT void SetFontBinary(char* path, BYTE* data, int size)
|
||||
}
|
||||
WASM_EXPORT int IsFontBinaryExist(char* path)
|
||||
{
|
||||
NSFonts::IFontsMemoryStorage* pStorage = NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
|
||||
NSFonts::IFontsMemoryStorage* pStorage = CDrawingFile::GetFontsStorage();
|
||||
if (pStorage)
|
||||
{
|
||||
std::string sPathA(path);
|
||||
@ -88,188 +87,100 @@ WASM_EXPORT int GetType(BYTE* data, LONG size)
|
||||
return 1;
|
||||
return 2;
|
||||
}
|
||||
WASM_EXPORT CGraphicsFileDrawing* Open(BYTE* data, LONG size, const char* password)
|
||||
WASM_EXPORT CDrawingFile* Open(BYTE* data, LONG size, const char* password)
|
||||
{
|
||||
if (!g_applicationFonts)
|
||||
g_applicationFonts = NSFonts::NSApplication::Create();
|
||||
|
||||
// всегда пересоздаем сторадж
|
||||
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NSFonts::NSApplicationFontStream::CreateDefaultGlobalMemoryStorage());
|
||||
CDrawingFile::InitFontsGlobalStorage();
|
||||
|
||||
CGraphicsFileDrawing* pGraphics = new CGraphicsFileDrawing(g_applicationFonts);
|
||||
pGraphics->Open(data, size, GetType(data, size), password);
|
||||
return pGraphics;
|
||||
CDrawingFile* pFile = new CDrawingFile(g_applicationFonts);
|
||||
std::wstring sPassword = L"";
|
||||
if (NULL != password)
|
||||
sPassword = NSFile::CUtf8Converter::GetUnicodeStringFromUTF8((BYTE*)password, strlen(password));
|
||||
pFile->OpenFile(data, size, sPassword);
|
||||
return pFile;
|
||||
}
|
||||
WASM_EXPORT int GetErrorCode(CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT int GetErrorCode(CDrawingFile* pFile)
|
||||
{
|
||||
if (!pGraphics)
|
||||
if (!pFile)
|
||||
return -1;
|
||||
return pGraphics->GetErrorCode();
|
||||
return pFile->GetErrorCode();
|
||||
}
|
||||
WASM_EXPORT void Close (CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT void Close(CDrawingFile* pFile)
|
||||
{
|
||||
delete pGraphics;
|
||||
delete pFile;
|
||||
NSFonts::NSApplicationFontStream::SetGlobalMemoryStorage(NULL);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetInfo (CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT BYTE* GetInfo(CDrawingFile* pFile)
|
||||
{
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
|
||||
oRes.AddInt(pGraphics->GetMaxRefID());
|
||||
|
||||
int pages_count = pGraphics->GetPagesCount();
|
||||
oRes.AddInt(pages_count);
|
||||
for (int page = 0; page < pages_count; ++page)
|
||||
{
|
||||
int nW = 0;
|
||||
int nH = 0;
|
||||
int nDpi = 0;
|
||||
int nRotate = 0;
|
||||
pGraphics->GetPageInfo(page, nW, nH, nDpi, nRotate);
|
||||
oRes.AddInt(nW);
|
||||
oRes.AddInt(nH);
|
||||
oRes.AddInt(nDpi);
|
||||
oRes.AddInt(nRotate);
|
||||
}
|
||||
std::wstring wsInfo = pGraphics->GetInfo();
|
||||
std::string sInfo = U_TO_UTF8(wsInfo);
|
||||
oRes.WriteString((BYTE*)sInfo.c_str(), sInfo.length());
|
||||
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
return pFile->GetInfo();
|
||||
}
|
||||
WASM_EXPORT BYTE* GetPixmap (CGraphicsFileDrawing* pGraphics, int nPageIndex, int nRasterW, int nRasterH, int nBackgroundColor)
|
||||
WASM_EXPORT BYTE* GetPixmap(CDrawingFile* pFile, int nPageIndex, int nRasterW, int nRasterH, int nBackgroundColor)
|
||||
{
|
||||
return pGraphics->GetPage(nPageIndex, nRasterW, nRasterH, nBackgroundColor);
|
||||
return pFile->GetPixmap(nPageIndex, nRasterW, nRasterH, nBackgroundColor);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetGlyphs (CGraphicsFileDrawing* pGraphics, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetGlyphs(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pGraphics->GetGlyphs(nPageIndex);
|
||||
return pFile->GetGlyphs(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetLinks (CGraphicsFileDrawing* pGraphics, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetLinks (CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pGraphics->GetLinks(nPageIndex);
|
||||
return pFile->GetLinks(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetStructure(CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT BYTE* GetStructure(CDrawingFile* pFile)
|
||||
{
|
||||
return pGraphics->GetStructure();
|
||||
return pFile->GetStructure();
|
||||
}
|
||||
WASM_EXPORT BYTE* GetInteractiveFormsInfo(CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT BYTE* GetInteractiveFormsInfo(CDrawingFile* pFile)
|
||||
{
|
||||
return pGraphics->GetInteractiveFormsInfo();
|
||||
return pFile->GetInteractiveFormsInfo();
|
||||
}
|
||||
WASM_EXPORT BYTE* GetInteractiveFormsFonts(CGraphicsFileDrawing* pGraphics, int nType)
|
||||
WASM_EXPORT BYTE* GetInteractiveFormsFonts(CDrawingFile* pFile, int nType)
|
||||
{
|
||||
return pGraphics->GetAnnotFonts(nType);
|
||||
return pFile->GetInteractiveFormsFonts(nType);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetInteractiveFormsAP(CGraphicsFileDrawing* pGraphics, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nWidget, int nView, int nButtonView)
|
||||
WASM_EXPORT BYTE* GetInteractiveFormsAP(CDrawingFile* pFile, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nWidget, int nView, int nButtonView)
|
||||
{
|
||||
const char* sView = NULL;
|
||||
if (nView == 0)
|
||||
sView = "N";
|
||||
else if (nView == 1)
|
||||
sView = "D";
|
||||
else if (nView == 2)
|
||||
sView = "R";
|
||||
|
||||
const char* sButtonView = NULL;
|
||||
if (nButtonView == 0)
|
||||
sButtonView = "Off";
|
||||
else if (nButtonView == 1)
|
||||
sButtonView = "Yes";
|
||||
|
||||
return pGraphics->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sButtonView);
|
||||
return pFile->GetInteractiveFormsAP(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, nView, nButtonView);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nBackgroundColor, int nPageIndex, int bBase64, int nButtonWidget, int nIconView)
|
||||
WASM_EXPORT BYTE* GetButtonIcons(CDrawingFile* pFile, int nBackgroundColor, int nPageIndex, int bBase64, int nButtonWidget, int nIconView)
|
||||
{
|
||||
const char* sIconView = NULL;
|
||||
if (nIconView == 0)
|
||||
sIconView = "I";
|
||||
else if (nIconView == 1)
|
||||
sIconView = "RI";
|
||||
else if (nIconView == 2)
|
||||
sIconView = "IX";
|
||||
|
||||
return pGraphics->GetButtonIcon(nBackgroundColor, nPageIndex, bBase64 ? true : false, nButtonWidget, sIconView);
|
||||
return pFile->GetButtonIcons(nBackgroundColor, nPageIndex, bBase64 ? true : false, nButtonWidget, nIconView);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetAnnotationsInfo(CGraphicsFileDrawing* pGraphics, int nPageIndex)
|
||||
WASM_EXPORT BYTE* GetAnnotationsInfo(CDrawingFile* pFile, int nPageIndex)
|
||||
{
|
||||
return pGraphics->GetAnnots(nPageIndex);
|
||||
return pFile->GetAnnotationsInfo(nPageIndex);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetAnnotationsAP(CGraphicsFileDrawing* pGraphics, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nAnnot, int nView)
|
||||
WASM_EXPORT BYTE* GetAnnotationsAP(CDrawingFile* pFile, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nAnnot, int nView)
|
||||
{
|
||||
const char* sView = NULL;
|
||||
if (nView == 0)
|
||||
sView = "N";
|
||||
else if (nView == 1)
|
||||
sView = "D";
|
||||
else if (nView == 2)
|
||||
sView = "R";
|
||||
|
||||
return pGraphics->GetAPAnnots(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nAnnot, sView);
|
||||
return pFile->GetAnnotationsAP(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nAnnot, nView);
|
||||
}
|
||||
WASM_EXPORT BYTE* GetFontBinary(CGraphicsFileDrawing* pGraphics, char* path)
|
||||
WASM_EXPORT BYTE* GetFontBinary(CDrawingFile* pFile, char* path)
|
||||
{
|
||||
std::string sPathA(path);
|
||||
std::wstring sFontName = UTF8_TO_U(sPathA);
|
||||
std::wstring sFontFile = pGraphics->GetFont(sFontName);
|
||||
if (sFontFile.empty())
|
||||
sFontFile = sFontName;
|
||||
|
||||
NSFonts::IFontsMemoryStorage* pStorage = NSFonts::NSApplicationFontStream::GetGlobalMemoryStorage();
|
||||
if (pStorage)
|
||||
{
|
||||
NSFonts::IFontStream* pStream = pStorage->Get(sFontFile);
|
||||
if (pStream)
|
||||
{
|
||||
BYTE* pData = NULL;
|
||||
LONG lLength = 0;
|
||||
pStream->GetMemory(pData, lLength);
|
||||
|
||||
if (pData)
|
||||
{
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
|
||||
oRes.AddInt(lLength);
|
||||
|
||||
unsigned long long npSubMatrix = (unsigned long long)pData;
|
||||
unsigned int npSubMatrix1 = npSubMatrix & 0xFFFFFFFF;
|
||||
oRes.AddInt(npSubMatrix1);
|
||||
oRes.AddInt(npSubMatrix >> 32);
|
||||
|
||||
oRes.WriteLen();
|
||||
BYTE* bRes = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return bRes;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return pFile->GetFontBinary(std::string(path));
|
||||
}
|
||||
WASM_EXPORT void DestroyTextInfo(CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT void DestroyTextInfo(CDrawingFile* pFile)
|
||||
{
|
||||
return pGraphics->DestroyText();
|
||||
return pFile->DestroyTextInfo();
|
||||
}
|
||||
WASM_EXPORT int IsNeedCMap(CGraphicsFileDrawing* pGraphics)
|
||||
WASM_EXPORT int IsNeedCMap(CDrawingFile* pFile)
|
||||
{
|
||||
return pGraphics->IsNeedCMap() ? 1 : 0;
|
||||
return pFile->IsNeedCMap() ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT void SetCMapData(CGraphicsFileDrawing* pGraphics, BYTE* data, int size)
|
||||
WASM_EXPORT void SetCMapData(CDrawingFile* pFile, BYTE* data, int size)
|
||||
{
|
||||
pGraphics->SetCMapData(data, size);
|
||||
pFile->SetCMapData(data, size);
|
||||
}
|
||||
WASM_EXPORT BYTE* ScanPage(CGraphicsFileDrawing* pGraphics, int nPageIndex, int mode)
|
||||
WASM_EXPORT BYTE* ScanPage(CDrawingFile* pFile, int nPageIndex, int mode)
|
||||
{
|
||||
return pGraphics->GetPageShapes(nPageIndex, mode);
|
||||
return pFile->ScanPage(nPageIndex, mode);
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CGraphicsFileDrawing* pGraphics, int rId)
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
return pGraphics->GetImageBase64(rId);
|
||||
return pFile->GetImageBase64(rId);
|
||||
}
|
||||
WASM_EXPORT int GetImageBase64Len(std::string* p)
|
||||
{
|
||||
|
||||
@ -1,232 +0,0 @@
|
||||
#ifndef _WASM_GRAPHICS_
|
||||
#define _WASM_GRAPHICS_
|
||||
|
||||
#include "../../../../../common/File.h"
|
||||
#include "../../../../pro/officedrawingfile.h"
|
||||
#include "../../../../../../XpsFile/XpsFile.h"
|
||||
#include "../../../../../../DjVuFile/DjVu.h"
|
||||
#include "../../../../../../PdfFile/PdfFile.h"
|
||||
#include "../../../../../../HtmlRenderer/include/HTMLRendererText.h"
|
||||
#include "../../../../../../DocxRenderer/DocxRenderer.h"
|
||||
#include "serialize.h"
|
||||
|
||||
class CGraphicsFileDrawing
|
||||
{
|
||||
private:
|
||||
IOfficeDrawingFile* pReader;
|
||||
NSFonts::IApplicationFonts* pApplicationFonts;
|
||||
NSFonts::IFontManager* pFontManager;
|
||||
NSHtmlRenderer::CHTMLRendererText* pTextRenderer;
|
||||
NSDocxRenderer::IImageStorage* pImageStorage;
|
||||
int nType;
|
||||
public:
|
||||
CGraphicsFileDrawing(NSFonts::IApplicationFonts* pFonts)
|
||||
{
|
||||
pReader = NULL;
|
||||
pTextRenderer = NULL;
|
||||
pImageStorage = NULL;
|
||||
pApplicationFonts = pFonts;
|
||||
pApplicationFonts->AddRef();
|
||||
|
||||
pFontManager = pApplicationFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||
pFontCache->SetStreams(pApplicationFonts->GetStreams());
|
||||
pFontCache->SetCacheSize(8);
|
||||
pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
nType = -1;
|
||||
}
|
||||
~CGraphicsFileDrawing()
|
||||
{
|
||||
RELEASEOBJECT(pReader);
|
||||
RELEASEOBJECT(pTextRenderer);
|
||||
RELEASEOBJECT(pFontManager);
|
||||
RELEASEINTERFACE(pApplicationFonts);
|
||||
RELEASEOBJECT(pImageStorage);
|
||||
nType = -1;
|
||||
}
|
||||
bool Open(BYTE* data, DWORD length, int _nType, const char* password)
|
||||
{
|
||||
nType = _nType;
|
||||
if (nType == 0)
|
||||
pReader = new CPdfFile(pApplicationFonts);
|
||||
else if (nType == 1)
|
||||
pReader = new CDjVuFile(pApplicationFonts);
|
||||
else if (nType == 2)
|
||||
pReader = new CXpsFile(pApplicationFonts);
|
||||
if (!pReader)
|
||||
return false;
|
||||
std::wstring sPassword = L"";
|
||||
if (password)
|
||||
{
|
||||
std::string sPass(password);
|
||||
sPassword = UTF8_TO_U(sPass);
|
||||
}
|
||||
return pReader->LoadFromMemory(data, length, L"", sPassword, sPassword);
|
||||
}
|
||||
int GetErrorCode()
|
||||
{
|
||||
if (!pReader)
|
||||
return -1;
|
||||
if (nType == 0)
|
||||
// диапозон ошибки от 0 до 10
|
||||
return ((CPdfFile*)pReader)->GetError();
|
||||
return 0; // errNone
|
||||
}
|
||||
int GetPagesCount()
|
||||
{
|
||||
return pReader->GetPagesCount();
|
||||
}
|
||||
int GetMaxRefID()
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->GetMaxRefID();
|
||||
return 0;
|
||||
}
|
||||
void GetPageInfo(int nPageIndex, int& nWidth, int& nHeight, int& nPageDpiX, int& nRotate)
|
||||
{
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
pReader->GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
if (nType == 2)
|
||||
{
|
||||
dWidth = dWidth / 25.4 * 96.0;
|
||||
dHeight = dHeight / 25.4 * 96.0;
|
||||
dPageDpiX = dPageDpiX / 25.4 * 96.0;
|
||||
}
|
||||
if (nType == 0)
|
||||
nRotate = ((CPdfFile*)pReader)->GetRotate(nPageIndex);
|
||||
nWidth = dWidth;
|
||||
nHeight = dHeight;
|
||||
nPageDpiX = dPageDpiX;
|
||||
}
|
||||
std::wstring GetFont(const std::wstring& sFontName)
|
||||
{
|
||||
std::wstring sFontFile;
|
||||
if (nType == 0)
|
||||
sFontFile = ((CPdfFile*)pReader)->GetFontPath(sFontName);
|
||||
return sFontFile;
|
||||
}
|
||||
BYTE* GetPage(int nPageIndex, int nRasterW, int nRasterH, int nBackgroundColor)
|
||||
{
|
||||
return pReader->ConvertToPixels(nPageIndex, nRasterW, nRasterH, true, pFontManager, nBackgroundColor, (nBackgroundColor == 0xFFFFFF) ? false : true);
|
||||
}
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
if (NULL == pTextRenderer)
|
||||
pTextRenderer = new NSHtmlRenderer::CHTMLRendererText();
|
||||
|
||||
pTextRenderer->Init(pReader, 8);
|
||||
pReader->DrawPageOnRenderer(pTextRenderer, nPageIndex, NULL);
|
||||
|
||||
return pTextRenderer->GetBuffer();
|
||||
}
|
||||
BYTE* GetLinks(int nPageIndex)
|
||||
{
|
||||
return pReader->GetLinks(nPageIndex);
|
||||
}
|
||||
BYTE* GetStructure()
|
||||
{
|
||||
return pReader->GetStructure();
|
||||
}
|
||||
BYTE* GetInteractiveFormsInfo()
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->GetWidgets();
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetAnnotFonts(int nTypeFonts)
|
||||
{
|
||||
if (nType == 0)
|
||||
{
|
||||
if (nTypeFonts == 1)
|
||||
return ((CPdfFile*)pReader)->GetAnnotEmbeddedFonts();
|
||||
if (nTypeFonts == 2)
|
||||
return ((CPdfFile*)pReader)->GetAnnotStandardFonts();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetAnnots(int nPageIndex = -1)
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->GetAnnots(nPageIndex);
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetAPWidget (int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nWidget = -1, const char* sView = NULL, const char* sBView = NULL)
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sBView);
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetButtonIcon(int nBackgroundColor, int nPageIndex, bool bBase64, int nBWidget = -1, const char* sIView = NULL)
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->GetButtonIcon(nBackgroundColor, nPageIndex, bBase64, nBWidget, sIView);
|
||||
return NULL;
|
||||
}
|
||||
BYTE* GetAPAnnots (int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int nAnnot = -1, const char* sView = NULL)
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->GetAPAnnots(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nAnnot, sView);
|
||||
return NULL;
|
||||
}
|
||||
std::wstring GetInfo()
|
||||
{
|
||||
return pReader->GetInfo();
|
||||
}
|
||||
bool IsNeedCMap()
|
||||
{
|
||||
if (nType == 0)
|
||||
return ((CPdfFile*)pReader)->IsNeedCMap();
|
||||
return false;
|
||||
}
|
||||
void SetCMapData(BYTE* pData, DWORD nSizeData)
|
||||
{
|
||||
if (nType == 0)
|
||||
((CPdfFile*)pReader)->SetCMapMemory(pData, nSizeData);
|
||||
}
|
||||
void DestroyText()
|
||||
{
|
||||
RELEASEOBJECT(pTextRenderer);
|
||||
}
|
||||
|
||||
BYTE* GetPageShapes(const int& nPageIndex, int mode)
|
||||
{
|
||||
if (NULL == pImageStorage)
|
||||
pImageStorage = NSDocxRenderer::CreateWasmImageStorage();
|
||||
|
||||
CDocxRenderer oRenderer(pApplicationFonts);
|
||||
oRenderer.SetExternalImageStorage(pImageStorage);
|
||||
oRenderer.SetTextAssociationType(NSDocxRenderer::TextAssociationType::tatParagraphToShape);
|
||||
|
||||
std::vector<std::wstring> arShapes;
|
||||
if (0 == mode)
|
||||
arShapes = oRenderer.ScanPage(pReader, nPageIndex);
|
||||
else
|
||||
arShapes = oRenderer.ScanPagePptx(pReader, nPageIndex);
|
||||
|
||||
int nLen = (int)arShapes.size();
|
||||
|
||||
NSWasm::CData oRes;
|
||||
oRes.SkipLen();
|
||||
oRes.AddInt(nLen);
|
||||
|
||||
for (int i = 0; i < nLen; ++i)
|
||||
oRes.WriteString(arShapes[i]);
|
||||
|
||||
oRes.WriteLen();
|
||||
|
||||
BYTE* res = oRes.GetBuffer();
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string* GetImageBase64(int nRId)
|
||||
{
|
||||
if (NULL == pImageStorage)
|
||||
return NULL;
|
||||
return pImageStorage->GetBase64(nRId);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _WASM_GRAPHICS_
|
||||
@ -884,7 +884,6 @@ void ReadInteractiveFormsFonts(CGraphicsFileDrawing* pGrFile, int nType)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
|
||||
// CHECK SYSTEM FONTS
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
|
||||
@ -972,8 +971,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
free(pInfo);
|
||||
|
||||
// CMAP
|
||||
BYTE* pCMapData = NULL;
|
||||
if (IsNeedCMap(pGrFile))
|
||||
@ -985,24 +982,33 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
// RASTER
|
||||
if (true && nPagesCount > 0)
|
||||
int i = nTestPage;
|
||||
for (int i = 0; i < nPagesCount; ++i)
|
||||
{
|
||||
BYTE* res = NULL;
|
||||
res = GetPixmap(pGrFile, nTestPage, nWidth, nHeight, 0xFFFFFF);
|
||||
// RASTER
|
||||
if (true)
|
||||
{
|
||||
nWidth = READ_INT(pInfo + i * 16 + 12);
|
||||
nHeight = READ_INT(pInfo + i * 16 + 16);
|
||||
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(res);
|
||||
oFrame.put_Width(nWidth);
|
||||
oFrame.put_Height(nHeight);
|
||||
oFrame.put_Stride(4 * nWidth);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.SaveFile(NSFile::GetProcessDirectory() + L"/res.png", _CXIMAGE_FORMAT_PNG);
|
||||
oFrame.ClearNoAttack();
|
||||
BYTE* res = NULL;
|
||||
res = GetPixmap(pGrFile, i, nWidth, nHeight, 0xFFFFFF);
|
||||
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(res);
|
||||
oFrame.put_Width(nWidth);
|
||||
oFrame.put_Height(nHeight);
|
||||
oFrame.put_Stride(4 * nWidth);
|
||||
oFrame.put_IsRGBA(true);
|
||||
oFrame.SaveFile(NSFile::GetProcessDirectory() + L"/res/res" + std::to_wstring(i) + L".png", _CXIMAGE_FORMAT_PNG);
|
||||
oFrame.ClearNoAttack();
|
||||
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
}
|
||||
}
|
||||
|
||||
free(pInfo);
|
||||
|
||||
// LINKS
|
||||
if (false && nPagesCount > 0)
|
||||
{
|
||||
@ -1078,7 +1084,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// INTERACTIVE FORMS
|
||||
if (true)
|
||||
if (false)
|
||||
{
|
||||
ReadInteractiveFormsFonts(pGrFile, 1);
|
||||
ReadInteractiveFormsFonts(pGrFile, 2);
|
||||
@ -1193,7 +1199,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
// ANNOTS
|
||||
if (true)
|
||||
if (false)
|
||||
{
|
||||
BYTE* pAnnots = GetAnnotationsInfo(pGrFile, -1);
|
||||
nLength = READ_INT(pAnnots);
|
||||
@ -1796,6 +1802,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
Close(pGrFile);
|
||||
RELEASEARRAYOBJECTS(pFileData);
|
||||
RELEASEARRAYOBJECTS(pCMapData);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -151,8 +151,8 @@ namespace NSWasm
|
||||
BYTE* pDataUtf8 = NULL;
|
||||
LONG lDataUtf8 = 0;
|
||||
NSFile::CUtf8Converter::GetUtf8StringFromUnicode(sStr.c_str(), (LONG)sStr.length(), pDataUtf8, lDataUtf8);
|
||||
|
||||
WriteString(pDataUtf8, (unsigned int)lDataUtf8);
|
||||
RELEASEARRAYOBJECTS(pDataUtf8);
|
||||
}
|
||||
void Write(BYTE* value, unsigned int len)
|
||||
{
|
||||
|
||||
@ -117,6 +117,7 @@ METAFILE_PATH = $$PWD/../../raster/Metafile
|
||||
$$METAFILE_PATH/svg/SvgObjects/CText.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CUse.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CPolyline.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CFont.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CStyle.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CObjectBase.h \
|
||||
$$METAFILE_PATH/svg/SvgUtils.h
|
||||
@ -141,6 +142,7 @@ METAFILE_PATH = $$PWD/../../raster/Metafile
|
||||
$$METAFILE_PATH/svg/SvgObjects/CText.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CUse.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CPolyline.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CFont.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CObjectBase.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CStyle.cpp
|
||||
|
||||
|
||||
@ -468,14 +468,14 @@ namespace NSStructures
|
||||
{
|
||||
GradientInfo ginfo;
|
||||
ginfo.shading.triangle = points;
|
||||
ginfo.shading.shading_type = ShadingInfo::Parametric;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
if (parametric)
|
||||
{
|
||||
ginfo.shading.triangle_parameters = params;
|
||||
ginfo.shading.f_type = ShadingInfo::UseNew;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.shading.shading_type = ShadingInfo::Parametric;
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -513,7 +513,10 @@ namespace NSStructures
|
||||
ginfo.shading.patch[2][0] = curve_points[10];
|
||||
ginfo.shading.patch[1][0] = curve_points[11];
|
||||
|
||||
|
||||
ginfo.shading.f_type = ShadingInfo::UseNew;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
|
||||
if (parametric)
|
||||
{
|
||||
@ -522,11 +525,7 @@ namespace NSStructures
|
||||
ginfo.shading.patch_parameters[0][1] = curve_parametrs[1];
|
||||
ginfo.shading.patch_parameters[1][0] = curve_parametrs[3];
|
||||
ginfo.shading.patch_parameters[1][1] = curve_parametrs[2];
|
||||
ginfo.shading.f_type = ShadingInfo::UseNew;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.shading.shading_type = ShadingInfo::Parametric;
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -549,14 +548,15 @@ namespace NSStructures
|
||||
|
||||
ginfo.shading.patch = curve_poits;
|
||||
|
||||
ginfo.shading.f_type = ShadingInfo::UseNew;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
|
||||
if (parametric)
|
||||
{
|
||||
ginfo.shading.patch_parameters = curve_parametrs;
|
||||
ginfo.shading.f_type = ShadingInfo::UseNew;
|
||||
ginfo.shading.function = ColorFunction<agg::rgba8>(256, t0, t1);
|
||||
ginfo.shading.shading_type = ShadingInfo::Parametric;
|
||||
ginfo.continue_shading_f = false;
|
||||
ginfo.continue_shading_b = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -81,10 +81,6 @@ namespace MetaFile
|
||||
Close();
|
||||
RELEASEINTERFACE(m_pFontManager);
|
||||
}
|
||||
void CMetaFile::SetImageSize(int nWidth, int nHeight)
|
||||
{
|
||||
// for meta with empty size
|
||||
}
|
||||
|
||||
std::wstring CMetaFile::ConvertToSvg(unsigned int unWidth, unsigned int unHeight)
|
||||
{
|
||||
|
||||
@ -62,7 +62,6 @@ namespace MetaFile
|
||||
CMetaFile(NSFonts::IApplicationFonts *pAppFonts);
|
||||
virtual ~CMetaFile();
|
||||
|
||||
void SetImageSize(int nWidth, int nHeight);
|
||||
bool LoadFromFile(const wchar_t* wsFilePath);
|
||||
bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize);
|
||||
bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "CSvgFile.h"
|
||||
|
||||
#include "SvgObjects/CContainer.h"
|
||||
#include "SvgObjects/CFont.h"
|
||||
|
||||
#define SVG_FILE_WIDTH 300
|
||||
#define SVG_FILE_HEIGHT 150
|
||||
@ -132,6 +133,16 @@ SVG::CObject *CSvgFile::GetMarkedObject(const std::wstring &wsId) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SVG::CFont *CSvgFile::GetFont(const std::wstring &wsFontFamily) const
|
||||
{
|
||||
FontsFaceMap::const_iterator itFound = std::find_if(m_mFontsFace.cbegin(), m_mFontsFace.cend(), [&wsFontFamily](const std::pair<std::wstring, std::wstring>& oValue){ return wsFontFamily == oValue.first; });
|
||||
|
||||
if (m_mFontsFace.cend() == itFound)
|
||||
return NULL;
|
||||
|
||||
return dynamic_cast<SVG::CFont*>(GetMarkedObject(itFound->second));
|
||||
}
|
||||
|
||||
std::wstring CSvgFile::GetWorkingDirectory() const
|
||||
{
|
||||
return m_wsWorkingDirectory;
|
||||
@ -142,6 +153,11 @@ void CSvgFile::AddStyles(const std::wstring &wsStyles)
|
||||
m_oSvgCalculator.AddStyles(wsStyles);
|
||||
}
|
||||
|
||||
void CSvgFile::AddFontFace(const SVG::TFontArguments& oArguments, const std::wstring &wsId)
|
||||
{
|
||||
m_mFontsFace.insert(std::make_pair(oArguments.m_wsFontFamily, wsId));
|
||||
}
|
||||
|
||||
bool CSvgFile::Draw(IRenderer *pRenderer, double dX, double dY, double dWidth, double dHeight)
|
||||
{
|
||||
if (NULL == pRenderer || m_oContainer.Empty())
|
||||
|
||||
@ -9,6 +9,12 @@
|
||||
|
||||
#define SVG_DECL_IMPORT Q_DECL_IMPORT
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
struct TFontArguments;
|
||||
class CFont;
|
||||
}
|
||||
|
||||
class SVG_DECL_IMPORT CSvgFile
|
||||
{
|
||||
public:
|
||||
@ -28,9 +34,12 @@ class SVG_DECL_IMPORT CSvgFile
|
||||
bool MarkObject(SVG::CObject* pObject);
|
||||
SVG::CObject* GetMarkedObject(const std::wstring& wsId) const;
|
||||
|
||||
SVG::CFont* GetFont(const std::wstring& wsFontFamily) const;
|
||||
|
||||
std::wstring GetWorkingDirectory() const;
|
||||
|
||||
|
||||
void AddStyles(const std::wstring& wsStyles);
|
||||
void AddFontFace(const SVG::TFontArguments& oArguments, const std::wstring& wsId);
|
||||
|
||||
bool Draw(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight);
|
||||
private:
|
||||
@ -44,6 +53,9 @@ class SVG_DECL_IMPORT CSvgFile
|
||||
|
||||
MarkedMap m_mMarkedObjects;
|
||||
std::wstring m_wsWorkingDirectory;
|
||||
|
||||
typedef std::map<std::wstring, std::wstring> FontsFaceMap;
|
||||
FontsFaceMap m_mFontsFace;
|
||||
};
|
||||
|
||||
#endif // CSVGFILE_H
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
#include "CSvgFile.h"
|
||||
|
||||
#include "SvgObjects/CContainer.h"
|
||||
#include "SvgObjects/CPolyline.h"
|
||||
#include "SvgObjects/CGradient.h"
|
||||
#include "SvgObjects/CClipPath.h"
|
||||
@ -21,6 +20,7 @@
|
||||
#include "SvgObjects/CRect.h"
|
||||
#include "SvgObjects/CLine.h"
|
||||
#include "SvgObjects/CPath.h"
|
||||
#include "SvgObjects/CFont.h"
|
||||
#include "SvgObjects/CText.h"
|
||||
#include "SvgObjects/CMask.h"
|
||||
#include "SvgObjects/CUse.h"
|
||||
@ -95,7 +95,7 @@ namespace SVG
|
||||
|
||||
if (L"style" == wsElementName)
|
||||
{
|
||||
pFile->AddStyles(oElement.GetText());
|
||||
ParseStyles(oElement.GetText(), pFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -116,6 +116,61 @@ namespace SVG
|
||||
|
||||
return bScanResult;
|
||||
}
|
||||
|
||||
void CSvgParser::ParseStyles(const std::wstring &wsStyles, CSvgFile *pFile) const
|
||||
{
|
||||
if (NULL == pFile)
|
||||
return;
|
||||
|
||||
pFile->AddStyles(wsStyles);
|
||||
|
||||
std::wregex oRegex(L"@font-face\\s*(\\{[^}]*\\})");
|
||||
std::wsmatch oMatch;
|
||||
std::wstring::const_iterator oSearchStart(wsStyles.cbegin());
|
||||
|
||||
while (std::regex_search(oSearchStart, wsStyles.cend(), oMatch, oRegex))
|
||||
{
|
||||
if (oMatch[1].str().empty())
|
||||
continue;
|
||||
|
||||
std::wstring wsValue{oMatch[1].str()};
|
||||
|
||||
std::wstring::const_iterator itStart = std::find_if(wsValue.cbegin(), wsValue.cend(), [](const wchar_t& wChar) { return !std::iswspace(wChar) && L'{' != wChar; });
|
||||
std::wstring::const_reverse_iterator itEnd = std::find_if(wsValue.crbegin(), wsValue.crend(), [](const wchar_t& wChar) { return !std::iswspace(wChar) && L'}' != wChar; });
|
||||
|
||||
if (wsValue.cend() != itStart && wsValue.crend() != itEnd)
|
||||
wsValue = std::wstring(itStart, itEnd.base());
|
||||
|
||||
const std::vector<std::wstring> arWords{NSCSS::NS_STATIC_FUNCTIONS::GetWordsW(wsValue, true, L":;")};
|
||||
|
||||
SvgURL oURL;
|
||||
TFontArguments m_oArguments;
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arWords.size(); ++unIndex)
|
||||
{
|
||||
if (arWords[unIndex].length() > 3 && L"src" == arWords[unIndex].substr(0, 3) && L':' == arWords[unIndex].back() &&
|
||||
unIndex + 1 < arWords.size() && oURL.SetValue(arWords[++unIndex]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (arWords[unIndex].length() > 11 && L"font-family" == arWords[unIndex].substr(0, 11) && L':' == arWords[unIndex].back() &&
|
||||
unIndex + 1 < arWords.size())
|
||||
{
|
||||
const std::vector<std::wstring> arFontFamily{NSCSS::NS_STATIC_FUNCTIONS::GetWordsW(arWords[++unIndex], false, L"\"\',;")};
|
||||
|
||||
if (arFontFamily.empty())
|
||||
continue;
|
||||
|
||||
m_oArguments.m_wsFontFamily = arFontFamily.back();
|
||||
}
|
||||
}
|
||||
|
||||
if (!oURL.Empty() && !m_oArguments.m_wsFontFamily.empty())
|
||||
pFile->AddFontFace(m_oArguments, oURL.GetValue());
|
||||
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ObjectType>
|
||||
bool CSvgParser::ReadObject(XmlUtils::CXmlNode &oElement, CContainer<ObjectType> *pContainer, CSvgFile *pFile, CRenderedObject *pParent) const
|
||||
@ -229,6 +284,10 @@ namespace SVG
|
||||
else
|
||||
RELEASEOBJECT(pObject);
|
||||
}
|
||||
else if (L"font" == wsElementName)
|
||||
{
|
||||
pObject = new CFont(oElement);
|
||||
}
|
||||
|
||||
if (NULL != pObject)
|
||||
{
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define CSVGPARSER_H
|
||||
|
||||
#include "../../../common/Directory.h"
|
||||
#include "../../../graphics/pro/Fonts.h"
|
||||
#include "../../../xml/include/xmlutils.h"
|
||||
|
||||
#include "SvgObjects/CContainer.h"
|
||||
@ -29,6 +30,7 @@ namespace SVG
|
||||
bool ReadChildrens(XmlUtils::CXmlNode& oElement, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject* pParent = NULL) const;
|
||||
|
||||
bool ScanStyles(XmlUtils::CXmlNode& oElement, CSvgFile* pFile) const;
|
||||
void ParseStyles(const std::wstring& wsStyles, CSvgFile *pFile) const;
|
||||
|
||||
void UpdateStyles(CObject* pObject, CSvgFile* pFile) const;
|
||||
bool MarkObject(CObject* pObject, CSvgFile* pFile) const;
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
|
||||
#include "CObjectBase.h"
|
||||
|
||||
#include "../../../../graphics/pro/Fonts.h"
|
||||
|
||||
class CSvgFile;
|
||||
|
||||
namespace SVG
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user