mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-08 11:29:57 +08:00
Compare commits
201 Commits
v8.1.0.110
...
v8.1.0.155
| Author | SHA1 | Date | |
|---|---|---|---|
| dc485997f0 | |||
| 2e6d5450b4 | |||
| b428487d07 | |||
| 96ea86e3c0 | |||
| 5c7d0a61be | |||
| 4014d4914f | |||
| 0b77fb2bba | |||
| 2e1ccbc985 | |||
| f5202108a1 | |||
| 2f7407bd8e | |||
| ac721572f2 | |||
| 33da43b2f4 | |||
| 591dffc965 | |||
| cd74ef4ded | |||
| c7612a259d | |||
| 586455310a | |||
| 96008085d6 | |||
| 282b87e518 | |||
| 115a60c273 | |||
| 66d48673cf | |||
| 29ef74770a | |||
| 15247d39f0 | |||
| 145154690b | |||
| 4f28d8d3d8 | |||
| 2fdd88bee2 | |||
| 7c501fe5a3 | |||
| acbf5b0c40 | |||
| d843cf1fe1 | |||
| 50529346e4 | |||
| 803fcf3602 | |||
| d83930bf67 | |||
| cd5ca284e1 | |||
| 7a1a59a883 | |||
| bfb97ef026 | |||
| 742cfde620 | |||
| 600fd26e30 | |||
| 92fa08303e | |||
| 17bd0f99dd | |||
| d5d4d06553 | |||
| 400da99fa9 | |||
| b209e00333 | |||
| 1859173fb6 | |||
| dfb0aeefcb | |||
| 6ba5d1141e | |||
| 8d6a13b24a | |||
| a66fdc73a5 | |||
| a2b8fcc5e1 | |||
| 7ac5ff5383 | |||
| 5e560528a4 | |||
| b8c57da779 | |||
| 19951d807c | |||
| 49d1426831 | |||
| e8ae960a26 | |||
| 11ddc0ab4f | |||
| 5361740a02 | |||
| 0050c6148c | |||
| 8e3df68ffc | |||
| ab829fa8db | |||
| bc56de19c1 | |||
| 1de6787014 | |||
| b02189c14d | |||
| 63003a5e76 | |||
| 499810dbae | |||
| f55d822c4f | |||
| 4c51371b96 | |||
| 986bcae0e2 | |||
| 96b87265bb | |||
| 0be217ba05 | |||
| af12226bfa | |||
| d51f035561 | |||
| d01681bb1e | |||
| 72e975f7d9 | |||
| ba87df6b9d | |||
| a1fed79a78 | |||
| 08111e8fde | |||
| 1286b7f458 | |||
| dcb4364410 | |||
| 55a009713e | |||
| 474828364f | |||
| 9e145ef9e0 | |||
| 40b6178a0d | |||
| a70f50206d | |||
| 40fa3e60c4 | |||
| 105a193742 | |||
| 4ca9a94609 | |||
| 3bfb3ee045 | |||
| 512df584ba | |||
| 84eebc69e1 | |||
| 7abb3899a7 | |||
| f19906c14c | |||
| fd15cdf4d0 | |||
| 9d3e553086 | |||
| a19b4a03b3 | |||
| 90650b1af8 | |||
| 3780922610 | |||
| fbb7ab93d6 | |||
| ca5201e704 | |||
| 2b13696379 | |||
| 24b32a2ba7 | |||
| 1cdb2b0f15 | |||
| 7758da7173 | |||
| 3cd89354bc | |||
| 5fbed3db1c | |||
| f28119e646 | |||
| a2b0495254 | |||
| 28f873be5c | |||
| 5dede9304b | |||
| ab52ee7486 | |||
| 8f711f607f | |||
| f2c5fed3c1 | |||
| 1602fb2106 | |||
| c3f72756a4 | |||
| 5f8b557eb5 | |||
| 9d8e75a957 | |||
| 839844cb4f | |||
| fac976a22e | |||
| 84cb59d7b2 | |||
| 788620079d | |||
| 0e5b95f1d8 | |||
| d0a82d71ee | |||
| 97f742f816 | |||
| 58980e61b7 | |||
| 5a04f9033b | |||
| 28785f13bc | |||
| 7a73d3288c | |||
| d82b2dc6ef | |||
| 6ad319554d | |||
| ff3b94a23a | |||
| 5227a593ed | |||
| c802944d3b | |||
| 93d77ee945 | |||
| 4c101b21d0 | |||
| 05366635c1 | |||
| d853d42090 | |||
| cb06eae63e | |||
| 6ba40aba51 | |||
| b8d54fb295 | |||
| 84d7eb03f2 | |||
| 28cd584393 | |||
| bd6cc8a759 | |||
| 7cfd4e2dfa | |||
| f923f4e03d | |||
| e8898ce424 | |||
| ebe045a833 | |||
| 140f9970f9 | |||
| 3d23e74818 | |||
| c24c78267b | |||
| a7501e370b | |||
| 68200895d0 | |||
| b6b99ee9f0 | |||
| 5ea601cde9 | |||
| 1e7611f3f9 | |||
| c14856ac6f | |||
| 8857d3daca | |||
| ad1bd06bb3 | |||
| 52555f4d9d | |||
| d85b3dd7f0 | |||
| 6af44146e5 | |||
| f704c44e9e | |||
| a9884c1efb | |||
| 2dc0956b3c | |||
| 7dbe7eb3e1 | |||
| 5617968a0c | |||
| 3b029ae4cd | |||
| 73dc770870 | |||
| 46e56afa5c | |||
| e6842f50b3 | |||
| f008857ab2 | |||
| e7022472ff | |||
| b470c4b259 | |||
| 155103b40f | |||
| 0eee7ea548 | |||
| b53527c9fd | |||
| 7a842c4b14 | |||
| 9779e53fe7 | |||
| 6bccf233ee | |||
| 83e020f492 | |||
| 5c7b7615dd | |||
| d8bed77b67 | |||
| 7ae79f20b8 | |||
| bb2967c3ea | |||
| 88aba1cb02 | |||
| f1fbcf653b | |||
| a2e76364e9 | |||
| 051ae3fab6 | |||
| f1544a6f6c | |||
| 715facaefc | |||
| 6de671ccd5 | |||
| 9dceffdbeb | |||
| e107a67f55 | |||
| ddc413a1b3 | |||
| 5c6aaed51f | |||
| 234c1766dc | |||
| 95d8fd2871 | |||
| 013d6990ce | |||
| f9bfdee8c3 | |||
| 4880ff705b | |||
| 3acb44a5c9 | |||
| 1e18eb4335 | |||
| ddb01d9478 | |||
| 10c6def10e |
@ -110,7 +110,7 @@ namespace NSCSS
|
||||
void CCompiledStyle::AddStyle(const std::map<std::wstring, std::wstring>& mStyle, const unsigned int unLevel, const bool& bHardMode)
|
||||
{
|
||||
const bool bIsThereBorder = (m_oBorder.Empty()) ? false : true;
|
||||
const double dFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Twips) : DEFAULT_FONT_SIZE;
|
||||
const double dFontSize = (!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE;
|
||||
|
||||
for (std::pair<std::wstring, std::wstring> pPropertie : mStyle)
|
||||
{
|
||||
@ -180,7 +180,6 @@ namespace NSCSS
|
||||
break;
|
||||
|
||||
m_oMargin.SetTop(pPropertie.second, unLevel, bHardMode);
|
||||
m_oMargin.UpdateTop(dFontSize);
|
||||
break;
|
||||
}
|
||||
CASE(L"margin-right"):
|
||||
@ -489,6 +488,11 @@ namespace NSCSS
|
||||
return arParentsName;
|
||||
}
|
||||
|
||||
std::set<std::wstring> CCompiledStyle::GetParentsNamesSet() const
|
||||
{
|
||||
return m_arParentsStyles;
|
||||
}
|
||||
|
||||
void CCompiledStyle::SetID(const std::wstring& sId)
|
||||
{
|
||||
m_sId = sId;
|
||||
|
||||
@ -48,6 +48,7 @@ namespace NSCSS
|
||||
void AddParent(const std::wstring& sParentName);
|
||||
|
||||
std::vector<std::wstring> GetParentsName() const;
|
||||
std::set<std::wstring> GetParentsNamesSet() const;
|
||||
|
||||
void SetID(const std::wstring& sId);
|
||||
std::wstring GetId() const;
|
||||
|
||||
@ -52,13 +52,6 @@ namespace NSCSS
|
||||
|
||||
m_mData.clear();
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
for (std::map<std::vector<CNode>, CCompiledStyle*>::iterator iter = m_mUsedStyles.begin(); iter != m_mUsedStyles.end(); ++iter)
|
||||
delete iter->second;
|
||||
|
||||
m_mUsedStyles.clear();
|
||||
#endif
|
||||
|
||||
if (NULL != m_mStatictics)
|
||||
delete m_mStatictics;
|
||||
}
|
||||
@ -494,11 +487,11 @@ namespace NSCSS
|
||||
|
||||
if (!bIsSettings)
|
||||
{
|
||||
const std::map<std::vector<CNode>, CCompiledStyle*>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
const std::map<std::vector<CNode>, CCompiledStyle>::iterator oItem = m_mUsedStyles.find(arSelectors);
|
||||
|
||||
if (oItem != m_mUsedStyles.end())
|
||||
{
|
||||
oStyle = *oItem->second;
|
||||
oStyle = oItem->second;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -517,22 +510,22 @@ namespace NSCSS
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
{
|
||||
oStyle.AddParent(arSelectors[i].m_wsName);
|
||||
|
||||
// Скидываем некоторые внешние стили, которые внутри таблицы переопределяются
|
||||
if (L"table" == arSelectors[i].m_wsName)
|
||||
bInTable = true;
|
||||
|
||||
if (bInTable)
|
||||
{
|
||||
oStyle.m_oFont.GetLineHeight().Clear();
|
||||
oStyle.m_oPadding.Clear();
|
||||
oStyle.m_oMargin.Clear();
|
||||
bInTable = true;
|
||||
}
|
||||
|
||||
if (bInTable)
|
||||
oStyle.m_oBorder.Clear();
|
||||
}
|
||||
|
||||
CCompiledStyle oTempStyle;
|
||||
|
||||
@ -562,14 +555,10 @@ namespace NSCSS
|
||||
oStyle += oTempStyle;
|
||||
}
|
||||
|
||||
if (!bIsSettings)
|
||||
{
|
||||
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(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));
|
||||
|
||||
CCompiledStyle *pTemp = new CCompiledStyle(oStyle);
|
||||
|
||||
m_mUsedStyles[arSelectors] = pTemp;
|
||||
}
|
||||
if (!bIsSettings && !oStyle.Empty())
|
||||
m_mUsedStyles[arSelectors] = oStyle;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace NSCSS
|
||||
std::map<StatistickElement, unsigned int> *m_mStatictics; // Количество повторений свойств id и style у селекторов
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
std::map<std::vector<CNode>, CCompiledStyle*> m_mUsedStyles;
|
||||
std::map<std::vector<CNode>, CCompiledStyle> m_mUsedStyles;
|
||||
|
||||
std::map<std::wstring, std::wstring> GetPageData(const std::wstring& wsPageName);
|
||||
void SetPageData(NSProperties::CPage& oPage, const std::map<std::wstring, std::wstring>& mData, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
@ -25,7 +25,7 @@ namespace NSCSS
|
||||
}
|
||||
|
||||
CString::CString()
|
||||
: CValue(L"", 0, false)
|
||||
: CValue(L"", 0, false)
|
||||
{}
|
||||
|
||||
CString::CString(const std::wstring &wsValue, unsigned int unLevel, bool bImportant)
|
||||
@ -63,7 +63,7 @@ namespace NSCSS
|
||||
if (m_bImportant && !bImportant)
|
||||
return false;
|
||||
|
||||
if (arValiableValues.end() != std::find(arValiableValues.begin(), arValiableValues.end(), wsNewValue))\
|
||||
if (arValiableValues.end() != std::find(arValiableValues.begin(), arValiableValues.end(), wsNewValue))
|
||||
{
|
||||
m_oValue = wsNewValue;
|
||||
m_unLevel = unLevel;
|
||||
@ -254,8 +254,9 @@ namespace NSCSS
|
||||
|
||||
bool CDigit::operator==(const CDigit &oDigit) const
|
||||
{
|
||||
return (std::abs(oDigit.m_oValue - m_oValue) <= DBL_EPSILON) &&
|
||||
m_enUnitMeasure == oDigit.m_enUnitMeasure;
|
||||
return (Empty() && oDigit.Empty()) ||
|
||||
((std::abs(oDigit.m_oValue - m_oValue) <= DBL_EPSILON) &&
|
||||
m_enUnitMeasure == oDigit.m_enUnitMeasure);
|
||||
}
|
||||
|
||||
bool CDigit::operator!=(const double &oValue) const
|
||||
@ -374,7 +375,7 @@ namespace NSCSS
|
||||
|
||||
bool CDigit::SetValue(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
if (wsValue.empty() || (CHECK_CONDITIONS && !bHardMode))
|
||||
if (wsValue.empty() || (CHECK_CONDITIONS && !bHardMode) || unLevel < m_unLevel)
|
||||
return false;
|
||||
|
||||
std::wstring wsNewValue = wsValue;
|
||||
@ -404,7 +405,12 @@ namespace NSCSS
|
||||
m_enUnitMeasure = oValue.m_enUnitMeasure;
|
||||
}
|
||||
else if (NSCSS::Percent == oValue.m_enUnitMeasure)
|
||||
m_oValue *= oValue.m_oValue / 100.;
|
||||
{
|
||||
if (m_unLevel == oValue.m_unLevel)
|
||||
m_oValue = oValue.m_oValue;
|
||||
else
|
||||
m_oValue *= oValue.m_oValue / 100.;
|
||||
}
|
||||
else
|
||||
m_oValue = oValue.ToDouble(m_enUnitMeasure);
|
||||
|
||||
@ -599,6 +605,11 @@ namespace NSCSS
|
||||
return m_oValue.Empty();
|
||||
}
|
||||
|
||||
bool CColor::None() const
|
||||
{
|
||||
return ColorNone == m_oValue.m_enType;
|
||||
}
|
||||
|
||||
void CColor::Clear()
|
||||
{
|
||||
m_oValue.Clear();
|
||||
@ -616,10 +627,10 @@ namespace NSCSS
|
||||
if (m_oOpacity.Empty())
|
||||
return 1.;
|
||||
|
||||
if (Percent == m_oOpacity.GetUnitMeasure())
|
||||
if (UnitMeasure::Percent == m_oOpacity.GetUnitMeasure())
|
||||
return m_oOpacity.ToDouble() / 100.;
|
||||
|
||||
if (None == m_oOpacity.GetUnitMeasure() && m_oOpacity.ToDouble() <= 1.)
|
||||
if (UnitMeasure::None == m_oOpacity.GetUnitMeasure() && m_oOpacity.ToDouble() <= 1.)
|
||||
return m_oOpacity.ToDouble();
|
||||
|
||||
return 1.;
|
||||
@ -1126,7 +1137,7 @@ namespace NSCSS
|
||||
|
||||
bool CDisplay::SetDisplay(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oHAlign.SetValue(wsValue, NSConstValues::DISPLAY_VALUES, unLevel, bHardMode);
|
||||
return m_oDisplay.SetValue(wsValue, NSConstValues::DISPLAY_VALUES, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
const CDigit& CDisplay::GetX() const
|
||||
@ -1471,7 +1482,7 @@ namespace NSCSS
|
||||
|
||||
bool CBorderSide::Empty() const
|
||||
{
|
||||
return m_oWidth.Empty();
|
||||
return m_oWidth.Empty() || m_oColor.None();
|
||||
}
|
||||
|
||||
bool CBorderSide::Zero() const
|
||||
@ -1503,6 +1514,15 @@ namespace NSCSS
|
||||
m_oColor == oBorderSide.m_oColor;
|
||||
}
|
||||
|
||||
CBorderSide &CBorderSide::operator =(const CBorderSide &oBorderSide)
|
||||
{
|
||||
m_oWidth = oBorderSide.m_oWidth;
|
||||
m_oStyle = oBorderSide.m_oStyle;
|
||||
m_oColor = oBorderSide.m_oColor;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// BORDER
|
||||
CBorder::CBorder()
|
||||
{
|
||||
@ -1739,6 +1759,18 @@ namespace NSCSS
|
||||
m_oBottom == oBorder.m_oBottom;
|
||||
}
|
||||
|
||||
CBorder &CBorder::operator =(const CBorder &oBorder)
|
||||
{
|
||||
m_oLeft = oBorder.m_oLeft;
|
||||
m_oTop = oBorder.m_oTop;
|
||||
m_oRight = oBorder.m_oRight;
|
||||
m_oBottom = oBorder.m_oBottom;
|
||||
|
||||
m_enCollapse = oBorder.m_enCollapse;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TEXT
|
||||
CText::CText()
|
||||
{}
|
||||
@ -1978,10 +2010,10 @@ namespace NSCSS
|
||||
|
||||
CIndent &CIndent::operator+=(const CIndent &oIndent)
|
||||
{
|
||||
m_oTop = oIndent.m_oTop;
|
||||
m_oRight = oIndent.m_oRight;
|
||||
m_oBottom = oIndent.m_oBottom;
|
||||
m_oLeft = oIndent.m_oLeft;
|
||||
if (!oIndent.m_oTop.Empty()) m_oTop = oIndent.m_oTop;
|
||||
if (!oIndent.m_oRight.Empty()) m_oRight = oIndent.m_oRight;
|
||||
if (!oIndent.m_oBottom.Empty()) m_oBottom = oIndent.m_oBottom;
|
||||
if (!oIndent.m_oLeft.Empty()) m_oLeft = oIndent.m_oLeft;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -2186,16 +2218,16 @@ namespace NSCSS
|
||||
|
||||
bool CFont::SetSize(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
const std::map<std::wstring, std::wstring> arAbsoluteFontValues =
|
||||
{{L"xx-small", L"7.5pt"}, {L"x-small", L"10pt" },
|
||||
const std::vector<std::pair<std::wstring, std::wstring>> arAbsoluteFontValues =
|
||||
{{L"xx-small", L"7.5pt"}, {L"xx-large", L"36pt" },
|
||||
{L"x-small", L"10pt" }, {L"x-large", L"24pt" },
|
||||
{L"small", L"12pt" }, {L"medium", L"13.5pt"},
|
||||
{L"large", L"18pt" }, {L"x-large", L"24pt" },
|
||||
{L"xx-large", L"36pt" }};
|
||||
{L"large", L"18pt" }};
|
||||
|
||||
size_t unFoundPos = std::wstring::npos;
|
||||
std::wstring wsNewValue(wsValue);
|
||||
|
||||
for (const std::pair<std::wstring, std::wstring> oAbsValue : arAbsoluteFontValues)
|
||||
for (const std::pair<std::wstring, std::wstring>& oAbsValue : arAbsoluteFontValues)
|
||||
{
|
||||
unFoundPos = wsNewValue.find(oAbsValue.first);
|
||||
if (std::wstring::npos != unFoundPos)
|
||||
|
||||
@ -229,6 +229,7 @@ namespace NSCSS
|
||||
bool SetOpacity(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true);
|
||||
|
||||
bool Empty() const override;
|
||||
bool None() const;
|
||||
void Clear() override;
|
||||
|
||||
ColorType GetType() const;
|
||||
@ -444,6 +445,7 @@ namespace NSCSS
|
||||
|
||||
CBorderSide& operator+=(const CBorderSide& oBorderSide);
|
||||
bool operator==(const CBorderSide& oBorderSide) const;
|
||||
CBorderSide& operator =(const CBorderSide& oBorderSide);
|
||||
private:
|
||||
CDigit m_oWidth;
|
||||
CString m_oStyle;
|
||||
@ -513,6 +515,8 @@ namespace NSCSS
|
||||
|
||||
CBorder& operator+=(const CBorder& oBorder);
|
||||
bool operator==(const CBorder& oBorder) const;
|
||||
|
||||
CBorder& operator =(const CBorder& oBorder);
|
||||
private:
|
||||
CBorderSide m_oLeft;
|
||||
CBorderSide m_oTop;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "CDocumentStyle.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <unordered_set>
|
||||
#include <wchar.h>
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
@ -10,33 +11,66 @@
|
||||
#define DEFAULT_LINEHEIGHT 240
|
||||
#define LINEHEIGHTSCALE 10 // Значение LineHeight в OOXML должно быть в 10 раз больше чем указано в стиле
|
||||
|
||||
#define VALUE_TO_INT(value, unit_measure) \
|
||||
(NSCSS::UnitMeasure::None != value.GetUnitMeasure()) ? \
|
||||
value.ToInt(unit_measure) : \
|
||||
static_cast<int>(NSCSS::CUnitMeasureConverter::ConvertPx(value.ToDouble(), unit_measure, 96) + 0.5)
|
||||
|
||||
namespace NSCSS
|
||||
{
|
||||
CStyleUsed::CStyleUsed(const std::wstring &wsId, bool bIsPStyle)
|
||||
: m_bIsPStyle(bIsPStyle), m_wsId(wsId)
|
||||
CStyleUsed::CStyleUsed(const CCompiledStyle &oStyle, bool bIsPStyle)
|
||||
: m_oStyle(oStyle), m_bIsPStyle(bIsPStyle)
|
||||
{}
|
||||
|
||||
bool CheckArrays(const std::vector<std::wstring>& arInitial, const std::set<std::wstring>& arFirst, const std::set<std::wstring>& arSecond)
|
||||
{
|
||||
std::unordered_set<std::wstring> arInitialSet(arInitial.begin(), arInitial.end());
|
||||
|
||||
std::vector<std::wstring> arCommonElements1;
|
||||
std::vector<std::wstring> arCommonElements2;
|
||||
|
||||
for (const std::wstring& wsValue : arFirst)
|
||||
{
|
||||
if (arInitialSet.count(wsValue) > 0)
|
||||
arCommonElements1.push_back(wsValue);
|
||||
}
|
||||
|
||||
for (const std::wstring& wsValue : arSecond)
|
||||
{
|
||||
if (arInitialSet.count(wsValue) > 0)
|
||||
arCommonElements2.push_back(wsValue);
|
||||
}
|
||||
|
||||
if (arCommonElements1.size() != arCommonElements2.size())
|
||||
return false;
|
||||
|
||||
std::sort(arCommonElements1.begin(), arCommonElements1.end());
|
||||
std::sort(arCommonElements2.begin(), arCommonElements2.end());
|
||||
|
||||
return arCommonElements1 == arCommonElements2;
|
||||
}
|
||||
|
||||
bool CStyleUsed::operator==(const CStyleUsed &oUsedStyle) const
|
||||
{
|
||||
return (m_bIsPStyle == oUsedStyle.m_bIsPStyle) && (m_wsId == oUsedStyle.m_wsId);
|
||||
return m_bIsPStyle == oUsedStyle.m_bIsPStyle &&
|
||||
CheckArrays(Names_Standard_Styles, m_oStyle.GetParentsNamesSet(), oUsedStyle.m_oStyle.GetParentsNamesSet()) &&
|
||||
m_oStyle == oUsedStyle.m_oStyle;
|
||||
}
|
||||
|
||||
std::wstring CStyleUsed::getId()
|
||||
{
|
||||
if (m_bIsPStyle)
|
||||
return m_wsId;
|
||||
return m_oStyle.GetId();
|
||||
|
||||
return m_wsId + L"-c";
|
||||
return m_oStyle.GetId() + L"-c";
|
||||
}
|
||||
|
||||
void CStyleUsed::setId(const std::wstring &sId)
|
||||
CDocumentStyle::CDocumentStyle() : m_arStandardStyles(Names_Standard_Styles)
|
||||
{
|
||||
m_wsId = sId;
|
||||
for (const std::wstring& oNameStandardStyle : Names_Standard_Styles)
|
||||
m_arStandardStyles.push_back(oNameStandardStyle + L"-c");
|
||||
}
|
||||
|
||||
CDocumentStyle::CDocumentStyle() : m_arStandardStyles({L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6", L"h1-c",
|
||||
L"h2-c", L"h3-c", L"h4-c", L"h5-c", L"h6-c", L"p-c", L"p", L"div-c", L"div", L"a-c"}) {}
|
||||
|
||||
CDocumentStyle::~CDocumentStyle()
|
||||
{
|
||||
m_arStandardStyles. clear();
|
||||
@ -270,9 +304,10 @@ namespace NSCSS
|
||||
oElement.AddBasicProperties(BProperties::B_CustomStyle, L"1");
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
|
||||
void CDocumentStyle::SetPStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
ConvertStyle(oStyle, oXmlElement, true);
|
||||
if (!bIsLite)
|
||||
ConvertStyle(oStyle, oXmlElement, true);
|
||||
|
||||
if (oStyle.Empty())
|
||||
return;
|
||||
@ -306,10 +341,12 @@ namespace NSCSS
|
||||
sSpacingValue.reserve(128);
|
||||
|
||||
if (!oStyle.m_oMargin.GetTop().Empty() && !oStyle.m_oMargin.GetTop().Zero())
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(oStyle.m_oMargin.GetTop().ToInt(NSCSS::Twips)) + L"\" ";
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"0\" ";
|
||||
|
||||
if (!oStyle.m_oMargin.GetBottom().Empty() && !oStyle.m_oMargin.GetBottom().Zero())
|
||||
sSpacingValue += L"w:after=\"" + std::to_wstring(oStyle.m_oMargin.GetBottom().ToInt(NSCSS::Twips)) + L"\" ";
|
||||
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\" ";
|
||||
|
||||
if (!oStyle.m_oFont.GetLineHeight().Empty() && !oStyle.m_oFont.GetLineHeight().Zero())
|
||||
{
|
||||
@ -318,6 +355,8 @@ 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\"";
|
||||
|
||||
if (!sSpacingValue.empty())
|
||||
oXmlElement.AddPropertiesInP(PProperties::P_Spacing, sSpacingValue);
|
||||
@ -435,9 +474,11 @@ namespace NSCSS
|
||||
return L"w:val=\"" + wsStyle + L"\" w:sz=\"" + std::to_wstring(nWidth) + + L"\" w:space=\"" + std::to_wstring(nSpace) + L"\" w:color=\"" + wsColor + L"\"";
|
||||
}
|
||||
|
||||
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement)
|
||||
void CDocumentStyle::SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite)
|
||||
{
|
||||
ConvertStyle(oStyle, oXmlElement, false);
|
||||
if (!bIsLite)
|
||||
ConvertStyle(oStyle, oXmlElement, false);
|
||||
|
||||
if (oStyle.Empty() && oXmlElement.Empty())
|
||||
return;
|
||||
|
||||
@ -482,9 +523,9 @@ namespace NSCSS
|
||||
return false;
|
||||
}
|
||||
|
||||
CStyleUsed structStyle(oStyle.GetId(), false);
|
||||
CStyleUsed structStyle(oStyle, false);
|
||||
|
||||
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
@ -506,11 +547,13 @@ namespace NSCSS
|
||||
|
||||
bool CDocumentStyle::WriteLitePStyle(const CCompiledStyle &oStyle)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (oStyle.Empty())
|
||||
return false;
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetPStyle(oStyle, oXmlElement);
|
||||
SetPStyle(oStyle, oXmlElement, true);
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
@ -521,11 +564,13 @@ namespace NSCSS
|
||||
|
||||
bool CDocumentStyle::WriteLiteRStyle(const CCompiledStyle &oStyle)
|
||||
{
|
||||
Clear();
|
||||
|
||||
if (oStyle.Empty())
|
||||
return false;
|
||||
|
||||
CXmlElement oXmlElement;
|
||||
SetRStyle(oStyle, oXmlElement);
|
||||
SetRStyle(oStyle, oXmlElement, true);
|
||||
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
@ -544,8 +589,8 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
|
||||
CStyleUsed structStyle(oStyle.GetId(), true);
|
||||
std::list<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
CStyleUsed structStyle(oStyle, true);
|
||||
std::vector<CStyleUsed>::iterator oItem = std::find(m_arStyleUsed.begin(), m_arStyleUsed.end(), structStyle);
|
||||
|
||||
if (oItem != m_arStyleUsed.end())
|
||||
{
|
||||
@ -559,11 +604,6 @@ namespace NSCSS
|
||||
if (oXmlElement.Empty())
|
||||
return false;
|
||||
|
||||
structStyle.setId(oXmlElement.GetStyleId());
|
||||
|
||||
if (structStyle.getId().empty())
|
||||
structStyle.setId(m_sId);
|
||||
|
||||
m_arStyleUsed.push_back(structStyle);
|
||||
m_sStyle += oXmlElement.GetPStyle();
|
||||
|
||||
|
||||
@ -10,27 +10,28 @@ namespace NSCSS
|
||||
{
|
||||
class CStyleUsed
|
||||
{
|
||||
CCompiledStyle m_oStyle;
|
||||
bool m_bIsPStyle;
|
||||
std::wstring m_wsId;
|
||||
|
||||
public:
|
||||
CStyleUsed(const std::wstring& wsId, bool bIsPStyle);
|
||||
CStyleUsed(const CCompiledStyle& oStyle, bool bIsPStyle);
|
||||
|
||||
bool operator==(const CStyleUsed& oUsedStyle) const;
|
||||
|
||||
std::wstring getId();
|
||||
void setId(const std::wstring& sId);
|
||||
};
|
||||
|
||||
static const std::vector<std::wstring> Names_Standard_Styles = {L"a", L"li", L"h1", L"h2", L"h3", L"h4", L"h5", L"h6",L"p", L"div"};
|
||||
|
||||
class CSSCALCULATOR_EXPORT CDocumentStyle
|
||||
{
|
||||
typedef NSConstValues::NSProperties::BasicProperties BProperties;
|
||||
typedef NSConstValues::NSProperties::ParagraphProperties PProperties;
|
||||
typedef NSConstValues::NSProperties::RunnerProperties RProperties;
|
||||
|
||||
std::list<std::wstring> m_arStandardStylesUsed;
|
||||
std::list<std::wstring> m_arStandardStyles;
|
||||
std::list<CStyleUsed> m_arStyleUsed;
|
||||
std::vector<std::wstring> m_arStandardStylesUsed;
|
||||
std::vector<std::wstring> m_arStandardStyles;
|
||||
std::vector<CStyleUsed> m_arStyleUsed;
|
||||
|
||||
std::wstring m_sStyle;
|
||||
std::wstring m_sId;
|
||||
@ -39,8 +40,8 @@ namespace NSCSS
|
||||
void CreateStandardStyle (const std::wstring& sNameStyle, CXmlElement& oElement);
|
||||
void ConvertStyle (const NSCSS::CCompiledStyle& oStyle, CXmlElement& oElement, bool bIsPStyle);
|
||||
|
||||
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
|
||||
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement);
|
||||
void SetRStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
void SetPStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, bool bIsLite = false);
|
||||
|
||||
void SetBorderStyle(const NSCSS::CCompiledStyle& oStyle, CXmlElement& oXmlElement, const PProperties& enBorderProperty);
|
||||
public:
|
||||
|
||||
@ -45,7 +45,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_UnhideWhenUsed, L"true");
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_SemiHidden, L"true");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"li")
|
||||
{
|
||||
@ -67,7 +67,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h1-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"0");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h2")
|
||||
{
|
||||
@ -78,7 +78,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h2-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"1");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h3")
|
||||
{
|
||||
@ -89,7 +89,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h3-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"2");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h4")
|
||||
{
|
||||
@ -100,7 +100,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h4-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"3");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h5")
|
||||
{
|
||||
@ -111,7 +111,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h5-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"4");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
|
||||
}
|
||||
else if (sNameDefaultElement == L"h6")
|
||||
@ -123,7 +123,7 @@ void CXmlElement::CreateDefaultElement(const std::wstring& sNameDefaultElement)
|
||||
AddBasicProperties(CSSProperties::BasicProperties::B_Link, L"h6-c");
|
||||
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_OutlineLvl, L"5");
|
||||
AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
// AddPropertiesInP(CSSProperties::ParagraphProperties::P_Spacing, L"w:before=\"100\" w:beforeAutospacing=\"1\" w:after=\"100\" w:afterAutospacing=\"1\"");
|
||||
}
|
||||
else if (sNameDefaultElement == L"h1-c")
|
||||
{
|
||||
@ -298,7 +298,7 @@ CXmlElement& CXmlElement::operator=(const CXmlElement& oElement)
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CXmlElement::operator==(const CXmlElement &oElement)
|
||||
bool CXmlElement::operator==(const CXmlElement &oElement) const
|
||||
{
|
||||
return m_mBasicValues == oElement.m_mBasicValues &&
|
||||
m_mPStyleValues == oElement.m_mPStyleValues &&
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
|
||||
CXmlElement& operator+=(const CXmlElement& oElement);
|
||||
CXmlElement& operator= (const CXmlElement& oelement);
|
||||
bool operator== (const CXmlElement& oElement);
|
||||
bool operator== (const CXmlElement& oElement) const;
|
||||
};
|
||||
|
||||
#endif // CXMLELEMENT_H
|
||||
|
||||
@ -5,7 +5,6 @@ sys.path.append('../../../../build_tools/scripts')
|
||||
import config
|
||||
import base
|
||||
import os
|
||||
import build
|
||||
|
||||
base_directory = os.getcwd()
|
||||
|
||||
|
||||
@ -22,6 +22,23 @@ static std::string special_handling = "|html|body|";
|
||||
static std::string no_entity_sub = ""; //"|style|";
|
||||
static std::string treat_like_inline = "|p|";
|
||||
|
||||
static std::vector<std::string> html_tags = {"div","span","a","img","p","h1","h2","h3","h4","h5","h6",
|
||||
"ul", "ol", "li","td","tr","table","thead","tbody","tfoot","th",
|
||||
"br","form","input","button","section","nav","header","footer",
|
||||
"main","figure","figcaption","strong","em","i", "b", "u","pre",
|
||||
"code","blockquote","hr","script","link","meta","style","title",
|
||||
"head","body","html","legend","optgroup","option","select","dl",
|
||||
"dt","dd","time","data","abbr","address","area","base","bdi",
|
||||
"bdo","cite","col","iframe","video","source","track","textarea",
|
||||
"label","fieldset","colgroup","del","ins","details","summary",
|
||||
"dialog","embed","kbd","map","mark","menu","meter","object",
|
||||
"output","param","progress","q","samp","small","sub","sup","var",
|
||||
"wbr","acronym","applet","article","aside","audio","basefont",
|
||||
"bgsound","big","blink","canvas","caption","center","command",
|
||||
"comment","datalist","dfn","dir","font","frame","frameset",
|
||||
"hgroup","isindex","keygen","marquee","nobr","noembed","noframes",
|
||||
"noscript","plaintext","rp","rt","ruby","s","strike","tt","xmp"};
|
||||
|
||||
static void prettyprint(GumboNode*, NSStringUtils::CStringBuilderA& oBuilder);
|
||||
static std::string mhtTohtml(const std::string &sFileContent);
|
||||
|
||||
@ -40,10 +57,10 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
{
|
||||
if (bNeedConvert)
|
||||
{ // Определение кодировки
|
||||
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""});
|
||||
std::string sEncoding = NSStringFinder::FindPropety(sFileContent, "charset", {"="}, {";", "\\n", "\\r", " ", "\""}).m_sValue;
|
||||
|
||||
if (sEncoding.empty())
|
||||
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "});
|
||||
sEncoding = NSStringFinder::FindPropety(sFileContent, "encoding", {"="}, {";", "\\n", "\\r", " "}).m_sValue;
|
||||
|
||||
if (!sEncoding.empty() && !NSStringFinder::Equals("utf-8", sEncoding))
|
||||
{
|
||||
@ -59,39 +76,12 @@ static std::wstring htmlToXhtml(std::string& sFileContent, bool bNeedConvert)
|
||||
if (boost::regex_search(sFileContent, oResult, oRegex))
|
||||
sFileContent.erase(0, oResult.position());
|
||||
|
||||
// Избавление от <a/>
|
||||
size_t posA = sFileContent.find("<a ");
|
||||
while(posA != std::string::npos)
|
||||
{
|
||||
size_t nBegin = sFileContent.find('<', posA + 1);
|
||||
size_t nEnd = sFileContent.find("/>", posA);
|
||||
if(nEnd < nBegin)
|
||||
sFileContent.replace(nEnd, 2, "></a>");
|
||||
posA = sFileContent.find("<a ", nBegin);
|
||||
}
|
||||
// Избавление от <title/>
|
||||
posA = sFileContent.find("<title/>");
|
||||
while (posA != std::string::npos)
|
||||
{
|
||||
sFileContent.replace(posA, 8, "<title></title>");
|
||||
posA = sFileContent.find("<title/>", posA);
|
||||
}
|
||||
// Избавление от <script/>
|
||||
posA = sFileContent.find("<script");
|
||||
while (posA != std::string::npos)
|
||||
{
|
||||
size_t nEnd = 0;
|
||||
size_t nEnd1 = sFileContent.find("/>", posA);
|
||||
size_t nEnd2 = sFileContent.find("</script>", posA);
|
||||
if (nEnd1 != std::string::npos)
|
||||
nEnd = nEnd1 + 2;
|
||||
if (nEnd2 != std::string::npos && (nEnd == 0 || (nEnd > 0 && nEnd2 < nEnd)))
|
||||
nEnd = nEnd2 + 9;
|
||||
|
||||
sFileContent.erase(posA, nEnd - posA);
|
||||
|
||||
posA = sFileContent.find("<script", posA);
|
||||
}
|
||||
//Избавление от <a ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "a"));
|
||||
//Избавление от <title ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "title"));
|
||||
//Избавление от <script ... />
|
||||
while (NSStringFinder::RemoveEmptyTag(sFileContent, "script"));
|
||||
|
||||
// Gumbo
|
||||
GumboOptions options = kGumboDefaultOptions;
|
||||
@ -204,49 +194,69 @@ static std::string QuotedPrintableDecode(const std::string& sContent, std::strin
|
||||
|
||||
static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::string>& sRes, NSStringUtils::CStringBuilderA& oRes)
|
||||
{
|
||||
size_t unContentPosition = 0, unLastPosition = 0;
|
||||
size_t unContentPosition = 0, unCharsetBegin = 0, unCharsetEnd = std::string::npos;
|
||||
|
||||
NSStringFinder::TFoundedData<char> oData;
|
||||
|
||||
// Content-Type
|
||||
std::string sContentType = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-type", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentType{oData.m_sValue};
|
||||
|
||||
if (sContentType.empty())
|
||||
return;
|
||||
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "multipart/alternative"))
|
||||
{
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(unLastPosition, sMhtContent.length() - unLastPosition)));
|
||||
oRes.WriteString(mhtTohtml(sMhtContent.substr(oData.m_unEndPosition, sMhtContent.length() - oData.m_unEndPosition)));
|
||||
return;
|
||||
}
|
||||
|
||||
unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetBegin = oData.m_unEndPosition;
|
||||
|
||||
// name
|
||||
// std::string sName = NSStringFinder::FindPropety(sMhtContent, "name", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
// unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
|
||||
// charset
|
||||
std::string sCharset = NSStringFinder::FindPropety(sMhtContent, "charset", {"="}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
|
||||
// Content-Location
|
||||
std::string sContentLocation = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-location", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentLocation{oData.m_sValue};
|
||||
|
||||
if (sContentLocation.empty())
|
||||
if (!oData.Empty())
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
|
||||
// Content-ID
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"});
|
||||
std::string sContentID{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
// Content-ID
|
||||
std::string sContentID = NSStringFinder::FindPropety(sMhtContent, "content-id", {":"}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "<", ">");
|
||||
|
||||
if (!sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
NSStringFinder::CutInside<std::string>(sContentID, "<", ">");
|
||||
}
|
||||
|
||||
if (sContentLocation.empty() && !sContentID.empty())
|
||||
sContentLocation = "cid:" + sContentID;
|
||||
|
||||
// Content-Transfer-Encoding
|
||||
std::string sContentEncoding = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"}, 0, unLastPosition);
|
||||
unContentPosition = std::max(unContentPosition, unLastPosition);
|
||||
oData = NSStringFinder::FindPropety(sMhtContent, "content-transfer-encoding", {":"}, {";", "\\n", "\\r"});
|
||||
const std::string sContentEncoding{oData.m_sValue};
|
||||
|
||||
if (!oData.Empty())
|
||||
{
|
||||
unContentPosition = std::max(unContentPosition, oData.m_unEndPosition);
|
||||
unCharsetEnd = std::min(unCharsetEnd, oData.m_unBeginPosition);
|
||||
}
|
||||
|
||||
// charset
|
||||
std::string sCharset = "utf-8";
|
||||
|
||||
if (std::string::npos != unCharsetEnd && unCharsetBegin < unCharsetEnd)
|
||||
{
|
||||
sCharset = NSStringFinder::FindPropety(sMhtContent.substr(unCharsetBegin, unCharsetEnd - unCharsetBegin), "charset", {"="}, {";", "\\n", "\\r"}).m_sValue;
|
||||
NSStringFinder::CutInside<std::string>(sCharset, "\"");
|
||||
}
|
||||
|
||||
// Content
|
||||
std::string sContent = sMhtContent.substr(unContentPosition, sMhtContent.length() - unContentPosition);
|
||||
@ -266,7 +276,7 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
oRes.WriteString("<style>");
|
||||
|
||||
if (NSStringFinder::Equals(sContentEncoding, "base64"))
|
||||
oRes.WriteString(Base64ToString(sContent, sCharset));
|
||||
sContent = Base64ToString(sContent, sCharset);
|
||||
else if (NSStringFinder::EqualOf(sContentEncoding, {"8bit", "7bit"}) || sContentEncoding.empty())
|
||||
{
|
||||
if (!NSStringFinder::Equals(sCharset, "utf-8") && !sCharset.empty())
|
||||
@ -274,7 +284,6 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
oRes.WriteString(sContent);
|
||||
}
|
||||
else if (NSStringFinder::Equals(sContentEncoding, "quoted-printable"))
|
||||
{
|
||||
@ -284,9 +293,13 @@ static void ReadMht(const std::string& sMhtContent, std::map<std::string, std::s
|
||||
NSUnicodeConverter::CUnicodeConverter oConverter;
|
||||
sContent = U_TO_UTF8(oConverter.toUnicode(sContent, sCharset.data()));
|
||||
}
|
||||
oRes.WriteString(sContent);
|
||||
}
|
||||
|
||||
if (NSStringFinder::Equals(sContentType, "text/html"))
|
||||
sContent = U_TO_UTF8(htmlToXhtml(sContent, false));
|
||||
|
||||
oRes.WriteString(sContent);
|
||||
|
||||
if(bAddTagStyle)
|
||||
oRes.WriteString("</style>");
|
||||
}
|
||||
@ -312,9 +325,11 @@ static std::string mhtTohtml(const std::string& sFileContent)
|
||||
std::map<std::string, std::string> sRes;
|
||||
NSStringUtils::CStringBuilderA oRes;
|
||||
|
||||
size_t nFound = 0;
|
||||
// Поиск boundary
|
||||
std::string sBoundary = NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""}, 0, nFound);
|
||||
NSStringFinder::TFoundedData<char> oData{NSStringFinder::FindPropety(sFileContent, "boundary", {"="}, {"\\r", "\\n", "\""})};
|
||||
|
||||
size_t nFound{oData.m_unEndPosition};
|
||||
std::string sBoundary{oData.m_sValue};
|
||||
|
||||
if (sBoundary.empty())
|
||||
{
|
||||
@ -568,13 +583,20 @@ static void prettyprint(GumboNode* node, NSStringUtils::CStringBuilderA& oBuilde
|
||||
return;
|
||||
}
|
||||
|
||||
std::string tagname = get_tag_name(node);
|
||||
|
||||
if (html_tags.end() == std::find(html_tags.begin(), html_tags.end(), tagname))
|
||||
{
|
||||
prettyprint_contents(node, oBuilder);
|
||||
return;
|
||||
}
|
||||
|
||||
std::string close = "";
|
||||
std::string closeTag = "";
|
||||
std::string tagname = get_tag_name(node);
|
||||
std::string key = "|" + tagname + "|";
|
||||
bool is_empty_tag = empty_tags.find(key) != std::string::npos;
|
||||
bool no_entity_substitution = no_entity_sub.find(key) != std::string::npos;
|
||||
|
||||
|
||||
// determine closing tag type
|
||||
if (is_empty_tag)
|
||||
close = "/";
|
||||
|
||||
@ -326,27 +326,33 @@ bool COfficeFileFormatChecker::isOleObjectFile(POLE::Storage *storage)
|
||||
if (sz_obj > 4)
|
||||
Program = ReadStringFromOle(&streamCompObject, sz_obj);
|
||||
}
|
||||
if (std::string::npos != Program.find("Excel") || std::string::npos != UserType.find("Excel"))
|
||||
POLE::Stream streamPackage(storage, L"Package");
|
||||
if (false == streamPackage.fail())
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_OTHER_PACKAGE_IN_OLE;
|
||||
}
|
||||
else if (std::string::npos != Program.find("Excel") || std::string::npos != UserType.find("Excel"))
|
||||
{
|
||||
if (isXlsFormatFile(storage))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_SPREADSHEET_XLS;
|
||||
}
|
||||
}
|
||||
if (std::string::npos != Program.find("Word") || std::string::npos != UserType.find("Word"))
|
||||
else if (std::string::npos != Program.find("Word") || std::string::npos != UserType.find("Word"))
|
||||
{
|
||||
if (isDocFormatFile(storage))
|
||||
{
|
||||
//nFileType inside
|
||||
}
|
||||
}
|
||||
if (std::string::npos != Program.find("PowerPoint") || std::string::npos != UserType.find("PowerPoint"))
|
||||
else if (std::string::npos != Program.find("PowerPoint") || std::string::npos != UserType.find("PowerPoint"))
|
||||
{
|
||||
if (isPptFormatFile(storage))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_PRESENTATION_PPT;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -858,7 +864,7 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_CANVAS_PDF;
|
||||
else if (0 == sExt.compare(L".doct")) // случай архива с html viewer
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY;
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx"))
|
||||
else if (0 == sExt.compare(L".txt") || 0 == sExt.compare(L".xml") || 0 == sExt.compare(L".rtf") || 0 == sExt.compare(L".doc") || 0 == sExt.compare(L".docx") || 0 == sExt.compare(L".md"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_TXT;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
|
||||
@ -127,6 +127,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_OTHER_ODF AVS_OFFICESTUDIO_FILE_OTHER + 0x000a
|
||||
#define AVS_OFFICESTUDIO_FILE_OTHER_MS_MITCRYPTO AVS_OFFICESTUDIO_FILE_OTHER + 0x000b
|
||||
#define AVS_OFFICESTUDIO_FILE_OTHER_MS_VBAPROJECT AVS_OFFICESTUDIO_FILE_OTHER + 0x000c
|
||||
#define AVS_OFFICESTUDIO_FILE_OTHER_PACKAGE_IN_OLE AVS_OFFICESTUDIO_FILE_OTHER + 0x000d
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB 0x1000
|
||||
#define AVS_OFFICESTUDIO_FILE_TEAMLAB_DOCY AVS_OFFICESTUDIO_FILE_TEAMLAB + 0x0001
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_DOTX OFFICESTUDIO_FILE_DOCUMENT + 0x000c
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_OTT OFFICESTUDIO_FILE_DOCUMENT + 0x000f
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_HTML OFFICESTUDIO_FILE_DOCUMENT + 0x0012
|
||||
#define OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF OFFICESTUDIO_FILE_DOCUMENT + 0x0017
|
||||
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION 0x0080
|
||||
#define OFFICESTUDIO_FILE_PRESENTATION_PPTX OFFICESTUDIO_FILE_PRESENTATION + 0x0001
|
||||
|
||||
@ -357,6 +357,7 @@ namespace NSDoctRenderer
|
||||
/**
|
||||
* Creates a new file. The type of the file which will be created needs to be set.
|
||||
* @param type The type of the file to be created set as a hexadecimal integer for the C++ code or docx, xlsx or pptx for the .docbuilder script file (see AVS_OFFICESTUDIO_FILE_XXX values).
|
||||
* Possible values for wchar_t version: "docx", "pptx", "xlsx", "pdf", "form"
|
||||
* @return True if the operation is successful
|
||||
*/
|
||||
bool CreateFile(const int& type);
|
||||
|
||||
@ -50,7 +50,8 @@ namespace docbuilder_net
|
||||
TXT = MASK + 0x0005,
|
||||
DOTX = MASK + 0x000c,
|
||||
OTT = MASK + 0x000f,
|
||||
HTML = MASK + 0x0012
|
||||
HTML = MASK + 0x0012,
|
||||
OFORM_PDF = MASK + 0x0017
|
||||
};
|
||||
|
||||
public enum class Spreadsheet : int
|
||||
|
||||
2
DesktopEditor/doctrenderer/docbuilder.python/.gitignore
vendored
Normal file
2
DesktopEditor/doctrenderer/docbuilder.python/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
result.docx
|
||||
*.pyc
|
||||
596
DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder.py
Normal file
596
DesktopEditor/doctrenderer/docbuilder.python/src/docbuilder.py
Normal file
@ -0,0 +1,596 @@
|
||||
import ctypes
|
||||
import os
|
||||
import platform
|
||||
import atexit
|
||||
|
||||
OBJECT_HANDLE = ctypes.c_void_p
|
||||
STRING_HANDLE = ctypes.c_void_p
|
||||
|
||||
_lib = None
|
||||
|
||||
def _loadLibrary(path):
|
||||
global _lib
|
||||
if _lib is not None:
|
||||
return
|
||||
|
||||
os_name = platform.system().lower()
|
||||
library_name = ''
|
||||
if 'windows' == os_name:
|
||||
# modify PATH to load all DLLs
|
||||
os.environ['PATH'] = path + os.pathsep + os.environ['PATH']
|
||||
library_name = 'docbuilder.c.dll'
|
||||
elif 'linux' == os_name:
|
||||
library_name = 'libdocbuilder.c.so'
|
||||
elif 'darwin' == os_name:
|
||||
library_name = 'libdocbuilder.c.dylib'
|
||||
|
||||
_lib = ctypes.CDLL(path + '/' + library_name)
|
||||
|
||||
# init all function signatures
|
||||
# ===== CDocBuilderValue =====
|
||||
_lib.CDocBuilderValue_Create.argtypes = []
|
||||
_lib.CDocBuilderValue_Create.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Copy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Copy.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Destroy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Destroy.restype = None
|
||||
|
||||
_lib.CDocBuilderValue_IsEmpty.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsEmpty.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_Clear.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Clear.restype = None
|
||||
|
||||
_lib.CDocBuilderValue_IsNull.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsNull.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsUndefined.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsUndefined.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsInt.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsInt.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsDouble.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsDouble.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsString.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsString.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsFunction.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsFunction.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsObject.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsObject.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_IsArray.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_IsArray.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_GetLength.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_GetLength.restype = ctypes.c_uint
|
||||
|
||||
_lib.CDocBuilderValue_ToBool.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_ToBool.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilderValue_ToInt.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_ToInt.restype = ctypes.c_int
|
||||
|
||||
_lib.CDocBuilderValue_ToDouble.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_ToDouble.restype = ctypes.c_double
|
||||
|
||||
_lib.CDocBuilderValue_ToString.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_ToString.restype = STRING_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_GetProperty.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilderValue_GetProperty.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_GetByIndex.argtypes = [OBJECT_HANDLE, ctypes.c_int]
|
||||
_lib.CDocBuilderValue_GetByIndex.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_SetProperty.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_SetProperty.restype = None
|
||||
|
||||
_lib.CDocBuilderValue_SetByIndex.argtypes = [OBJECT_HANDLE, ctypes.c_int, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_SetByIndex.restype = None
|
||||
|
||||
_lib.CDocBuilderValue_CreateWithBool.argtypes = [ctypes.c_bool]
|
||||
_lib.CDocBuilderValue_CreateWithBool.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateWithInt.argtypes = [ctypes.c_int]
|
||||
_lib.CDocBuilderValue_CreateWithInt.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateWithUInt.argtypes = [ctypes.c_uint]
|
||||
_lib.CDocBuilderValue_CreateWithUInt.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateWithDouble.argtypes = [ctypes.c_double]
|
||||
_lib.CDocBuilderValue_CreateWithDouble.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateWithString.argtypes = [ctypes.c_wchar_p]
|
||||
_lib.CDocBuilderValue_CreateWithString.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateUndefined.argtypes = []
|
||||
_lib.CDocBuilderValue_CreateUndefined.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateNull.argtypes = []
|
||||
_lib.CDocBuilderValue_CreateNull.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_CreateArray.argtypes = [ctypes.c_int]
|
||||
_lib.CDocBuilderValue_CreateArray.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call0.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilderValue_Call0.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call1.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Call1.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call2.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Call2.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call3.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Call3.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call4.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Call4.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call5.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Call5.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderValue_Call6.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE, OBJECT_HANDLE]
|
||||
_lib.CDocBuilderValue_Call6.restype = OBJECT_HANDLE
|
||||
|
||||
# ===== CDocBuilder =====
|
||||
_lib.CDocBuilder_Create.argtypes = []
|
||||
_lib.CDocBuilder_Create.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilder_Destroy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_Destroy.restype = None
|
||||
|
||||
_lib.CDocBuilder_OpenFile.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_OpenFile.restype = ctypes.c_int
|
||||
|
||||
_lib.CDocBuilder_CreateFileByType.argtypes = [OBJECT_HANDLE, ctypes.c_int]
|
||||
_lib.CDocBuilder_CreateFileByType.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_CreateFileByExtension.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_CreateFileByExtension.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_SetTmpFolder.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_SetTmpFolder.restype = None
|
||||
|
||||
_lib.CDocBuilder_SaveFileByType.argtypes = [OBJECT_HANDLE, ctypes.c_int, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_SaveFileByType.restype = ctypes.c_int
|
||||
|
||||
_lib.CDocBuilder_SaveFileByTypeWithParams.argtypes = [OBJECT_HANDLE, ctypes.c_int, ctypes.c_wchar_p, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_SaveFileByTypeWithParams.restype = ctypes.c_int
|
||||
|
||||
_lib.CDocBuilder_SaveFileByExtension.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_SaveFileByExtension.restype = ctypes.c_int
|
||||
|
||||
_lib.CDocBuilder_SaveFileByExtensionWithParams.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_SaveFileByExtensionWithParams.restype = ctypes.c_int
|
||||
|
||||
_lib.CDocBuilder_CloseFile.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_CloseFile.restype = None
|
||||
|
||||
_lib.CDocBuilder_ExecuteCommand.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_ExecuteCommand.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_ExecuteCommandWithRetValue.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_ExecuteCommandWithRetValue.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_Run.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_Run.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_RunText.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_RunText.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_SetProperty.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_SetProperty.restype = None
|
||||
|
||||
_lib.CDocBuilder_WriteData.argtypes = [OBJECT_HANDLE, ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_bool]
|
||||
_lib.CDocBuilder_WriteData.restype = None
|
||||
|
||||
_lib.CDocBuilder_IsSaveWithDoctrendererMode.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_IsSaveWithDoctrendererMode.restype = ctypes.c_bool
|
||||
|
||||
_lib.CDocBuilder_GetVersion.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_GetVersion.restype = STRING_HANDLE
|
||||
|
||||
_lib.CDocBuilder_GetContext.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilder_GetContext.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilder_Initialize.argtypes = []
|
||||
_lib.CDocBuilder_Initialize.restype = None
|
||||
|
||||
_lib.CDocBuilder_InitializeWithDirectory.argtypes = [ctypes.c_wchar_p]
|
||||
_lib.CDocBuilder_InitializeWithDirectory.restype = None
|
||||
|
||||
_lib.CDocBuilder_Dispose.argtypes = []
|
||||
_lib.CDocBuilder_Dispose.restype = None
|
||||
|
||||
# ===== CDocBuilderContextScope =====
|
||||
_lib.CDocBuilderContextScope_Create.argtypes = []
|
||||
_lib.CDocBuilderContextScope_Create.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContextScope_Copy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContextScope_Copy.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContextScope_Destroy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContextScope_Destroy.restype = None
|
||||
|
||||
_lib.CDocBuilderContextScope_Close.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContextScope_Close.restype = None
|
||||
|
||||
# ===== CDocBuilderContext =====
|
||||
_lib.CDocBuilderContext_Create.argtypes = []
|
||||
_lib.CDocBuilderContext_Create.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_Copy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_Copy.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_Destroy.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_Destroy.restype = None
|
||||
|
||||
_lib.CDocBuilderContext_CreateUndefined.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_CreateUndefined.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_CreateNull.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_CreateNull.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_CreateObject.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_CreateObject.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_CreateArray.argtypes = [OBJECT_HANDLE, ctypes.c_int]
|
||||
_lib.CDocBuilderContext_CreateArray.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_GetGlobal.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_GetGlobal.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_CreateScope.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_CreateScope.restype = OBJECT_HANDLE
|
||||
|
||||
_lib.CDocBuilderContext_IsError.argtypes = [OBJECT_HANDLE]
|
||||
_lib.CDocBuilderContext_IsError.restype = ctypes.c_bool
|
||||
|
||||
# ===== Utility =====
|
||||
_lib.DeleteWCharP.argtypes = [ctypes.c_wchar_p]
|
||||
_lib.DeleteWCharP.restype = None
|
||||
|
||||
_lib.DeleteCharP.argtypes = [ctypes.c_char_p]
|
||||
_lib.DeleteCharP.restype = None
|
||||
|
||||
class CDocBuilderValue:
|
||||
def __init__(self, value=None):
|
||||
if value is None:
|
||||
self._internal = _lib.CDocBuilderValue_Create()
|
||||
elif isinstance(value, bool):
|
||||
self._internal = _lib.CDocBuilderValue_CreateWithBool(ctypes.c_bool(value))
|
||||
elif isinstance(value, int):
|
||||
self._internal = _lib.CDocBuilderValue_CreateWithInt(ctypes.c_int(value))
|
||||
elif isinstance(value, float):
|
||||
self._internal = _lib.CDocBuilderValue_CreateWithDouble(ctypes.c_double(value))
|
||||
elif isinstance(value, str):
|
||||
self._internal = _lib.CDocBuilderValue_CreateWithString(ctypes.c_wchar_p(value))
|
||||
elif isinstance(value, list):
|
||||
length = len(value)
|
||||
self._internal = _lib.CDocBuilderValue_CreateArray(length)
|
||||
for i in range(length):
|
||||
self.Set(i, value[i])
|
||||
elif isinstance(value, CDocBuilderValue):
|
||||
self._internal = _lib.CDocBuilderValue_Copy(value._internal)
|
||||
elif isinstance(value, OBJECT_HANDLE):
|
||||
self._internal = value
|
||||
else:
|
||||
raise TypeError("Unsupported type for CDocBuilderValue constructor")
|
||||
self._lib = _lib
|
||||
|
||||
def __del__(self):
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilderValue_Destroy(self._internal)
|
||||
|
||||
def IsEmpty(self):
|
||||
return _lib.CDocBuilderValue_IsEmpty(self._internal)
|
||||
|
||||
def Clear(self):
|
||||
_lib.CDocBuilderValue_Clear(self._internal)
|
||||
|
||||
def IsNull(self):
|
||||
return _lib.CDocBuilderValue_IsNull(self._internal)
|
||||
|
||||
def IsUndefined(self):
|
||||
return _lib.CDocBuilderValue_IsUndefined(self._internal)
|
||||
|
||||
def IsInt(self):
|
||||
return _lib.CDocBuilderValue_IsInt(self._internal)
|
||||
|
||||
def IsDouble(self):
|
||||
return _lib.CDocBuilderValue_IsDouble(self._internal)
|
||||
|
||||
def IsString(self):
|
||||
return _lib.CDocBuilderValue_IsString(self._internal)
|
||||
|
||||
def IsFunction(self):
|
||||
return _lib.CDocBuilderValue_IsFunction(self._internal)
|
||||
|
||||
def IsObject(self):
|
||||
return _lib.CDocBuilderValue_IsObject(self._internal)
|
||||
|
||||
def IsArray(self):
|
||||
return _lib.CDocBuilderValue_IsArray(self._internal)
|
||||
|
||||
def GetLength(self):
|
||||
return _lib.CDocBuilderValue_GetLength(self._internal)
|
||||
|
||||
def ToBool(self):
|
||||
return _lib.CDocBuilderValue_ToBool(self._internal)
|
||||
|
||||
def ToInt(self):
|
||||
return _lib.CDocBuilderValue_ToInt(self._internal)
|
||||
|
||||
def ToDouble(self):
|
||||
return _lib.CDocBuilderValue_ToDouble(self._internal)
|
||||
|
||||
def ToString(self):
|
||||
strRes = _lib.CDocBuilderValue_ToString(self._internal)
|
||||
res = ctypes.cast(strRes, ctypes.c_wchar_p).value
|
||||
_lib.DeleteWCharP(ctypes.cast(strRes, ctypes.c_wchar_p))
|
||||
return res
|
||||
|
||||
def GetProperty(self, name):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_GetProperty(self._internal, ctypes.c_wchar_p(name))))
|
||||
|
||||
def Get(self, key):
|
||||
if isinstance(key, int):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_GetByIndex(self._internal, ctypes.c_int(key))))
|
||||
elif isinstance(key, str):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_GetProperty(self._internal, ctypes.c_wchar_p(key))))
|
||||
else:
|
||||
return None
|
||||
|
||||
def SetProperty(self, name, value):
|
||||
if not isinstance(value, CDocBuilderValue):
|
||||
value = CDocBuilderValue(value)
|
||||
_lib.CDocBuilderValue_SetProperty(self._internal, ctypes.c_wchar_p(name), value._internal)
|
||||
|
||||
def Set(self, key, value):
|
||||
if not isinstance(value, CDocBuilderValue):
|
||||
value = CDocBuilderValue(value)
|
||||
if isinstance(key, int):
|
||||
_lib.CDocBuilderValue_SetByIndex(self._internal, ctypes.c_int(key), value._internal)
|
||||
elif isinstance(key, str):
|
||||
_lib.CDocBuilderValue_SetProperty(self._internal, ctypes.c_wchar_p(key), value._internal)
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.Get(key)
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
self.Set(key, value)
|
||||
|
||||
@staticmethod
|
||||
def CreateUndefined():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateUndefined()))
|
||||
|
||||
@staticmethod
|
||||
def CreateNull():
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateNull()))
|
||||
|
||||
@staticmethod
|
||||
def CreateArray(length):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_CreateArray(length)))
|
||||
|
||||
def Call(self, name, *args):
|
||||
if len(args) == 0:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call0(self._internal, ctypes.c_wchar_p(name))))
|
||||
elif len(args) < 7:
|
||||
values = []
|
||||
for i in range(len(args)):
|
||||
p = args[i]
|
||||
if not isinstance(p, CDocBuilderValue):
|
||||
p = CDocBuilderValue(p)
|
||||
values.append(p)
|
||||
if len(args) == 1:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call1(self._internal, ctypes.c_wchar_p(name), values[0]._internal)))
|
||||
elif len(args) == 2:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call2(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal)))
|
||||
elif len(args) == 3:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call3(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal)))
|
||||
elif len(args) == 4:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call4(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal)))
|
||||
elif len(args) == 5:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call5(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal, values[4]._internal)))
|
||||
elif len(args) == 6:
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderValue_Call6(self._internal, ctypes.c_wchar_p(name), values[0]._internal, values[1]._internal, values[2]._internal, values[3]._internal, values[4]._internal, values[5]._internal)))
|
||||
else:
|
||||
raise TypeError("Call() expects at most 6 arguments")
|
||||
|
||||
class CDocBuilder:
|
||||
_initialized = False
|
||||
|
||||
def __init__(self):
|
||||
self._internal = _lib.CDocBuilder_Create()
|
||||
self._lib = _lib
|
||||
|
||||
def __del__(self):
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilder_Destroy(self._internal)
|
||||
|
||||
def OpenFile(self, path, params):
|
||||
return _lib.CDocBuilder_OpenFile(self._internal, ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
|
||||
def CreateFile(self, type):
|
||||
if isinstance(type, int):
|
||||
return _lib.CDocBuilder_CreateFileByType(self._internal, ctypes.c_int(type))
|
||||
elif isinstance(type, str):
|
||||
return _lib.CDocBuilder_CreateFileByExtension(self._internal, ctypes.c_wchar_p(type))
|
||||
else:
|
||||
return False
|
||||
|
||||
def SetTmpFolder(self, folder):
|
||||
_lib.CDocBuilder_SetTmpFolder(self._internal, ctypes.c_wchar_p(folder))
|
||||
|
||||
def SaveFile(self, type, path, params=None):
|
||||
if isinstance(type, int):
|
||||
if params is None:
|
||||
return _lib.CDocBuilder_SaveFileByType(self._internal, ctypes.c_int(type), ctypes.c_wchar_p(path))
|
||||
else:
|
||||
return _lib.CDocBuilder_SaveFileByTypeWithParams(self._internal, ctypes.c_int(type), ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
elif isinstance(type, str):
|
||||
if params is None:
|
||||
return _lib.CDocBuilder_SaveFileByExtension(self._internal, ctypes.c_wchar_p(type), ctypes.c_wchar_p(path))
|
||||
else:
|
||||
return _lib.CDocBuilder_SaveFileByExtensionWithParams(self._internal, ctypes.c_wchar_p(type), ctypes.c_wchar_p(path), ctypes.c_wchar_p(params))
|
||||
else:
|
||||
return -1
|
||||
|
||||
def CloseFile(self):
|
||||
_lib.CDocBuilder_CloseFile(self._internal)
|
||||
|
||||
def ExecuteCommand(self, command, retValue=None):
|
||||
if retValue is None:
|
||||
return _lib.CDocBuilder_ExecuteCommand(self._internal, ctypes.c_wchar_p(command))
|
||||
else:
|
||||
return _lib.CDocBuilder_ExecuteCommandWithRetValue(self._internal, ctypes.c_wchar_p(command), retValue._internal)
|
||||
|
||||
def Run(self, path):
|
||||
return _lib.CDocBuilder_Run(self._internal, ctypes.c_wchar_p(path))
|
||||
|
||||
def RunText(self, commands):
|
||||
return _lib.CDocBuilder_RunText(self._internal, ctypes.c_wchar_p(commands))
|
||||
|
||||
def SetProperty(self, param, value):
|
||||
_lib.CDocBuilder_SetProperty(self._internal, ctypes.c_wchar_p(param), ctypes.c_wchar_p(value))
|
||||
|
||||
def WriteData(self, path, value, append):
|
||||
_lib.CDocBuilder_WriteData(self._internal, ctypes.c_wchar_p(path), ctypes.c_wchar_p(value), ctypes.c_bool(append))
|
||||
|
||||
def IsSaveWithDoctrendererMode(self):
|
||||
return _lib.CDocBuilder_IsSaveWithDoctrendererMode(self._internal)
|
||||
|
||||
def GetVersion(self):
|
||||
strVersion = _lib.CDocBuilder_GetVersion(self._internal)
|
||||
version = ctypes.cast(strVersion, ctypes.c_char_p).value
|
||||
_lib.DeleteCharP(ctypes.cast(strVersion, ctypes.c_char_p))
|
||||
return version
|
||||
|
||||
def GetContext(self):
|
||||
return CDocBuilderContext(OBJECT_HANDLE(_lib.CDocBuilder_GetContext(self._internal)))
|
||||
|
||||
@classmethod
|
||||
def Initialize(cls, directory=None):
|
||||
if directory is None:
|
||||
_lib.CDocBuilder_Initialize()
|
||||
else:
|
||||
_lib.CDocBuilder_InitializeWithDirectory(ctypes.c_wchar_p(directory))
|
||||
cls._initialized = True
|
||||
|
||||
@classmethod
|
||||
def Dispose(cls):
|
||||
if (cls._initialized):
|
||||
_lib.CDocBuilder_Dispose()
|
||||
cls._initialized = False
|
||||
|
||||
class CDocBuilderContextScope:
|
||||
def __init__(self, value=None):
|
||||
self._lib = _lib
|
||||
if value is None:
|
||||
self._internal = _lib.CDocBuilderContextScope_Create()
|
||||
elif isinstance(value, CDocBuilderContextScope):
|
||||
self._internal = _lib.CDocBuilderContextScope_Copy(value._internal)
|
||||
elif isinstance(value, OBJECT_HANDLE):
|
||||
self._internal = value
|
||||
else:
|
||||
raise TypeError("Unsupported type for CDocBuilderContextScope constructor")
|
||||
self._lib = _lib
|
||||
|
||||
def __del__(self):
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilderContextScope_Destroy(self._internal)
|
||||
|
||||
def Close(self):
|
||||
_lib.CDocBuilderContextScope_Close(self._internal)
|
||||
|
||||
class CDocBuilderContext:
|
||||
def __init__(self, value=None):
|
||||
if value is None:
|
||||
self._internal = _lib.CDocBuilderContext_Create()
|
||||
elif isinstance(value, CDocBuilderContext):
|
||||
self._internal = _lib.CDocBuilderContext_Copy(value._internal)
|
||||
elif isinstance(value, OBJECT_HANDLE):
|
||||
self._internal = value
|
||||
else:
|
||||
raise TypeError("Unsupported type for CDocBuilderContext constructor")
|
||||
self._lib = _lib
|
||||
|
||||
def __del__(self):
|
||||
# using self._lib instead of global _lib because it might be already garbage collected during this function call
|
||||
self._lib.CDocBuilderContext_Destroy(self._internal)
|
||||
|
||||
def CreateUndefined(self):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderContext_CreateUndefined(self._internal)))
|
||||
|
||||
def CreateNull(self):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderContext_CreateNull(self._internal)))
|
||||
|
||||
def CreateObject(self):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderContext_CreateObject(self._internal)))
|
||||
|
||||
def CreateArray(self, length):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderContext_CreateArray(self._internal, ctypes.c_int(length))))
|
||||
|
||||
def GetGlobal(self):
|
||||
return CDocBuilderValue(OBJECT_HANDLE(_lib.CDocBuilderContext_GetGlobal(self._internal)))
|
||||
|
||||
def CreateScope(self):
|
||||
return CDocBuilderContextScope(OBJECT_HANDLE(_lib.CDocBuilderContext_CreateScope(self._internal)))
|
||||
|
||||
def IsError(self):
|
||||
return _lib.CDocBuilderContext_IsError(self._internal)
|
||||
|
||||
# Constants
|
||||
class FileTypes:
|
||||
class Document:
|
||||
_MASK = 0x0040
|
||||
DOCX = _MASK + 0x0001
|
||||
DOC = _MASK + 0x0002
|
||||
ODT = _MASK + 0x0003
|
||||
RTF = _MASK + 0x0004
|
||||
TXT = _MASK + 0x0005
|
||||
DOTX = _MASK + 0x000c
|
||||
OTT = _MASK + 0x000f
|
||||
HTML = _MASK + 0x0012
|
||||
OFORM_PDF = _MASK + 0x0017
|
||||
|
||||
class Presentation:
|
||||
_MASK = 0x0080
|
||||
PPTX = _MASK + 0x0001
|
||||
PPT = _MASK + 0x0002
|
||||
ODP = _MASK + 0x0003
|
||||
PPSX = _MASK + 0x0004
|
||||
POTX = _MASK + 0x0007
|
||||
OTP = _MASK + 0x000a
|
||||
|
||||
class Spreadsheet:
|
||||
_MASK = 0x0100
|
||||
XLSX = _MASK + 0x0001
|
||||
XLS = _MASK + 0x0002
|
||||
ODS = _MASK + 0x0003
|
||||
CSV = _MASK + 0x0004
|
||||
XLTX = _MASK + 0x0006
|
||||
OTS = _MASK + 0x0009
|
||||
|
||||
class Graphics:
|
||||
_PDF_MASK = 0x0200
|
||||
PDF = _PDF_MASK + 0x0001
|
||||
PDFA = _PDF_MASK + 0x0009
|
||||
|
||||
_IMAGE_MASK = 0x0400
|
||||
JPG = _IMAGE_MASK + 0x0001
|
||||
PNG = _IMAGE_MASK + 0x0005
|
||||
BMP = _IMAGE_MASK + 0x0008
|
||||
|
||||
builder_path = os.path.dirname(os.path.realpath(__file__))
|
||||
_loadLibrary(builder_path)
|
||||
CDocBuilder.Initialize(builder_path)
|
||||
|
||||
atexit.register(CDocBuilder.Dispose)
|
||||
@ -0,0 +1,27 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = docbuilder.c
|
||||
|
||||
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 += ../..
|
||||
|
||||
DEFINES += DOCBUILDER_FUNCTIONS_EXPORT
|
||||
|
||||
SOURCES += \
|
||||
docbuilder_functions.cpp
|
||||
|
||||
HEADERS += \
|
||||
docbuilder_functions.h
|
||||
@ -0,0 +1,395 @@
|
||||
#include "docbuilder_functions.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <wchar.h>
|
||||
|
||||
// ===== CDocBuilderValue =====
|
||||
CDocBuilderValue* CDocBuilderValue_Create()
|
||||
{
|
||||
return new CDocBuilderValue();
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Copy(CDocBuilderValue* other)
|
||||
{
|
||||
return new CDocBuilderValue(*other);
|
||||
}
|
||||
|
||||
void CDocBuilderValue_Destroy(CDocBuilderValue* self)
|
||||
{
|
||||
delete self;
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsEmpty(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsEmpty();
|
||||
}
|
||||
|
||||
void CDocBuilderValue_Clear(CDocBuilderValue* self)
|
||||
{
|
||||
self->Clear();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsNull(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsNull();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsUndefined(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsUndefined();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsInt(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsInt();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsDouble(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsDouble();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsString(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsString();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsFunction(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsFunction();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsObject(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsObject();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_IsArray(CDocBuilderValue* self)
|
||||
{
|
||||
return self->IsArray();
|
||||
}
|
||||
|
||||
unsigned int CDocBuilderValue_GetLength(CDocBuilderValue* self)
|
||||
{
|
||||
return self->GetLength();
|
||||
}
|
||||
|
||||
bool CDocBuilderValue_ToBool(CDocBuilderValue* self)
|
||||
{
|
||||
return self->ToBool();
|
||||
}
|
||||
|
||||
int CDocBuilderValue_ToInt(CDocBuilderValue* self)
|
||||
{
|
||||
return self->ToInt();
|
||||
}
|
||||
|
||||
double CDocBuilderValue_ToDouble(CDocBuilderValue* self)
|
||||
{
|
||||
return self->ToDouble();
|
||||
}
|
||||
|
||||
const wchar_t* CDocBuilderValue_ToString(CDocBuilderValue* self)
|
||||
{
|
||||
// NOTE: User is responsible for calling DeleteWCharP() on returned pointer
|
||||
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));
|
||||
return strRes;
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_GetProperty(CDocBuilderValue* self, const wchar_t* name)
|
||||
{
|
||||
return new CDocBuilderValue(self->GetProperty(name));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_GetByIndex(CDocBuilderValue* self, int index)
|
||||
{
|
||||
return new CDocBuilderValue(self->Get(index));
|
||||
}
|
||||
|
||||
void CDocBuilderValue_SetProperty(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* value)
|
||||
{
|
||||
self->Set(name, *value);
|
||||
}
|
||||
|
||||
void CDocBuilderValue_SetByIndex(CDocBuilderValue* self, int index, CDocBuilderValue* value)
|
||||
{
|
||||
self->Set(index, *value);
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateWithBool(bool value)
|
||||
{
|
||||
return new CDocBuilderValue(value);
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateWithInt(int value)
|
||||
{
|
||||
return new CDocBuilderValue(value);
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateWithUInt(unsigned int value)
|
||||
{
|
||||
return new CDocBuilderValue(value);
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateWithDouble(double value)
|
||||
{
|
||||
return new CDocBuilderValue(value);
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateWithString(const wchar_t* value)
|
||||
{
|
||||
return new CDocBuilderValue(value);
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateUndefined()
|
||||
{
|
||||
return new CDocBuilderValue(CDocBuilderValue::CreateUndefined());
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateNull()
|
||||
{
|
||||
return new CDocBuilderValue(CDocBuilderValue::CreateNull());
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_CreateArray(int length)
|
||||
{
|
||||
return new CDocBuilderValue(CDocBuilderValue::CreateArray(length));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call0(CDocBuilderValue* self, const wchar_t* name)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call1(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name, *p1));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call2(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name, *p1, *p2));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call3(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name, *p1, *p2, *p3));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call4(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3, CDocBuilderValue* p4)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name, *p1, *p2, *p3, *p4));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call5(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3, CDocBuilderValue* p4, CDocBuilderValue* p5)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name, *p1, *p2, *p3, *p4, *p5));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderValue_Call6(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3, CDocBuilderValue* p4, CDocBuilderValue* p5, CDocBuilderValue* p6)
|
||||
{
|
||||
return new CDocBuilderValue(self->Call(name, *p1, *p2, *p3, *p4, *p5, *p6));
|
||||
}
|
||||
|
||||
// ===== CDocBuilder =====
|
||||
CDocBuilder* CDocBuilder_Create()
|
||||
{
|
||||
return new CDocBuilder();
|
||||
}
|
||||
|
||||
void CDocBuilder_Destroy(CDocBuilder* self)
|
||||
{
|
||||
delete self;
|
||||
}
|
||||
|
||||
int CDocBuilder_OpenFile(CDocBuilder* self, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return self->OpenFile(path, params);
|
||||
}
|
||||
|
||||
bool CDocBuilder_CreateFileByType(CDocBuilder* self, int type)
|
||||
{
|
||||
return self->CreateFile(type);
|
||||
}
|
||||
|
||||
bool CDocBuilder_CreateFileByExtension(CDocBuilder* self, const wchar_t* extension)
|
||||
{
|
||||
return self->CreateFile(extension);
|
||||
}
|
||||
|
||||
void CDocBuilder_SetTmpFolder(CDocBuilder* self, const wchar_t* folder)
|
||||
{
|
||||
self->SetTmpFolder(folder);
|
||||
}
|
||||
|
||||
int CDocBuilder_SaveFileByType(CDocBuilder* self, int type, const wchar_t* path)
|
||||
{
|
||||
return self->SaveFile(type, path);
|
||||
}
|
||||
|
||||
int CDocBuilder_SaveFileByTypeWithParams(CDocBuilder* self, int type, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return self->SaveFile(type, path, params);
|
||||
}
|
||||
|
||||
int CDocBuilder_SaveFileByExtension(CDocBuilder* self, const wchar_t* extension, const wchar_t* path)
|
||||
{
|
||||
return self->SaveFile(extension, path);
|
||||
}
|
||||
|
||||
int CDocBuilder_SaveFileByExtensionWithParams(CDocBuilder* self, const wchar_t* extension, const wchar_t* path, const wchar_t* params)
|
||||
{
|
||||
return self->SaveFile(extension, path, params);
|
||||
}
|
||||
|
||||
void CDocBuilder_CloseFile(CDocBuilder* self)
|
||||
{
|
||||
self->CloseFile();
|
||||
}
|
||||
|
||||
bool CDocBuilder_ExecuteCommand(CDocBuilder* self, const wchar_t* command)
|
||||
{
|
||||
return self->ExecuteCommand(command);
|
||||
}
|
||||
|
||||
bool CDocBuilder_ExecuteCommandWithRetValue(CDocBuilder* self, const wchar_t* command, CDocBuilderValue* retValue)
|
||||
{
|
||||
return self->ExecuteCommand(command, retValue);
|
||||
}
|
||||
|
||||
bool CDocBuilder_Run(CDocBuilder* self, const wchar_t* path)
|
||||
{
|
||||
return self->Run(path);
|
||||
}
|
||||
|
||||
bool CDocBuilder_RunText(CDocBuilder* self, const wchar_t* commands)
|
||||
{
|
||||
return self->RunTextW(commands);
|
||||
}
|
||||
|
||||
void CDocBuilder_SetProperty(CDocBuilder* self, const wchar_t* param, const wchar_t* value)
|
||||
{
|
||||
self->SetPropertyW(param, value);
|
||||
}
|
||||
|
||||
void CDocBuilder_WriteData(CDocBuilder* self, const wchar_t* path, const wchar_t* value, bool append)
|
||||
{
|
||||
self->WriteData(path, value, append);
|
||||
}
|
||||
|
||||
bool CDocBuilder_IsSaveWithDoctrendererMode(CDocBuilder* self)
|
||||
{
|
||||
return self->IsSaveWithDoctrendererMode();
|
||||
}
|
||||
|
||||
char* CDocBuilder_GetVersion(CDocBuilder* self)
|
||||
{
|
||||
// NOTE: User is responsible for calling DeleteCharP() on returned pointer
|
||||
return self->GetVersion();
|
||||
}
|
||||
|
||||
CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self)
|
||||
{
|
||||
return new CDocBuilderContext(self->GetContext());
|
||||
}
|
||||
|
||||
void CDocBuilder_Initialize()
|
||||
{
|
||||
CDocBuilder::Initialize();
|
||||
}
|
||||
|
||||
void CDocBuilder_InitializeWithDirectory(const wchar_t* directory)
|
||||
{
|
||||
CDocBuilder::Initialize(directory);
|
||||
}
|
||||
|
||||
void CDocBuilder_Dispose()
|
||||
{
|
||||
CDocBuilder::Dispose();
|
||||
}
|
||||
|
||||
// ===== CDocBuilderContextScope =====
|
||||
CDocBuilderContextScope* CDocBuilderContextScope_Create()
|
||||
{
|
||||
return new CDocBuilderContextScope();
|
||||
}
|
||||
|
||||
CDocBuilderContextScope* CDocBuilderContextScope_Copy(CDocBuilderContextScope* other)
|
||||
{
|
||||
return new CDocBuilderContextScope(*other);
|
||||
}
|
||||
|
||||
void CDocBuilderContextScope_Destroy(CDocBuilderContextScope* self)
|
||||
{
|
||||
delete self;
|
||||
}
|
||||
|
||||
void CDocBuilderContextScope_Close(CDocBuilderContextScope* self)
|
||||
{
|
||||
self->Close();
|
||||
}
|
||||
|
||||
// ===== CDocBuilderContext =====
|
||||
CDocBuilderContext* CDocBuilderContext_Create()
|
||||
{
|
||||
return new CDocBuilderContext();
|
||||
}
|
||||
|
||||
CDocBuilderContext* CDocBuilderContext_Copy(CDocBuilderContext* other)
|
||||
{
|
||||
return new CDocBuilderContext(*other);
|
||||
}
|
||||
|
||||
void CDocBuilderContext_Destroy(CDocBuilderContext* self)
|
||||
{
|
||||
delete self;
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderContext_CreateUndefined(CDocBuilderContext* self)
|
||||
{
|
||||
return new CDocBuilderValue(self->CreateUndefined());
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderContext_CreateNull(CDocBuilderContext* self)
|
||||
{
|
||||
return new CDocBuilderValue(self->CreateNull());
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderContext_CreateObject(CDocBuilderContext* self)
|
||||
{
|
||||
return new CDocBuilderValue(self->CreateObject());
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderContext_CreateArray(CDocBuilderContext* self, int length)
|
||||
{
|
||||
return new CDocBuilderValue(self->CreateArray(length));
|
||||
}
|
||||
|
||||
CDocBuilderValue* CDocBuilderContext_GetGlobal(CDocBuilderContext* self)
|
||||
{
|
||||
return new CDocBuilderValue(self->GetGlobal());
|
||||
}
|
||||
|
||||
CDocBuilderContextScope* CDocBuilderContext_CreateScope(CDocBuilderContext* self)
|
||||
{
|
||||
return new CDocBuilderContextScope(self->CreateScope());
|
||||
}
|
||||
|
||||
bool CDocBuilderContext_IsError(CDocBuilderContext* self)
|
||||
{
|
||||
return self->IsError();
|
||||
}
|
||||
|
||||
// ===== Utility =====
|
||||
void DeleteWCharP(wchar_t* str)
|
||||
{
|
||||
delete[] str;
|
||||
}
|
||||
|
||||
void DeleteCharP(char* str)
|
||||
{
|
||||
delete[] str;
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
#ifndef DOCBUILDER_FUNCTIONS_H
|
||||
#define DOCBUILDER_FUNCTIONS_H
|
||||
|
||||
#include "docbuilder.h"
|
||||
|
||||
#include "../common/base_export.h"
|
||||
#ifdef DOCBUILDER_FUNCTIONS_EXPORT
|
||||
#define DOCBUILDER_FUNC_DECL Q_DECL_EXPORT
|
||||
#else
|
||||
#define DOCBUILDER_FUNC_DECL Q_DECL_IMPORT
|
||||
#endif
|
||||
|
||||
using namespace NSDoctRenderer;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
// ===== CDocBuilderValue =====
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Create();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Copy(CDocBuilderValue* other);
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderValue_Destroy(CDocBuilderValue* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsEmpty(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderValue_Clear(CDocBuilderValue* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsNull(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsUndefined(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsInt(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsDouble(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsString(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsFunction(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsObject(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsArray(CDocBuilderValue* self);
|
||||
// TODO:
|
||||
// DOCBUILDER_FUNC_DECL bool CDocBuilderValue_IsTypedArray(CDocBuilderValue* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL unsigned int CDocBuilderValue_GetLength(CDocBuilderValue* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderValue_ToBool(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL int CDocBuilderValue_ToInt(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL double CDocBuilderValue_ToDouble(CDocBuilderValue* self);
|
||||
DOCBUILDER_FUNC_DECL const wchar_t* CDocBuilderValue_ToString(CDocBuilderValue* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_GetProperty(CDocBuilderValue* self, const wchar_t* name);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_GetByIndex(CDocBuilderValue* self, int index);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderValue_SetProperty(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* value);
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderValue_SetByIndex(CDocBuilderValue* self, int index, CDocBuilderValue* value);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateWithBool(bool value);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateWithInt(int value);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateWithUInt(unsigned int value);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateWithDouble(double value);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateWithString(const wchar_t* value);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateUndefined();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateNull();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_CreateArray(int length);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call0(CDocBuilderValue* self, const wchar_t* name);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call1(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call2(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call3(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call4(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3, CDocBuilderValue* p4);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call5(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3, CDocBuilderValue* p4, CDocBuilderValue* p5);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderValue_Call6(CDocBuilderValue* self, const wchar_t* name, CDocBuilderValue* p1, CDocBuilderValue* p2, CDocBuilderValue* p3, CDocBuilderValue* p4, CDocBuilderValue* p5, CDocBuilderValue* p6);
|
||||
|
||||
// ===== CDocBuilder =====
|
||||
DOCBUILDER_FUNC_DECL CDocBuilder* CDocBuilder_Create();
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_Destroy(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL int CDocBuilder_OpenFile(CDocBuilder* self, const wchar_t* path, const wchar_t* params);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_CreateFileByType(CDocBuilder* self, int type);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_CreateFileByExtension(CDocBuilder* self, const wchar_t* extension);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_SetTmpFolder(CDocBuilder* self, const wchar_t* folder);
|
||||
|
||||
DOCBUILDER_FUNC_DECL int CDocBuilder_SaveFileByType(CDocBuilder* self, int type, const wchar_t* path);
|
||||
DOCBUILDER_FUNC_DECL int CDocBuilder_SaveFileByTypeWithParams(CDocBuilder* self, int type, const wchar_t* path, const wchar_t* params);
|
||||
DOCBUILDER_FUNC_DECL int CDocBuilder_SaveFileByExtension(CDocBuilder* self, const wchar_t* extension, const wchar_t* path);
|
||||
DOCBUILDER_FUNC_DECL int CDocBuilder_SaveFileByExtensionWithParams(CDocBuilder* self, const wchar_t* extension, const wchar_t* path, const wchar_t* params);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_CloseFile(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_ExecuteCommand(CDocBuilder* self, const wchar_t* command);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_ExecuteCommandWithRetValue(CDocBuilder* self, const wchar_t* command, CDocBuilderValue* retValue);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_Run(CDocBuilder* self, const wchar_t* path);
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_RunText(CDocBuilder* self, const wchar_t* commands);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_SetProperty(CDocBuilder* self, const wchar_t* param, const wchar_t* value);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_WriteData(CDocBuilder* self, const wchar_t* path, const wchar_t* value, bool append);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilder_IsSaveWithDoctrendererMode(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL char* CDocBuilder_GetVersion(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilder_GetContext(CDocBuilder* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_Initialize();
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_InitializeWithDirectory(const wchar_t* directory);
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilder_Dispose();
|
||||
|
||||
// ===== CDocBuilderContextScope =====
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContextScope* CDocBuilderContextScope_Create();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContextScope* CDocBuilderContextScope_Copy(CDocBuilderContextScope* other);
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderContextScope_Destroy(CDocBuilderContextScope* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderContextScope_Close(CDocBuilderContextScope* self);
|
||||
|
||||
// ===== CDocBuilderContext =====
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilderContext_Create();
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContext* CDocBuilderContext_Copy(CDocBuilderContext* other);
|
||||
DOCBUILDER_FUNC_DECL void CDocBuilderContext_Destroy(CDocBuilderContext* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderContext_CreateUndefined(CDocBuilderContext* self);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderContext_CreateNull(CDocBuilderContext* self);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderContext_CreateObject(CDocBuilderContext* self);
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderContext_CreateArray(CDocBuilderContext* self, int length);
|
||||
// TODO:
|
||||
// CDocBuilderContext_CreateTypedArray(CDocBuilderContext* self, unsigned char* buffer);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderValue* CDocBuilderContext_GetGlobal(CDocBuilderContext* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL CDocBuilderContextScope* CDocBuilderContext_CreateScope(CDocBuilderContext* self);
|
||||
|
||||
DOCBUILDER_FUNC_DECL bool CDocBuilderContext_IsError(CDocBuilderContext* self);
|
||||
|
||||
// ===== Utility =====
|
||||
DOCBUILDER_FUNC_DECL void DeleteWCharP(wchar_t* str);
|
||||
DOCBUILDER_FUNC_DECL void DeleteCharP(char* str);
|
||||
}
|
||||
|
||||
#endif // DOCBUILDER_FUNCTIONS_H
|
||||
@ -0,0 +1,27 @@
|
||||
QT -= core
|
||||
QT -= gui
|
||||
|
||||
TARGET = test
|
||||
|
||||
TEMPLATE = app
|
||||
|
||||
CONFIG -= app_bundle
|
||||
CONFIG += console
|
||||
|
||||
CORE_ROOT_DIR = $$PWD/../../../../..
|
||||
PWD_ROOT_DIR = $$PWD
|
||||
|
||||
include($$CORE_ROOT_DIR/Common/base.pri)
|
||||
|
||||
# Set docbuilder path here
|
||||
DOCUMENT_BUILDER_INSTALL_PATH=C:/Program Files/ONLYOFFICE/DocumentBuilder
|
||||
|
||||
DEFINES += "DOCUMENT_BUILDER_INSTALL_PATH=\"$$DOCUMENT_BUILDER_INSTALL_PATH\""
|
||||
LIBS += -L'$$DOCUMENT_BUILDER_INSTALL_PATH' -ldocbuilder.c
|
||||
|
||||
DESTDIR = $$PWD/build
|
||||
|
||||
INCLUDEPATH += ../../..
|
||||
|
||||
SOURCES += \
|
||||
main.cpp
|
||||
@ -0,0 +1,74 @@
|
||||
#include "docbuilder.python/src/docbuilder_functions.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include "app_builder_lib/utils.cpp"
|
||||
|
||||
#define DECLARE_RAII_DOCBUILDER_FUNC_CLASS( CLASS_NAME ) \
|
||||
class CLASS_NAME ## F \
|
||||
{ \
|
||||
public: \
|
||||
CLASS_NAME ## F(CLASS_NAME* internal) { m_internal = internal; } \
|
||||
~CLASS_NAME ## F() { CLASS_NAME ## _Destroy(m_internal); } \
|
||||
\
|
||||
CLASS_NAME* get() { return m_internal; } \
|
||||
\
|
||||
private: \
|
||||
CLASS_NAME* m_internal; \
|
||||
};
|
||||
|
||||
DECLARE_RAII_DOCBUILDER_FUNC_CLASS(CDocBuilder)
|
||||
DECLARE_RAII_DOCBUILDER_FUNC_CLASS(CDocBuilderValue)
|
||||
DECLARE_RAII_DOCBUILDER_FUNC_CLASS(CDocBuilderContext)
|
||||
DECLARE_RAII_DOCBUILDER_FUNC_CLASS(CDocBuilderContextScope)
|
||||
|
||||
int main()
|
||||
{
|
||||
std::wstring sWorkDirectory = NSUtils::GetBuilderDirectory();
|
||||
|
||||
#if 0
|
||||
// Simple test that shows builder version if everything is correct
|
||||
CDocBuilder_InitializeWithDirectory(sWorkDirectory.c_str());
|
||||
CDocBuilder* pBuilder = CDocBuilder_Create();
|
||||
|
||||
char* sVersion = CDocBuilder_GetVersion(pBuilder);
|
||||
std::cout << sVersion << std::endl;
|
||||
DeleteCharP(sVersion);
|
||||
|
||||
CDocBuilder_Dispose();
|
||||
CDocBuilder_Destroy(pBuilder);
|
||||
#else
|
||||
// Test is identical to app_builder_lib.pro
|
||||
// The test uses RAII wrappers - classes with 'F' postfix, which are destroyed automatically
|
||||
CDocBuilder_InitializeWithDirectory(sWorkDirectory.c_str());
|
||||
|
||||
CDocBuilderF oBuilder = CDocBuilder_Create();
|
||||
CDocBuilder_SetProperty(oBuilder.get(), L"--work-directory", sWorkDirectory.c_str());
|
||||
|
||||
CDocBuilder_CreateFileByExtension(oBuilder.get(), L"docx");
|
||||
|
||||
CDocBuilderContextF oContext = CDocBuilder_GetContext(oBuilder.get());
|
||||
CDocBuilderContextScopeF oScope = CDocBuilderContext_CreateScope(oContext.get());
|
||||
|
||||
CDocBuilderValueF oGlobal = CDocBuilderContext_GetGlobal(oContext.get());
|
||||
|
||||
CDocBuilderValueF oApi = CDocBuilderValue_GetProperty(oGlobal.get(), L"Api");
|
||||
CDocBuilderValueF oDocument = CDocBuilderValue_Call0(oApi.get(), L"GetDocument");
|
||||
CDocBuilderValueF oParagraph = CDocBuilderValue_Call0(oApi.get(), L"CreateParagraph");
|
||||
CDocBuilderValue_Call2(oParagraph.get(), L"SetSpacingAfter", CDocBuilderValueF(CDocBuilderValue_CreateWithInt(1000)).get(), CDocBuilderValueF(CDocBuilderValue_CreateWithBool(false)).get());
|
||||
CDocBuilderValue_Call1(oParagraph.get(), L"AddText", CDocBuilderValueF(CDocBuilderValue_CreateWithString(L"Hello, world!")).get());
|
||||
CDocBuilderValueF oContent = CDocBuilderContext_CreateArray(oContext.get(), 1);
|
||||
CDocBuilderValue_SetByIndex(oContent.get(), 0, oParagraph.get());
|
||||
CDocBuilderValue_Call1(oDocument.get(), L"InsertContent", oContent.get());
|
||||
|
||||
std::wstring sProcessDirectory = NSUtils::GetProcessDirectory();
|
||||
std::wstring sDstPath = sProcessDirectory + L"/result.docx";
|
||||
CDocBuilder_SaveFileByExtension(oBuilder.get(), L"docx", sDstPath.c_str());
|
||||
CDocBuilder_CloseFile(oBuilder.get());
|
||||
|
||||
CDocBuilder_Dispose();
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
import os
|
||||
import sys
|
||||
sys.path.append('path_to_docbuilder')
|
||||
import docbuilder
|
||||
|
||||
builder = docbuilder.CDocBuilder()
|
||||
|
||||
builder.CreateFile(docbuilder.FileTypes.Document.DOCX)
|
||||
|
||||
context = builder.GetContext()
|
||||
scope = context.CreateScope()
|
||||
|
||||
globalObj = context.GetGlobal()
|
||||
|
||||
api = globalObj['Api']
|
||||
document = api.Call('GetDocument')
|
||||
paragraph1 = api.Call('CreateParagraph')
|
||||
paragraph1.Call('SetSpacingAfter', 1000, False)
|
||||
paragraph1.Call('AddText', 'Hello from Python!')
|
||||
|
||||
paragraph2 = api.Call('CreateParagraph')
|
||||
paragraph2.Call('AddText', 'Goodbye!')
|
||||
|
||||
content = [paragraph1, paragraph2]
|
||||
document.Call('InsertContent', content)
|
||||
|
||||
dstPath = os.getcwd() + '/result.docx'
|
||||
builder.SaveFile(docbuilder.FileTypes.Document.DOCX, dstPath)
|
||||
builder.CloseFile()
|
||||
@ -1440,7 +1440,11 @@ namespace NSDoctRenderer
|
||||
bIsNoError = (0 == this->OpenFile(_builder_params[0].c_str(), _builder_params[1].c_str()));
|
||||
else if ("CreateFile" == sFuncNum)
|
||||
{
|
||||
if (L"docx" == _builder_params[0] || L"docxf" == _builder_params[0] || L"oform" == _builder_params[0])
|
||||
if (L"docx" == _builder_params[0] ||
|
||||
L"docxf" == _builder_params[0] ||
|
||||
L"oform" == _builder_params[0] ||
|
||||
L"pdf" == _builder_params[0] ||
|
||||
L"form" == _builder_params[0])
|
||||
bIsNoError = this->CreateFile(AVS_OFFICESTUDIO_FILE_DOCUMENT_DOCX);
|
||||
else if (L"pptx" == _builder_params[0])
|
||||
bIsNoError = this->CreateFile(AVS_OFFICESTUDIO_FILE_PRESENTATION_PPTX);
|
||||
|
||||
@ -110,6 +110,8 @@ namespace NSDoctRenderer
|
||||
nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM;
|
||||
else if (L"html" == sExt)
|
||||
nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_HTML_IN_CONTAINER;
|
||||
else if (L"form" == sExt)
|
||||
nFormat = AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF;
|
||||
return nFormat;
|
||||
}
|
||||
}
|
||||
@ -619,7 +621,10 @@ namespace NSDoctRenderer
|
||||
|
||||
if (type & AVS_OFFICESTUDIO_FILE_DOCUMENT)
|
||||
{
|
||||
sEmptyPath = sEmptyPath + L"new.docx";
|
||||
if (type == AVS_OFFICESTUDIO_FILE_DOCUMENT_OFORM_PDF)
|
||||
sEmptyPath = sEmptyPath + L"new.pdf";
|
||||
else
|
||||
sEmptyPath = sEmptyPath + L"new.docx";
|
||||
m_nFileType = 0;
|
||||
}
|
||||
else if (type & AVS_OFFICESTUDIO_FILE_PRESENTATION)
|
||||
|
||||
@ -219,6 +219,13 @@ namespace NSJSBase
|
||||
{
|
||||
m_internal->context = [[JSContext alloc] init];
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (@available(macOS 10.11, iOS 16.0, *))
|
||||
{
|
||||
JSGlobalContextSetInspectable(m_internal->context.JSGlobalContextRef, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
ASC_THREAD_ID nThreadId = NSThreads::GetCurrentThreadId();
|
||||
MoveToThread(&nThreadId);
|
||||
if (CGlobalContext::GetInstance().IsOldVersion())
|
||||
|
||||
@ -65,7 +65,7 @@ namespace NSJSON
|
||||
|
||||
bool CPrimitive::isDouble() const
|
||||
{
|
||||
return m_type == ptDouble;
|
||||
return m_type == ptDouble || m_type == ptInteger;
|
||||
}
|
||||
|
||||
bool CPrimitive::isStringA() const
|
||||
|
||||
@ -247,7 +247,8 @@ TEST_F(CJSONTest, bool_)
|
||||
TEST_F(CJSONTest, int_)
|
||||
{
|
||||
CValue val = 42;
|
||||
EXPECT_FALSE(val.IsDouble());
|
||||
EXPECT_TRUE(val.IsDouble());
|
||||
EXPECT_TRUE(val.IsInt());
|
||||
JSSmart<CJSValue> jsVal = CJSContext::createInt(42);
|
||||
EXPECT_TRUE(compare(val, jsVal));
|
||||
val = 100;
|
||||
|
||||
@ -110,7 +110,9 @@
|
||||
"_getcwd=getcwd",
|
||||
"NO_CONSOLE_IO",
|
||||
"BUILD_ZLIB_AS_SOURCES",
|
||||
"IMAGE_CHECKER_DISABLE_XML"
|
||||
"IMAGE_CHECKER_DISABLE_XML",
|
||||
|
||||
"BUILDING_WASM_MODULE"
|
||||
],
|
||||
"compile_files_array": [
|
||||
{
|
||||
|
||||
@ -625,7 +625,7 @@ namespace Aggplus
|
||||
}
|
||||
|
||||
double dWidth = pPen->Size;
|
||||
double dWidthMinSize = 1.0 / sqrt(m_oCoordTransform.m_internal->m_agg_mtx.determinant());
|
||||
double dWidthMinSize = 1.0 / sqrt(m_oFullTransform.m_internal->m_agg_mtx.determinant());
|
||||
|
||||
if ((0 == dWidth && !m_bIntegerGrid) || dWidth < dWidthMinSize)
|
||||
{
|
||||
@ -762,6 +762,7 @@ namespace Aggplus
|
||||
}
|
||||
}
|
||||
|
||||
dWidthMinSize = 1.0 / sqrt(m_oCoordTransform.m_internal->m_agg_mtx.determinant());
|
||||
if ((0 == dWidth && !m_bIntegerGrid) || dWidth < dWidthMinSize)
|
||||
dWidth = dWidthMinSize;
|
||||
|
||||
|
||||
@ -563,11 +563,11 @@ HRESULT CGraphicsRenderer::get_BrushTextureImage(Aggplus::CImage** pImage)
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushTextureImage(Aggplus::CImage *pImage)
|
||||
{
|
||||
if (NULL == pImage)
|
||||
return S_FALSE;
|
||||
|
||||
RELEASEINTERFACE(m_oBrush.Image);
|
||||
|
||||
if (NULL == pImage)
|
||||
return S_OK;
|
||||
|
||||
m_oBrush.Image = pImage;
|
||||
m_oBrush.Image->AddRef();
|
||||
|
||||
|
||||
@ -370,15 +370,20 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
return m_nType != -1;
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CMarkupAnnotPr::~CMarkupAnnotPr()
|
||||
{
|
||||
for (int i = 0; i < m_arrRC.size(); ++i)
|
||||
RELEASEOBJECT(m_arrRC[i]);
|
||||
}
|
||||
BYTE CAnnotFieldInfo::CMarkupAnnotPr::GetRT() const { return m_nRT; }
|
||||
int CAnnotFieldInfo::CMarkupAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CMarkupAnnotPr::GetPopupID() const { return m_nPopupID; }
|
||||
int CAnnotFieldInfo::CMarkupAnnotPr::GetIRTID() const { return m_nIRTID; }
|
||||
double CAnnotFieldInfo::CMarkupAnnotPr::GetCA() const { return m_dCA; }
|
||||
const std::wstring& CAnnotFieldInfo::CMarkupAnnotPr::GetT() { return m_wsT; }
|
||||
const std::wstring& CAnnotFieldInfo::CMarkupAnnotPr::GetRC() { return m_wsRC; }
|
||||
const std::wstring& CAnnotFieldInfo::CMarkupAnnotPr::GetCD() { return m_wsCD; }
|
||||
const std::wstring& CAnnotFieldInfo::CMarkupAnnotPr::GetSubj() { return m_wsSubj; }
|
||||
const std::vector<CAnnotFieldInfo::CMarkupAnnotPr::CFontData*>& CAnnotFieldInfo::CMarkupAnnotPr::GetRC() { return m_arrRC; }
|
||||
void CAnnotFieldInfo::CMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
m_nFlag = nFlags;
|
||||
@ -389,7 +394,26 @@ void CAnnotFieldInfo::CMarkupAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader
|
||||
if (nFlags & (1 << 2))
|
||||
m_dCA = pReader->ReadDouble();
|
||||
if (nFlags & (1 << 3))
|
||||
m_wsRC = pReader->ReadString();
|
||||
{
|
||||
int nFont = pReader->ReadInt();
|
||||
for (int i = 0; i < nFont; ++i)
|
||||
{
|
||||
CFontData* pFont = new CFontData();
|
||||
pFont->nAlignment = pReader->ReadByte();
|
||||
pFont->nFontFlag = pReader->ReadInt();
|
||||
if (pFont->nFontFlag & (1 << 5))
|
||||
pFont->dVAlign = pReader->ReadDouble();
|
||||
if (pFont->nFontFlag & (1 << 6))
|
||||
pFont->sActualFont = pReader->ReadString();
|
||||
pFont->dFontSise = pReader->ReadDouble();
|
||||
pFont->dColor[0] = pReader->ReadDouble();
|
||||
pFont->dColor[1] = pReader->ReadDouble();
|
||||
pFont->dColor[2] = pReader->ReadDouble();
|
||||
pFont->sFontFamily = pReader->ReadString();
|
||||
pFont->sText = pReader->ReadString();
|
||||
m_arrRC.push_back(pFont);
|
||||
}
|
||||
}
|
||||
if (nFlags & (1 << 4))
|
||||
m_wsCD = pReader->ReadString();
|
||||
if (nFlags & (1 << 5))
|
||||
@ -538,12 +562,20 @@ void CAnnotFieldInfo::CPolygonLineAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferR
|
||||
BYTE CAnnotFieldInfo::CFreeTextAnnotPr::GetQ() const { return m_nQ; }
|
||||
BYTE CAnnotFieldInfo::CFreeTextAnnotPr::GetIT() const { return m_nIT; }
|
||||
BYTE CAnnotFieldInfo::CFreeTextAnnotPr::GetLE() const { return m_nLE; }
|
||||
int CAnnotFieldInfo::CFreeTextAnnotPr::GetRotate() { return m_nRotate; }
|
||||
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();
|
||||
m_nRotate = pReader->ReadInt();
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
m_dRD[0] = pReader->ReadDouble();
|
||||
@ -563,6 +595,18 @@ void CAnnotFieldInfo::CFreeTextAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferRead
|
||||
m_nLE = pReader->ReadByte();
|
||||
if (nFlags & (1 << 20))
|
||||
m_nIT = pReader->ReadByte();
|
||||
if (nFlags & (1 << 21))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
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; }
|
||||
|
||||
@ -201,15 +201,29 @@ public:
|
||||
class GRAPHICS_DECL CMarkupAnnotPr
|
||||
{
|
||||
public:
|
||||
struct GRAPHICS_DECL CFontData
|
||||
{
|
||||
BYTE nAlignment;
|
||||
int nFontFlag;
|
||||
double dFontSise;
|
||||
double dVAlign;
|
||||
double dColor[3];
|
||||
std::wstring sFontFamily;
|
||||
std::wstring sActualFont;
|
||||
std::wstring sText;
|
||||
};
|
||||
|
||||
virtual ~CMarkupAnnotPr();
|
||||
|
||||
BYTE GetRT() const;
|
||||
int GetFlag() const;
|
||||
int GetPopupID() const;
|
||||
int GetIRTID() const;
|
||||
double GetCA() const;
|
||||
const std::wstring& GetT();
|
||||
const std::wstring& GetRC();
|
||||
const std::wstring& GetCD();
|
||||
const std::wstring& GetSubj();
|
||||
const std::vector<CFontData*>& GetRC();
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
@ -223,6 +237,7 @@ public:
|
||||
std::wstring m_wsRC;
|
||||
std::wstring m_wsCD;
|
||||
std::wstring m_wsSubj;
|
||||
std::vector<CFontData*> m_arrRC;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CTextAnnotPr
|
||||
@ -352,9 +367,12 @@ public:
|
||||
BYTE GetQ() const;
|
||||
BYTE GetIT() const;
|
||||
BYTE GetLE() const;
|
||||
int GetRotate();
|
||||
const std::wstring& GetDS();
|
||||
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);
|
||||
|
||||
@ -362,9 +380,13 @@ public:
|
||||
BYTE m_nQ;
|
||||
BYTE m_nIT;
|
||||
BYTE m_nLE;
|
||||
int m_nRotate;
|
||||
std::wstring m_wsDS;
|
||||
double m_dRD[4]{};
|
||||
std::vector<double> m_arrCL;
|
||||
std::vector<double> m_arrIC;
|
||||
LONG m_nRenderLen;
|
||||
BYTE* m_pRender;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CCaretAnnotPr
|
||||
|
||||
@ -129,9 +129,25 @@ bool CDocInfoCommand::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
return true;
|
||||
}
|
||||
|
||||
CShapeStart::CShapeStart() : IAdvancedCommand(AdvancedCommandType::ShapeStart) {}
|
||||
CShapeStart::CShapeStart() : IAdvancedCommand(AdvancedCommandType::ShapeStart)
|
||||
{
|
||||
m_pImage = NULL;
|
||||
}
|
||||
CShapeStart::~CShapeStart()
|
||||
{
|
||||
RELEASEINTERFACE(m_pImage);
|
||||
}
|
||||
void CShapeStart::SetShapeXML(const std::string& sShapeXML) { m_sShapeXML = sShapeXML; }
|
||||
const std::string& CShapeStart::GetShapeXML() { return m_sShapeXML; }
|
||||
void CShapeStart::SetShapeImage(BYTE* pImgData, int nWidth, int nHeight)
|
||||
{
|
||||
if (pImgData)
|
||||
{
|
||||
m_pImage = new Aggplus::CImage();
|
||||
m_pImage->Create(pImgData, nWidth, nHeight, -4 * nWidth);
|
||||
}
|
||||
}
|
||||
std::string& CShapeStart::GetShapeXML() { return m_sShapeXML; }
|
||||
Aggplus::CImage* CShapeStart::GetShapeImage() { return m_pImage; }
|
||||
bool CShapeStart::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
m_sShapeXML = pReader->ReadStringA();
|
||||
|
||||
@ -136,14 +136,19 @@ class GRAPHICS_DECL CShapeStart : public IAdvancedCommand
|
||||
{
|
||||
public:
|
||||
CShapeStart();
|
||||
~CShapeStart();
|
||||
|
||||
std::string& GetShapeXML();
|
||||
Aggplus::CImage* GetShapeImage();
|
||||
|
||||
void SetShapeXML(const std::string& sShapeXML);
|
||||
const std::string& GetShapeXML();
|
||||
void SetShapeImage(BYTE* pImgData, int nWidth, int nHeight);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::string m_sShapeXML;
|
||||
Aggplus::CImage* m_pImage;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CEmptyComand : public IAdvancedCommand
|
||||
|
||||
@ -45,7 +45,11 @@
|
||||
"_DestroyTextInfo",
|
||||
"_IsNeedCMap",
|
||||
"_SetCMapData",
|
||||
"_ScanPage"
|
||||
"_ScanPage",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
"_GetImageBase64Free"
|
||||
],
|
||||
"include_path": [
|
||||
"wasm/src/lib",
|
||||
|
||||
@ -158,6 +158,8 @@
|
||||
this.fontPageIndex = -1;
|
||||
this.fontPageUpdateType = UpdateFontsSource.Undefined;
|
||||
this.fontStreams = {};
|
||||
|
||||
this.scannedImages = {};
|
||||
}
|
||||
|
||||
CFile.prototype["loadFromData"] = function(arrayBuffer)
|
||||
@ -1345,6 +1347,7 @@
|
||||
}
|
||||
// 0 - left-justified, 1 - centered, 2 - right-justified
|
||||
rec["alignment"] = reader.readByte();
|
||||
rec["Rotate"] = reader.readInt();
|
||||
// Rect and RD differences
|
||||
if (flags & (1 << 15))
|
||||
{
|
||||
@ -1641,6 +1644,37 @@
|
||||
return shapes;
|
||||
};
|
||||
|
||||
CFile.prototype["getImageBase64"] = function(rId)
|
||||
{
|
||||
let strId = "" + rId;
|
||||
if (this.scannedImages[strId])
|
||||
return this.scannedImages[strId];
|
||||
|
||||
let strPtr = Module["_GetImageBase64"](this.nativeFile, rId);
|
||||
if (0 == strPtr)
|
||||
{
|
||||
this.scannedImages[strId] = "error";
|
||||
return this.scannedImages[strId];
|
||||
}
|
||||
|
||||
let len = Module["_GetImageBase64Len"](strPtr);
|
||||
let ptr = Module["_GetImageBase64Ptr"](strPtr);
|
||||
|
||||
var buffer = new Uint8Array(Module["HEAP8"].buffer, ptr, len);
|
||||
this.scannedImages[strId] = String.prototype.fromUtf8(buffer, 0, len);
|
||||
Module["_GetImageBase64Free"](strPtr);
|
||||
return this.scannedImages[strId];
|
||||
};
|
||||
|
||||
CFile.prototype["changeImageUrl"] = function(baseUrl, resultUrl)
|
||||
{
|
||||
for (let i in this.scannedImages)
|
||||
{
|
||||
if (this.scannedImages[i] == baseUrl)
|
||||
this.scannedImages[i] = resultUrl;
|
||||
}
|
||||
};
|
||||
|
||||
CFile.prototype.memory = function()
|
||||
{
|
||||
return Module["HEAP8"];
|
||||
|
||||
@ -267,6 +267,23 @@ WASM_EXPORT BYTE* ScanPage(CGraphicsFileDrawing* pGraphics, int nPageIndex, int
|
||||
return pGraphics->GetPageShapes(nPageIndex, mode);
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CGraphicsFileDrawing* pGraphics, int rId)
|
||||
{
|
||||
return pGraphics->GetImageBase64(rId);
|
||||
}
|
||||
WASM_EXPORT int GetImageBase64Len(std::string* p)
|
||||
{
|
||||
return (int)p->length();
|
||||
}
|
||||
WASM_EXPORT char* GetImageBase64Ptr(std::string* p)
|
||||
{
|
||||
return (char*)p->c_str();
|
||||
}
|
||||
WASM_EXPORT void GetImageBase64Free(std::string* p)
|
||||
{
|
||||
*p = "";
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -220,6 +220,13 @@ public:
|
||||
oRes.ClearWithoutAttack();
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string* GetImageBase64(int nRId)
|
||||
{
|
||||
if (NULL == pImageStorage)
|
||||
return NULL;
|
||||
return pImageStorage->GetBase64(nRId);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // _WASM_GRAPHICS_
|
||||
|
||||
@ -1597,6 +1597,10 @@ int main(int argc, char* argv[])
|
||||
i += 1;
|
||||
std::cout << "Q " << arrQ[nPathLength] << ", ";
|
||||
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
std::cout << "Rotate " << nPathLength << ", ";
|
||||
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
std::cout << "RD";
|
||||
|
||||
@ -149,6 +149,7 @@ void CPdfWriter::Sign(const double& dX, const double& dY, const double& dW, cons
|
||||
HRESULT CPdfWriter::EditWidgetParents(NSFonts::IApplicationFonts* pAppFonts, CWidgetsInfo* pFieldInfo, const std::wstring& wsTempDirectory) { return 0; }
|
||||
PdfWriter::CDocument* CPdfWriter::GetDocument() { return NULL; }
|
||||
PdfWriter::CPage* CPdfWriter::GetPage() { return NULL; }
|
||||
void CPdfWriter::AddFont(const std::wstring& wsFontName, const bool& bBold, const bool& bItalic, const std::wstring& wsFontPath, const LONG& lFaceIndex) {}
|
||||
PdfWriter::CImageDict* CPdfWriter::LoadImage(Aggplus::CImage* pImage, BYTE nAlpha) { return NULL; }
|
||||
PdfWriter::CImageDict* CPdfWriter::DrawImage(Aggplus::CImage* pImage, const double& dX, const double& dY, const double& dW, const double& dH, const BYTE& nAlpha) { return NULL; }
|
||||
bool CPdfWriter::DrawText(unsigned char* pCodes, const unsigned int& unLen, const double& dX, const double& dY) { return false; }
|
||||
|
||||
@ -442,6 +442,8 @@ namespace NSStructures
|
||||
Alpha2 = other.Alpha2;
|
||||
|
||||
Image = other.Image;
|
||||
if (Image)
|
||||
((IGrObject*)Image)->AddRef();
|
||||
Transform = other.Transform;
|
||||
|
||||
TexturePath = other.TexturePath;
|
||||
|
||||
@ -93,7 +93,7 @@ namespace MetaFile
|
||||
{
|
||||
public:
|
||||
|
||||
CDataStream() : pBuffer(NULL)
|
||||
CDataStream() : pBuffer(NULL), pBufferEnd(NULL), pEnd(NULL), pCur(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@ -103,10 +103,25 @@ namespace MetaFile
|
||||
|
||||
void SetStream(BYTE* pBuf, unsigned int unSize)
|
||||
{
|
||||
pBuffer = pBuf;
|
||||
pCur = pBuf;
|
||||
pEnd = pBuf + unSize;
|
||||
};
|
||||
pBuffer = pBuf;
|
||||
pCur = pBuf;
|
||||
pBufferEnd = pBuf + unSize;
|
||||
pEnd = pBufferEnd;
|
||||
}
|
||||
|
||||
void SetCurrentBlockSize(unsigned int unSize)
|
||||
{
|
||||
if (pCur + unSize >= pBufferEnd)
|
||||
pEnd = pBufferEnd;
|
||||
else
|
||||
pEnd = pCur + unSize;
|
||||
}
|
||||
|
||||
void ClearCurrentBlockSize()
|
||||
{
|
||||
pEnd = pBufferEnd;
|
||||
}
|
||||
|
||||
BYTE* GetCurPtr()
|
||||
{
|
||||
return pCur;
|
||||
@ -120,7 +135,7 @@ namespace MetaFile
|
||||
unsigned char unResult = pCur[0];
|
||||
pCur++;
|
||||
return unResult;
|
||||
};
|
||||
}
|
||||
unsigned short ReadUShort()
|
||||
{
|
||||
if (pCur + 1 >= pEnd)
|
||||
@ -129,7 +144,7 @@ namespace MetaFile
|
||||
unsigned short ushResult = (pCur[0]) | ((pCur[1]) << 8);
|
||||
pCur += 2;
|
||||
return ushResult;
|
||||
};
|
||||
}
|
||||
unsigned int ReadULong()
|
||||
{
|
||||
if (pCur + 3 >= pEnd)
|
||||
@ -138,7 +153,7 @@ namespace MetaFile
|
||||
unsigned int unResult = (unsigned int)((pCur[0] << 0) | ((pCur[1]) << 8) | ((pCur[2]) << 16) | ((pCur[3]) << 24));
|
||||
pCur += 4;
|
||||
return unResult;
|
||||
};
|
||||
}
|
||||
double ReadDouble()
|
||||
{
|
||||
if (pCur + 3 >= pEnd)
|
||||
@ -159,19 +174,19 @@ namespace MetaFile
|
||||
int lFracValue = (int)(pCur[3]);
|
||||
pCur += 4;
|
||||
return (double)(lIntValue + (lFracValue / 16.0));
|
||||
};
|
||||
}
|
||||
char ReadChar()
|
||||
{
|
||||
return (char)ReadUChar();
|
||||
};
|
||||
}
|
||||
short ReadShort()
|
||||
{
|
||||
return (short)ReadUShort();
|
||||
};
|
||||
}
|
||||
int ReadLong()
|
||||
{
|
||||
return (int)ReadULong();
|
||||
};
|
||||
}
|
||||
void ReadBytes(unsigned char* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
size_t ulRemainSize = (pEnd - pCur);
|
||||
@ -181,7 +196,7 @@ namespace MetaFile
|
||||
{
|
||||
pBuffer[ulIndex] = ReadChar();
|
||||
}
|
||||
};
|
||||
}
|
||||
void ReadBytes(unsigned short* pBuffer, unsigned int ulSize)
|
||||
{
|
||||
size_t ulRemainSize = (pEnd - pCur) / 2;
|
||||
@ -1047,7 +1062,7 @@ namespace MetaFile
|
||||
|
||||
bool IsEof() const
|
||||
{
|
||||
if (pCur >= pEnd)
|
||||
if (pCur >= pBufferEnd)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@ -1060,7 +1075,10 @@ namespace MetaFile
|
||||
|
||||
void Skip(unsigned int ulSkip)
|
||||
{
|
||||
pCur += ulSkip;
|
||||
if (pCur + ulSkip >= pEnd)
|
||||
pCur = pEnd;
|
||||
else
|
||||
pCur += ulSkip;
|
||||
}
|
||||
|
||||
void SeekBack(unsigned int ulSkipBack)
|
||||
@ -1071,6 +1089,7 @@ namespace MetaFile
|
||||
void SeekToStart()
|
||||
{
|
||||
pCur = pBuffer;
|
||||
ClearCurrentBlockSize();
|
||||
}
|
||||
|
||||
unsigned int CanRead()
|
||||
@ -1085,21 +1104,31 @@ namespace MetaFile
|
||||
*this >> oText;
|
||||
|
||||
// Читаем OutputString
|
||||
const unsigned int unCharsCount = oText.unChars;
|
||||
int nSkip = oText.unOffString - (unOffset + 40); // 40 - размер структуры TEmfEmrText
|
||||
Skip(nSkip);
|
||||
T* pString = new T[unCharsCount + 1];
|
||||
oText.unChars = std::min(oText.unChars, (UINT)(CanRead() / sizeof(T)));
|
||||
|
||||
if (0 == oText.unChars)
|
||||
return;
|
||||
|
||||
if (oText.unOffString - 40 > unOffset)
|
||||
Skip(oText.unOffString - (unOffset + 40)); // 40 - размер структуры TEmfEmrText
|
||||
|
||||
T* pString = new T[oText.unChars + 1];
|
||||
if (pString)
|
||||
{
|
||||
pString[unCharsCount] = 0x00;
|
||||
ReadBytes(pString, unCharsCount);
|
||||
pString[oText.unChars] = 0x00;
|
||||
ReadBytes(pString, oText.unChars);
|
||||
oText.pOutputString = pString;
|
||||
}
|
||||
|
||||
// Читаем OutputDx
|
||||
nSkip = oText.unOffDx - oText.unOffString - 2 * unCharsCount;
|
||||
Skip(nSkip);
|
||||
const unsigned int unDxCount = oText.unOptions & ETO_PDY ? 2 * unCharsCount : unCharsCount;
|
||||
if (oText.unChars < (UINT32_MAX / 2) && (oText.unOffDx > oText.unOffString) && (oText.unOffDx - oText.unOffString > 2 * oText.unChars))
|
||||
Skip(oText.unOffDx - oText.unOffString - 2 * oText.unChars);
|
||||
|
||||
const unsigned int unDxCount = (oText.unOptions & ETO_PDY ? 2 * oText.unChars : oText.unChars);
|
||||
|
||||
if ((CanRead() / 4) < unDxCount || 0 == unDxCount)
|
||||
return;
|
||||
|
||||
unsigned int* pDx = new unsigned int[unDxCount];
|
||||
if (pDx)
|
||||
{
|
||||
@ -1116,6 +1145,7 @@ namespace MetaFile
|
||||
private:
|
||||
|
||||
BYTE *pBuffer;
|
||||
BYTE *pBufferEnd;
|
||||
BYTE *pCur;
|
||||
BYTE *pEnd;
|
||||
};
|
||||
|
||||
@ -1169,6 +1169,7 @@ namespace MetaFile
|
||||
|
||||
std::wstring wsFontName = pFont->GetFaceName();
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (!wsFontName.empty())
|
||||
{
|
||||
NSFonts::CFontSelectFormat oFormat;
|
||||
@ -1179,6 +1180,7 @@ namespace MetaFile
|
||||
if (NULL != pFontInfo && !StringEquals(wsFontName, pFontInfo->m_wsFontName))
|
||||
wsFontName = L"'" + wsFontName + L"', '" + pFontInfo->m_wsFontName + L"'";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!wsFontName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFontName});
|
||||
|
||||
@ -63,6 +63,8 @@ namespace MetaFile
|
||||
m_ulRecordPos = m_oStream.Tell();
|
||||
m_ulRecordSize = ulSize - 8;
|
||||
|
||||
m_oStream.SetCurrentBlockSize(m_ulRecordSize);
|
||||
|
||||
if (ulType < EMR_MIN || ulType > EMR_MAX)
|
||||
{
|
||||
if (ENHMETA_SIGNATURE != m_oHeader.ulSignature || 0x00010000 != m_oHeader.ulVersion)
|
||||
@ -213,6 +215,8 @@ namespace MetaFile
|
||||
m_oStream.Skip(need_skip);
|
||||
ulRecordIndex++;
|
||||
|
||||
m_oStream.ClearCurrentBlockSize();
|
||||
|
||||
} while (!CheckError());
|
||||
|
||||
if (!CheckError())
|
||||
|
||||
@ -234,6 +234,8 @@ namespace MetaFile
|
||||
m_oStream >> unSize;
|
||||
m_oStream >> m_ulRecordSize;
|
||||
|
||||
m_oStream.SetCurrentBlockSize(m_ulRecordSize);
|
||||
|
||||
unsigned int unRecordPos = m_oStream.Tell();
|
||||
|
||||
LOGGING(ActionNamesEmfPlus[unShType] << L" DataSize = " << m_ulRecordSize)
|
||||
@ -318,6 +320,7 @@ namespace MetaFile
|
||||
|
||||
LOGGING(L"Skip: " << nNeedSkip)
|
||||
|
||||
m_oStream.ClearCurrentBlockSize();
|
||||
m_ulRecordSize = 0;
|
||||
}while(m_oStream.CanRead() >= 12 && !m_bEof);
|
||||
|
||||
|
||||
@ -283,6 +283,7 @@ namespace MetaFile
|
||||
|
||||
std::wstring wsFontName = pFont->GetFaceName();
|
||||
|
||||
#ifndef BUILDING_WASM_MODULE
|
||||
if (!wsFontName.empty())
|
||||
{
|
||||
NSFonts::CFontSelectFormat oFormat;
|
||||
@ -293,6 +294,7 @@ namespace MetaFile
|
||||
if (NULL != pFontInfo && !StringEquals(wsFontName, pFontInfo->m_wsFontName))
|
||||
wsFontName = L"'" + wsFontName + L"', '" + pFontInfo->m_wsFontName + L"'";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!wsFontName.empty())
|
||||
arNodeAttributes.push_back({L"font-family", wsFontName});
|
||||
|
||||
@ -52,6 +52,8 @@ namespace MetaFile
|
||||
|
||||
m_unRecordSize = unSize * 2; // Размер указан в WORD
|
||||
|
||||
m_oStream.SetCurrentBlockSize(m_unRecordSize);
|
||||
|
||||
switch (ushType)
|
||||
{
|
||||
//-----------------------------------------------------------
|
||||
@ -161,6 +163,7 @@ namespace MetaFile
|
||||
// Пропускаем лишние байты, которые могли быть в записи
|
||||
int need_skip = m_unRecordSize - (m_oStream.Tell() - m_unRecordPos);
|
||||
m_oStream.Skip(need_skip);
|
||||
m_oStream.ClearCurrentBlockSize();
|
||||
};
|
||||
|
||||
if (!m_bEof)
|
||||
|
||||
@ -42,30 +42,40 @@ bool CSvgFile::GetBounds(double &dX, double &dY, double &dWidth, double &dHeight
|
||||
|
||||
SVG::TRect oWindow = m_oContainer.GetWindow();
|
||||
|
||||
dX = oWindow.m_oX .ToDouble(NSCSS::Pixel, SVG_FILE_WIDTH);
|
||||
dY = oWindow.m_oY .ToDouble(NSCSS::Pixel, SVG_FILE_HEIGHT);
|
||||
dX = oWindow.m_oX.ToDouble(NSCSS::Pixel, SVG_FILE_WIDTH);
|
||||
dY = oWindow.m_oY.ToDouble(NSCSS::Pixel, SVG_FILE_HEIGHT);
|
||||
|
||||
dWidth = 0.;
|
||||
dHeight = 0.;
|
||||
|
||||
if (!oWindow.m_oWidth.Empty() && !oWindow.m_oWidth.Zero())
|
||||
{
|
||||
if (NSCSS::Percent != oWindow.m_oWidth.GetUnitMeasure() && !m_oContainer.GetViewBox().m_oWidth.Empty() && !m_oContainer.GetViewBox().m_oWidth.Zero())
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, m_oContainer.GetViewBox().m_oWidth.ToDouble(NSCSS::Pixel));
|
||||
if (NSCSS::Percent == oWindow.m_oWidth.GetUnitMeasure())
|
||||
{
|
||||
if (!m_oContainer.GetViewBox().m_oWidth.Empty() && !m_oContainer.GetViewBox().m_oWidth.Zero())
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, m_oContainer.GetViewBox().m_oWidth.ToDouble(NSCSS::Pixel));
|
||||
else
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, SVG_FILE_WIDTH);
|
||||
}
|
||||
else
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel);
|
||||
}
|
||||
else if (!m_oContainer.GetViewBox().m_oWidth.Empty() && !m_oContainer.GetViewBox().m_oWidth.Zero())
|
||||
else
|
||||
dWidth = m_oContainer.GetViewBox().m_oWidth.ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (!oWindow.m_oHeight.Empty() && !oWindow.m_oHeight.Zero())
|
||||
{
|
||||
if (NSCSS::Percent != oWindow.m_oHeight.GetUnitMeasure() && !m_oContainer.GetViewBox().m_oHeight.Empty() && !m_oContainer.GetViewBox().m_oHeight.Zero())
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, m_oContainer.GetViewBox().m_oHeight.ToDouble(NSCSS::Pixel));
|
||||
if (NSCSS::Percent == oWindow.m_oHeight.GetUnitMeasure())
|
||||
{
|
||||
if (!m_oContainer.GetViewBox().m_oHeight.Empty() && !m_oContainer.GetViewBox().m_oHeight.Zero())
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, m_oContainer.GetViewBox().m_oHeight.ToDouble(NSCSS::Pixel));
|
||||
else
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, SVG_FILE_WIDTH);
|
||||
}
|
||||
else
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel);
|
||||
}
|
||||
else if (!m_oContainer.GetViewBox().m_oHeight.Empty() && !m_oContainer.GetViewBox().m_oHeight.Zero())
|
||||
else
|
||||
dHeight = m_oContainer.GetViewBox().m_oHeight.ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (0. == dWidth)
|
||||
|
||||
@ -52,37 +52,21 @@ namespace SVG
|
||||
|
||||
bool CGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
{
|
||||
if (NULL == pRenderer)
|
||||
if (NULL == pRenderer || m_arObjects.empty())
|
||||
return false;
|
||||
|
||||
if (m_arObjects.empty())
|
||||
{
|
||||
if (m_wsXlinkHref.empty() || NULL == pFile)
|
||||
return false;
|
||||
std::vector<LONG> arColors;
|
||||
std::vector<double> arPositions;
|
||||
|
||||
CGradient *pGradiend = dynamic_cast<CGradient*>(pFile->GetMarkedObject(m_wsXlinkHref));
|
||||
|
||||
if (NULL == pGradiend)
|
||||
return false;
|
||||
|
||||
pGradiend->Apply(pRenderer, pFile, oObjectBounds);
|
||||
}
|
||||
else
|
||||
for (const CStopElement* pStopElement : m_arObjects)
|
||||
{
|
||||
std::vector<LONG> arColors;
|
||||
std::vector<double> arPositions;
|
||||
|
||||
for (const CStopElement* pStopElement : m_arObjects)
|
||||
{
|
||||
arColors.push_back(((unsigned int)(pStopElement->GetColor().ToInt() | ((unsigned char)(255. * pStopElement->GetColor().GetOpacity()) << 24))));
|
||||
arPositions.push_back(pStopElement->GetOffset().ToDouble());
|
||||
}
|
||||
|
||||
pRenderer->put_BrushGradientColors(arColors.data(), arPositions.data(), arColors.size());
|
||||
arColors.push_back(((unsigned int)(pStopElement->GetColor().ToInt() | ((unsigned char)(255. * pStopElement->GetColor().GetOpacity()) << 24))));
|
||||
arPositions.push_back(pStopElement->GetOffset().ToDouble());
|
||||
}
|
||||
|
||||
|
||||
pRenderer->put_BrushGradientColors(arColors.data(), arPositions.data(), arColors.size());
|
||||
pRenderer->put_BrushTransform(m_oTransform.GetMatrix().GetFinalValue());
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -108,6 +92,31 @@ namespace SVG
|
||||
pRenderer->BrushBounds(oNewBounds.m_dLeft, oNewBounds.m_dTop, oNewBounds.m_dRight - oNewBounds.m_dLeft, oNewBounds.m_dBottom - oNewBounds.m_dTop);
|
||||
}
|
||||
|
||||
CGradient *CGradient::GetRefGradient(const CSvgFile *pFile) const
|
||||
{
|
||||
if (m_wsXlinkHref.empty() || NULL == pFile)
|
||||
return NULL;
|
||||
|
||||
CGradient *pGradiend = dynamic_cast<CGradient*>(pFile->GetMarkedObject(m_wsXlinkHref));
|
||||
|
||||
if (NULL == pGradiend)
|
||||
return NULL;
|
||||
|
||||
CGradient *pRefGradient = pGradiend->GetRefGradient(pFile);
|
||||
|
||||
return (NULL != pRefGradient) ? pRefGradient : pGradiend;
|
||||
}
|
||||
|
||||
bool CGradient::ApplyRefGradient(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) const
|
||||
{
|
||||
CGradient *pRefGradient = GetRefGradient(pFile);
|
||||
|
||||
if (NULL == pRefGradient)
|
||||
return false;
|
||||
|
||||
return pRefGradient->Apply(pRenderer, pFile, oObjectBounds);
|
||||
}
|
||||
|
||||
CLinearGradient::CLinearGradient(XmlUtils::CXmlNode& oNode)
|
||||
: CGradient(oNode)
|
||||
{
|
||||
@ -120,10 +129,8 @@ namespace SVG
|
||||
bool CLinearGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
{
|
||||
if (!CGradient::Apply(pRenderer, pFile, oObjectBounds))
|
||||
return false;
|
||||
return ApplyRefGradient(pRenderer, pFile, oObjectBounds);
|
||||
|
||||
pRenderer->put_BrushType(c_BrushTypePathGradient1);
|
||||
|
||||
if (m_oX1 == m_oX2 && m_oY1 == m_oY2)
|
||||
{
|
||||
pRenderer->put_BrushType(c_BrushTypeSolid);
|
||||
@ -132,6 +139,8 @@ namespace SVG
|
||||
return true;
|
||||
}
|
||||
|
||||
pRenderer->put_BrushType(c_BrushTypePathGradient1);
|
||||
|
||||
double dAngle = 0.;
|
||||
|
||||
TBounds oNewBounds(oObjectBounds);
|
||||
@ -171,8 +180,8 @@ namespace SVG
|
||||
bool CRadialGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
{
|
||||
if (!CGradient::Apply(pRenderer, pFile, oObjectBounds) || m_oR.Zero())
|
||||
return false;
|
||||
|
||||
return ApplyRefGradient(pRenderer, pFile, oObjectBounds);
|
||||
|
||||
double dCX = (oObjectBounds.m_dRight + oObjectBounds.m_dLeft) / 2.;
|
||||
double dCY = (oObjectBounds.m_dBottom + oObjectBounds.m_dTop) / 2.;
|
||||
double dR = oObjectBounds.m_dBottom - oObjectBounds.m_dTop;
|
||||
|
||||
@ -47,6 +47,9 @@ namespace SVG
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
void ApplyTransform(IRenderer *pRenderer, const TBounds& oBounds, double& dAngle) const;
|
||||
private:
|
||||
CGradient* GetRefGradient(const CSvgFile *pFile) const;
|
||||
bool ApplyRefGradient(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) const;
|
||||
|
||||
std::wstring m_wsXlinkHref;
|
||||
GradientUnits m_enGradientUnits;
|
||||
SpreadMethod m_enSpreadMethod;
|
||||
|
||||
@ -29,35 +29,33 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
//#include <QCoreApplication>
|
||||
// #include <QCoreApplication>
|
||||
|
||||
#include "../../../../fontengine/ApplicationFontsWorker.h"
|
||||
#include "../../../../graphics/pro/Fonts.h"
|
||||
#include "../../../../graphics/pro/Graphics.h"
|
||||
#include "../../../../fontengine/ApplicationFontsWorker.h"
|
||||
|
||||
#include "../../../../raster/BgraFrame.h"
|
||||
#include "../../../../common/Directory.h"
|
||||
#include "../../../../raster/BgraFrame.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Check system fonts
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
// Check system fonts
|
||||
CApplicationFontsWorker oWorker;
|
||||
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
|
||||
oWorker.m_bIsNeedThumbnails = false;
|
||||
|
||||
if (!NSDirectory::Exists(oWorker.m_sDirectory))
|
||||
NSDirectory::CreateDirectory(oWorker.m_sDirectory);
|
||||
if (!NSDirectory::Exists(oWorker.m_sDirectory))
|
||||
NSDirectory::CreateDirectory(oWorker.m_sDirectory);
|
||||
|
||||
NSFonts::IApplicationFonts* pFonts = oWorker.Check();
|
||||
NSFonts::IApplicationFonts* pFonts = oWorker.Check();
|
||||
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts);
|
||||
pMetafile->LoadFromFile(L"PATH_TO_METAFILE");
|
||||
MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts);
|
||||
pMetafile->LoadFromFile(L"D:/image1.wmf");
|
||||
|
||||
std::wstring wsData;
|
||||
|
||||
pMetafile->ConvertToSvg(wsData);
|
||||
std::wstring wsData = pMetafile->ConvertToSvg();
|
||||
pMetafile->Release();
|
||||
|
||||
pFonts->Release();
|
||||
return 0;
|
||||
pFonts->Release();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -237,7 +237,14 @@ HRESULT CDocxRenderer::AdvancedCommand(IAdvancedCommand* command)
|
||||
case IAdvancedCommand::AdvancedCommandType::ShapeStart:
|
||||
{
|
||||
CShapeStart* pShape = (CShapeStart*)command;
|
||||
const std::string& sUtf8Shape = pShape->GetShapeXML();
|
||||
std::string& sUtf8Shape = pShape->GetShapeXML();
|
||||
Aggplus::CImage* pImage = pShape->GetShapeImage();
|
||||
if (pImage)
|
||||
{
|
||||
std::shared_ptr<NSDocxRenderer::CImageInfo> pInfo = m_pInternal->m_oDocument.m_oImageManager.GenerateImageID(pImage);
|
||||
std::string sNewId = "r:embed=\"rId" + std::to_string(pInfo->m_nId + c_iStartingIdForImages) + "\"";
|
||||
NSStringUtils::string_replaceA(sUtf8Shape, "r:embed=\"\"", sNewId);
|
||||
}
|
||||
m_pInternal->m_oDocument.m_oCurrentPage.m_arCompleteObjectsXml.push_back(UTF8_TO_U(sUtf8Shape));
|
||||
return S_OK;
|
||||
}
|
||||
@ -466,8 +473,23 @@ HRESULT CDocxRenderer::put_BrushGradientColors(LONG* pColors, double* pPositions
|
||||
// TODO:
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocxRenderer::get_BrushTextureImage(Aggplus::CImage** pImage) { return S_OK; }
|
||||
HRESULT CDocxRenderer::put_BrushTextureImage(Aggplus::CImage* pImage) { return S_OK; }
|
||||
HRESULT CDocxRenderer::get_BrushTextureImage(Aggplus::CImage** pImage)
|
||||
{
|
||||
*pImage = m_pInternal->m_oDocument.m_oBrush.Image;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocxRenderer::put_BrushTextureImage(Aggplus::CImage* pImage)
|
||||
{
|
||||
RELEASEINTERFACE(m_pInternal->m_oDocument.m_oBrush.Image);
|
||||
|
||||
if (NULL == pImage)
|
||||
return S_FALSE;
|
||||
|
||||
m_pInternal->m_oDocument.m_oBrush.Image = pImage;
|
||||
m_pInternal->m_oDocument.m_oBrush.Image->AddRef();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CDocxRenderer::get_BrushTransform(Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
HRESULT CDocxRenderer::put_BrushTransform(const Aggplus::CMatrix& oMatrix) { return S_OK; }
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
@ -635,7 +635,10 @@ namespace NSDocxRenderer
|
||||
double y = 0;
|
||||
double w = 0;
|
||||
double h = 0;
|
||||
pInfo = m_oImageManager.WriteImage(m_oBrush.TexturePath, x, y, w, h);
|
||||
if (m_oBrush.Image)
|
||||
pInfo = m_oImageManager.WriteImage(m_oBrush.Image, x, y, w, h);
|
||||
else
|
||||
pInfo = m_oImageManager.WriteImage(m_oBrush.TexturePath, x, y, w, h);
|
||||
}
|
||||
|
||||
m_oCurrentPage.DrawPath(nType, pInfo);
|
||||
|
||||
@ -1028,6 +1028,8 @@ namespace NSDocxRenderer
|
||||
{
|
||||
for (auto& pCont : line->m_arConts)
|
||||
{
|
||||
if (!pCont)
|
||||
continue;
|
||||
if (base_line->m_dLeft > pCont->m_dLeft)
|
||||
base_line->m_dLeft = pCont->m_dLeft;
|
||||
if (base_line->m_dRight < pCont->m_dRight)
|
||||
|
||||
@ -709,6 +709,8 @@ namespace NSDocxRenderer
|
||||
|
||||
void CShape::BuildPictureProperties(NSStringUtils::CStringBuilder &oWriter) const
|
||||
{
|
||||
// TODO: Clip path as geometry + tile!!!
|
||||
|
||||
oWriter.WriteString(L"<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
||||
|
||||
oWriter.WriteString(L"<pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
||||
@ -944,6 +946,39 @@ namespace NSDocxRenderer
|
||||
}
|
||||
void CShape::ToXmlPptx(NSStringUtils::CStringBuilder &oWriter) const
|
||||
{
|
||||
if (m_eType == eShapeType::stPicture ||
|
||||
m_eType == eShapeType::stVectorTexture)
|
||||
{
|
||||
// TODO: Clip path as geometry + tile!!!
|
||||
oWriter.WriteString(L"<p:pic>");
|
||||
oWriter.WriteString(L"<p:nvPicPr>");
|
||||
oWriter.WriteString(L"<p:cNvPr id=\"");
|
||||
oWriter.AddUInt(m_pImageInfo->m_nId);
|
||||
oWriter.WriteString(L"\" name=\"Picture ");
|
||||
oWriter.AddUInt(m_pImageInfo->m_nId);
|
||||
oWriter.WriteString(L"\"/>");
|
||||
oWriter.WriteString(L"<p:cNvPicPr><a:picLocks noChangeAspect=\"1\"/></p:cNvPicPr>");
|
||||
oWriter.WriteString(L"<p:nvPr/>");
|
||||
oWriter.WriteString(L"</p:nvPicPr>");
|
||||
|
||||
oWriter.WriteString(L"<p:blipFill>");
|
||||
oWriter.WriteString(L"<a:blip r:embed=\"rId");
|
||||
oWriter.AddUInt(c_iStartingIdForImages + m_pImageInfo->m_nId);
|
||||
oWriter.WriteString(L"\">");
|
||||
oWriter.WriteString(L"</a:blip>");
|
||||
oWriter.WriteString(L"<a:stretch><a:fillRect/></a:stretch>");
|
||||
oWriter.WriteString(L"</p:blipFill>");
|
||||
|
||||
oWriter.WriteString(L"<p:spPr>");
|
||||
BuildForm(oWriter, true);
|
||||
oWriter.WriteString(L"<a:prstGeom prst=\"rect\">");
|
||||
oWriter.WriteString(L"<a:avLst/>");
|
||||
oWriter.WriteString(L"</a:prstGeom>");
|
||||
oWriter.WriteString(L"</p:spPr>");
|
||||
oWriter.WriteString(L"</p:pic>");
|
||||
return;
|
||||
}
|
||||
|
||||
oWriter.WriteString(L"<p:sp>");
|
||||
oWriter.WriteString(L"<p:spPr>");
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ namespace NSDocxRenderer
|
||||
|
||||
public:
|
||||
virtual std::shared_ptr<CImageInfo> GenerateImageID(Aggplus::CImage* pImage) = 0;
|
||||
virtual std::map<std::wstring, std::string>* GetImages() = 0;
|
||||
virtual std::string* GetBase64(const int& nRId) = 0;
|
||||
};
|
||||
|
||||
DOCXRENDERER_DECL_EXPORT IImageStorage* CreateWasmImageStorage();
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
#include "ImageManager.h"
|
||||
#include "../../../../DesktopEditor/common/Directory.h"
|
||||
#include "../../resources/Constants.h"
|
||||
|
||||
namespace NSDocxRenderer
|
||||
{
|
||||
@ -10,7 +11,7 @@ namespace NSDocxRenderer
|
||||
{
|
||||
private:
|
||||
std::map<DWORD, std::shared_ptr<CImageInfo>> m_mapImageData;
|
||||
std::map<std::wstring, std::string> m_mapImages;
|
||||
std::map<int, std::string> m_mapImages;
|
||||
|
||||
int m_lMaxSizeImage{1200};
|
||||
int m_lNextIDImage{0};
|
||||
@ -87,21 +88,31 @@ namespace NSDocxRenderer
|
||||
oBgraFrame.put_Data(NULL);
|
||||
|
||||
int nBase64DataSize = NSBase64::Base64EncodeGetRequiredLength(nEncodeBufferSize);
|
||||
char* pBase64Data = new char[nBase64DataSize];
|
||||
int nHeaderSize = (pInfo->m_eType == CImageInfo::itPNG) ? 22 : 23;
|
||||
|
||||
NSBase64::Base64Encode(pEncodeBuffer, nEncodeBufferSize, (BYTE*)pBase64Data, &nBase64DataSize, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
char* pBase64Data = new char[nBase64DataSize + nHeaderSize];
|
||||
if (pInfo->m_eType == CImageInfo::itPNG)
|
||||
memcpy(pBase64Data, "data:image/png;base64,", nHeaderSize);
|
||||
else
|
||||
memcpy(pBase64Data, "data:image/jpeg;base64,", nHeaderSize);
|
||||
|
||||
NSBase64::Base64Encode(pEncodeBuffer, nEncodeBufferSize, (BYTE*)pBase64Data + nHeaderSize, &nBase64DataSize, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||
RELEASEARRAYOBJECTS(pEncodeBuffer);
|
||||
|
||||
m_mapImages.insert(std::pair<std::wstring, std::string>(pInfo->m_strFileName, std::string(pBase64Data, nBase64DataSize)));
|
||||
m_mapImages.insert(std::pair<int, std::string>((int)pInfo->m_nId, std::string(pBase64Data, nHeaderSize + nBase64DataSize)));
|
||||
RELEASEARRAYOBJECTS(pBase64Data);
|
||||
|
||||
m_mapImageData.insert(std::pair<DWORD, std::shared_ptr<CImageInfo>>(dwSum, pInfo));
|
||||
return pInfo;
|
||||
}
|
||||
|
||||
virtual std::map<std::wstring, std::string>* GetImages()
|
||||
virtual std::string* GetBase64(const int& nRId)
|
||||
{
|
||||
return &m_mapImages;
|
||||
std::map<int, std::string>::iterator iter = m_mapImages.find(nRId - c_iStartingIdForImages);
|
||||
if (iter == m_mapImages.end())
|
||||
return NULL;
|
||||
|
||||
return &iter->second;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -37,8 +37,6 @@ namespace NSDocxRenderer
|
||||
|
||||
void SaveImage(Aggplus::CImage* pImage, std::shared_ptr<CImageInfo> pInfo);
|
||||
|
||||
std::shared_ptr<CImageInfo> GenerateImageID(Aggplus::CImage* pImage);
|
||||
|
||||
std::shared_ptr<CImageInfo> GenerateImageID(const std::wstring& strFileName);
|
||||
|
||||
void FlipY(Aggplus::CImage* pImage);
|
||||
@ -47,5 +45,6 @@ namespace NSDocxRenderer
|
||||
|
||||
public:
|
||||
static CImageInfo::ImageType GetImageType(Aggplus::CImage* pFrame);
|
||||
std::shared_ptr<CImageInfo> GenerateImageID(Aggplus::CImage* pImage);
|
||||
};
|
||||
}
|
||||
|
||||
@ -146,6 +146,13 @@ const std::wstring CBookInfo::GetLanguages() const
|
||||
return sLanguages;
|
||||
}
|
||||
|
||||
const std::wstring CBookInfo::GetLanguage() const
|
||||
{
|
||||
if (m_arLanguages.empty())
|
||||
return L"";
|
||||
return m_arLanguages.front();
|
||||
}
|
||||
|
||||
const std::wstring CBookInfo::GetContibutors() const
|
||||
{
|
||||
if (m_arContributors.empty())
|
||||
|
||||
@ -30,6 +30,7 @@ public:
|
||||
const std::wstring GetCreators() const;
|
||||
const std::wstring GetPublishers() const;
|
||||
const std::wstring GetLanguages() const;
|
||||
const std::wstring GetLanguage() const;
|
||||
const std::wstring GetContibutors() const;
|
||||
const std::wstring GetDescriptions() const;
|
||||
const std::wstring GetSubjects() const;
|
||||
|
||||
@ -137,11 +137,13 @@ HRESULT CEpubFile::Convert(const std::wstring& sInputFile, const std::wstring& s
|
||||
CHtmlFile2 oFile;
|
||||
CHtmlParams oFileParams;
|
||||
|
||||
oFileParams.SetAuthors(m_oBookInfo.GetCreators());
|
||||
oFileParams.SetGenres (m_oBookInfo.GetSubjects());
|
||||
oFileParams.SetTitle (m_oBookInfo.GetTitle());
|
||||
oFileParams.SetDate (m_oBookInfo.GetDate());
|
||||
oFileParams.SetDescription(m_oBookInfo.GetDescriptions());
|
||||
oFileParams.SetAuthors (m_oBookInfo.GetCreators());
|
||||
oFileParams.SetGenres (m_oBookInfo.GetSubjects());
|
||||
oFileParams.SetTitle (m_oBookInfo.GetTitle());
|
||||
oFileParams.SetDate (m_oBookInfo.GetDate());
|
||||
oFileParams.SetDescription (m_oBookInfo.GetDescriptions());
|
||||
oFileParams.SetLanguage (m_oBookInfo.GetLanguage());
|
||||
|
||||
oFileParams.SetPageBreakBefore(true);
|
||||
|
||||
std::wstring sDocxFileTempDir = m_sTempDir + L"/tmp";
|
||||
|
||||
@ -31,4 +31,5 @@ ADD_DEPENDENCY(kernel, UnicodeConverter, graphics, kernel_network)
|
||||
SOURCES += htmlfile2.cpp
|
||||
|
||||
HEADERS += htmlfile2.h \
|
||||
./src/StringFinder.h
|
||||
./src/StringFinder.h \
|
||||
./src/Languages.h
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@ struct CHtmlParams
|
||||
std::wstring m_sBookTitle; // Название
|
||||
std::wstring m_sDate; // Дата
|
||||
std::wstring m_sDescription; // описание
|
||||
std::wstring m_sLanguage; // Язык
|
||||
bool m_bNeedPageBreakBefore; // Новый html с новой страницы
|
||||
std::wstring m_sdocDefaults; // Стиль docDefaults
|
||||
std::wstring m_sNormal; // Стиль normal
|
||||
@ -64,6 +65,11 @@ struct CHtmlParams
|
||||
{
|
||||
m_sBookTitle = sTitle;
|
||||
}
|
||||
|
||||
void SetLanguage(const std::wstring& sLanguage)
|
||||
{
|
||||
m_sLanguage = sLanguage;
|
||||
}
|
||||
};
|
||||
|
||||
class CHtmlFile2_Private;
|
||||
|
||||
84
HtmlFile2/src/Languages.h
Normal file
84
HtmlFile2/src/Languages.h
Normal file
@ -0,0 +1,84 @@
|
||||
#ifndef LANGUAGES_LIST_H
|
||||
#define LANGUAGES_LIST_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
const static std::map<std::wstring, std::wstring> m_Languages_HTML
|
||||
{
|
||||
//Язык, Регион
|
||||
{L"en", L"US"}, // Английский - США
|
||||
{L"ru", L"RU"}, // Русский - Россия
|
||||
{L"es", L"ES"}, // Испанский - Испания
|
||||
{L"de", L"DE"}, // Немецкий - Германия
|
||||
{L"fr", L"FR"}, // Французский - Франция
|
||||
{L"it", L"IT"}, // Итальянский - Италия
|
||||
{L"pt", L"PT"}, // Португальский - Португалия
|
||||
{L"pl", L"PL"}, // Польский - Польша
|
||||
{L"nl", L"NL"}, // Нидерландский - Нидерланды
|
||||
{L"sv", L"SE"}, // Шведский - Швеция
|
||||
{L"nb", L"NO"}, // Норвежский - Новегия
|
||||
{L"da", L"DK"}, // Датский - Дания
|
||||
{L"fi", L"FI"}, // Финский - Финляндия
|
||||
{L"el", L"GR"}, // Греческий - Греция
|
||||
{L"tr", L"TR"}, // Турецкий - Турция
|
||||
{L"ar", L"SA"}, // Арабский - Саудовская Аравия
|
||||
{L"he", L"IL"}, // Иврит - Израиль
|
||||
{L"ja", L"JP"}, // Японский - Япония
|
||||
{L"zh", L"CN"}, // Китайский (упрощенный) - Китай
|
||||
{L"hu", L"HU"}, // Венгерский - Венгрия
|
||||
{L"cs", L"CZ"}, // Чешский - Чехия
|
||||
{L"ro", L"RO"}, // Румынский - Румыния
|
||||
{L"bg", L"BG"}, // Болгарский - Болгария
|
||||
{L"hr", L"HR"}, // Хорватский - Хорватия
|
||||
{L"sr", L"Latn-RS"}, //Сербский - Сербия
|
||||
{L"sl", L"SI"}, // Словенский - Словения
|
||||
{L"lt", L"LT"}, // Литовский - Литва
|
||||
{L"lv", L"LV"}, // Латышский - Латвия
|
||||
{L"et", L"EE"}, // Эстонский - Эстония
|
||||
{L"uk", L"UA"}, // Украинский - Украина
|
||||
{L"be", L"BY"}, // Белорусский - Беларусь
|
||||
{L"kk", L"KZ"}, // Казахский - Казахстан
|
||||
{L"hi", L"IN"}, // Хинди - Индия
|
||||
{L"th", L"TH"}, // Тайский - Таиланд
|
||||
{L"vi", L"VN"}, // Вьетнамский - Вьетнам
|
||||
{L"id", L"ID"}, // Индонезийский - Индонезия
|
||||
{L"ms", L"MY"}, // Малайский - Малайзия
|
||||
{L"fil", L"PH"}, // Филиппинский - Филиппины
|
||||
{L"ko", L"KR"}, // Корейский - Южная Корея
|
||||
{L"is", L"IS"}, // Исландский - Исландия
|
||||
{L"ga", L"IE"}, // Ирландский - Ирландия
|
||||
{L"cy", L"GB"}, // Валлийский - Великобритания
|
||||
{L"ca", L"ES"}, // Каталанский - Испания
|
||||
{L"eu", L"ES"}, // Баскский - Испания
|
||||
{L"gl", L"ES"}, // Галисийский - Испания
|
||||
{L"af", L"ZA"}, // Африкаанс - Южная Африка
|
||||
{L"zu", L"ZA"}, // Зулу - Южная Африка
|
||||
{L"ha", L"Latn-NG"}, // Хауса - Нигерия
|
||||
{L"yo", L"NG"}, // Йоруба - Нигерия
|
||||
{L"sw", L"KE"}, // Суахили - Кения
|
||||
{L"am", L"ET"}, // Амхарский - Эфиопия
|
||||
{L"ti", L"ET"}, // Тигринья - Эфиопия
|
||||
{L"ur", L"PK"}, // Урду - Пакистан
|
||||
{L"pa", L"IN"}, // Панджаби - Индия
|
||||
{L"gu", L"IN"}, // Гуджарати - Индия
|
||||
{L"ta", L"IN"}, // Тамильский - Индия
|
||||
{L"te", L"IN"}, // Телугу - Индия
|
||||
{L"ml", L"IN"}, // Малаялам - Индия
|
||||
{L"kn", L"IN"} // Каннада - Индия
|
||||
};
|
||||
|
||||
static std::wstring IndentifyLanguage(std::wstring wsLanguage)
|
||||
{
|
||||
std::transform(wsLanguage.begin(), wsLanguage.end(), wsLanguage.begin(), towlower);
|
||||
|
||||
std::map<std::wstring, std::wstring>::const_iterator itFounded = m_Languages_HTML.find(wsLanguage);
|
||||
|
||||
if (m_Languages_HTML.end() != itFounded)
|
||||
return itFounded->first + L"-" + itFounded->second;
|
||||
|
||||
return std::wstring();
|
||||
}
|
||||
|
||||
#endif // LANGUAGES_LIST_H
|
||||
@ -13,6 +13,23 @@
|
||||
|
||||
namespace NSStringFinder
|
||||
{
|
||||
template<class CharType, class StringType = std::basic_string<CharType, std::char_traits<CharType>, std::allocator<CharType>>>
|
||||
struct TFoundedData
|
||||
{
|
||||
size_t m_unBeginPosition;
|
||||
size_t m_unEndPosition;
|
||||
StringType m_sValue;
|
||||
|
||||
TFoundedData()
|
||||
: m_unBeginPosition(0), m_unEndPosition(0)
|
||||
{}
|
||||
|
||||
bool Empty() const
|
||||
{
|
||||
return 0 == m_unEndPosition || StringType::npos == m_unEndPosition;
|
||||
}
|
||||
};
|
||||
|
||||
template<class CharType, class StringType = std::basic_string<CharType, std::char_traits<CharType>, std::allocator<CharType>>>
|
||||
StringType FindPropetyTemplate(const StringType& sString, const StringType& sProperty, const StringType& sDelimiter, const StringType& sEnding, const size_t& unStarting, size_t& unEndPosition)
|
||||
{
|
||||
@ -66,70 +83,85 @@ namespace NSStringFinder
|
||||
}
|
||||
|
||||
template<class CharType, class StringType = std::basic_string<CharType, std::char_traits<CharType>, std::allocator<CharType>>>
|
||||
StringType FindPropetyTemplate(const StringType& sString, const StringType& sProperty, const std::vector<StringType>& arDelimiters, const std::vector<StringType>& arEndings, const size_t& unStarting, size_t& unEndPosition)
|
||||
TFoundedData<CharType> FindPropetyTemplate(const StringType& sString, const StringType& sProperty, const std::vector<StringType>& arDelimiters, const std::vector<StringType>& arEndings, const size_t& unStarting)
|
||||
{
|
||||
if (sString.length() < unStarting)
|
||||
return StringType();
|
||||
return TFoundedData<CharType>();
|
||||
|
||||
std::string sRegexValue = "(?i)" + std::string(sProperty.begin(), sProperty.end());
|
||||
std::wstring wsRegexValue = L"(?i)" + std::wstring(sProperty.begin(), sProperty.end());
|
||||
|
||||
if (!arDelimiters.empty())
|
||||
{
|
||||
sRegexValue += "\\s*[";
|
||||
for (const StringType& sDelimiter : arDelimiters)
|
||||
sRegexValue += std::string(sDelimiter.begin(), sDelimiter.end()) + "|";
|
||||
sRegexValue.pop_back();
|
||||
sRegexValue += "]{1}";
|
||||
wsRegexValue += L"\\s*[";
|
||||
for (const StringType& wsDelimiter : arDelimiters)
|
||||
wsRegexValue += std::wstring(wsDelimiter.begin(), wsDelimiter.end()) + L"|";
|
||||
wsRegexValue.pop_back();
|
||||
wsRegexValue += L"]{1}";
|
||||
}
|
||||
|
||||
if (!arEndings.empty())
|
||||
{
|
||||
std::string sEndingValue;
|
||||
std::wstring wsEndingValue;
|
||||
|
||||
for (const StringType& sEnding : arEndings)
|
||||
sEndingValue += std::string(sEnding.begin(), sEnding.end()) + "|";
|
||||
wsEndingValue += std::wstring(sEnding.begin(), sEnding.end()) + L"|";
|
||||
|
||||
sEndingValue.pop_back();
|
||||
wsEndingValue.pop_back();
|
||||
|
||||
sRegexValue += "\\s*(.[^" + sEndingValue + "]*)\\s*[" + sEndingValue + "]?";
|
||||
wsRegexValue += L"\\s*(.[^" + wsEndingValue + L"]*)\\s*[" + wsEndingValue + L"]?";
|
||||
}
|
||||
else
|
||||
sRegexValue += "\\s*(.*)[\\n|\\r]?";
|
||||
wsRegexValue += L"\\s*(.*)[\\n|\\r]?";
|
||||
|
||||
boost::regex oRegex(sRegexValue);
|
||||
boost::wregex oRegex(wsRegexValue);
|
||||
boost::match_results<typename StringType::const_iterator> oResult;
|
||||
|
||||
if (!boost::regex_search(sString.begin() + unStarting, sString.end(), oResult, oRegex))
|
||||
return StringType();
|
||||
return TFoundedData<CharType>();
|
||||
|
||||
unEndPosition = unStarting + oResult.position() + oResult.length();
|
||||
TFoundedData<CharType> oData;
|
||||
|
||||
StringType sValue(oResult[1]);
|
||||
boost::algorithm::trim(sValue);
|
||||
oData.m_unBeginPosition = unStarting + oResult.position();
|
||||
oData.m_unEndPosition = unStarting + oResult.position() + oResult.length();
|
||||
|
||||
return sValue;
|
||||
oData.m_sValue = oResult[1];
|
||||
boost::algorithm::trim(oData.m_sValue);
|
||||
|
||||
return oData;
|
||||
}
|
||||
|
||||
std::string FindPropety(const std::string& sString, const std::string& sProperty, const std::vector<std::string>& arDelimiters, const std::vector<std::string>& arEndings, const size_t& unStarting, size_t& unEndPosition)
|
||||
TFoundedData<char> FindPropety(const std::string& sString, const std::string& sProperty, const std::vector<std::string>& arDelimiters, const std::vector<std::string>& arEndings, const size_t& unStarting = 0)
|
||||
{
|
||||
return FindPropetyTemplate<char>(sString, sProperty, arDelimiters, arEndings, unStarting, unEndPosition);
|
||||
return FindPropetyTemplate<char>(sString, sProperty, arDelimiters, arEndings, unStarting);
|
||||
}
|
||||
|
||||
std::wstring FindPropety(const std::wstring& wsString, const std::wstring& wsProperty, const std::vector<std::wstring>& arDelimiters, const std::vector<std::wstring>& arEndings, const size_t& unStarting, size_t& unEndPosition)
|
||||
TFoundedData<wchar_t> FindPropety(const std::wstring& wsString, const std::wstring& wsProperty, const std::vector<std::wstring>& arDelimiters, const std::vector<std::wstring>& arEndings, const size_t& unStarting = 0)
|
||||
{
|
||||
return FindPropetyTemplate<wchar_t>(wsString, wsProperty, arDelimiters, arEndings, unStarting, unEndPosition);
|
||||
return FindPropetyTemplate<wchar_t>(wsString, wsProperty, arDelimiters, arEndings, unStarting);
|
||||
}
|
||||
|
||||
std::string FindPropety(const std::string& sString, const std::string& sProperty, const std::vector<std::string>& arDelimiters, const std::vector<std::string>& arEndings, const size_t& unStarting = 0)
|
||||
template<class CharType, class StringType = std::basic_string<CharType, std::char_traits<CharType>, std::allocator<CharType>>>
|
||||
bool RemoveEmptyTagTemplate(StringType& sValue, const StringType& sTagName, size_t unStart)
|
||||
{
|
||||
size_t unEndPosition = 0;
|
||||
return FindPropetyTemplate<char>(sString, sProperty, arDelimiters, arEndings, unStarting, unEndPosition);
|
||||
boost::wregex oRegex(L"<\\s*(?i)" + std::wstring(sTagName.begin(), sTagName.end()) + L"\\s*[^>]*/>");
|
||||
boost::match_results<typename StringType::const_iterator> oResult;
|
||||
|
||||
if (unStart >= sValue.length() || !boost::regex_search(sValue.cbegin() + unStart, sValue.cend(), oResult, oRegex))
|
||||
return false;
|
||||
|
||||
sValue.erase(unStart + oResult.position(), oResult.length());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::wstring FindPropety(const std::wstring& wsString, const std::wstring& wsProperty, const std::vector<std::wstring>& arDelimiters, const std::vector<std::wstring>& arEndings, const size_t& unStarting = 0)
|
||||
bool RemoveEmptyTag(std::string& sValue, const std::string& sTagName, size_t unStart = 0)
|
||||
{
|
||||
size_t unEndPosition = 0;
|
||||
return FindPropetyTemplate<wchar_t>(wsString, wsProperty, arDelimiters, arEndings, unStarting, unEndPosition);
|
||||
return RemoveEmptyTagTemplate<char>(sValue, sTagName, unStart);
|
||||
}
|
||||
|
||||
bool RemoveEmptyTag(std::wstring& sValue, const std::wstring& sTagName, size_t unStart = 0)
|
||||
{
|
||||
return RemoveEmptyTagTemplate<wchar_t>(sValue, sTagName, unStart);
|
||||
}
|
||||
|
||||
template <typename StringType, typename StringEndgeType>
|
||||
|
||||
@ -41,6 +41,8 @@ namespace VBA
|
||||
|
||||
bool DirStreamObject::loadContent()
|
||||
{
|
||||
if (!reader) return false;
|
||||
|
||||
InformationRecord = boost::make_shared<PROJECTINFORMATION>(reader);
|
||||
ReferencesRecord = boost::make_shared<PROJECTREFERENCES>(reader);
|
||||
ModulesRecord = boost::make_shared<PROJECTMODULES>(reader);
|
||||
@ -50,12 +52,16 @@ bool DirStreamObject::loadContent()
|
||||
|
||||
bool ModuleStreamObject::loadContent()
|
||||
{
|
||||
SourceCode = convert_string_icu((char*)reader->getData(), (unsigned int)reader->getDataSize(), reader->CodePage);
|
||||
if (!reader) return false;
|
||||
|
||||
SourceCode = convert_string_icu((char*)reader->getData(), (unsigned int)reader->getDataSize(), reader->CodePage);
|
||||
|
||||
return true;
|
||||
}
|
||||
bool ProjectStreamObject::loadContent()
|
||||
{
|
||||
if (!reader) return false;
|
||||
|
||||
std::string strProps((char*)reader->getData(), reader->getDataSize());
|
||||
|
||||
std::vector<std::string> arrProps;
|
||||
@ -72,6 +78,8 @@ bool ProjectStreamObject::loadContent()
|
||||
}
|
||||
bool VBFrameObject::loadContent()
|
||||
{
|
||||
if (!reader) return false;
|
||||
|
||||
std::wstring strProps = convert_string_icu((char*)reader->getData(), (unsigned int)reader->getDataSize(), reader->CodePage);
|
||||
|
||||
std::vector<std::wstring> arrProps;
|
||||
@ -94,6 +102,8 @@ bool VBFrameObject::loadContent()
|
||||
|
||||
bool FormControlStream::loadContent()
|
||||
{
|
||||
if (!reader) return false;
|
||||
|
||||
unsigned char MinorVersion, MajorVersion;
|
||||
_UINT16 cbForm;
|
||||
|
||||
|
||||
@ -171,7 +171,8 @@ bool OleObject::processPackageStream(const std::wstring& packageStream)
|
||||
POLE::Stream* pPackageStream = new POLE::Stream(oleStorage, packageStream);
|
||||
|
||||
if ((pPackageStream) && (false == pPackageStream->fail()))
|
||||
{
|
||||
{
|
||||
// AVS_OFFICESTUDIO_FILE_OTHER_PACKAGE_IN_OLE
|
||||
VirtualStreamReader reader(pPackageStream, 0, false);
|
||||
|
||||
size_t sz = reader.GetSize();
|
||||
|
||||
@ -83,32 +83,48 @@ namespace DocFileFormat
|
||||
|
||||
if (_ctx->_doc->FIB->m_FibBase.fWriteReservation)
|
||||
{
|
||||
m_oXmlWriter.WriteNodeBegin( L"w:writeProtection", TRUE );
|
||||
WideString* passw = static_cast<WideString*>(_ctx->_doc->AssocNames->operator[]( 17 ));
|
||||
CRYPT::_ecmaWriteProtectData data;
|
||||
|
||||
WideString* passw = static_cast<WideString*>(_ctx->_doc->AssocNames->operator[]( 17 ));
|
||||
if (passw && false == passw->empty())
|
||||
{
|
||||
CRYPT::_ecmaWriteProtectData data;
|
||||
|
||||
CRYPT::ECMAWriteProtect protect;
|
||||
protect.SetCryptData(data);
|
||||
protect.SetPassword(*passw);
|
||||
|
||||
protect.Generate();
|
||||
protect.GetCryptData(data);
|
||||
}
|
||||
|
||||
m_oXmlWriter.WriteNodeBegin(L"w:writeProtection", TRUE);
|
||||
if (false == data.saltValue.empty())
|
||||
{
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptProviderType", L"rsaAES");
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmSid", 14); //sha-512
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmType", L"typeAny");
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptAlgorithmClass", L"hash");
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:cryptSpinCount", data.spinCount);
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:hash", EncodeBase64(data.hashValue));
|
||||
//m_oXmlWriter.WriteAttribute ( L"w:salt", EncodeBase64(data.saltValue));
|
||||
|
||||
m_oXmlWriter.WriteAttribute ( L"w:algorithmName", L"SHA-512");
|
||||
m_oXmlWriter.WriteAttribute ( L"w:spinCount", data.spinCount);
|
||||
m_oXmlWriter.WriteAttribute ( L"w:hashValue", EncodeBase64(data.hashValue));
|
||||
m_oXmlWriter.WriteAttribute ( L"w:saltValue", EncodeBase64(data.saltValue));
|
||||
m_oXmlWriter.WriteAttribute ( L"w:saltValue", EncodeBase64(data.saltValue));
|
||||
}
|
||||
m_oXmlWriter.WriteNodeEnd( L"", TRUE, TRUE );
|
||||
if (false == data.saltValue.empty())
|
||||
{
|
||||
m_oXmlWriter.WriteNodeBegin(L"w:documentProtection", TRUE);
|
||||
m_oXmlWriter.WriteAttribute(L"w:edit", L"readOnly");
|
||||
m_oXmlWriter.WriteAttribute(L"w:enforcement", L"1");
|
||||
m_oXmlWriter.WriteAttribute(L"w:cryptProviderType", L"rsaAES");
|
||||
m_oXmlWriter.WriteAttribute(L"w:cryptAlgorithmClass", L"hash");
|
||||
m_oXmlWriter.WriteAttribute(L"w:cryptAlgorithmType", L"typeAny");
|
||||
m_oXmlWriter.WriteAttribute(L"w:cryptAlgorithmSid", 14); //sha-512
|
||||
m_oXmlWriter.WriteAttribute(L"w:cryptSpinCount", data.spinCount);
|
||||
m_oXmlWriter.WriteAttribute(L"w:spinCount", data.spinCount);
|
||||
m_oXmlWriter.WriteAttribute(L"w:hash", EncodeBase64(data.hashValue));
|
||||
m_oXmlWriter.WriteAttribute(L"w:salt", EncodeBase64(data.saltValue));
|
||||
m_oXmlWriter.WriteNodeEnd(L"", TRUE, TRUE);
|
||||
}
|
||||
}
|
||||
//zoom
|
||||
m_oXmlWriter.WriteNodeBegin ( L"w:zoom", TRUE );
|
||||
|
||||
@ -109,7 +109,7 @@ bool COfficePPTFile::CloseFile()
|
||||
|
||||
PPT::CPPTFileReader* r = (PPT::CPPTFileReader*)m_pReader; RELEASEOBJECT(r);
|
||||
m_pReader = NULL;
|
||||
return S_OK;
|
||||
return true;
|
||||
}
|
||||
|
||||
_UINT32 COfficePPTFile::LoadFromFile(std::wstring sSrcFileName, std::wstring sDstPath, std::wstring password, bool &bMacros)
|
||||
|
||||
@ -178,11 +178,16 @@ std::wstring CMediaManager::GenerateMedia(const std::wstring& strInput, const st
|
||||
if (strExts == L".video" || strExts == L".audio")
|
||||
{
|
||||
std::wstring strInput1 = strInput.substr(0, nIndexExt);
|
||||
nIndexExt = strInput1.rfind(wchar_t('.'));
|
||||
strExts = nIndexExt < 0 ? L"" : strInput1.substr(nIndexExt);
|
||||
strExts.clear();
|
||||
}
|
||||
if (strExts == L".tmp" || strExts.empty()) strExts = strDefaultExt;
|
||||
|
||||
if (strDefaultExt == L"sfil")
|
||||
{
|
||||
strExts = L".wav";
|
||||
//todooo - detect format by file
|
||||
}
|
||||
|
||||
std::wstring strMediaName = Template + std::to_wstring(++Indexer);
|
||||
|
||||
std::wstring strOutput = m_strDstMedia + strMediaName + strExts;
|
||||
|
||||
@ -243,7 +243,15 @@ bool ProtoTable::fillCells(std::vector<CElementPtr> &arrCells)
|
||||
if (top == m_arrTop[posRow]) break;
|
||||
for (; posCol < countCol; posCol++)
|
||||
if (left == m_arrLeft[posCol]) break;
|
||||
TCell* pParent = &m_table[posRow][posCol];
|
||||
TCell* pParent = NULL;
|
||||
|
||||
if (posRow < m_table.size())
|
||||
{
|
||||
if (posCol < m_table[posRow].size())
|
||||
{
|
||||
pParent = &m_table[posRow][posCol];
|
||||
}
|
||||
}
|
||||
|
||||
UINT posRightCol = 0, posBottomRow = 0;
|
||||
for (; posBottomRow < countRow; posBottomRow++)
|
||||
@ -263,9 +271,11 @@ bool ProtoTable::fillCells(std::vector<CElementPtr> &arrCells)
|
||||
if (posRow == cRow)
|
||||
tCell.setRowSpan(posBottomRow - cRow);
|
||||
}
|
||||
pParent->setPParent(nullptr);
|
||||
pParent->setPShape(ptrCell);
|
||||
|
||||
if (pParent)
|
||||
{
|
||||
pParent->setPParent(nullptr);
|
||||
pParent->setPShape(ptrCell);
|
||||
}
|
||||
// pParent->setGridSpan(posRightCol - posCol);
|
||||
// pParent->setRowSpan(posBottomRow - posRow);
|
||||
}
|
||||
@ -562,7 +572,7 @@ bool TCell::isRealCell() const
|
||||
return true;
|
||||
}
|
||||
|
||||
void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody, CTextCFRun* pLastCF)
|
||||
void TCell::FillTxBody(PPTX::Logic::TxBody& oTxBody, CTextCFRun* pLastCF)
|
||||
{
|
||||
TxBodyConverter txBodyConverter(m_ptrSpElCell, m_pRels, pLastCF);
|
||||
txBodyConverter.FillTxBody(oTxBody);
|
||||
@ -570,6 +580,8 @@ void TCell::FillTxBody(PPTX::Logic::TxBody &oTxBody, CTextCFRun* pLastCF)
|
||||
|
||||
void TCell::FillTcPr(PPTX::Logic::TableCellProperties &oTcPr)
|
||||
{
|
||||
if (!m_ptrSpElCell) return;
|
||||
|
||||
auto pShapeEl = static_cast<CShapeElement*>(m_ptrSpElCell.get());
|
||||
auto pShape = pShapeEl->m_pShape;
|
||||
//anchor
|
||||
|
||||
@ -144,6 +144,8 @@ bool CPPTDocumentInfo::LoadDocument()
|
||||
{
|
||||
m_arUsers[0]->ReadExtenalObjects(); // todooo ???? прочитать по всем (см 66864)
|
||||
m_arUsers[0]->FromDocument();
|
||||
|
||||
m_bMacroEnabled = m_arUsers[0]->m_bMacroEnabled;
|
||||
}
|
||||
catch(int) //error code
|
||||
{
|
||||
|
||||
@ -229,8 +229,9 @@ void CPPTElement::SetUpProperties(CElementPtr pElement, CTheme* pTheme, CSlideIn
|
||||
{
|
||||
if (reset_default)
|
||||
{
|
||||
pElement->m_oBrush.Type = c_BrushTypeTexture; // or 3000 set ???
|
||||
pElement->m_bIsFilled = false;
|
||||
pElement->m_bLine = false;
|
||||
pElement->m_oBrush.Type = c_BrushTypeTexture; // or 3000 set ???
|
||||
}
|
||||
for (size_t i = 0; i < lCount; ++i)
|
||||
{
|
||||
@ -249,6 +250,7 @@ void CPPTElement::SetUpProperties(CElementPtr pElement, CTheme* pTheme, CSlideIn
|
||||
{
|
||||
if (reset_default)
|
||||
{
|
||||
pElement->m_bIsFilled = false;
|
||||
pElement->m_bLine = false;
|
||||
}
|
||||
for (size_t i = 0; i < lCount; ++i)
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
namespace XLS
|
||||
{
|
||||
|
||||
char CFRecord::intData[MAX_RECORD_SIZE];
|
||||
char CFRecord::intData[MAX_RECORD_SIZE_XLSB];
|
||||
|
||||
// Create a record and read its data from the stream
|
||||
CFRecord::CFRecord(CFStreamPtr stream, GlobalWorkbookInfoPtr global_info)
|
||||
@ -262,6 +262,10 @@ const BYTE CFRecord::getSizeOfRecordTypeRecordLength() const
|
||||
|
||||
const size_t CFRecord::getMaxRecordSize() const
|
||||
{
|
||||
if(global_info_ && (global_info_.get()->Version == 0x0800))
|
||||
{
|
||||
return MAX_RECORD_SIZE_XLSB;
|
||||
}
|
||||
return MAX_RECORD_SIZE;
|
||||
}
|
||||
|
||||
@ -302,6 +306,11 @@ void CFRecord::appendRawDataToStatic(const unsigned char *raw_data, const size_t
|
||||
memcpy(&intData[rdPtr], raw_data, size);
|
||||
rdPtr += size;
|
||||
}
|
||||
else if(global_info_ && (global_info_.get()->Version == 0x0800) && (MAX_RECORD_SIZE_XLSB - rdPtr > size))
|
||||
{
|
||||
memcpy(&intData[rdPtr], raw_data, size);
|
||||
rdPtr += size;
|
||||
}
|
||||
|
||||
}
|
||||
void CFRecord::appendRawDataToStatic(const wchar_t *raw_data, const size_t size)
|
||||
@ -311,6 +320,11 @@ void CFRecord::appendRawDataToStatic(const wchar_t *raw_data, const size_t size)
|
||||
for(int i = 0; i < size; ++i)
|
||||
storeAnyData(raw_data[i]);
|
||||
}
|
||||
else if(global_info_ && (global_info_.get()->Version == 0x0800) && (MAX_RECORD_SIZE_XLSB - rdPtr > size))
|
||||
{
|
||||
for(int i = 0; i < size; ++i)
|
||||
storeAnyData(raw_data[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -387,6 +401,8 @@ const bool CFRecord::checkFitReadSafe(const size_t size) const
|
||||
|
||||
const bool CFRecord::checkFitWriteSafe(const size_t size) const
|
||||
{
|
||||
if(global_info_ && (global_info_.get()->Version == 0x0800))
|
||||
return (rdPtr + size <= MAX_RECORD_SIZE_XLSB);
|
||||
return (rdPtr + size <= MAX_RECORD_SIZE);
|
||||
}
|
||||
|
||||
@ -432,6 +448,12 @@ void CFRecord::reserveNunBytes(const size_t n)
|
||||
if (rdPtr + n < MAX_RECORD_SIZE)
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
intData[rdPtr++] = 0;
|
||||
else if(global_info_ && (global_info_.get()->Version == 0x0800) && (rdPtr + n < MAX_RECORD_SIZE_XLSB))
|
||||
{
|
||||
for (size_t i = 0; i < n; ++i)
|
||||
intData[rdPtr++] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -131,6 +131,12 @@ public:
|
||||
rdPtr += sizeof(T);
|
||||
return true;
|
||||
}
|
||||
else if(global_info_ && (global_info_.get()->Version == 0x0800) && (rdPtr + sizeof(T) < MAX_RECORD_SIZE_XLSB))
|
||||
{
|
||||
memcpy(&intData[rdPtr], &val, sizeof(T));
|
||||
rdPtr += sizeof(T);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -161,7 +167,8 @@ public:
|
||||
CFRecord& operator << (bool& val);
|
||||
|
||||
private:
|
||||
static const size_t MAX_RECORD_SIZE = 8224;
|
||||
static const size_t MAX_RECORD_SIZE = 8224;
|
||||
static const size_t MAX_RECORD_SIZE_XLSB = 0xFFFFFFF;
|
||||
|
||||
CFStream::ReceiverItems receiver_items;
|
||||
CFStream::SourceItems source_items;
|
||||
@ -172,7 +179,7 @@ private:
|
||||
char* data_;
|
||||
BYTE sizeOfRecordTypeRecordLength; //размер RecordType и RecordLength
|
||||
size_t rdPtr;
|
||||
static char intData[MAX_RECORD_SIZE];
|
||||
static char intData[MAX_RECORD_SIZE_XLSB];
|
||||
|
||||
GlobalWorkbookInfoPtr global_info_;
|
||||
};
|
||||
|
||||
@ -74,6 +74,8 @@ void BOF::readFields(CFRecord& record)
|
||||
|
||||
if (type_id_ == rt_BOF_BIFF8)
|
||||
{
|
||||
if (vers > 0x0700) vers = 0x0600;
|
||||
|
||||
record >> rupBuild >> rupYear; // biff 5 - 8
|
||||
|
||||
if ( record.checkFitReadSafe(8)) // biff 8
|
||||
|
||||
@ -70,5 +70,31 @@ void FileSharing::readFields(CFRecord& record)
|
||||
}
|
||||
}
|
||||
|
||||
void FileSharing::writeFields(CFRecord& record)
|
||||
{
|
||||
if(record.getGlobalWorkbookInfo()->Version == 0x0800)
|
||||
{
|
||||
auto readOnlyrec = fReadOnlyRec.value();
|
||||
if(readOnlyrec.is_initialized() &&(readOnlyrec.get() == 1 || readOnlyrec.get() == 0))
|
||||
record << fReadOnlyRec;
|
||||
else
|
||||
{
|
||||
_UINT16 defaulTRec = 0;
|
||||
record << defaulTRec;
|
||||
}
|
||||
if(!wResPass.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
wResPassNum = std::stoi(wResPass, nullptr, 16);
|
||||
}
|
||||
catch(const std::exception&)
|
||||
{
|
||||
wResPassNum = 0;
|
||||
}
|
||||
}
|
||||
record << wResPassNum << stUserName;
|
||||
}
|
||||
}
|
||||
} // namespace XLS
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ public:
|
||||
BaseObjectPtr clone();
|
||||
|
||||
void readFields(CFRecord& record);
|
||||
void writeFields(CFRecord& record) override;
|
||||
|
||||
static const ElementType type = typeFileSharing;
|
||||
|
||||
|
||||
@ -57,7 +57,7 @@ void Label::readFields(CFRecord& record)
|
||||
|
||||
record >> cell;
|
||||
|
||||
if (global_info_->Version == 0x0200)
|
||||
if (global_info_->Version == 0x0200 || global_info_->Version == 0x0400)
|
||||
{
|
||||
ShortXLAnsiString name;
|
||||
record >> name;
|
||||
|
||||
@ -94,7 +94,7 @@ int Number::serialize(std::wostream & stream)
|
||||
return 0;
|
||||
}
|
||||
//---------------------------------------------------------------------------------
|
||||
Integer_BIFF2::Integer_BIFF2()
|
||||
Integer_BIFF2::Integer_BIFF2() : num(0)
|
||||
{}
|
||||
Integer_BIFF2::~Integer_BIFF2()
|
||||
{}
|
||||
@ -106,7 +106,18 @@ void Integer_BIFF2::readFields(CFRecord& record)
|
||||
{
|
||||
global_info_ = record.getGlobalWorkbookInfo();
|
||||
|
||||
record >> cell >> num;
|
||||
record >> cell;
|
||||
|
||||
if (record.getRdPtr() + 2 < record.getDataSize())
|
||||
{
|
||||
record >> num;
|
||||
}
|
||||
else
|
||||
{
|
||||
_INT16 num_2byte = 0;
|
||||
record >> num_2byte;
|
||||
num = num_2byte;
|
||||
}
|
||||
}
|
||||
const CellRef Integer_BIFF2::getLocation() const
|
||||
{
|
||||
|
||||
@ -69,7 +69,7 @@ void Pane::readFields(CFRecord& record)
|
||||
else
|
||||
{
|
||||
record >> xnumXSplit >> xnumYSplit >> rwTop >> colLeft >> pnnAcct_xlsb;
|
||||
topLeftCell = static_cast<std::wstring >(CellRef(rwTop, colLeft, true, true));
|
||||
topLeftCell = CellRef(rwTop, colLeft, true, true).toString(true);
|
||||
|
||||
unsigned char flags;
|
||||
record >> flags;
|
||||
|
||||
@ -80,12 +80,12 @@ void Selection::readFields(CFRecord& record)
|
||||
{
|
||||
XLSB::UncheckedSqRfX sqrfx;
|
||||
record >> pnn_xlsb >> rwAct >> colAct >> irefAct >> sqrfx;
|
||||
activeCell = static_cast<std::wstring >(CellRef(rwAct, colAct, true, true));
|
||||
activeCell = CellRef(rwAct, colAct, true, true).toString(true);
|
||||
std::wstring sqref_str;
|
||||
int i = 0, cref = sqrfx.rgrfx.size();
|
||||
|
||||
std::for_each(sqrfx.rgrfx.begin(), sqrfx.rgrfx.end(), [&](XLSB::UncheckedRfX &refu) {
|
||||
sqref_str += std::wstring (refu.toString(false).c_str()) + ((i == cref - 1) ? L"" : L" ");
|
||||
sqref_str += std::wstring (refu.toString(false, true).c_str()) + ((i == cref - 1) ? L"" : L" ");
|
||||
});
|
||||
|
||||
sqref = sqref_str;
|
||||
|
||||
@ -152,7 +152,7 @@ void Window2::readFields(CFRecord& record)
|
||||
|
||||
record >> xlView >> rwTop >> colLeft;
|
||||
|
||||
topLeftCell = static_cast<std::wstring >(CellRef(rwTop, colLeft, true, true));
|
||||
topLeftCell = CellRef(rwTop, colLeft, true, true).toString(true);
|
||||
|
||||
BYTE icvHdr_1b;
|
||||
record >> icvHdr_1b;
|
||||
|
||||
@ -59,7 +59,8 @@ void Cell::load(CFRecord& record)
|
||||
{
|
||||
record >> rw >> col;
|
||||
|
||||
if (record.getGlobalWorkbookInfo()->Version == 0x0200)
|
||||
if (record.getGlobalWorkbookInfo()->Version == 0x0200 ||
|
||||
record.getGlobalWorkbookInfo()->Version == 0x0400)
|
||||
{
|
||||
unsigned char flags1, flags2, flags3;
|
||||
|
||||
|
||||
@ -100,7 +100,7 @@ const std::wstring CellRef::toString(const bool xlsb) const
|
||||
{
|
||||
column_norm = maxCol;
|
||||
}
|
||||
return to_string_cache = AUX::loc2str(row_norm, rowRelative, column_norm, colRelative);
|
||||
return to_string_cache = AUX::loc2str(row_norm, rowRelative, column_norm, colRelative, xlsb);
|
||||
}
|
||||
return to_string_cache;
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ void DVParsedFormula::save(CFRecord& record, bool bSave)
|
||||
else
|
||||
{
|
||||
cce = 0;
|
||||
auto cb = 0;
|
||||
_UINT32 cb = 0;
|
||||
record << cce << cb;
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,48 +69,52 @@ void DXFFntD::load(CFRecord& record)
|
||||
record >> ich >> cch >> iFnt;
|
||||
}
|
||||
|
||||
int DXFFntD::serialize(std::wostream & stream)
|
||||
int DXFFntD::serialize(std::wostream & stream, bool extOnly)
|
||||
{
|
||||
std::map<ExtProp::_type, ExtProp>::iterator pFind;
|
||||
|
||||
if (parent && parent->xfext)
|
||||
pFind = parent->xfext->mapRgExt.find(ExtProp::FontScheme);
|
||||
|
||||
CP_XML_WRITER(stream)
|
||||
{
|
||||
CP_XML_NODE(L"font")
|
||||
{
|
||||
if (!stFontName.value().empty())
|
||||
{
|
||||
std::wstring name = stFontName.value();
|
||||
|
||||
if (parent->xfext)
|
||||
pFind = parent->xfext->mapRgExt.find(ExtProp::FontScheme);
|
||||
|
||||
BYTE font_scheme = (parent->xfext && pFind != parent->xfext->mapRgExt.end()) ? pFind->second.extPropData.font_scheme : 0;
|
||||
{
|
||||
std::wstring name = stFontName.value();
|
||||
|
||||
if (global_info->m_pTheme && font_scheme == 0x01)
|
||||
if (parent && parent->xfext)
|
||||
{
|
||||
BYTE font_scheme = (pFind != parent->xfext->mapRgExt.end()) ? pFind->second.extPropData.font_scheme : 0;
|
||||
|
||||
if (global_info && global_info->m_pTheme && font_scheme == 0x01)
|
||||
{
|
||||
name = global_info->m_pTheme->themeElements.fontScheme.majorFont.latin.typeface;
|
||||
}
|
||||
else if (global_info->m_pTheme && font_scheme == 0x02)
|
||||
else if (global_info && global_info->m_pTheme && font_scheme == 0x02)
|
||||
{
|
||||
name = global_info->m_pTheme->themeElements.fontScheme.minorFont.latin.typeface;
|
||||
}
|
||||
}
|
||||
|
||||
if (!name.empty())
|
||||
{
|
||||
CP_XML_NODE(L"name")
|
||||
{
|
||||
CP_XML_ATTR(L"val", name.substr(0, 31));
|
||||
}
|
||||
}
|
||||
if (stxp.twpHeight > 20)
|
||||
|
||||
if (!extOnly && stxp.twpHeight > 20)
|
||||
{
|
||||
CP_XML_NODE(L"sz")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.twpHeight/20.f);
|
||||
}
|
||||
}
|
||||
if (parent->xfext)
|
||||
if ((parent && parent->xfext) && (pFind == parent->xfext->mapRgExt.end()))
|
||||
pFind = parent->xfext->mapRgExt.find(ExtProp::ForeColor);
|
||||
|
||||
if (parent->xfext && pFind != parent->xfext->mapRgExt.end())
|
||||
if ((parent && parent->xfext) && pFind != parent->xfext->mapRgExt.end())
|
||||
{
|
||||
pFind->second.extPropData.color.serialize(CP_XML_STREAM(), L"color");
|
||||
}
|
||||
@ -121,68 +125,71 @@ int DXFFntD::serialize(std::wostream & stream)
|
||||
CP_XML_ATTR(L"indexed", icvFore);
|
||||
}
|
||||
}
|
||||
CP_XML_NODE(L"charset")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.bCharSet);
|
||||
}
|
||||
//CP_XML_NODE(L"condense")
|
||||
//{
|
||||
// CP_XML_ATTR(L"val", 1);
|
||||
//}
|
||||
//CP_XML_NODE(L"extend")
|
||||
//{
|
||||
// CP_XML_ATTR(L"val", stxp.fExtend);
|
||||
//}
|
||||
CP_XML_NODE(L"family")
|
||||
if (!extOnly)
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.bFamily);
|
||||
}
|
||||
if (tsNinch.ftsItalic == 0)
|
||||
{
|
||||
CP_XML_NODE(L"i")
|
||||
CP_XML_NODE(L"charset")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.ts.ftsItalic);
|
||||
CP_XML_ATTR(L"val", stxp.bCharSet);
|
||||
}
|
||||
}
|
||||
if (fBlsNinch == 0)
|
||||
{
|
||||
CP_XML_NODE(L"b")
|
||||
//CP_XML_NODE(L"condense")
|
||||
//{
|
||||
// CP_XML_ATTR(L"val", 1);
|
||||
//}
|
||||
//CP_XML_NODE(L"extend")
|
||||
//{
|
||||
// CP_XML_ATTR(L"val", stxp.fExtend);
|
||||
//}
|
||||
CP_XML_NODE(L"family")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.bls == 700 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
if (tsNinch.ftsStrikeout == 0)
|
||||
{
|
||||
CP_XML_NODE(L"strike")
|
||||
CP_XML_ATTR(L"val", stxp.bFamily);
|
||||
}
|
||||
if (tsNinch.ftsItalic == 0)
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.ts.ftsStrikeout);
|
||||
}
|
||||
}
|
||||
if (fUlsNinch == 0)
|
||||
{
|
||||
CP_XML_NODE(L"u")
|
||||
{
|
||||
switch(stxp.uls)
|
||||
CP_XML_NODE(L"i")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.ts.ftsItalic);
|
||||
}
|
||||
}
|
||||
if (fBlsNinch == 0)
|
||||
{
|
||||
CP_XML_NODE(L"b")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.bls == 700 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
if (tsNinch.ftsStrikeout == 0)
|
||||
{
|
||||
CP_XML_NODE(L"strike")
|
||||
{
|
||||
CP_XML_ATTR(L"val", stxp.ts.ftsStrikeout);
|
||||
}
|
||||
}
|
||||
if (fUlsNinch == 0)
|
||||
{
|
||||
CP_XML_NODE(L"u")
|
||||
{
|
||||
switch (stxp.uls)
|
||||
{
|
||||
case 0: CP_XML_ATTR(L"val", L"none"); break;
|
||||
case 1: CP_XML_ATTR(L"val", L"single"); break;
|
||||
case 2: CP_XML_ATTR(L"val", L"double"); break;
|
||||
case 33: CP_XML_ATTR(L"val", L"singleAccounting");break;
|
||||
case 34: CP_XML_ATTR(L"val", L"doubleAccounting");break;
|
||||
case 33: CP_XML_ATTR(L"val", L"singleAccounting"); break;
|
||||
case 34: CP_XML_ATTR(L"val", L"doubleAccounting"); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fSssNinch == 0)
|
||||
{
|
||||
CP_XML_NODE(L"vertAlign")
|
||||
if (fSssNinch == 0)
|
||||
{
|
||||
switch(stxp.sss)
|
||||
CP_XML_NODE(L"vertAlign")
|
||||
{
|
||||
switch (stxp.sss)
|
||||
{
|
||||
case 0: CP_XML_ATTR(L"val", L"baseline"); break;
|
||||
case 1: CP_XML_ATTR(L"val", L"superscript");break;
|
||||
case 1: CP_XML_ATTR(L"val", L"superscript"); break;
|
||||
case 2: CP_XML_ATTR(L"val", L"subscript"); break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,26 +50,25 @@ class DXFFntD : public BiffStructure
|
||||
public:
|
||||
BiffStructurePtr clone();
|
||||
|
||||
static const ElementType type = typeDXFFntD;
|
||||
static const ElementType type = typeDXFFntD;
|
||||
|
||||
virtual void load(CFRecord& record);
|
||||
|
||||
int serialize(std::wostream & stream);
|
||||
int serialize(std::wostream & stream, bool extOnly = false);
|
||||
|
||||
XLUnicodeStringNoCch stFontName;
|
||||
|
||||
Stxp stxp;
|
||||
_INT32 icvFore;
|
||||
_INT32 icvFore = 0;
|
||||
|
||||
Ts tsNinch;
|
||||
|
||||
_UINT32 fSssNinch;
|
||||
_UINT32 fUlsNinch;
|
||||
_UINT32 fBlsNinch;
|
||||
|
||||
_INT32 ich;
|
||||
_INT32 cch;
|
||||
_UINT16 iFnt;
|
||||
_UINT32 fSssNinch = 0;
|
||||
_UINT32 fUlsNinch = 0;
|
||||
_UINT32 fBlsNinch = 0;
|
||||
_INT32 ich = 0;
|
||||
_INT32 cch = 0;
|
||||
_UINT16 iFnt = 0;
|
||||
|
||||
//------------------------------------------------
|
||||
GlobalWorkbookInfoPtr global_info;
|
||||
|
||||
@ -122,9 +122,9 @@ int DXFN::serialize(std::wostream & stream)
|
||||
{
|
||||
CP_XML_NODE(L"dxf")
|
||||
{
|
||||
if(ibitAtrFnt)
|
||||
if (ibitAtrFnt || (xfext && (xfext->mapRgExt.end() != xfext->mapRgExt.find(ExtProp::FontScheme))))
|
||||
{
|
||||
dxffntd.serialize(CP_XML_STREAM());
|
||||
dxffntd.serialize(CP_XML_STREAM(), ibitAtrFnt == false);
|
||||
}
|
||||
if(ibitAtrNum)
|
||||
{
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
|
||||
virtual void load(CFRecord& record);
|
||||
|
||||
static const ElementType type = typeExtProp;
|
||||
static const ElementType type = typeExtProp;
|
||||
|
||||
unsigned short cb;
|
||||
|
||||
@ -72,8 +72,8 @@ public:
|
||||
{
|
||||
FullColorExt color;
|
||||
XFExtGradient gradient_fill;
|
||||
unsigned char font_scheme;
|
||||
unsigned short indent_level;
|
||||
unsigned char font_scheme = 0;
|
||||
unsigned short indent_level = 0;
|
||||
|
||||
} extPropData;
|
||||
};
|
||||
|
||||
@ -521,15 +521,15 @@ Ftab_Cetab::ValuesDetermination::ValuesDetermination()
|
||||
params_fixed.insert(ParamsFixed(0x01D6, 4, L"ACCRINTM"));
|
||||
params_fixed.insert(ParamsFixed(0x01D7, 2, L"WORKDAY"));
|
||||
params_fixed.insert(ParamsFixed(0x01D8, 2, L"NETWORKDAYS"));
|
||||
params_fixed.insert(ParamsFixed(0x01D9, 1, L"GCD"));
|
||||
params_fixed.insert(ParamsFixed(0x01D9, -1, L"GCD"));
|
||||
params_fixed.insert(ParamsFixed(0x01DA, 1, L"MULTINOMIAL"));
|
||||
params_fixed.insert(ParamsFixed(0x01DB, 1, L"LCM"));
|
||||
params_fixed.insert(ParamsFixed(0x01DB, -1, L"LCM"));
|
||||
params_fixed.insert(ParamsFixed(0x01DC, 2, L"FVSCHEDULE"));
|
||||
params_fixed.insert(ParamsFixed(0x01DD, 3, L"CUBEKPIMEMBER"));
|
||||
params_fixed.insert(ParamsFixed(0x01DE, 1, L"CUBESET"));
|
||||
params_fixed.insert(ParamsFixed(0x01DF, 1, L"CUBESETCOUNT"));
|
||||
params_fixed.insert(ParamsFixed(0x01E0, 2, L"IFERROR"));
|
||||
params_fixed.insert(ParamsFixed(0x01E1, 2, L"COUNTIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E1, -1, L"COUNTIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E2, 3, L"SUMIFS"));
|
||||
params_fixed.insert(ParamsFixed(0x01E3, 2, L"AVERAGEIF"));
|
||||
params_fixed.insert(ParamsFixed(0x01E4, 3, L"AVERAGEIFS"));
|
||||
|
||||
@ -62,8 +62,14 @@ int FullColorExt::serialize(std::wostream & stream, const std::wstring &node_nam
|
||||
case 0: CP_XML_ATTR(L"auto", 1); break;
|
||||
case 1: CP_XML_ATTR(L"indexed", xclrValue); break;
|
||||
case 3: CP_XML_ATTR(L"theme", xclrValue); break;
|
||||
default:
|
||||
CP_XML_ATTR(L"rgb", xclrValue); break;
|
||||
default:
|
||||
{
|
||||
BYTE r = GETBITS(xclrValue, 0, 7);
|
||||
BYTE g = GETBITS(xclrValue, 8, 15);
|
||||
BYTE b = GETBITS(xclrValue, 16, 23);
|
||||
BYTE a = GETBITS(xclrValue, 24, 31);
|
||||
CP_XML_ATTR(L"rgb", STR::toARGB(r, g, b, a));
|
||||
}break;
|
||||
}
|
||||
if (nTintShade != 0)
|
||||
{
|
||||
|
||||
@ -49,11 +49,11 @@ public:
|
||||
virtual void load(CFRecord& record);
|
||||
int serialize(std::wostream & stream, const std::wstring &sNode);
|
||||
|
||||
static const ElementType type = typeFullColorExt;
|
||||
static const ElementType type = typeFullColorExt;
|
||||
|
||||
unsigned short xclrType;
|
||||
short nTintShade;
|
||||
_UINT32 xclrValue;
|
||||
unsigned short xclrType = 0;
|
||||
short nTintShade = 0;
|
||||
_UINT32 xclrValue = 0;
|
||||
};
|
||||
|
||||
} // namespace XLS
|
||||
|
||||
@ -106,68 +106,68 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
|
||||
switch (rc_header.recType)
|
||||
{
|
||||
case OfficeArtRecord::BlipEMF:
|
||||
{
|
||||
pict_type = L".emf";
|
||||
if (rc_header.recInstance == 0x3D4)
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
else
|
||||
{
|
||||
pict_type = L".emf";
|
||||
if (rc_header.recInstance == 0x3D4)
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
else
|
||||
{
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
rgbUid2 = ReadMD4Digest(record);
|
||||
}
|
||||
|
||||
OfficeArtMetafileHeader metafileHeader;
|
||||
record >> metafileHeader;
|
||||
|
||||
if (metafileHeader.compression == 0)
|
||||
{
|
||||
isCompressed = true;
|
||||
readCompressedData(record, metafileHeader);
|
||||
}
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
rgbUid2 = ReadMD4Digest(record);
|
||||
}
|
||||
break;
|
||||
|
||||
OfficeArtMetafileHeader metafileHeader;
|
||||
record >> metafileHeader;
|
||||
|
||||
if (metafileHeader.compression == 0)
|
||||
{
|
||||
isCompressed = true;
|
||||
readCompressedData(record, metafileHeader);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OfficeArtRecord::BlipWMF:
|
||||
{
|
||||
pict_type = L".wmf";
|
||||
if (rc_header.recInstance == 0x216)
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
else
|
||||
{
|
||||
pict_type = L".wmf";
|
||||
if (rc_header.recInstance == 0x216)
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
else
|
||||
{
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
rgbUid2 = ReadMD4Digest(record);
|
||||
}
|
||||
|
||||
OfficeArtMetafileHeader metafileHeader;
|
||||
record >> metafileHeader;
|
||||
|
||||
if (metafileHeader.compression == 0)
|
||||
{
|
||||
isCompressed = true;
|
||||
readCompressedData(record, metafileHeader);
|
||||
}
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
rgbUid2 = ReadMD4Digest(record);
|
||||
}
|
||||
break;
|
||||
|
||||
OfficeArtMetafileHeader metafileHeader;
|
||||
record >> metafileHeader;
|
||||
|
||||
if (metafileHeader.compression == 0)
|
||||
{
|
||||
isCompressed = true;
|
||||
readCompressedData(record, metafileHeader);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OfficeArtRecord::BlipPICT:
|
||||
{
|
||||
pict_type = L".pcz";
|
||||
if (rc_header.recInstance == 0x542)
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
else
|
||||
{
|
||||
pict_type = L".pcz";
|
||||
if (rc_header.recInstance == 0x542)
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
else
|
||||
{
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
rgbUid2 = ReadMD4Digest(record);
|
||||
}
|
||||
|
||||
OfficeArtMetafileHeader metafileHeader;
|
||||
record >> metafileHeader;
|
||||
|
||||
if (metafileHeader.compression == 0)
|
||||
{
|
||||
isCompressed = true;
|
||||
readCompressedData(record, metafileHeader);
|
||||
}
|
||||
rgbUid1 = ReadMD4Digest(record);
|
||||
rgbUid2 = ReadMD4Digest(record);
|
||||
}
|
||||
break;
|
||||
|
||||
OfficeArtMetafileHeader metafileHeader;
|
||||
record >> metafileHeader;
|
||||
|
||||
if (metafileHeader.compression == 0)
|
||||
{
|
||||
isCompressed = true;
|
||||
readCompressedData(record, metafileHeader);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OfficeArtRecord::BlipJPEG:
|
||||
pict_type = L".jpeg";
|
||||
if ((rc_header.recInstance == 0x46A) || (rc_header.recInstance == 0x6E2))
|
||||
@ -232,7 +232,12 @@ void OfficeArtBStoreContainerFileBlock::load(XLS::CFRecord& record)
|
||||
record.RollRdPtrBack(32);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case 0xf018:
|
||||
{
|
||||
record.skipNunBytes(rc_header.recLen);
|
||||
return;
|
||||
}break;
|
||||
default: //0xf007
|
||||
record.RollRdPtrBack(rc_header.size());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ void PtgArray::loadFields(CFRecord& record)
|
||||
if (record.getGlobalWorkbookInfo()->Version < 0x0800)
|
||||
record.skipNunBytes(7); // unused
|
||||
else
|
||||
record.skipNunBytes(16); // unused
|
||||
record.skipNunBytes(14); // unused
|
||||
}
|
||||
|
||||
void PtgArray::writeFields(CFRecord& record)
|
||||
@ -63,7 +63,7 @@ void PtgArray::writeFields(CFRecord& record)
|
||||
if (record.getGlobalWorkbookInfo()->Version < 0x0800)
|
||||
record.reserveNunBytes(7); // unused
|
||||
else
|
||||
record.reserveNunBytes(16); // unused
|
||||
record.reserveNunBytes(14); // unused
|
||||
}
|
||||
|
||||
void PtgArray::assemble(AssemblerStack& ptg_stack, PtgQueue& extra_data, bool full_ref)
|
||||
|
||||
@ -99,7 +99,9 @@ void PtgExtraArray::save(CFRecord& record)
|
||||
}
|
||||
else
|
||||
{
|
||||
record << cols << rows;
|
||||
cols++;
|
||||
rows++;
|
||||
record << rows << cols;
|
||||
}
|
||||
for (auto& item : array_)
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user