mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Compare commits
30 Commits
v9.2.0.55
...
feature/te
| Author | SHA1 | Date | |
|---|---|---|---|
| a2fc927b39 | |||
| b6f024b73f | |||
| 3870d23511 | |||
| d2527e5707 | |||
| 81b4ba3493 | |||
| 44e217cf7c | |||
| b5f0b39258 | |||
| 3f6a800dd8 | |||
| 1c8ad7a5c4 | |||
| 8464d3aeb7 | |||
| ed939ebd1d | |||
| fe6c5614d4 | |||
| f0b266793f | |||
| 490281dda0 | |||
| b98b808cda | |||
| 6c77718f17 | |||
| 74a2b3b06f | |||
| 8f3e19a5db | |||
| 0019f589bc | |||
| 200c17ee40 | |||
| 4543bfa6cd | |||
| 16e78d87a4 | |||
| 051597a78a | |||
| 13e03328af | |||
| 04ccd4fe27 | |||
| 4b335fc796 | |||
| 5e177412e2 | |||
| dec13334db | |||
| c8ebcfac87 | |||
| 2931c4b53e |
@ -514,9 +514,6 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!arSelectors.back().m_pCompiledStyle->Empty())
|
||||
return true;
|
||||
|
||||
arSelectors.back().m_pCompiledStyle->SetDpi(m_nDpi);
|
||||
unsigned int unStart = 0;
|
||||
|
||||
@ -525,8 +522,8 @@ namespace NSCSS
|
||||
if (itFound != arSelectors.crend())
|
||||
unStart = itFound.base() - arSelectors.cbegin();
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart, arSelectors.size());
|
||||
std::vector<std::wstring> arPrevNodes = CalculateAllNodes(arSelectors, 0, unStart);
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, unStart);
|
||||
std::vector<std::wstring> arPrevNodes;
|
||||
bool bInTable = false;
|
||||
|
||||
for (size_t i = 0; i < unStart; ++i)
|
||||
@ -551,7 +548,6 @@ namespace NSCSS
|
||||
{
|
||||
arSelectors[i].m_pCompiledStyle->m_oBackground.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oBorder.Clear();
|
||||
arSelectors[i].m_pCompiledStyle->m_oDisplay.Clear();
|
||||
}
|
||||
|
||||
arSelectors[i].m_pCompiledStyle->AddStyle(arSelectors[i].m_mAttributes, i + 1);
|
||||
@ -596,14 +592,11 @@ namespace NSCSS
|
||||
}
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart, unsigned int unEnd)
|
||||
std::vector<std::wstring> CCssCalculator_Private::CalculateAllNodes(const std::vector<CNode> &arSelectors, unsigned int unStart)
|
||||
{
|
||||
if ((0 != unEnd && (unEnd < unStart || unEnd > arSelectors.size())) || (unStart == unEnd))
|
||||
return std::vector<std::wstring>();
|
||||
|
||||
std::vector<std::wstring> arNodes;
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin() + ((0 != unEnd) ? (arSelectors.size() - unEnd) : 0); oNode != arSelectors.rend() - unStart; ++oNode)
|
||||
|
||||
for (std::vector<CNode>::const_reverse_iterator oNode = arSelectors.rbegin(); oNode != arSelectors.rend() - unStart; ++oNode)
|
||||
{
|
||||
if (!oNode->m_wsName.empty())
|
||||
arNodes.push_back(oNode->m_wsName);
|
||||
@ -634,7 +627,7 @@ namespace NSCSS
|
||||
if (arNextNodes.empty())
|
||||
return;
|
||||
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.cbegin(), arNextNodes.cend());
|
||||
const std::vector<CElement*> arTempPrev = pElement->GetPrevElements(arNextNodes.crbegin() + 1, arNextNodes.crend());
|
||||
const std::vector<CElement*> arTempKins = pElement->GetNextOfKin(wsName, arClasses);
|
||||
|
||||
if (!arTempPrev.empty())
|
||||
@ -651,19 +644,20 @@ namespace NSCSS
|
||||
|
||||
std::vector<const CElement*> arFindedElements;
|
||||
|
||||
std::wstring wsName, wsClasses, wsId;
|
||||
std::wstring wsName, wsId;
|
||||
std::vector<std::wstring> arClasses;
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'#')
|
||||
{
|
||||
wsId = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsId);
|
||||
}
|
||||
|
||||
if (!arNodes.empty() && arNodes.back()[0] == L'.')
|
||||
{
|
||||
wsClasses = arNodes.back();
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(wsClasses, false, L" ");
|
||||
arClasses = NS_STATIC_FUNCTIONS::GetWordsW(arNodes.back(), false, L" ");
|
||||
arNextNodes.push_back(arNodes.back());
|
||||
arNodes.pop_back();
|
||||
}
|
||||
|
||||
@ -671,6 +665,7 @@ namespace NSCSS
|
||||
{
|
||||
wsName = arNodes.back();
|
||||
arNodes.pop_back();
|
||||
arNextNodes.push_back(wsName);
|
||||
}
|
||||
|
||||
if (!wsId.empty())
|
||||
@ -729,14 +724,6 @@ namespace NSCSS
|
||||
{ return oFirstElement->GetWeight() > oSecondElement->GetWeight(); });
|
||||
}
|
||||
|
||||
if (!wsId.empty())
|
||||
arNextNodes.push_back(wsId);
|
||||
|
||||
if (!wsClasses.empty())
|
||||
arNextNodes.push_back(wsClasses);
|
||||
|
||||
arNextNodes.push_back(wsName);
|
||||
|
||||
return arFindedElements;
|
||||
}
|
||||
|
||||
@ -751,7 +738,7 @@ namespace NSCSS
|
||||
if (arSelectors.empty())
|
||||
return false;
|
||||
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors, 0, arSelectors.size());
|
||||
std::vector<std::wstring> arNodes = CalculateAllNodes(arSelectors);
|
||||
std::vector<std::wstring> arNextNodes;
|
||||
|
||||
for (size_t i = 0; i < arSelectors.size(); ++i)
|
||||
|
||||
@ -110,7 +110,7 @@ namespace NSCSS
|
||||
void ClearPageData();
|
||||
#endif
|
||||
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart, unsigned int unEnd);
|
||||
std::vector<std::wstring> CalculateAllNodes(const std::vector<CNode>& arSelectors, unsigned int unStart = 0);
|
||||
std::vector<const CElement*> FindElements(std::vector<std::wstring>& arNodes, std::vector<std::wstring>& arNextNodes);
|
||||
|
||||
void AddStyles(const std::string& sStyle);
|
||||
|
||||
@ -176,14 +176,14 @@ namespace NSCSS
|
||||
return arElements;
|
||||
}
|
||||
|
||||
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::const_iterator& oNodesBegin, const std::vector<std::wstring>::const_iterator& oNodesEnd) const
|
||||
std::vector<CElement *> CElement::GetPrevElements(const std::vector<std::wstring>::const_reverse_iterator& oNodesRBegin, const std::vector<std::wstring>::const_reverse_iterator& oNodesREnd) const
|
||||
{
|
||||
if (oNodesBegin >= oNodesEnd || m_arPrevElements.empty())
|
||||
if (oNodesRBegin >= oNodesREnd || m_arPrevElements.empty())
|
||||
return std::vector<CElement*>();
|
||||
|
||||
std::vector<CElement*> arElements;
|
||||
|
||||
for (std::vector<std::wstring>::const_iterator iWord = oNodesBegin; iWord != oNodesEnd; ++iWord)
|
||||
for (std::vector<std::wstring>::const_reverse_iterator iWord = oNodesRBegin; iWord != oNodesREnd; ++iWord)
|
||||
{
|
||||
if ((*iWord)[0] == L'.' && ((*iWord).find(L" ") != std::wstring::npos))
|
||||
{
|
||||
@ -195,7 +195,7 @@ namespace NSCSS
|
||||
if (oPrevElement->m_sSelector == wsClass)
|
||||
{
|
||||
arElements.push_back(oPrevElement);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesEnd);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesREnd);
|
||||
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
|
||||
}
|
||||
}
|
||||
@ -208,8 +208,9 @@ namespace NSCSS
|
||||
if (oPrevElement->m_sSelector == *iWord)
|
||||
{
|
||||
arElements.push_back(oPrevElement);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesEnd);
|
||||
std::vector<CElement*> arTempElements = oPrevElement->GetPrevElements(iWord + 1, oNodesREnd);
|
||||
arElements.insert(arElements.end(), arTempElements.begin(), arTempElements.end());
|
||||
// return arElements;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ namespace NSCSS
|
||||
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<CNode>& arSelectors) const;
|
||||
std::map<std::wstring, std::wstring> GetFullStyle(const std::vector<std::wstring>& arNodes) const;
|
||||
std::vector<CElement *> GetNextOfKin(const std::wstring& sName, const std::vector<std::wstring>& arClasses = {}) const;
|
||||
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::const_iterator& oNodesBegin, const std::vector<std::wstring>::const_iterator& oNodesEnd) const;
|
||||
std::vector<CElement *> GetPrevElements(const std::vector<std::wstring>::const_reverse_iterator& oNodesRBegin, const std::vector<std::wstring>::const_reverse_iterator& oNodesREnd) const;
|
||||
std::map<std::wstring, std::wstring> GetConvertStyle(const std::vector<CNode>& arNodes) const;
|
||||
|
||||
CElement *FindPrevElement(const std::wstring& sSelector) const;
|
||||
|
||||
@ -18,7 +18,6 @@ namespace NSCSS
|
||||
std::wstring m_wsId; // Id тэга
|
||||
std::wstring m_wsStyle; // Стиль тэга
|
||||
std::map<std::wstring, std::wstring> m_mAttributes; // Остальные аттрибуты тэга
|
||||
//TODO:: возможно использование std::wstring излишне
|
||||
|
||||
#ifdef CSS_CALCULATOR_WITH_XHTML
|
||||
CCompiledStyle *m_pCompiledStyle;
|
||||
|
||||
@ -436,13 +436,12 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDigit::SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CDigit::SetValue(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
if (CHECK_CONDITIONS && !bHardMode)
|
||||
return false;
|
||||
|
||||
m_enUnitMeasure = enUnitMeasure;
|
||||
m_oValue = dValue;
|
||||
m_oValue = dValue;
|
||||
|
||||
if (UINT_MAX == unLevel)
|
||||
m_unLevel++;
|
||||
@ -1327,23 +1326,6 @@ namespace NSCSS
|
||||
return true;
|
||||
}
|
||||
|
||||
CMatrix& CMatrix::operator+=(const CMatrix& oMatrix)
|
||||
{
|
||||
m_oValue.insert(m_oValue.end(), oMatrix.m_oValue.begin(), oMatrix.m_oValue.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
CMatrix& CMatrix::operator-=(const CMatrix& oMatrix)
|
||||
{
|
||||
for (MatrixValues::const_reverse_iterator itElement = oMatrix.m_oValue.crbegin(); itElement < oMatrix.m_oValue.crend(); ++itElement)
|
||||
{
|
||||
if (!m_oValue.empty() && m_oValue.back() == *itElement)
|
||||
m_oValue.pop_back();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// DISPLAY
|
||||
CDisplay::CDisplay()
|
||||
{
|
||||
@ -1483,21 +1465,6 @@ namespace NSCSS
|
||||
(m_eWhiteSpace.Empty() || m_eWhiteSpace == EWhiteSpace::Normal);
|
||||
}
|
||||
|
||||
void CDisplay::Clear()
|
||||
{
|
||||
m_oX.Clear();
|
||||
m_oY.Clear();
|
||||
m_oWidth.Clear();
|
||||
m_oHeight.Clear();
|
||||
|
||||
m_oHAlign.Clear();
|
||||
m_oVAlign.Clear();
|
||||
|
||||
m_oDisplay.Clear();
|
||||
|
||||
m_eWhiteSpace.Clear();
|
||||
}
|
||||
|
||||
CDisplay &CDisplay::operator+=(const CDisplay &oDisplay)
|
||||
{
|
||||
m_oX += oDisplay.m_oX;
|
||||
@ -1776,9 +1743,9 @@ namespace NSCSS
|
||||
return m_oWidth.SetValue(wsNewValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorderSide::SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CBorderSide::SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oWidth.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oWidth.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorderSide::SetStyle(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -1954,14 +1921,14 @@ namespace NSCSS
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool CBorder::SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CBorder::SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
if (m_oLeft .SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oTop .SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oRight .SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oBottom.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oLeft .SetWidth(dValue, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oTop .SetWidth(dValue, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oRight .SetWidth(dValue, unLevel, bHardMode)) bResult = true;
|
||||
if (m_oBottom.SetWidth(dValue, unLevel, bHardMode)) bResult = true;
|
||||
|
||||
return bResult;
|
||||
}
|
||||
@ -2005,9 +1972,9 @@ namespace NSCSS
|
||||
return m_oLeft.SetWidth(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetWidthLeftSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CBorder::SetWidthLeftSide(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oLeft.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oLeft.SetWidth(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetStyleLeftSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -2030,9 +1997,9 @@ namespace NSCSS
|
||||
return m_oTop.SetWidth(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetWidthTopSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CBorder::SetWidthTopSide(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oTop.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oTop.SetWidth(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetStyleTopSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -2055,9 +2022,9 @@ namespace NSCSS
|
||||
return m_oRight.SetWidth(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetWidthRightSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CBorder::SetWidthRightSide(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oRight.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oRight.SetWidth(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetStyleRightSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -2080,9 +2047,9 @@ namespace NSCSS
|
||||
return m_oBottom.SetWidth(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetWidthBottomSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CBorder::SetWidthBottomSide(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oBottom.SetWidth(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oBottom.SetWidth(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CBorder::SetStyleBottomSide(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -2381,49 +2348,39 @@ namespace NSCSS
|
||||
return m_oTop.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetTop(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oTop.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetRight(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oRight.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetRight(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oRight.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetBottom(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oBottom.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetBottom(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oBottom.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetLeft(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oLeft.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetValues(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CIndent::SetLeft(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
const bool bTopResult = SetTop (dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
const bool bRightResult = SetRight (dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
const bool bBottomResult = SetBottom (dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
const bool bLeftResult = SetLeft (dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
|
||||
return bTopResult || bRightResult || bBottomResult || bLeftResult;
|
||||
}
|
||||
|
||||
bool CIndent::SetTop(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oTop.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetRight(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oRight.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetBottom(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oBottom.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CIndent::SetLeft(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oLeft.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oLeft.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CIndent::UpdateAll(const double& dParentFontSize, const double& dCoreFontSize)
|
||||
@ -2715,9 +2672,9 @@ namespace NSCSS
|
||||
return m_oSize.SetValue(wsNewValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CFont:: SetSize(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
bool CFont:: SetSize(const double& dValue, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oSize.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
return m_oSize.SetValue(dValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CFont::SetLineHeight(const std::wstring &wsValue, unsigned int unLevel, bool bHardMode)
|
||||
@ -3042,31 +2999,6 @@ namespace NSCSS
|
||||
return m_oHeader.SetValue(wsValue, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CPage::SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oWidth.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CPage::SetHeight(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oHeight.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CPage::SetMargin(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oMargin.SetValues(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CPage::SetFooter(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oFooter.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
bool CPage::SetHeader(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode)
|
||||
{
|
||||
return m_oHeader.SetValue(dValue, enUnitMeasure, unLevel, bHardMode);
|
||||
}
|
||||
|
||||
const CDigit &CPage::GetWidth() const
|
||||
{
|
||||
return m_oWidth;
|
||||
|
||||
@ -138,7 +138,7 @@ namespace NSCSS
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel = 0, bool bHardMode = true) override;
|
||||
bool SetValue(const CDigit& oValue);
|
||||
bool SetValue(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel = 0, bool bHardMode = true);
|
||||
bool SetValue(const double& dValue, unsigned int unLevel, bool bHardMode);
|
||||
|
||||
bool Empty() const override;
|
||||
bool Zero() const;
|
||||
@ -302,8 +302,6 @@ namespace NSCSS
|
||||
void ApplyTranform(Aggplus::CMatrix& oMatrix, Aggplus::MatrixOrder order = Aggplus::MatrixOrderPrepend) const;
|
||||
|
||||
bool operator==(const CMatrix& oMatrix) const;
|
||||
CMatrix& operator+=(const CMatrix& oMatrix);
|
||||
CMatrix& operator-=(const CMatrix& oMatrix);
|
||||
};
|
||||
|
||||
class CEnum : public CValue<int>
|
||||
@ -373,7 +371,6 @@ namespace NSCSS
|
||||
const CEnum& GetWhiteSpace() const;
|
||||
|
||||
bool Empty() const;
|
||||
void Clear();
|
||||
|
||||
CDisplay& operator+=(const CDisplay& oDisplay);
|
||||
bool operator==(const CDisplay& oDisplay) const;
|
||||
@ -475,7 +472,7 @@ namespace NSCSS
|
||||
|
||||
bool SetValue(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
@ -527,7 +524,7 @@ namespace NSCSS
|
||||
|
||||
bool SetSides(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidth(const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyle(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColor(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetCollapse(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
@ -535,28 +532,28 @@ namespace NSCSS
|
||||
//Left Side
|
||||
bool SetLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthLeftSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorLeftSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Top Side
|
||||
bool SetTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthTopSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorTopSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Right Side
|
||||
bool SetRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthRightSide (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorRightSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
//Bottom Side
|
||||
bool SetBottomSide (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetWidthBottomSide(const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStyleBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetColorBottomSide(const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
@ -669,15 +666,13 @@ namespace NSCSS
|
||||
|
||||
bool SetValues (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetValues (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetTop (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetRight (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetBottom (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLeft (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
void UpdateAll (const double& dParentFontSize, const double& dCoreFontSize);
|
||||
void UpdateTop (const double& dParentFontSize, const double& dCoreFontSize);
|
||||
@ -690,9 +685,6 @@ namespace NSCSS
|
||||
const CDigit& GetBottom() const;
|
||||
const CDigit& GetLeft () const;
|
||||
|
||||
bool GetAfterAutospacing () const;
|
||||
bool GetBeforeAutospacing() const;
|
||||
|
||||
bool Empty() const;
|
||||
bool Zero() const;
|
||||
|
||||
@ -720,7 +712,7 @@ namespace NSCSS
|
||||
|
||||
bool SetValue (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetSize (const double& dValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetLineHeight (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFamily (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetStretch (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
@ -770,12 +762,6 @@ namespace NSCSS
|
||||
bool SetFooter (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHeader (const std::wstring& wsValue, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
bool SetWidth (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHeight (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetMargin (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetFooter (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
bool SetHeader (const double& dValue, UnitMeasure enUnitMeasure, unsigned int unLevel, bool bHardMode = false);
|
||||
|
||||
const CDigit& GetWidth() const;
|
||||
const CDigit& GetHeight() const;
|
||||
const CIndent& GetMargin() const;
|
||||
|
||||
@ -341,14 +341,14 @@ namespace NSCSS
|
||||
sSpacingValue.reserve(128);
|
||||
|
||||
if (!oStyle.m_oMargin.GetTop().Empty() && !oStyle.m_oMargin.GetTop().Zero())
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"1\"";
|
||||
sSpacingValue += L"w:before=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetTop(), NSCSS::Twips)) + L"\" w:beforeAutospacing=\"0\"";
|
||||
else if (oStyle.m_oMargin.GetBottom().Zero() || bInTable)
|
||||
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"1\"";
|
||||
sSpacingValue += L"w:before=\"0\" w:beforeAutospacing=\"0\"";
|
||||
|
||||
if (!oStyle.m_oMargin.GetBottom().Empty() && !oStyle.m_oMargin.GetBottom().Zero())
|
||||
sSpacingValue += L" w:after=\"" + std::to_wstring(VALUE_TO_INT(oStyle.m_oMargin.GetBottom(), NSCSS::Twips)) + L"\" w:afterAutospacing=\"1\"";
|
||||
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\" w:afterAutospacing=\"1\"";
|
||||
sSpacingValue += L" w:after=\"0\" w:afterAutospacing=\"0\"";
|
||||
|
||||
if (!oStyle.m_oFont.GetLineHeight().Empty() && !oStyle.m_oFont.GetLineHeight().Zero())
|
||||
{
|
||||
|
||||
@ -39,18 +39,19 @@ void WriteBaseHtmlStyles(NSFile::CFileBinary& oFile)
|
||||
oFile.WriteStringUTF8(L"table { margin-bottom: 20px; width: 100%; max-width: 100%; border-spacing:0; border-collapse: collapse; border-color: gray;}");
|
||||
oFile.WriteStringUTF8(L"thead { display: table-header-group; vertical-align: middle; }");
|
||||
oFile.WriteStringUTF8(L"tr { display: table-row; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: center; display: table-cell; font-weight: bold; }");
|
||||
oFile.WriteStringUTF8(L"th { text-align: left; display: table-cell; font-weight: bold; }");
|
||||
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table thead tr td { vertical-align: bottom; border-bottom: 2px solid #ddd; border-top: none; }");
|
||||
oFile.WriteStringUTF8(L"table tbody tr th, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th { vertical-align: bottom; border-bottom: 2px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table thead tr th, table tbody tr th, table thead tr td, table tbody tr td { padding 8px; line-height: 1.4; vertical-align: top; border-top: 1px solid #ddd; }");
|
||||
oFile.WriteStringUTF8(L"table > caption + thead > tr > th, table > colgroup + thead > tr > th, table > thead > tr > th, table > caption + thead > tr > td, table > colgroup + thead > tr > td, table > thead > tr > td { border-top: 0; }");
|
||||
|
||||
// Styles for blockquote
|
||||
oFile.WriteStringUTF8(L"blockquote { border-left: 3px solid #e9e9e9; margin: 1.5em 0; padding: 0.5em 10px 0.5em 24px; font-size: 1.25rem; display: block; margin-top: 8pt; font-style: italic; color: #404040; }");
|
||||
|
||||
// Styles for code
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; border-radius: 0; background-color: #f8f8f8; color:black; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f8f8f8; border: none; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code { padding: 2px 4px; font-size: 90%; color: #c7254e; background-color: #f9f2f4; border-radius: 4px; }");
|
||||
oFile.WriteStringUTF8(L"pre code { padding: 0px; white-space: pre-wrap; border-radius: 0; background-color: #f5f5f5; color:black; }");
|
||||
oFile.WriteStringUTF8(L"pre { display: block; padding: 9.5px; margin: 0 0 10px; line-height: 1.4; word-break: break-all; word-wrap: break-word; background-color: #f5f5f5; border: 1px solid #ccc; border-radius: 4px; font-size: 1em; }");
|
||||
oFile.WriteStringUTF8(L"code, pre { font-family: Menlo, Monaco, Consolas, \"Courier New\", monospace; }");
|
||||
|
||||
// Styles for headings
|
||||
@ -87,7 +88,7 @@ bool ConvertMdFileToHtml(const std::wstring& wsPathToMdFile, const std::wstring&
|
||||
bool bResult = true;
|
||||
|
||||
if (0 != md_html(sMdData.c_str(), sMdData.length(), ToHtmlFile, &oFile,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM | MD_FLAG_HARD_SOFT_BREAKS,
|
||||
MD_DIALECT_GITHUB | MD_FLAG_NOINDENTEDCODEBLOCKS | MD_HTML_FLAG_SKIP_UTF8_BOM,
|
||||
0))
|
||||
bResult = false;
|
||||
|
||||
|
||||
1
Common/3dParty/socketio/.gitignore
vendored
1
Common/3dParty/socketio/.gitignore
vendored
@ -1,2 +1 @@
|
||||
socket.io-client-cpp/
|
||||
socketio.data
|
||||
@ -1,5 +0,0 @@
|
||||
<<<<<<<
|
||||
if((c >= 'a' && c <= 'z') || (c>= 'A' && c<= 'Z') || (c >= '0' && c<= '9')){
|
||||
=======
|
||||
if((c >= 'a' && c <= 'z') || (c>= 'A' && c<= 'Z') || (c >= '0' && c<= '9') || ('-' == c) || ('_' == c) || ('.' == c) || ('~' == c)){
|
||||
>>>>>>>
|
||||
@ -69,7 +69,6 @@ public:
|
||||
bool isOpenOfficeFormatFile(const std::wstring& fileName, std::wstring& documentID);
|
||||
bool isOnlyOfficeFormatFile(const std::wstring& fileName);
|
||||
bool isMacFormatFile(const std::wstring& fileName);
|
||||
bool isHwpxFile(const std::wstring& fileName);
|
||||
|
||||
bool isDocFormatFile(const std::wstring& fileName);
|
||||
bool isXlsFormatFile(const std::wstring& fileName);
|
||||
@ -100,7 +99,6 @@ public:
|
||||
bool isPdfFormatFile(unsigned char* pBuffer, int dwBytes, std::wstring& documentID);
|
||||
bool isPdfOformFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isOpenOfficeFlatFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isHwpmlFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
bool isBinaryDoctFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
bool isBinaryXlstFormatFile(unsigned char* pBuffer, int dwBytes);
|
||||
|
||||
@ -467,18 +467,15 @@ bool COfficeFileFormatChecker::isHwpFile(POLE::Storage* storage)
|
||||
if (storage == NULL)
|
||||
return false;
|
||||
|
||||
unsigned char buffer[17];
|
||||
unsigned char buffer[10];
|
||||
|
||||
POLE::Stream stream(storage, L"FileHeader");
|
||||
|
||||
static constexpr const char* hwpFormatLine = "HWP Document File";
|
||||
|
||||
if (17 == stream.read(buffer, 17) && NULL != strstr((char*)buffer, hwpFormatLine))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
POLE::Stream stream(storage, L"BodyText/Section0");
|
||||
if (stream.read(buffer, 10) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isXlsFormatFile(POLE::Storage *storage)
|
||||
{
|
||||
if (storage == NULL)
|
||||
@ -814,13 +811,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
else if (isHwpxFile(fileName))
|
||||
{
|
||||
if (bufferDetect)
|
||||
delete[] bufferDetect;
|
||||
bufferDetect = NULL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
@ -900,10 +890,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_MHT;
|
||||
}
|
||||
else if (isHwpmlFile(bufferDetect, sizeRead))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
file.CloseFile();
|
||||
}
|
||||
@ -973,8 +959,6 @@ bool COfficeFileFormatChecker::isOfficeFile(const std::wstring &_fileName)
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
else if (0 == sExt.compare(L".hwpx"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
else if (0 == sExt.compare(L".hml"))
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML;
|
||||
|
||||
if (nFileType != AVS_OFFICESTUDIO_FILE_UNKNOWN)
|
||||
return true;
|
||||
@ -1419,31 +1403,6 @@ bool COfficeFileFormatChecker::isMacFormatFile(const std::wstring& fileName)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isHwpxFile(const std::wstring &fileName)
|
||||
{
|
||||
COfficeUtils oOfficeUtils;
|
||||
|
||||
ULONG unSize = 0;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
HRESULT hresult = oOfficeUtils.LoadFileFromArchive(fileName, L"mimetype", &pBuffer, unSize);
|
||||
|
||||
if (hresult != S_OK || NULL == pBuffer)
|
||||
return false;
|
||||
|
||||
static constexpr const char* hwpxFormatLine = "application/hwp+zip";
|
||||
bool bResult = false;
|
||||
|
||||
if (19 <= unSize && NULL != strstr((char *)pBuffer, hwpxFormatLine))
|
||||
{
|
||||
nFileType = AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
bResult = true;
|
||||
}
|
||||
|
||||
delete[] pBuffer;
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOpenOfficeFormatFile(const std::wstring &fileName, std::wstring &documentID)
|
||||
{
|
||||
documentID.clear();
|
||||
@ -1609,28 +1568,6 @@ bool COfficeFileFormatChecker::isOpenOfficeFlatFormatFile(unsigned char *pBuffer
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isHwpmlFile(unsigned char *pBuffer, int dwBytes)
|
||||
{
|
||||
if (NULL == pBuffer || dwBytes < 8)
|
||||
return false;
|
||||
|
||||
for (unsigned int unPos = 0; unPos < dwBytes - 8; ++unPos)
|
||||
{
|
||||
if ('<' != pBuffer[unPos])
|
||||
continue;
|
||||
|
||||
if (dwBytes - unPos >= 15 && '!' == pBuffer[unPos + 1] &&
|
||||
0 == memcmp(&pBuffer[unPos], "<!DOCTYPE HWPML", 15))
|
||||
return true;
|
||||
|
||||
if (dwBytes - unPos >= 6 && 0 == memcmp(&pBuffer[unPos], "<HWPML", 6))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool COfficeFileFormatChecker::isOOXFlatFormatFile(unsigned char *pBuffer, int dwBytes)
|
||||
{
|
||||
if (dwBytes < 8)
|
||||
@ -1739,8 +1676,6 @@ std::wstring COfficeFileFormatChecker::GetExtensionByType(int type)
|
||||
return L".hwp";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX:
|
||||
return L".hwpx";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML:
|
||||
return L".hml";
|
||||
case AVS_OFFICESTUDIO_FILE_DOCUMENT_MD:
|
||||
return L".md";
|
||||
|
||||
@ -1926,8 +1861,6 @@ int COfficeFileFormatChecker::GetFormatByExtension(const std::wstring &sExt)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP;
|
||||
if (L".hwpx" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX;
|
||||
if (L".hml" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML;
|
||||
if (L".md" == ext)
|
||||
return AVS_OFFICESTUDIO_FILE_DOCUMENT_MD;
|
||||
|
||||
|
||||
@ -59,8 +59,7 @@
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_PAGES AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0018
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWP AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0019
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPX AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001a
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_HWPML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001c
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_MD AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x001b
|
||||
|
||||
#define AVS_OFFICESTUDIO_FILE_DOCUMENT_XML AVS_OFFICESTUDIO_FILE_DOCUMENT + 0x0030
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@ win32 {
|
||||
}
|
||||
|
||||
DEFINES += COPYRIGHT_YEAR=$${CURRENT_YEAR}
|
||||
#DEFINES += _LOGOUT_ALWAYS
|
||||
|
||||
QMAKE_TARGET_COMPANY = $$PUBLISHER_NAME
|
||||
QMAKE_TARGET_COPYRIGHT = © $${PUBLISHER_NAME} $${CURRENT_YEAR}. All rights reserved.
|
||||
@ -216,8 +215,7 @@ core_linux {
|
||||
QMAKE_LINK = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
QMAKE_LINK_SHLIB = $$join(QMAKE_CUSTOM_SYSROOT_BIN, , , "g++")
|
||||
|
||||
QMAKE_CFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_CXXFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
QMAKE_LFLAGS += --sysroot $$QMAKE_CUSTOM_SYSROOT
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,11 +29,11 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#ifndef _SYSTEMUTILS_H
|
||||
#define _SYSTEMUTILS_H
|
||||
|
||||
#include <string>
|
||||
#include "../../Common/kernel_config.h"
|
||||
#include "../../OdfFile/Common/logging.h"
|
||||
|
||||
#define VALUE_STRINGIFY(d) L##d
|
||||
#define VALUE_TO_STR(v) VALUE_STRINGIFY(v)
|
||||
@ -59,7 +59,7 @@ namespace NSSystemUtils
|
||||
static const wchar_t* gc_EnvLastModifiedBy = L"LAST_MODIFIED_BY";
|
||||
static const wchar_t* gc_EnvModified = L"MODIFIED";
|
||||
static const wchar_t* gc_EnvMemoryLimit = L"X2T_MEMORY_LIMIT";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"4GiB";
|
||||
static const wchar_t* gc_EnvMemoryLimitDefault = L"3GiB";
|
||||
|
||||
KERNEL_DECL std::string GetEnvVariableA(const std::wstring& strName);
|
||||
KERNEL_DECL std::wstring GetEnvVariable(const std::wstring& strName);
|
||||
@ -76,3 +76,4 @@ namespace NSSystemUtils
|
||||
};
|
||||
KERNEL_DECL std::wstring GetSystemDirectory(const SystemDirectoryType& type);
|
||||
}
|
||||
#endif // _SYSTEMUTILS_H
|
||||
|
||||
@ -311,28 +311,6 @@ public:
|
||||
return ((CPdfFile*)m_pFile)->UnmergePages();
|
||||
return false;
|
||||
}
|
||||
bool RedactPage(int nPageIndex, double* arrRedactBox, int nLengthX8, BYTE* data, int size, bool bCopy = false)
|
||||
{
|
||||
if (m_nType == 0)
|
||||
{
|
||||
// Память из CDrawingFileEmbed освобождается сразу после вызова функции, поэтому копируем
|
||||
if (bCopy)
|
||||
{
|
||||
BYTE* pCopy = (BYTE*)malloc(size);
|
||||
memcpy(pCopy, data, size);
|
||||
data = pCopy;
|
||||
}
|
||||
// Захватывает полученную память data
|
||||
return ((CPdfFile*)m_pFile)->RedactPage(nPageIndex, arrRedactBox, nLengthX8, data, size);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool UndoRedact()
|
||||
{
|
||||
if (m_nType == 0)
|
||||
return ((CPdfFile*)m_pFile)->UndoRedact();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE* GetGlyphs(int nPageIndex)
|
||||
{
|
||||
|
||||
@ -207,40 +207,6 @@ JSSmart<CJSValue> CDrawingFileEmbed::UnmergePages()
|
||||
return CJSContext::createBool(m_pFile->UnmergePages());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::RedactPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> arrRedactBox, JSSmart<CJSValue> dataFiller)
|
||||
{
|
||||
bool result = false;
|
||||
if (m_pFile)
|
||||
{
|
||||
int pageIndex = nPageIndex->toInt32();
|
||||
|
||||
JSSmart<CJSArray> arrBox = arrRedactBox->toArray();
|
||||
int nCountBox = arrBox->getCount();
|
||||
double* pBox = NULL;
|
||||
if (0 < nCountBox)
|
||||
pBox = new double[nCountBox];
|
||||
|
||||
for (int i = 0; i < nCountBox; i++)
|
||||
pBox[i] = arrBox->get(i)->toDouble();
|
||||
|
||||
JSSmart<CJSTypedArray> dataPtr = dataFiller->toTypedArray();
|
||||
CJSDataBuffer buffer = dataPtr->getData();
|
||||
|
||||
result = m_pFile->RedactPage(pageIndex, pBox, nCountBox / 8, buffer.Data, (int)buffer.Len, true);
|
||||
|
||||
if (pBox)
|
||||
delete[] pBox;
|
||||
if (buffer.IsExternalize)
|
||||
buffer.Free();
|
||||
}
|
||||
return CJSContext::createBool(result);
|
||||
}
|
||||
JSSmart<CJSValue> CDrawingFileEmbed::UndoRedact()
|
||||
{
|
||||
if (m_pFile)
|
||||
return CJSContext::createBool(m_pFile->UndoRedact());
|
||||
return CJSContext::createBool(false);
|
||||
}
|
||||
|
||||
bool EmbedDrawingFile(JSSmart<NSJSBase::CJSContext>& context, IOfficeDrawingFile* pFile)
|
||||
{
|
||||
|
||||
@ -54,8 +54,6 @@ public:
|
||||
JSSmart<CJSValue> SplitPages(JSSmart<CJSValue> arrPageIndexes, JSSmart<CJSValue> data);
|
||||
JSSmart<CJSValue> MergePages(JSSmart<CJSValue> data, JSSmart<CJSValue> nMaxID, JSSmart<CJSValue> sPrefixForm);
|
||||
JSSmart<CJSValue> UnmergePages();
|
||||
JSSmart<CJSValue> RedactPage(JSSmart<CJSValue> nPageIndex, JSSmart<CJSValue> arrRedactBox, JSSmart<CJSValue> dataFiller);
|
||||
JSSmart<CJSValue> UndoRedact();
|
||||
|
||||
DECLARE_EMBED_METHODS
|
||||
};
|
||||
|
||||
@ -33,8 +33,6 @@ namespace NSDrawingFileEmbed
|
||||
FUNCTION_WRAPPER_V8_2(_SplitPages, SplitPages)
|
||||
FUNCTION_WRAPPER_V8_3(_MergePages, MergePages)
|
||||
FUNCTION_WRAPPER_V8_0(_UnmergePages, UnmergePages)
|
||||
FUNCTION_WRAPPER_V8_3(_RedactPage, RedactPage)
|
||||
FUNCTION_WRAPPER_V8_0(_UndoRedact, UndoRedact)
|
||||
|
||||
v8::Handle<v8::ObjectTemplate> CreateTemplate(v8::Isolate* isolate)
|
||||
{
|
||||
@ -67,8 +65,6 @@ namespace NSDrawingFileEmbed
|
||||
NSV8Objects::Template_Set(result, "SplitPages", _SplitPages);
|
||||
NSV8Objects::Template_Set(result, "MergePages", _MergePages);
|
||||
NSV8Objects::Template_Set(result, "UnmergePages", _UnmergePages);
|
||||
NSV8Objects::Template_Set(result, "RedactPage", _RedactPage);
|
||||
NSV8Objects::Template_Set(result, "UndoRedact", _UndoRedact);
|
||||
|
||||
return handle_scope.Escape(result);
|
||||
}
|
||||
|
||||
@ -1046,28 +1046,6 @@ int CFontFile::GetGIDByUnicode(int code)
|
||||
return unGID;
|
||||
}
|
||||
|
||||
int CFontFile::GetUnicodeByGID(int gid)
|
||||
{
|
||||
if (!m_pFace)
|
||||
return 0;
|
||||
|
||||
FT_ULong charcode;
|
||||
FT_UInt gindex;
|
||||
|
||||
charcode = FT_Get_First_Char(m_pFace, &gindex);
|
||||
|
||||
while (gindex != 0)
|
||||
{
|
||||
if (gindex == gid)
|
||||
{
|
||||
return charcode;
|
||||
}
|
||||
charcode = FT_Get_Next_Char(m_pFace, charcode, &gindex);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
INT CFontFile::GetString(CGlyphString& oString)
|
||||
{
|
||||
int nCountGlyph = oString.GetLength();
|
||||
|
||||
@ -254,7 +254,6 @@ public:
|
||||
double GetCharWidth(int gid);
|
||||
|
||||
int GetGIDByUnicode(int code);
|
||||
int GetUnicodeByGID(int gid);
|
||||
|
||||
int GetKerning(FT_UInt unPrevGID, FT_UInt unGID);
|
||||
void SetStringGID(const INT& bGID);
|
||||
|
||||
@ -851,14 +851,6 @@ unsigned int CFontManager::GetGIDByUnicode(const unsigned int& unCode)
|
||||
|
||||
return m_pFont->GetGIDByUnicode(unCode);
|
||||
}
|
||||
int CFontManager::GetUnicodeByGID(const int& gid)
|
||||
{
|
||||
if (!m_pFont)
|
||||
return 0;
|
||||
|
||||
return m_pFont->GetUnicodeByGID(gid);
|
||||
}
|
||||
|
||||
void CFontManager::SetSubpixelRendering(const bool& hmul, const bool& vmul)
|
||||
{
|
||||
if (hmul)
|
||||
|
||||
@ -186,7 +186,6 @@ public:
|
||||
virtual std::wstring GetFontType();
|
||||
virtual unsigned int GetNameIndex(const std::wstring& wsName);
|
||||
virtual unsigned int GetGIDByUnicode(const unsigned int& unCode);
|
||||
virtual int GetUnicodeByGID(const int& gid);
|
||||
|
||||
virtual void SetSubpixelRendering(const bool& hmul, const bool& vmul);
|
||||
|
||||
|
||||
@ -758,36 +758,12 @@ CGraphicsPath&& CBooleanOperations::GetResult()
|
||||
return std::move(Result);
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IsSelfInters(const CGraphicsPath& p)
|
||||
{
|
||||
PreparePath(p, 1, Segments1, Curves1);
|
||||
PreparePath(p, 2, Segments2, Curves2);
|
||||
|
||||
OriginCurves1 = Curves1;
|
||||
OriginCurves2 = Curves2;
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (Locations.empty())
|
||||
return false;
|
||||
else
|
||||
{
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
if (!isZero(l->Time) && !isZero(l->Time - 1.0) && l->C.Segment2.Index != l->Inters->C.Segment1.Index)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void CBooleanOperations::TraceBoolean()
|
||||
{
|
||||
bool reverse = false;
|
||||
bool self = Path1 == Path2;
|
||||
if (((Op == Subtraction || Op == Exclusion) ^
|
||||
Path1.IsClockwise() ^
|
||||
Path2.IsClockwise()) && !self)
|
||||
if ((Op == Subtraction || Op == Exclusion) ^
|
||||
Path1.IsClockwise() ^
|
||||
Path2.IsClockwise())
|
||||
reverse = true;
|
||||
|
||||
PreparePath(Path1, 1, Segments1, Curves1);
|
||||
@ -798,32 +774,6 @@ void CBooleanOperations::TraceBoolean()
|
||||
|
||||
GetIntersection();
|
||||
|
||||
if (self)
|
||||
{
|
||||
if (Op == Subtraction)
|
||||
return;
|
||||
|
||||
std::vector<std::vector<int>> adj_matr(Locations.size());
|
||||
|
||||
for (size_t i = 0; i < Locations.size(); i++)
|
||||
{
|
||||
std::vector<int> adj_vec;
|
||||
|
||||
if (CheckLocation(Locations[i], true))
|
||||
adj_vec.push_back(Locations[i]->C.Segment1.Index);
|
||||
if (CheckLocation(Locations[i], false))
|
||||
adj_vec.push_back(Locations[i]->C.Segment2.Index);
|
||||
if (CheckLocation(Locations[i]->Inters, true))
|
||||
adj_vec.push_back(Locations[i]->Inters->C.Segment1.Index);
|
||||
if (CheckLocation(Locations[i]->Inters, false))
|
||||
adj_vec.push_back(Locations[i]->Inters->C.Segment2.Index);
|
||||
adj_matr[i] = adj_vec;
|
||||
}
|
||||
|
||||
CreateNewPath(adj_matr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Locations.empty())
|
||||
{
|
||||
int length = static_cast<int>(Locations.size());
|
||||
@ -852,16 +802,6 @@ void CBooleanOperations::TraceBoolean()
|
||||
TraceAllOverlap();
|
||||
return;
|
||||
}
|
||||
if (IsOneCurvePath(1))
|
||||
{
|
||||
TraceOneCurvePath1();
|
||||
return;
|
||||
}
|
||||
if (IsOneCurvePath(2))
|
||||
{
|
||||
TraceOneCurvePath2();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SetWinding();
|
||||
@ -1068,100 +1008,6 @@ void CBooleanOperations::TraceAllOverlap()
|
||||
}
|
||||
}
|
||||
|
||||
void CBooleanOperations::TraceOneCurvePath1()
|
||||
{
|
||||
if (Op == Intersection)
|
||||
{
|
||||
Result.StartFigure();
|
||||
for (const auto& s : Segments1)
|
||||
{
|
||||
if (s.Inters && Result.GetPointCount() == 0)
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
Segment s2 = GetNextSegment(s);
|
||||
if (s2.IsCurve)
|
||||
Result.CurveTo(s2.HI.X + s2.P.X, s2.HI.Y + s2.P.Y,
|
||||
s2.HO.X + s2.P.X, s2.HO.Y + s2.P.Y,
|
||||
s2.P.X, s2.P.Y);
|
||||
else
|
||||
Result.LineTo(s2.P.X, s2.P.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Op == Union)
|
||||
{
|
||||
Result.AddPath(Path2);
|
||||
for (size_t i = 0; i < Segments1.size(); i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Result.MoveTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else if (Segments1[i].IsCurve)
|
||||
Result.CurveTo(Segments1[i].HI.X + Segments1[i].P.X, Segments1[i].HI.Y + Segments1[i].P.Y,
|
||||
Segments1[i].HO.X + Segments1[i].P.X, Segments1[i].HO.Y + Segments1[i].P.Y,
|
||||
Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else
|
||||
Result.LineTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Result.StartFigure();
|
||||
|
||||
for (size_t i = 0; i < Segments1.size(); i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Result.MoveTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else if (Segments1[i].IsCurve)
|
||||
Result.CurveTo(Segments1[i].HI.X + Segments1[i].P.X, Segments1[i].HI.Y + Segments1[i].P.Y,
|
||||
Segments1[i].HO.X + Segments1[i].P.X, Segments1[i].HO.Y + Segments1[i].P.Y,
|
||||
Segments1[i].P.X, Segments1[i].P.Y);
|
||||
else
|
||||
Result.LineTo(Segments1[i].P.X, Segments1[i].P.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBooleanOperations::TraceOneCurvePath2()
|
||||
{
|
||||
if (Op == Intersection)
|
||||
{
|
||||
Result.StartFigure();
|
||||
for (const auto& s : Segments2)
|
||||
{
|
||||
if (s.Inters && Result.GetPointCount() == 0)
|
||||
{
|
||||
Result.MoveTo(s.P.X, s.P.Y);
|
||||
Segment s2 = GetNextSegment(s);
|
||||
if (s2.IsCurve)
|
||||
Result.CurveTo(s2.HI.X + s2.P.X, s2.HI.Y + s2.P.Y,
|
||||
s2.HO.X + s2.P.X, s2.HO.Y + s2.P.Y,
|
||||
s2.P.X, s2.P.Y);
|
||||
else
|
||||
Result.LineTo(s2.P.X, s2.P.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Op == Union)
|
||||
{
|
||||
Result.AddPath(Path1);
|
||||
for (size_t i = 0; i < Segments2.size(); i++)
|
||||
{
|
||||
if (i % 2 == 0)
|
||||
Result.MoveTo(Segments2[i].P.X, Segments2[i].P.Y);
|
||||
else if (Segments2[i].IsCurve)
|
||||
Result.CurveTo(Segments2[i].HI.X + Segments2[i].P.X, Segments2[i].HI.Y + Segments2[i].P.Y,
|
||||
Segments2[i].HO.X + Segments2[i].P.X, Segments2[i].HO.Y + Segments2[i].P.Y,
|
||||
Segments2[i].P.X, Segments2[i].P.Y);
|
||||
else
|
||||
Result.LineTo(Segments2[i].P.X, Segments2[i].P.Y);
|
||||
}
|
||||
}
|
||||
else
|
||||
Result = std::move(Path1);
|
||||
}
|
||||
|
||||
void CBooleanOperations::TracePaths()
|
||||
{
|
||||
size_t length = Segments1.size();
|
||||
@ -1198,10 +1044,7 @@ void CBooleanOperations::TracePaths()
|
||||
Segment tmp = GetNextSegment(prev.Inters->S);
|
||||
if (tmp.IsEmpty()) break;
|
||||
if (tmp.IsValid(Op))
|
||||
{
|
||||
s = tmp;
|
||||
valid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!valid && prev.Inters)
|
||||
@ -1410,218 +1253,6 @@ void CBooleanOperations::SetVisited(const Segment& segment)
|
||||
Segments2[segment.Index].Visited = true;
|
||||
}
|
||||
|
||||
void CBooleanOperations::CreateNewPath(const std::vector<std::vector<int>>& adjMatr) noexcept
|
||||
{
|
||||
int* loc_visited = new int[Locations.size()];
|
||||
memset(loc_visited, false, Locations.size());
|
||||
bool* seg_visited = new bool[Segments1.size()];
|
||||
memset(seg_visited, false, Segments1.size());
|
||||
|
||||
Result.StartFigure();
|
||||
for (int i = 0; i < Locations.size(); i++)
|
||||
{
|
||||
auto loc = Locations[i];
|
||||
if (loc_visited[i] == 2)
|
||||
continue;
|
||||
|
||||
bool finish = true;
|
||||
for (size_t j = 0; j < Segments1.size(); j++)
|
||||
finish = finish && seg_visited[j];
|
||||
|
||||
if (finish)
|
||||
break;
|
||||
|
||||
auto add_seg = [&](int x, int prev_x) {
|
||||
for (int j = adjMatr[x].size() - 1; j >= 0; j--)
|
||||
{
|
||||
int ver = adjMatr[x][j];
|
||||
if (seg_visited[ver] || ver == prev_x)
|
||||
continue;
|
||||
|
||||
seg_visited[ver] = true;
|
||||
if (Segments1[ver].IsCurve)
|
||||
{
|
||||
Segment seg;
|
||||
auto curve = Curves1[ver];
|
||||
auto curve1 = Curves1[ver == 0 ? Curves1.size() - 1 : ver - 1];
|
||||
if (curve.Segment2.Index == Locations[x]->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve.DivideAtTime(Locations[x]->Time);
|
||||
seg = new_curve.Segment1;
|
||||
}
|
||||
if (curve.Segment2.Index == Locations[x]->Inters->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve.DivideAtTime(Locations[x]->Inters->Time);
|
||||
seg = new_curve.Segment1;
|
||||
}
|
||||
if (curve1.Segment2.Index == Locations[x]->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve1.DivideAtTime(Locations[x]->Time);
|
||||
seg = new_curve.Segment2;
|
||||
}
|
||||
if (curve1.Segment2.Index == Locations[x]->Inters->C.Segment2.Index)
|
||||
{
|
||||
auto new_curve = curve1.DivideAtTime(Locations[x]->Inters->Time);
|
||||
seg = new_curve.Segment2;
|
||||
}
|
||||
Result.CurveTo(seg.HI.X + seg.P.X, seg.HI.Y + seg.P.Y,
|
||||
seg.HO.X + seg.P.X, seg.HO.Y + seg.P.Y,
|
||||
seg.P.X, seg.P.Y);
|
||||
}
|
||||
else
|
||||
Result.LineTo(Segments1[ver].P.X, Segments1[ver].P.Y);
|
||||
|
||||
return ver;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
auto add_loc = [&](int x, int prev_x) {
|
||||
while (1)
|
||||
{
|
||||
for (int j = 0; j < adjMatr.size(); j++)
|
||||
{
|
||||
if (std::find(adjMatr[j].begin(), adjMatr[j].end(), x) != adjMatr[j].end())
|
||||
{
|
||||
if (loc_visited[j] == 2 || j == prev_x)
|
||||
continue;
|
||||
|
||||
if (j != i)
|
||||
loc_visited[j]++;
|
||||
auto ll = Locations[j];
|
||||
Curve curve;
|
||||
double t;
|
||||
if ((x == Curves1.size() - 1 ? 0 : x + 1) == ll->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x];
|
||||
t = ll->Time;
|
||||
}
|
||||
if ((x == Curves1.size() - 1 ? 0 : x + 1) == ll->Inters->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x];
|
||||
t = ll->Inters->Time;
|
||||
}
|
||||
if (x == ll->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x == 0 ? Curves1.size() - 1 : x - 1];
|
||||
t = ll->Time;
|
||||
}
|
||||
if (x == ll->Inters->C.Segment2.Index)
|
||||
{
|
||||
curve = Curves1[x == 0 ? Curves1.size() - 1 : x - 1];
|
||||
t = ll->Inters->Time;
|
||||
}
|
||||
if (curve.Segment2.IsCurve)
|
||||
{
|
||||
auto new_curve = curve.DivideAtTime(t);
|
||||
Result.CurveTo(new_curve.Segment1.HI.X + new_curve.Segment1.P.X, new_curve.Segment1.HI.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.HO.X + new_curve.Segment1.P.X, new_curve.Segment1.HO.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.P.X, new_curve.Segment1.P.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pt = curve.GetPoint(t);
|
||||
Result.LineTo(pt.X, pt.Y);
|
||||
}
|
||||
|
||||
return j;
|
||||
}
|
||||
}
|
||||
x = (x >= Curves1.size() - 1) ? 0 : x + 1;
|
||||
prev_x = -1;
|
||||
if (Curves1[x].Segment2.IsCurve)
|
||||
Result.CurveTo(Curves1[x].Segment2.HI.X + Curves1[x].Segment2.P.X, Curves1[x].Segment2.HI.Y + Curves1[x].Segment2.P.Y,
|
||||
Curves1[x].Segment2.HO.X + Curves1[x].Segment2.P.X, Curves1[x].Segment2.HO.Y + Curves1[x].Segment2.P.Y,
|
||||
Curves1[x].Segment2.P.X, Curves1[x].Segment2.P.Y);
|
||||
else
|
||||
Result.LineTo(Curves1[x].Segment2.P.X, Curves1[x].Segment2.P.Y);
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
|
||||
loc_visited[i]++;
|
||||
auto p = loc->C.GetPoint(loc->Time);
|
||||
Result.MoveTo(p.X, p.Y);
|
||||
int cur_seg = -1;
|
||||
int cur_loc = i;
|
||||
while (1)
|
||||
{
|
||||
cur_seg = add_seg(cur_loc, cur_seg);
|
||||
if (cur_seg == -1)
|
||||
break;
|
||||
cur_loc = add_loc(cur_seg, cur_loc);
|
||||
if (cur_loc == i || cur_loc == -1)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < Locations.size(); i++)
|
||||
{
|
||||
if (loc_visited[i] != 2)
|
||||
{
|
||||
loc_visited[i]++;
|
||||
auto p = Locations[i]->C.GetPoint(Locations[i]->Time);
|
||||
Result.MoveTo(p.X, p.Y);
|
||||
auto prev_loc = Locations[i];
|
||||
|
||||
auto add_loc = [&](std::shared_ptr<Location> l1, std::shared_ptr<Location> l2) {
|
||||
auto add_pt = [&](std::shared_ptr<Location> lc, std::shared_ptr<Location> prev){
|
||||
if (prev->C.Segment2.IsCurve)
|
||||
{
|
||||
auto new_curve = prev->C;
|
||||
double t1 = prev->Time;
|
||||
double t2 = lc->Time;
|
||||
if (t2 < t1)
|
||||
{
|
||||
new_curve.Flip();
|
||||
t1 = 1.0 - t1;
|
||||
t2 = 1.0 - t2;
|
||||
}
|
||||
new_curve = new_curve.DivideAtTime(t1);
|
||||
new_curve = new_curve.DivideAtTime((t2 - t1) / (1.0 - t1));
|
||||
|
||||
Result.CurveTo(new_curve.Segment1.HI.X + new_curve.Segment1.P.X, new_curve.Segment1.HI.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.HO.X + new_curve.Segment1.P.X, new_curve.Segment1.HO.Y + new_curve.Segment1.P.Y,
|
||||
new_curve.Segment1.P.X, new_curve.Segment1.P.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pt = lc->C.GetPoint(lc->Time);
|
||||
Result.LineTo(pt.X, pt.Y);
|
||||
}
|
||||
};
|
||||
|
||||
if (l1->C.Segment2.Index == l2->C.Segment2.Index)
|
||||
add_pt(l1, l2);
|
||||
else if (l1->C.Segment2.Index == l2->Inters->C.Segment2.Index)
|
||||
add_pt(l1, l2->Inters);
|
||||
else if (l1->Inters->C.Segment2.Index == l2->C.Segment2.Index)
|
||||
add_pt(l1->Inters, l2);
|
||||
else if (l1->Inters->C.Segment2.Index == l2->Inters->C.Segment2.Index)
|
||||
add_pt(l1->Inters, l2->Inters);
|
||||
};
|
||||
|
||||
for (int j = i + 1; j < Locations.size(); j++)
|
||||
{
|
||||
if (loc_visited[j] == 2)
|
||||
continue;
|
||||
|
||||
loc_visited[j]++;
|
||||
add_loc(Locations[j], prev_loc);
|
||||
prev_loc = Locations[j];
|
||||
}
|
||||
add_loc(Locations[i], prev_loc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Result.CloseFigure();
|
||||
|
||||
delete[] seg_visited;
|
||||
delete[] loc_visited;
|
||||
}
|
||||
|
||||
std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
{
|
||||
std::vector<std::vector<double>> allBounds, bounds2;
|
||||
@ -1665,14 +1296,13 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
|
||||
activeIndicesByPri2.erase(activeIndicesByPri2.begin(),
|
||||
activeIndicesByPri2.begin() + pruneCount);
|
||||
|
||||
for (int j = 0; j < static_cast<int>(activeIndicesByPri2.size()); j++)
|
||||
{
|
||||
bool isActive1 = activeIndicesByPri2[j] < length1,
|
||||
isActive2 = self || !isActive1,
|
||||
isActive1Or2 = (isCurrent1 && isActive2) || (isCurrent2 && isActive1),
|
||||
inRange1 = allBounds[allIdicesByPri1[i]][1] <= allBounds[activeIndicesByPri2[j]][3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = allBounds[allIdicesByPri1[i]][3] >= allBounds[activeIndicesByPri2[j]][1] - GEOMETRIC_EPSILON;
|
||||
isActive2 = self || !isActive1,
|
||||
isActive1Or2 = (isCurrent1 && isActive2) || (isCurrent2 && isActive1),
|
||||
inRange1 = allBounds[allIdicesByPri1[i]][1] <= allBounds[activeIndicesByPri2[j]][3] + GEOMETRIC_EPSILON,
|
||||
inRange2 = allBounds[allIdicesByPri1[i]][3] >= allBounds[activeIndicesByPri2[j]][1] - GEOMETRIC_EPSILON;
|
||||
|
||||
if (isActive1Or2 && (inRange2 && inRange1))
|
||||
{
|
||||
@ -1684,7 +1314,10 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
}
|
||||
}
|
||||
if (isCurrent1)
|
||||
{
|
||||
if (self) curCollisions.push_back(allIdicesByPri1[i]);
|
||||
allCollisions[allIdicesByPri1[i]] = curCollisions;
|
||||
}
|
||||
if (activeIndicesByPri2.size() > 0)
|
||||
{
|
||||
int index = 1 + binarySearch(allBounds, activeIndicesByPri2, 2, allBounds[allIdicesByPri1[i]][2]);
|
||||
@ -1694,23 +1327,8 @@ std::vector<std::vector<int>> CBooleanOperations::FindBoundsCollisions()
|
||||
activeIndicesByPri2.push_back(allIdicesByPri1[i]);
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
std::vector<std::vector<int>> erase_ver(length1);
|
||||
for (auto& c : allCollisions)
|
||||
{
|
||||
std::sort(c.begin(), c.end());
|
||||
if (self)
|
||||
{
|
||||
c.erase(std::remove(c.begin(), c.end(), index), c.end());
|
||||
c.erase(std::remove(c.begin(), c.end(), index == allLength - 1 ? 0 : index + 1), c.end());
|
||||
c.erase(std::remove(c.begin(), c.end(), index == 0 ? allLength - 1 : index - 1), c.end());
|
||||
for (const auto& ind : erase_ver[index])
|
||||
c.erase(std::remove(c.begin(), c.end(), ind), c.end());
|
||||
for (const auto& ind : c)
|
||||
erase_ver[ind].push_back(index);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
return allCollisions;
|
||||
}
|
||||
@ -2270,12 +1888,6 @@ bool CBooleanOperations::AllInters(const std::vector<Segment>& segments) const n
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CBooleanOperations::IsOneCurvePath(int pathIndex) const noexcept
|
||||
{
|
||||
return Locations.size() == 4 && pathIndex == 1 ? (OriginCurves1.size() == 1 && OriginCurves2.size() != 1)
|
||||
: (OriginCurves2.size() == 1 && OriginCurves1.size() != 1);
|
||||
}
|
||||
|
||||
void CBooleanOperations::AddLocation(Curve curve1, Curve curve2, double t1,
|
||||
double t2, bool overlap, bool filter, bool ends)
|
||||
{
|
||||
@ -2316,29 +1928,6 @@ void CBooleanOperations::AddOffsets(std::vector<double>& offsets,
|
||||
offsets.push_back(count != 0 ? offset : offset / 32);
|
||||
}
|
||||
|
||||
bool CBooleanOperations::CheckLocation(std::shared_ptr<Location> loc, bool start) const noexcept
|
||||
{
|
||||
for (const auto& l : Locations)
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
if (l->C.Segment1.Index == loc->C.Segment1.Index && l->Time != loc->Time)
|
||||
return loc->Time < l->Time;
|
||||
if (l->Inters->C.Segment1.Index == loc->C.Segment1.Index && l->Inters->Time != loc->Time)
|
||||
return loc->Time < l->Inters->Time;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (l->C.Segment2.Index == loc->C.Segment2.Index && l->Time != loc->Time)
|
||||
return loc->Time > l->Time;
|
||||
if (l->Inters->C.Segment2.Index == loc->C.Segment2.Index && l->Inters->Time != loc->Time)
|
||||
return loc->Time > l->Inters->Time;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
const CGraphicsPath& path2,
|
||||
BooleanOpType op,
|
||||
@ -2348,54 +1937,21 @@ CGraphicsPath CalcBooleanOperation(const CGraphicsPath& path1,
|
||||
std::vector<CGraphicsPath> paths1 = path1.GetSubPaths(),
|
||||
paths2 = path2.GetSubPaths(),
|
||||
paths;
|
||||
int skip_end1 = -1;
|
||||
for (size_t i = 0; i < paths2.size(); i++)
|
||||
|
||||
for (const auto& p1 : paths1)
|
||||
{
|
||||
int skip_end2 = -1;
|
||||
CBooleanOperations o;
|
||||
if (i > skip_end2 && o.IsSelfInters(paths2[i]))
|
||||
for (const auto& p2 : paths2)
|
||||
{
|
||||
CBooleanOperations operation(paths2[i], paths2[i], Intersection, fillType, isLuminosity);
|
||||
CGraphicsPath p = std::move(operation.GetResult());
|
||||
|
||||
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
|
||||
paths2[i] = tmp_paths[0];
|
||||
skip_end2 = i + tmp_paths.size() - 1;
|
||||
for (size_t k = 1; k < tmp_paths.size(); k++)
|
||||
paths2.insert(paths2.begin() + i + k, tmp_paths[k]);
|
||||
}
|
||||
|
||||
for (size_t j = 0; j < paths1.size(); j++)
|
||||
{
|
||||
CBooleanOperations o2;
|
||||
if (j > skip_end1 && o2.IsSelfInters(paths1[j]))
|
||||
{
|
||||
CBooleanOperations operation(paths1[j], paths1[j], Intersection, fillType, isLuminosity);
|
||||
CGraphicsPath p = std::move(operation.GetResult());
|
||||
|
||||
std::vector<CGraphicsPath> tmp_paths = p.GetSubPaths();
|
||||
paths1[j] = tmp_paths[0];
|
||||
skip_end1 = j + tmp_paths.size() - 1;
|
||||
for (size_t k = 1; k < tmp_paths.size(); k++)
|
||||
paths1.insert(paths1.begin() + i + k, tmp_paths[k]);
|
||||
}
|
||||
|
||||
CBooleanOperations operation(paths1[j], paths2[i], op, fillType, isLuminosity);
|
||||
CBooleanOperations operation(p1, p2, op, fillType, isLuminosity);
|
||||
paths.push_back(operation.GetResult());
|
||||
}
|
||||
|
||||
if (op == Subtraction)
|
||||
{
|
||||
paths1 = CGraphicsPath(paths).GetSubPaths();
|
||||
paths.clear();
|
||||
}
|
||||
}
|
||||
|
||||
return op == Subtraction ? CGraphicsPath(paths1) : CGraphicsPath(paths);
|
||||
return CGraphicsPath(paths);
|
||||
}
|
||||
|
||||
// For Unit-tests
|
||||
bool CGraphicsPath::Equals(const CGraphicsPath& other) noexcept
|
||||
//For unit-tests
|
||||
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
|
||||
{
|
||||
unsigned pointsCount = GetPointCount(),
|
||||
otherPointsCount = other.GetPointCount();
|
||||
@ -2404,7 +1960,7 @@ bool CGraphicsPath::Equals(const CGraphicsPath& other) noexcept
|
||||
return false;
|
||||
|
||||
std::vector<PointD> points = GetPoints(0, pointsCount),
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
for (unsigned i = 0; i < pointsCount; i++)
|
||||
if (getDistance(points[i], otherPoints[i]) > POINT_EPSILON)
|
||||
|
||||
@ -107,19 +107,15 @@ namespace Aggplus
|
||||
class CBooleanOperations
|
||||
{
|
||||
public:
|
||||
CBooleanOperations() {};
|
||||
CBooleanOperations(const CGraphicsPath& path1, const CGraphicsPath& path2, BooleanOpType op, long fillType, bool isLuminosity);
|
||||
~CBooleanOperations();
|
||||
CGraphicsPath&& GetResult();
|
||||
bool IsSelfInters(const CGraphicsPath& p);
|
||||
|
||||
// BooleanOp
|
||||
void TraceBoolean();
|
||||
void TraceOneInters();
|
||||
void TraceAllOverlap();
|
||||
void TracePaths();
|
||||
void TraceOneCurvePath1();
|
||||
void TraceOneCurvePath2();
|
||||
|
||||
// Path
|
||||
void PreparePath(const CGraphicsPath& path, int id, std::vector<Segment>& segments,
|
||||
@ -131,7 +127,6 @@ namespace Aggplus
|
||||
Segment GetPreviousSegment(const Segment& segment) const noexcept;
|
||||
Segment GetNextSegment(const Segment& segment) const noexcept;
|
||||
void SetVisited(const Segment& segment);
|
||||
void CreateNewPath(const std::vector<std::vector<int>>& adjMatr) noexcept;
|
||||
|
||||
// Bounds
|
||||
std::vector<std::vector<int>> FindBoundsCollisions();
|
||||
@ -156,9 +151,7 @@ namespace Aggplus
|
||||
void InsertLocation(std::shared_ptr<Location> loc, bool overlap);
|
||||
bool AllOverlap() const noexcept;
|
||||
bool AllInters(const std::vector<Segment>& segments) const noexcept;
|
||||
bool IsOneCurvePath(int pathIndex) const noexcept;
|
||||
void AddOffsets(std::vector<double>& offsets, const Curve& curve, bool end);
|
||||
bool CheckLocation(std::shared_ptr<Location> loc, bool start) const noexcept;
|
||||
|
||||
private:
|
||||
BooleanOpType Op = Intersection;
|
||||
@ -170,9 +163,9 @@ namespace Aggplus
|
||||
// c_nStroke, c_nWindingFillMode, c_nEvenOddFillMode
|
||||
long FillType = c_nWindingFillMode;
|
||||
|
||||
CGraphicsPath Path1{};
|
||||
CGraphicsPath Path2{};
|
||||
CGraphicsPath Result{};
|
||||
CGraphicsPath Path1;
|
||||
CGraphicsPath Path2;
|
||||
CGraphicsPath Result;
|
||||
|
||||
std::vector<Segment> Segments1;
|
||||
std::vector<Segment> Segments2;
|
||||
|
||||
@ -419,6 +419,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(const std::wstring& strName, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -427,6 +428,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = TRUE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::CBrushTexture(CImage *pImage, WrapMode wrapMode) : CBrush(BrushTypeTextureFill), m_wrapMode(wrapMode)
|
||||
@ -435,6 +437,7 @@ namespace Aggplus
|
||||
m_bReleaseImage = FALSE;
|
||||
Alpha = 255;
|
||||
m_bUseBounds = false;
|
||||
m_bIsScale = false;
|
||||
}
|
||||
|
||||
CBrushTexture::~CBrushTexture()
|
||||
|
||||
@ -205,6 +205,10 @@ public:
|
||||
bool m_bUseBounds;
|
||||
CDoubleRect m_oBounds;
|
||||
|
||||
bool m_bIsScale;
|
||||
double m_dScaleX;
|
||||
double m_dScaleY;
|
||||
|
||||
BYTE Alpha;
|
||||
};
|
||||
}
|
||||
|
||||
@ -847,6 +847,8 @@ namespace Aggplus
|
||||
double dScaleY = m_dDpiY / m_dDpiTile;
|
||||
|
||||
brushMatrix.Scale(dScaleX, dScaleY, Aggplus::MatrixOrderAppend);
|
||||
if (ptxBrush->m_bIsScale)
|
||||
brushMatrix.Scale(ptxBrush->m_dScaleX, ptxBrush->m_dScaleY, Aggplus::MatrixOrderAppend);
|
||||
}
|
||||
|
||||
brushMatrix.Translate(x, y, Aggplus::MatrixOrderAppend);
|
||||
|
||||
@ -76,7 +76,7 @@ namespace Aggplus
|
||||
j += 2;
|
||||
}
|
||||
}
|
||||
//if (p.Is_poly_closed()) CloseFigure();
|
||||
if (p.Is_poly_closed()) CloseFigure();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,25 +262,6 @@ namespace Aggplus
|
||||
m_internal->m_agg_ps.line_to(x + width, y);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y + height);
|
||||
m_internal->m_agg_ps.line_to(x, y);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
Status CGraphicsPath::AddRoundRectangle(double x, double y, double width, double height, double cx, double cy)
|
||||
{
|
||||
m_internal->m_agg_ps.move_to(x + cx, y);
|
||||
m_internal->m_agg_ps.line_to(x + width - cx, y);
|
||||
agg::bezier_arc arc1(x + width - cx, y + cy, cx, cy, -agg::pi / 2.0, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc1, 0);
|
||||
m_internal->m_agg_ps.line_to(x + width, y + height - cy);
|
||||
agg::bezier_arc arc2(x + width - cx, y + height - cy, cx, cy, 0.0, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc2, 0);
|
||||
m_internal->m_agg_ps.line_to(x + cx, y + height);
|
||||
agg::bezier_arc arc3(x + cx, y + height - cy, cx, cy, agg::pi / 2.0, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc3, 0);
|
||||
m_internal->m_agg_ps.line_to(x, y + cy);
|
||||
agg::bezier_arc arc4(x + cx, y + cy, cx, cy, agg::pi, agg::pi / 2.0);
|
||||
m_internal->m_agg_ps.join_path(arc4, 0);
|
||||
m_internal->m_agg_ps.close_polygon();
|
||||
return Ok;
|
||||
}
|
||||
@ -917,11 +898,14 @@ namespace Aggplus
|
||||
PointD firstPoint = subPath.GetPoints(0, 1)[0];
|
||||
double x, y;
|
||||
subPath.GetLastPoint(x, y);
|
||||
if ((abs(firstPoint.X - x) >= 1e-2 || abs(firstPoint.Y - y) >= 1e-2) ||
|
||||
if ((abs(firstPoint.X - x) <= 1e-2 && abs(firstPoint.Y - y) <= 1e-2) ||
|
||||
subPath.GetPointCount() == 1)
|
||||
subPath.LineTo(firstPoint.X, firstPoint.Y);
|
||||
{
|
||||
if (!firstPoint.Equals(PointD(x, y)) || subPath.GetPointCount() == 1)
|
||||
subPath.LineTo(firstPoint.X, firstPoint.Y);
|
||||
subPath.CloseFigure();
|
||||
}
|
||||
|
||||
subPath.CloseFigure();
|
||||
result.push_back(subPath);
|
||||
subPath.Reset();
|
||||
}
|
||||
@ -949,7 +933,7 @@ namespace Aggplus
|
||||
double x, y;
|
||||
subPath.GetLastPoint(x, y);
|
||||
|
||||
if ((abs(firstPoint.X - x) >= 1e-2 || abs(firstPoint.Y - y) >= 1e-2) || subPath.GetPointCount() == 1)
|
||||
if (!firstPoint.Equals(PointD(x, y)) || subPath.GetPointCount() == 1)
|
||||
subPath.LineTo(firstPoint.X, firstPoint.Y);
|
||||
|
||||
subPath.CloseFigure();
|
||||
@ -1003,24 +987,6 @@ namespace Aggplus
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool CGraphicsPath::operator==(const CGraphicsPath& other) noexcept
|
||||
{
|
||||
unsigned pointsCount = GetPointCount(),
|
||||
otherPointsCount = other.GetPointCount();
|
||||
|
||||
if (pointsCount != otherPointsCount)
|
||||
return false;
|
||||
|
||||
std::vector<PointD> points = GetPoints(0, pointsCount),
|
||||
otherPoints = other.GetPoints(0, otherPointsCount);
|
||||
|
||||
for (unsigned i = 0; i < pointsCount; i++)
|
||||
if (!points[i].Equals(otherPoints[i]))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
namespace Aggplus
|
||||
@ -1549,3 +1515,31 @@ namespace Aggplus
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
HRESULT IRenderer::AddPath(const Aggplus::CGraphicsPath& path)
|
||||
{
|
||||
if (path.GetPointCount() == 0)
|
||||
return S_FALSE;
|
||||
|
||||
size_t length = path.GetPointCount() + path.GetCloseCount();
|
||||
std::vector<Aggplus::PointD> points = path.GetPoints(0, length);
|
||||
|
||||
for (size_t i = 0; i < length; i++)
|
||||
{
|
||||
if (path.IsCurvePoint(i))
|
||||
{
|
||||
PathCommandCurveTo(points[i].X, points[i].Y,
|
||||
points[i + 1].X, points[i + 1].Y,
|
||||
points[i + 2].X, points[i + 2].Y);
|
||||
i += 2;
|
||||
}
|
||||
else if (path.IsMovePoint(i))
|
||||
PathCommandMoveTo(points[i].X, points[i].Y);
|
||||
else if (path.IsLinePoint(i))
|
||||
PathCommandLineTo(points[i].X, points[i].Y);
|
||||
else
|
||||
PathCommandClose();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@ -72,7 +72,6 @@ namespace Aggplus
|
||||
Status AddCurve(double* pPoints, int nCount);
|
||||
Status AddEllipse(double x, double y, double width, double height);
|
||||
Status AddRectangle(double x, double y, double width, double height);
|
||||
Status AddRoundRectangle(double x, double y, double width, double height, double cx, double cy);
|
||||
Status AddPolygon(double* pPoints, int nCount);
|
||||
Status AddPath(const CGraphicsPath& oPath);
|
||||
Status AddArc(double x, double y, double width, double height, double startAngle, double sweepAngle);
|
||||
@ -117,7 +116,6 @@ namespace Aggplus
|
||||
std::vector<PointD> GetPoints(unsigned idx, unsigned count) const noexcept;
|
||||
std::vector<CGraphicsPath> GetSubPaths() const;
|
||||
|
||||
bool Equals(const CGraphicsPath& other) noexcept;
|
||||
CGraphicsPath& operator=(const CGraphicsPath& other) noexcept;
|
||||
CGraphicsPath& operator=(CGraphicsPath&& other) noexcept;
|
||||
bool operator==(const CGraphicsPath& other) noexcept;
|
||||
|
||||
@ -613,6 +613,32 @@ HRESULT CGraphicsRenderer::put_BrushTransform(const Aggplus::CMatrix& oMatrix)
|
||||
m_oBrush.Transform = oMatrix;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
offsetX = m_oBrush.OffsetX;
|
||||
offsetY = m_oBrush.OffsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
m_oBrush.OffsetX = offsetX;
|
||||
m_oBrush.OffsetY = offsetY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
isScale = m_oBrush.IsScale;
|
||||
scaleX = m_oBrush.ScaleX;
|
||||
scaleY = m_oBrush.ScaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
m_oBrush.IsScale = isScale;
|
||||
m_oBrush.ScaleX = scaleX;
|
||||
m_oBrush.ScaleY = scaleY;
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT CGraphicsRenderer::BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height)
|
||||
{
|
||||
m_oBrush.Rectable = val;
|
||||
@ -946,11 +972,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
switch (m_oBrush.TextureMode)
|
||||
{
|
||||
case c_BrushTextureModeTile:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileCenter:
|
||||
oMode = Aggplus::WrapModeTile;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipX:
|
||||
oMode = Aggplus::WrapModeTileFlipX;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipY:
|
||||
oMode = Aggplus::WrapModeTileFlipY;
|
||||
break;
|
||||
case c_BrushTextureModeTileFlipXY:
|
||||
oMode = Aggplus::WrapModeTileFlipXY;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -1023,11 +1056,18 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
|
||||
if (m_oBrush.Rectable == 1)
|
||||
{
|
||||
pTextureBrush->m_bUseBounds = true;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y;
|
||||
pTextureBrush->m_oBounds.left = m_oBrush.Rect.X + m_oBrush.OffsetX;
|
||||
pTextureBrush->m_oBounds.top = m_oBrush.Rect.Y + m_oBrush.OffsetY;
|
||||
pTextureBrush->m_oBounds.right = pTextureBrush->m_oBounds.left + m_oBrush.Rect.Width;
|
||||
pTextureBrush->m_oBounds.bottom = pTextureBrush->m_oBounds.top + m_oBrush.Rect.Height;
|
||||
}
|
||||
|
||||
if (m_oBrush.IsScale == 1)
|
||||
{
|
||||
pTextureBrush->m_bIsScale = true;
|
||||
pTextureBrush->m_dScaleX = m_oBrush.ScaleX;
|
||||
pTextureBrush->m_dScaleY = m_oBrush.ScaleY;
|
||||
}
|
||||
}
|
||||
|
||||
pBrush = pTextureBrush;
|
||||
|
||||
@ -189,6 +189,10 @@ public:
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle);
|
||||
virtual HRESULT get_BrushTransform(Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix);
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const;
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY);
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const;
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY);
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height);
|
||||
virtual HRESULT put_BrushGradientColors(LONG* lColors, double* pPositions, LONG nCount);
|
||||
|
||||
@ -156,7 +156,6 @@ public:
|
||||
PageClear = 9,
|
||||
PageRotate = 10,
|
||||
Headings = 11,
|
||||
Redact = 12,
|
||||
|
||||
Undefined = 255
|
||||
};
|
||||
@ -168,7 +167,10 @@ public:
|
||||
AdvancedCommandType GetCommandType() { return m_nCommandType; }
|
||||
};
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
namespace Aggplus {
|
||||
class CImage;
|
||||
class CGraphicsPath;
|
||||
}
|
||||
|
||||
// IRenderer
|
||||
class IRenderer : public IGrObject
|
||||
@ -240,6 +242,32 @@ public:
|
||||
virtual HRESULT put_BrushTransform(const Aggplus::CMatrix& oMatrix) = 0;
|
||||
virtual HRESULT get_BrushLinearAngle(double* dAngle) = 0;
|
||||
virtual HRESULT put_BrushLinearAngle(const double& dAngle) = 0;
|
||||
virtual HRESULT get_BrushOffset(double& offsetX, double& offsetY) const
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushOffset(const double& offsetX, const double& offsetY)
|
||||
{
|
||||
UNUSED_VARIABLE(offsetX);
|
||||
UNUSED_VARIABLE(offsetY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT get_BrushScale(bool& isScale, double& scaleX, double& scaleY) const
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT put_BrushScale(bool isScale, const double& scaleX, const double& scaleY)
|
||||
{
|
||||
UNUSED_VARIABLE(isScale);
|
||||
UNUSED_VARIABLE(scaleX);
|
||||
UNUSED_VARIABLE(scaleY);
|
||||
return S_OK;
|
||||
}
|
||||
virtual HRESULT BrushRect(const INT& val, const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
virtual HRESULT BrushBounds(const double& left, const double& top, const double& width, const double& height) = 0;
|
||||
|
||||
@ -299,6 +327,8 @@ public:
|
||||
virtual HRESULT PathCommandTextExCHAR(const LONG& c, const LONG& gid, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT PathCommandTextEx(const std::wstring& sText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
|
||||
HRESULT AddPath(const Aggplus::CGraphicsPath& path);
|
||||
|
||||
//-------- Функции для вывода изображений ---------------------------------------------------
|
||||
virtual HRESULT DrawImage(IGrObject* pImage, const double& x, const double& y, const double& w, const double& h) = 0;
|
||||
virtual HRESULT DrawImageFromFile(const std::wstring&, const double& x, const double& y, const double& w, const double& h, const BYTE& lAlpha = 255) = 0;
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
#include "../fontengine/FontManager.h"
|
||||
#include "../raster/BgraFrame.h"
|
||||
#include "../common/StringExt.h"
|
||||
#include "../GraphicsPath.h"
|
||||
|
||||
// этот класс нужно переписать. должно работать как и в js
|
||||
// а не просто на каждом символе переключаться, если нужно
|
||||
@ -351,7 +352,13 @@ namespace NSOnlineOfficeBinToPdf
|
||||
bool bIsPathOpened = false;
|
||||
bool bIsEnableBrushRect = false;
|
||||
|
||||
double old_t1, old_t2, old_t3, old_t4, old_t5, old_t6;
|
||||
|
||||
CBufferReader oReader(pBuffer, lBufferLen);
|
||||
Aggplus::CGraphicsPath path;
|
||||
Aggplus::CMatrix transMatrRot;
|
||||
Aggplus::RectF_T<double> clipRect;
|
||||
bool isResetRot = false;
|
||||
while (oReader.Check())
|
||||
{
|
||||
eCommand = (CommandType)(oReader.ReadByte());
|
||||
@ -471,6 +478,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m2 = oReader.ReadDouble();
|
||||
double m3 = oReader.ReadDouble();
|
||||
double m4 = oReader.ReadDouble();
|
||||
|
||||
long type;
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
if (type != c_BrushTextureModeStretch)
|
||||
{
|
||||
m1 = 0.0;
|
||||
m2 = 0.0;
|
||||
}
|
||||
|
||||
clipRect = Aggplus::RectF_T<double>(m1, m2, m3, m4);
|
||||
pRenderer->BrushRect(bIsEnableBrushRect ? 1 : 0, m1, m2, m3, m4);
|
||||
break;
|
||||
}
|
||||
@ -590,6 +607,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
pRenderer->put_BrushTextureAlpha(lAlpha);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
pRenderer->GetTransform(&old_t1, &old_t2, &old_t3, &old_t4, &old_t5, &old_t6);
|
||||
|
||||
Aggplus::CMatrix mtr(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
double rot = mtr.rotation();
|
||||
transMatrRot.Rotate(agg::rad2deg(rot));
|
||||
isResetRot = true;
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
@ -611,6 +638,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
|
||||
pRenderer->BeginCommand(c_nPathType);
|
||||
pRenderer->PathCommandStart();
|
||||
path.Reset();
|
||||
path.StartFigure();
|
||||
|
||||
bIsPathOpened = true;
|
||||
break;
|
||||
@ -619,14 +648,14 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandMoveTo(m1, m2);
|
||||
path.MoveTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandLineTo:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandLineTo(m1, m2);
|
||||
path.LineTo(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandCurveTo:
|
||||
@ -637,12 +666,12 @@ namespace NSOnlineOfficeBinToPdf
|
||||
double m4 = oReader.ReadDouble();
|
||||
double m5 = oReader.ReadDouble();
|
||||
double m6 = oReader.ReadDouble();
|
||||
pRenderer->PathCommandCurveTo(m1, m2, m3, m4, m5, m6);
|
||||
path.CurveTo(m1, m2, m3, m4, m5, m6);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandClose:
|
||||
{
|
||||
pRenderer->PathCommandClose();
|
||||
path.CloseFigure();
|
||||
break;
|
||||
}
|
||||
case ctPathCommandEnd:
|
||||
@ -655,9 +684,101 @@ namespace NSOnlineOfficeBinToPdf
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushOffset(m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
double m1 = oReader.ReadDouble();
|
||||
double m2 = oReader.ReadDouble();
|
||||
|
||||
pRenderer->put_BrushScale(true, m1, m2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
pRenderer->DrawPath(oReader.ReadInt());
|
||||
long fill = oReader.ReadInt();
|
||||
long type;
|
||||
pRenderer->get_BrushType(&type);
|
||||
|
||||
if (fill != c_nStroke && type == c_BrushTypeTexture)
|
||||
{
|
||||
Aggplus::CGraphicsPath clipPath;
|
||||
Aggplus::CGraphicsPath drawPath(path);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->get_BrushTextureMode(&type);
|
||||
bool isStretch = type == c_BrushTextureModeStretch;
|
||||
|
||||
double left, top, width, height;
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
|
||||
double rot = transMatrRot.rotation();
|
||||
double cX = left + width / 2.0;
|
||||
double cY = top + height / 2.0;
|
||||
|
||||
bool isZeroPt = clipRect.X < 0.1 && clipRect.X > -0.1 && clipRect.Y < 0.1 && clipRect.Y > -0.1;
|
||||
bool isZeroRot = rot < 1e-6 && rot > -1e-6;
|
||||
|
||||
transMatrRot.Reset();
|
||||
transMatrRot.RotateAt(agg::rad2deg(rot), cX, cY, Aggplus::MatrixOrderAppend);
|
||||
|
||||
double offX = old_t5 - transMatrRot.tx();
|
||||
double offY = old_t6 - transMatrRot.ty();
|
||||
|
||||
drawPath.Transform(&transMatrRot);
|
||||
pRenderer->SetTransform(1.0, 0.0, 0.0, 1.0, offX, offY);
|
||||
|
||||
if (isZeroPt && !isZeroRot && isStretch)
|
||||
drawPath.GetBounds(left, top, width, height);
|
||||
else
|
||||
{
|
||||
Aggplus::CGraphicsPath tmpPath;
|
||||
tmpPath.AddRectangle(left, top, width, height);
|
||||
tmpPath.Transform(&transMatrRot);
|
||||
tmpPath.GetBounds(left, top, width, height);
|
||||
}
|
||||
|
||||
if (isZeroPt || !isStretch)
|
||||
clipRect = Aggplus::RectF_T<double>(left, top, width, height);
|
||||
|
||||
if (isStretch)
|
||||
{
|
||||
if (!isZeroPt)
|
||||
clipRect.Offset(-offX, -offY);
|
||||
pRenderer->BrushRect(true, clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
double tileOffX, tileOffY;
|
||||
pRenderer->get_BrushOffset(tileOffX, tileOffY);
|
||||
pRenderer->put_BrushOffset(tileOffX - offX, tileOffY - offY);
|
||||
}
|
||||
}
|
||||
|
||||
clipPath.AddRectangle(clipRect.X, clipRect.Y, clipRect.Width, clipRect.Height);
|
||||
path = Aggplus::CalcBooleanOperation(drawPath, clipPath, Aggplus::Intersection);
|
||||
clipRect = Aggplus::RectF_T<double>();
|
||||
}
|
||||
|
||||
pRenderer->AddPath(path);
|
||||
pRenderer->DrawPath(fill);
|
||||
|
||||
if (isResetRot)
|
||||
{
|
||||
pRenderer->SetTransform(old_t1, old_t2, old_t3, old_t4, old_t5, old_t6);
|
||||
transMatrRot.Reset();
|
||||
isResetRot = false;
|
||||
}
|
||||
|
||||
pRenderer->put_BrushScale(false, 1.0, 1.0);
|
||||
pRenderer->put_BrushOffset(0.0, 0.0);
|
||||
break;
|
||||
}
|
||||
case ctDrawImageFromFile:
|
||||
@ -921,7 +1042,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctPageClear:
|
||||
case ctPageRotate:
|
||||
case ctHeadings:
|
||||
case ctRedact:
|
||||
{
|
||||
IAdvancedCommand::AdvancedCommandType eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Undefined;
|
||||
switch (eCommand)
|
||||
@ -935,7 +1055,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctPageClear: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageClear; break;
|
||||
case ctPageRotate: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::PageRotate; break;
|
||||
case ctHeadings: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Headings; break;
|
||||
case ctRedact: eAdvancedCommandType = IAdvancedCommand::AdvancedCommandType::Redact; break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -946,7 +1065,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
if ((IAdvancedCommand::AdvancedCommandType::Undefined != eAdvancedCommandType) &&
|
||||
(S_OK == pRenderer->IsSupportAdvancedCommand(eAdvancedCommandType)))
|
||||
{
|
||||
IAdvancedCommand* pCommand = oReader.Read(eCommand, pCorrector, nLen);
|
||||
IAdvancedCommand* pCommand = oReader.Read(eCommand, pCorrector);
|
||||
if (pCommand)
|
||||
{
|
||||
pRenderer->AdvancedCommand(pCommand);
|
||||
@ -1132,6 +1251,10 @@ namespace NSOnlineOfficeBinToPdf
|
||||
oReader.Skip(1);
|
||||
break;
|
||||
}
|
||||
case ctBrushResetRotation:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctSetTransform:
|
||||
{
|
||||
oReader.SkipInt(6);
|
||||
@ -1164,6 +1287,16 @@ namespace NSOnlineOfficeBinToPdf
|
||||
{
|
||||
break;
|
||||
}
|
||||
case ctPathCommandOffset:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctPathCommandScale:
|
||||
{
|
||||
oReader.SkipInt(2);
|
||||
break;
|
||||
}
|
||||
case ctDrawPath:
|
||||
{
|
||||
oReader.SkipInt();
|
||||
|
||||
@ -108,6 +108,7 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctBrushRectableEnabled = 30,
|
||||
ctBrushGradient = 31,
|
||||
ctBrushTexturePath = 32,
|
||||
ctBrushResetRotation = 33,
|
||||
|
||||
// font
|
||||
ctFontXML = 40,
|
||||
@ -153,6 +154,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctPathCommandGetCurrentPoint = 101,
|
||||
ctPathCommandText = 102,
|
||||
ctPathCommandTextEx = 103,
|
||||
ctPathCommandOffset = 104,
|
||||
ctPathCommandScale = 105,
|
||||
|
||||
// image
|
||||
ctDrawImage = 110,
|
||||
@ -185,7 +188,6 @@ namespace NSOnlineOfficeBinToPdf
|
||||
ctShapeStart = 167,
|
||||
ctShapeEnd = 168,
|
||||
ctHeadings = 169,
|
||||
ctRedact = 170,
|
||||
|
||||
ctPageWidth = 200,
|
||||
ctPageHeight = 201,
|
||||
|
||||
@ -46,16 +46,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
RELEASEOBJECT(command);
|
||||
return command;
|
||||
}
|
||||
template<typename T>
|
||||
inline IAdvancedCommand* Read_Command_Len(CBufferReader* pReader, IMetafileToRenderter* pCorrector, int nLen)
|
||||
{
|
||||
T* command = new T();
|
||||
if (!command->Read(pReader, pCorrector, nLen))
|
||||
RELEASEOBJECT(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
IAdvancedCommand* CBufferReader::Read(int type, IMetafileToRenderter* pCorrector, int nLen)
|
||||
IAdvancedCommand* CBufferReader::Read(int type, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -66,12 +58,11 @@ namespace NSOnlineOfficeBinToPdf
|
||||
case ctFormField: return Read_Command<CFormFieldInfo> (this, pCorrector);
|
||||
case ctAnnotFieldDelete: return Read_Command<CAnnotFieldDelete>(this, pCorrector);
|
||||
case ctWidgetsInfo: return Read_Command<CWidgetsInfo> (this, pCorrector);
|
||||
case ctShapeStart: return Read_Command_Len<CShapeStart> (this, pCorrector, nLen);
|
||||
case ctShapeStart: return Read_Command<CShapeStart> (this, pCorrector);
|
||||
case ctShapeEnd: return new CEmptyComand(IAdvancedCommand::AdvancedCommandType::ShapeEnd);
|
||||
case ctPageClear: return new CEmptyComand(IAdvancedCommand::AdvancedCommandType::PageClear);
|
||||
case ctPageRotate: return Read_Command<CPageRotate> (this, pCorrector);
|
||||
case ctHeadings: return Read_Command<CHeadings> (this, pCorrector);
|
||||
case ctRedact: return Read_Command<CRedact> (this, pCorrector);
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
@ -190,12 +190,8 @@ namespace NSOnlineOfficeBinToPdf
|
||||
int len = 2 * ReadUShort();
|
||||
SkipString16(len);
|
||||
}
|
||||
inline int Tell()
|
||||
{
|
||||
return (int)(m_cur - m_buffer);
|
||||
}
|
||||
|
||||
IAdvancedCommand* Read(int type, IMetafileToRenderter* pCorrector, int nLen = 0);
|
||||
IAdvancedCommand* Read(int type, IMetafileToRenderter* pCorrector);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -214,6 +214,19 @@ public:
|
||||
|
||||
inline bool IsPositive() { return Width > 0 && Height > 0; }
|
||||
|
||||
RectF_T& operator=(const RectF_T& other)
|
||||
{
|
||||
if (this == &other)
|
||||
return *this;
|
||||
|
||||
X = other.X;
|
||||
Y = other.Y;
|
||||
Width = other.Width;
|
||||
Height = other.Height;
|
||||
|
||||
return *this;
|
||||
};
|
||||
|
||||
public:
|
||||
T X, Y, Width, Height;
|
||||
};
|
||||
|
||||
@ -76,7 +76,6 @@ CAnnotFieldInfo::CAnnotFieldInfo() : IAdvancedCommand(AdvancedCommandType::Annot
|
||||
m_pFreeTextPr = NULL;
|
||||
m_pCaretPr = NULL;
|
||||
m_pStampPr = NULL;
|
||||
m_pRedactPr = NULL;
|
||||
m_pWidgetPr = NULL;
|
||||
}
|
||||
CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
@ -92,7 +91,6 @@ CAnnotFieldInfo::~CAnnotFieldInfo()
|
||||
RELEASEOBJECT(m_pFreeTextPr);
|
||||
RELEASEOBJECT(m_pCaretPr);
|
||||
RELEASEOBJECT(m_pStampPr);
|
||||
RELEASEOBJECT(m_pRedactPr);
|
||||
RELEASEOBJECT(m_pWidgetPr);
|
||||
}
|
||||
|
||||
@ -180,13 +178,6 @@ void CAnnotFieldInfo::SetType(int nType)
|
||||
m_pPopupPr = new CAnnotFieldInfo::CPopupAnnotPr();
|
||||
break;
|
||||
}
|
||||
case EAnnotType::Redact:
|
||||
{
|
||||
CreateMarkup();
|
||||
RELEASEOBJECT(m_pRedactPr);
|
||||
m_pRedactPr = new CAnnotFieldInfo::CRedactAnnotPr();
|
||||
break;
|
||||
}
|
||||
case EAnnotType::Widget:
|
||||
case EAnnotType::WidgetPushButton:
|
||||
case EAnnotType::WidgetRadioButton:
|
||||
@ -301,10 +292,6 @@ bool CAnnotFieldInfo::IsStamp() const
|
||||
{
|
||||
return (m_nType == 12);
|
||||
}
|
||||
bool CAnnotFieldInfo::IsRedact() const
|
||||
{
|
||||
return (m_nType == 25);
|
||||
}
|
||||
|
||||
CAnnotFieldInfo::CMarkupAnnotPr* CAnnotFieldInfo::GetMarkupAnnotPr() { return m_pMarkupPr; }
|
||||
CAnnotFieldInfo::CTextAnnotPr* CAnnotFieldInfo::GetTextAnnotPr() { return m_pTextPr; }
|
||||
@ -317,7 +304,6 @@ CAnnotFieldInfo::CPopupAnnotPr* CAnnotFieldInfo::GetPopupAnnotPr()
|
||||
CAnnotFieldInfo::CFreeTextAnnotPr* CAnnotFieldInfo::GetFreeTextAnnotPr() { return m_pFreeTextPr; }
|
||||
CAnnotFieldInfo::CCaretAnnotPr* CAnnotFieldInfo::GetCaretAnnotPr() { return m_pCaretPr; }
|
||||
CAnnotFieldInfo::CStampAnnotPr* CAnnotFieldInfo::GetStampAnnotPr() { return m_pStampPr; }
|
||||
CAnnotFieldInfo::CRedactAnnotPr* CAnnotFieldInfo::GetRedactAnnotPr() { return m_pRedactPr; }
|
||||
CAnnotFieldInfo::CWidgetAnnotPr* CAnnotFieldInfo::GetWidgetAnnotPr() { return m_pWidgetPr; }
|
||||
|
||||
bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
@ -405,8 +391,6 @@ bool CAnnotFieldInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMeta
|
||||
m_pCaretPr->Read(pReader, nFlags);
|
||||
else if (IsStamp())
|
||||
m_pStampPr->Read(pReader, nFlags);
|
||||
else if (IsRedact())
|
||||
m_pRedactPr->Read(pReader, nFlags);
|
||||
}
|
||||
else if (IsPopup())
|
||||
m_pPopupPr->Read(pReader);
|
||||
@ -681,46 +665,6 @@ void CAnnotFieldInfo::CStampAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader*
|
||||
m_dInRect[3] = pReader->ReadDouble();
|
||||
}
|
||||
|
||||
BYTE CAnnotFieldInfo::CRedactAnnotPr::GetQ() const { return m_nQ; }
|
||||
int CAnnotFieldInfo::CRedactAnnotPr::GetFontStyle() const { return m_nFontStyle; }
|
||||
double CAnnotFieldInfo::CRedactAnnotPr::GetFontSize() const { return m_dFS; }
|
||||
const std::wstring& CAnnotFieldInfo::CRedactAnnotPr::GetFontName() { return m_wsFN; }
|
||||
const std::wstring& CAnnotFieldInfo::CRedactAnnotPr::GetOverlayText() { return m_wsOverlayText; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetIC() { return m_arrIC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetFontColor() { return m_arrFC; }
|
||||
const std::vector<double>& CAnnotFieldInfo::CRedactAnnotPr::GetQuadPoints() { return m_arrQuadPoints; }
|
||||
void CAnnotFieldInfo::CRedactAnnotPr::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags)
|
||||
{
|
||||
if (nFlags & (1 << 15))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrQuadPoints.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
}
|
||||
if (nFlags & (1 << 16))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrIC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrIC.push_back(pReader->ReadDouble());
|
||||
}
|
||||
if (nFlags & (1 << 17))
|
||||
m_wsOverlayText = pReader->ReadString();
|
||||
if (nFlags & (1 << 19))
|
||||
m_nQ = pReader->ReadByte();
|
||||
if (nFlags & (1 << 20))
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrFC.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrFC.push_back(pReader->ReadDouble());
|
||||
m_dFS = pReader->ReadDouble();
|
||||
m_wsFN = pReader->ReadString();
|
||||
m_nFontStyle = pReader->ReadInt();
|
||||
}
|
||||
}
|
||||
|
||||
bool CAnnotFieldInfo::CPopupAnnotPr::IsOpen() const { return m_bOpen; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetFlag() const { return m_nFlag; }
|
||||
int CAnnotFieldInfo::CPopupAnnotPr::GetParentID() const { return m_nParentID; }
|
||||
@ -1222,46 +1166,3 @@ bool CWidgetsInfo::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafil
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CRedact::CRedact() : IAdvancedCommand(AdvancedCommandType::Redact) {}
|
||||
CRedact::~CRedact()
|
||||
{
|
||||
for (int i = 0; i < m_arrRedact.size(); ++i)
|
||||
RELEASEOBJECT(m_arrRedact[i]);
|
||||
}
|
||||
const std::vector<CRedact::SRedact*>& CRedact::GetRedact() { return m_arrRedact; }
|
||||
bool CRedact::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrRedact.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
{
|
||||
SRedact* pRedact = new SRedact();
|
||||
pRedact->sID = pReader->ReadString();
|
||||
int m = pReader->ReadInt();
|
||||
pRedact->arrQuadPoints.reserve(m * 8);
|
||||
for (int j = 0; j < m; ++j)
|
||||
{
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
double x = pReader->ReadDouble();
|
||||
double y = pReader->ReadDouble();
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(pReader->ReadDouble());
|
||||
pRedact->arrQuadPoints.push_back(x);
|
||||
pRedact->arrQuadPoints.push_back(y);
|
||||
}
|
||||
pRedact->nFlag = pReader->ReadInt();
|
||||
if (pRedact->nFlag & (1 << 0))
|
||||
{
|
||||
pRedact->nRenderLen = pReader->ReadInt() - 4;
|
||||
pRedact->pRender = pReader->GetCurrentBuffer();
|
||||
pReader->Skip(pRedact->nRenderLen);
|
||||
}
|
||||
m_arrRedact.push_back(pRedact);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -59,7 +59,6 @@ public:
|
||||
Ink = 14,
|
||||
Popup = 15,
|
||||
FileAttachment = 16,
|
||||
Redact = 25,
|
||||
Widget = 26,
|
||||
WidgetPushButton = 27,
|
||||
WidgetRadioButton = 28,
|
||||
@ -453,31 +452,6 @@ public:
|
||||
double m_dInRect[4]{};
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CRedactAnnotPr
|
||||
{
|
||||
public:
|
||||
BYTE GetQ() const;
|
||||
int GetFontStyle() const;
|
||||
double GetFontSize() const;
|
||||
const std::wstring& GetFontName();
|
||||
const std::wstring& GetOverlayText();
|
||||
const std::vector<double>& GetIC();
|
||||
const std::vector<double>& GetFontColor();
|
||||
const std::vector<double>& GetQuadPoints();
|
||||
|
||||
void Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, int nFlags);
|
||||
|
||||
private:
|
||||
BYTE m_nQ;
|
||||
int m_nFontStyle;
|
||||
double m_dFS;
|
||||
std::wstring m_wsFN;
|
||||
std::wstring m_wsOverlayText;
|
||||
std::vector<double> m_arrIC;
|
||||
std::vector<double> m_arrFC;
|
||||
std::vector<double> m_arrQuadPoints;
|
||||
};
|
||||
|
||||
CAnnotFieldInfo();
|
||||
virtual ~CAnnotFieldInfo();
|
||||
|
||||
@ -517,7 +491,6 @@ public:
|
||||
bool IsFreeText() const;
|
||||
bool IsCaret() const;
|
||||
bool IsStamp() const;
|
||||
bool IsRedact() const;
|
||||
|
||||
CMarkupAnnotPr* GetMarkupAnnotPr();
|
||||
CTextAnnotPr* GetTextAnnotPr();
|
||||
@ -530,7 +503,6 @@ public:
|
||||
CFreeTextAnnotPr* GetFreeTextAnnotPr();
|
||||
CCaretAnnotPr* GetCaretAnnotPr();
|
||||
CStampAnnotPr* GetStampAnnotPr();
|
||||
CRedactAnnotPr* GetRedactAnnotPr();
|
||||
CWidgetAnnotPr* GetWidgetAnnotPr();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
@ -575,7 +547,6 @@ private:
|
||||
CFreeTextAnnotPr* m_pFreeTextPr;
|
||||
CCaretAnnotPr* m_pCaretPr;
|
||||
CStampAnnotPr* m_pStampPr;
|
||||
CRedactAnnotPr* m_pRedactPr;
|
||||
CWidgetAnnotPr* m_pWidgetPr;
|
||||
};
|
||||
|
||||
@ -631,27 +602,4 @@ private:
|
||||
std::vector<CParent*> m_arrParents;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL CRedact : public IAdvancedCommand
|
||||
{
|
||||
public:
|
||||
struct SRedact
|
||||
{
|
||||
std::wstring sID;
|
||||
std::vector<double> arrQuadPoints;
|
||||
int nFlag;
|
||||
LONG nRenderLen;
|
||||
BYTE* pRender;
|
||||
};
|
||||
|
||||
CRedact();
|
||||
virtual ~CRedact();
|
||||
|
||||
const std::vector<SRedact*>& GetRedact();
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::vector<SRedact*> m_arrRedact;
|
||||
};
|
||||
|
||||
#endif // _BUILD_ANNOTFIELD_H_
|
||||
|
||||
@ -147,20 +147,10 @@ void CShapeStart::SetShapeImage(BYTE* pImgData, int nWidth, int nHeight)
|
||||
}
|
||||
}
|
||||
std::string& CShapeStart::GetShapeXML() { return m_sShapeXML; }
|
||||
const std::vector<std::wstring>& CShapeStart::GetRedactID() { return m_arrRedactID; }
|
||||
Aggplus::CImage* CShapeStart::GetShapeImage() { return m_pImage; }
|
||||
bool CShapeStart::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector, int nLen)
|
||||
bool CShapeStart::Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector)
|
||||
{
|
||||
int nStart = pReader->Tell();
|
||||
m_sShapeXML = pReader->ReadStringA();
|
||||
int nEnd = pReader->Tell();
|
||||
if (nEnd - nStart < nLen)
|
||||
{
|
||||
int n = pReader->ReadInt();
|
||||
m_arrRedactID.reserve(n);
|
||||
for (int i = 0; i < n; ++i)
|
||||
m_arrRedactID.push_back(pReader->ReadString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -139,17 +139,15 @@ public:
|
||||
~CShapeStart();
|
||||
|
||||
std::string& GetShapeXML();
|
||||
const std::vector<std::wstring>& GetRedactID();
|
||||
Aggplus::CImage* GetShapeImage();
|
||||
|
||||
void SetShapeXML(const std::string& sShapeXML);
|
||||
void SetShapeImage(BYTE* pImgData, int nWidth, int nHeight);
|
||||
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector, int nLen);
|
||||
bool Read(NSOnlineOfficeBinToPdf::CBufferReader* pReader, IMetafileToRenderter* pCorrector);
|
||||
|
||||
private:
|
||||
std::string m_sShapeXML;
|
||||
std::vector<std::wstring> m_arrRedactID;
|
||||
Aggplus::CImage* m_pImage;
|
||||
};
|
||||
|
||||
|
||||
@ -639,7 +639,6 @@ namespace NSFonts
|
||||
virtual double GetCharWidth(int gid) = 0;
|
||||
|
||||
virtual int GetGIDByUnicode(int code) = 0;
|
||||
virtual int GetUnicodeByGID(int gid) = 0;
|
||||
|
||||
virtual int GetEmbeddingLicenceType() = 0;
|
||||
virtual void FillFontSelectFormat(CFontSelectFormat& oFormat) = 0;
|
||||
@ -737,7 +736,6 @@ namespace NSFonts
|
||||
|
||||
virtual unsigned int GetNameIndex(const std::wstring& wsName) = 0;
|
||||
virtual unsigned int GetGIDByUnicode(const unsigned int& unCode) = 0;
|
||||
virtual int GetUnicodeByGID(const int& gid) = 0;
|
||||
|
||||
virtual void GetFace(double& d0, double& d1, double& d2) = 0;
|
||||
virtual void GetLimitsY(double& dMin, double& dMax) = 0;
|
||||
|
||||
@ -54,8 +54,6 @@
|
||||
"_SplitPages",
|
||||
"_MergePages",
|
||||
"_UnmergePages",
|
||||
"_RedactPage",
|
||||
"_UndoRedact",
|
||||
"_GetImageBase64",
|
||||
"_GetImageBase64Len",
|
||||
"_GetImageBase64Ptr",
|
||||
@ -97,7 +95,7 @@
|
||||
"compile_files_array": [
|
||||
{
|
||||
"folder": "../../../raster/",
|
||||
"files": ["BgraFrame.cpp", "ImageFileFormatChecker.cpp", "PICT/PICFile.cpp"]
|
||||
"files": ["BgraFrame.cpp", "ImageFileFormatChecker.cpp", "PICT/PICFile.cpp", "PICT/pic.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../cximage/CxImage/",
|
||||
@ -157,11 +155,11 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../agg-2.4/src/",
|
||||
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp", "agg_image_filters.cpp", "agg_bezier_arc.cpp"]
|
||||
"files": ["agg_arc.cpp", "agg_vcgen_stroke.cpp", "agg_vcgen_dash.cpp", "agg_trans_affine.cpp", "agg_curves.cpp", "agg_image_filters.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../common/",
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp", "StringUTF32.cpp", "StringBuilder.cpp"]
|
||||
"files": ["File.cpp", "Directory.cpp", "ByteBuilder.cpp", "Base64.cpp", "StringExt.cpp", "Path.cpp", "SystemUtils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../Common/3dParty/icu/icu/source/common/",
|
||||
@ -197,7 +195,7 @@
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/SrcWriter/",
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontOTWriter.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp", "RedactOutputDev.cpp"]
|
||||
"files": ["AcroForm.cpp", "Annotation.cpp", "Catalog.cpp", "Destination.cpp", "Document.cpp", "Encrypt.cpp", "EncryptDictionary.cpp", "Field.cpp", "Font.cpp", "Font14.cpp", "FontCidTT.cpp", "FontOTWriter.cpp", "FontTT.cpp", "FontTTWriter.cpp", "GState.cpp", "Image.cpp", "Info.cpp", "Metadata.cpp", "Objects.cpp", "Outline.cpp", "Pages.cpp", "Pattern.cpp", "ResourcesDictionary.cpp", "Shading.cpp", "States.cpp", "Streams.cpp", "Utils.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../PdfFile/Resources/",
|
||||
@ -252,8 +250,8 @@
|
||||
"files": ["BaseItem.cpp", "ContText.cpp", "Paragraph.cpp", "Shape.cpp", "TextLine.cpp", "Table.cpp"]
|
||||
},
|
||||
{
|
||||
"folder": "../../../../OdfFile/Common",
|
||||
"files": ["logging.cpp"]
|
||||
"folder": "../../../common",
|
||||
"files": ["StringUTF32.cpp", "StringBuilder.cpp"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -113,6 +113,7 @@ SOURCES += \
|
||||
../../../../raster/ImageFileFormatChecker.cpp \
|
||||
../../../../raster/Metafile/MetaFile.cpp \
|
||||
../../../../raster/PICT/PICFile.cpp \
|
||||
../../../../raster/PICT/pic.cpp \
|
||||
\
|
||||
../../../ArrowHead.cpp \
|
||||
../../../Brush.cpp \
|
||||
@ -700,8 +701,7 @@ HEADERS += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/ICCProfile.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h \
|
||||
$$PDF_ROOT_DIR/SrcWriter/RedactOutputDev.h
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.h
|
||||
|
||||
SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/AcroForm.cpp \
|
||||
@ -730,8 +730,7 @@ SOURCES += \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Streams.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Utils.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/Metadata.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp \
|
||||
$$PDF_ROOT_DIR/SrcWriter/RedactOutputDev.cpp
|
||||
$$PDF_ROOT_DIR/SrcWriter/States.cpp
|
||||
|
||||
# PdfFile
|
||||
|
||||
|
||||
@ -145,9 +145,9 @@ CFile.prototype["isNeedPassword"] = function()
|
||||
{
|
||||
return this._isNeedPassword;
|
||||
};
|
||||
CFile.prototype["SplitPages"] = function(arrOriginIndex, arrayBufferChanges)
|
||||
CFile.prototype["SplitPages"] = function(arrPageIndex, arrayBufferChanges)
|
||||
{
|
||||
let ptr = this._SplitPages(arrOriginIndex, arrayBufferChanges);
|
||||
let ptr = this._SplitPages(arrPageIndex, arrayBufferChanges);
|
||||
let res = ptr.getMemory(true);
|
||||
ptr.free();
|
||||
return res;
|
||||
@ -160,14 +160,6 @@ CFile.prototype["UndoMergePages"] = function()
|
||||
{
|
||||
return this._UndoMergePages();
|
||||
};
|
||||
CFile.prototype["RedactPage"] = function(originIndex, arrRedactBox, arrayBufferFiller)
|
||||
{
|
||||
return this._RedactPage(originIndex, arrRedactBox, arrayBufferFiller);
|
||||
};
|
||||
CFile.prototype["UndoRedact"] = function()
|
||||
{
|
||||
return this._UndoRedact();
|
||||
};
|
||||
|
||||
// INFO DOCUMENT
|
||||
CFile.prototype.getInfo = function()
|
||||
@ -259,9 +251,9 @@ CFile.prototype["getStructure"] = function()
|
||||
return res;
|
||||
};
|
||||
|
||||
CFile.prototype["getLinks"] = function(originIndex)
|
||||
CFile.prototype["getLinks"] = function(pageIndex)
|
||||
{
|
||||
let ptr = this._getLinks(originIndex);
|
||||
let ptr = this._getLinks(pageIndex);
|
||||
let reader = ptr.getReader();
|
||||
|
||||
if (!reader) return [];
|
||||
@ -284,12 +276,11 @@ CFile.prototype["getLinks"] = function(originIndex)
|
||||
};
|
||||
|
||||
// TEXT
|
||||
CFile.prototype["getGlyphs"] = function(originIndex)
|
||||
CFile.prototype["getGlyphs"] = function(pageIndex)
|
||||
{
|
||||
let pageIndex = this.pages.findIndex(function(page) {
|
||||
return page.originIndex == originIndex;
|
||||
});
|
||||
let page = this.pages[pageIndex];
|
||||
if (page.originIndex == undefined)
|
||||
return [];
|
||||
if (page.fonts.length > 0)
|
||||
{
|
||||
// waiting fonts
|
||||
@ -297,7 +288,7 @@ CFile.prototype["getGlyphs"] = function(originIndex)
|
||||
}
|
||||
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Page);
|
||||
let res = this._getGlyphs(originIndex);
|
||||
let res = this._getGlyphs(page.originIndex);
|
||||
// there is no need to delete the result; this buffer is used as a text buffer
|
||||
// for text commands on other pages. After receiving ALL text pages,
|
||||
// you need to call destroyTextInfo()
|
||||
@ -621,7 +612,6 @@ function readAnnotType(reader, rec, readDoubleFunc, readDouble2Func, readStringF
|
||||
oFont["vertical"] = readDoubleFunc.call(reader);
|
||||
if (nFontFlag & (1 << 6))
|
||||
oFont["actual"] = readStringFunc.call(reader);
|
||||
oFont["rtl"] = (nFontFlag >> 7) & 1;
|
||||
oFont["size"] = readDoubleFunc.call(reader);
|
||||
oFont["color"] = [];
|
||||
oFont["color"].push(readDouble2Func.call(reader));
|
||||
@ -1409,7 +1399,7 @@ CFile.prototype["getInteractiveFormsInfo"] = function()
|
||||
// optional nWidget - rec["AP"]["i"]
|
||||
// optional sView - N/D/R
|
||||
// optional sButtonView - state pushbutton-annotation - Off/Yes(or rec["ExportValue"])
|
||||
CFile.prototype["getInteractiveFormsAP"] = function(originIndex, width, height, backgroundColor, nWidget, sView, sButtonView)
|
||||
CFile.prototype["getInteractiveFormsAP"] = function(pageIndex, width, height, backgroundColor, nWidget, sView, sButtonView)
|
||||
{
|
||||
let nView = -1;
|
||||
if (sView)
|
||||
@ -1425,11 +1415,8 @@ CFile.prototype["getInteractiveFormsAP"] = function(originIndex, width, height,
|
||||
if (sButtonView)
|
||||
nButtonView = (sButtonView == "Off" ? 0 : 1);
|
||||
|
||||
let pageIndex = this.pages.findIndex(function(page) {
|
||||
return page.originIndex == originIndex;
|
||||
});
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Forms);
|
||||
let ptr = this._getInteractiveFormsAP(width, height, backgroundColor, originIndex, nWidget, nView, nButtonView);
|
||||
let ptr = this._getInteractiveFormsAP(width, height, backgroundColor, pageIndex, nWidget, nView, nButtonView);
|
||||
let reader = ptr.getReader();
|
||||
this.unlockPageNumForFontsLoader();
|
||||
|
||||
@ -1514,13 +1501,13 @@ CFile.prototype["getButtonIcons"] = function(pageIndex, width, height, backgroun
|
||||
ptr.free();
|
||||
return res;
|
||||
};
|
||||
// optional originIndex - get annotations from specific page
|
||||
CFile.prototype["getAnnotationsInfo"] = function(originIndex)
|
||||
// optional pageIndex - get annotations from specific page
|
||||
CFile.prototype["getAnnotationsInfo"] = function(pageIndex)
|
||||
{
|
||||
if (!this.nativeFile)
|
||||
return [];
|
||||
|
||||
let ptr = this._getAnnotationsInfo(originIndex);
|
||||
let ptr = this._getAnnotationsInfo(pageIndex);
|
||||
let reader = ptr.getReader();
|
||||
|
||||
if (!reader) return [];
|
||||
@ -1552,7 +1539,7 @@ CFile.prototype["getAnnotationsInfo"] = function(originIndex)
|
||||
};
|
||||
// optional nAnnot ...
|
||||
// optional sView ...
|
||||
CFile.prototype["getAnnotationsAP"] = function(originIndex, width, height, backgroundColor, nAnnot, sView)
|
||||
CFile.prototype["getAnnotationsAP"] = function(pageIndex, width, height, backgroundColor, nAnnot, sView)
|
||||
{
|
||||
let nView = -1;
|
||||
if (sView)
|
||||
@ -1565,11 +1552,8 @@ CFile.prototype["getAnnotationsAP"] = function(originIndex, width, height, backg
|
||||
nView = 2;
|
||||
}
|
||||
|
||||
let pageIndex = this.pages.findIndex(function(page) {
|
||||
return page.originIndex == originIndex;
|
||||
});
|
||||
this.lockPageNumForFontsLoader(pageIndex, UpdateFontsSource.Annotation);
|
||||
let ptr = this._getAnnotationsAP(width, height, backgroundColor, originIndex, nAnnot, nView);
|
||||
let ptr = this._getAnnotationsAP(width, height, backgroundColor, pageIndex, nAnnot, nView);
|
||||
let reader = ptr.getReader();
|
||||
this.unlockPageNumForFontsLoader();
|
||||
|
||||
|
||||
@ -135,17 +135,6 @@ CFile.prototype._UndoMergePages = function()
|
||||
return g_native_drawing_file["UnmergePages"]();
|
||||
};
|
||||
|
||||
CFile.prototype._RedactPage = function(pageIndex, box, filler)
|
||||
{
|
||||
let dataFiller = (undefined !== filler.byteLength) ? new Uint8Array(filler) : filler;
|
||||
return g_native_drawing_file["RedactPage"](pageIndex, box, dataFiller);
|
||||
};
|
||||
|
||||
CFile.prototype._UndoRedact = function()
|
||||
{
|
||||
return g_native_drawing_file["UndoRedact"]();
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -192,38 +192,6 @@ CFile.prototype._UndoMergePages = function()
|
||||
return Module["_UnmergePages"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._RedactPage = function(pageIndex, arrRedactBox, arrayBufferFiller)
|
||||
{
|
||||
let changesPtr = 0;
|
||||
let changesLen = 0;
|
||||
if (arrayBufferFiller)
|
||||
{
|
||||
let changes = new Uint8Array(arrayBufferFiller);
|
||||
changesLen = changes.length;
|
||||
changesPtr = Module["_malloc"](changesLen);
|
||||
Module["HEAP8"].set(changes, changesPtr);
|
||||
}
|
||||
|
||||
let memoryBuffer = new Int32Array(arrRedactBox.length);
|
||||
for (let i = 0; i < arrRedactBox.length; i++)
|
||||
memoryBuffer[i] = Math.round(arrRedactBox[i] * 10000);
|
||||
|
||||
let pointer = Module["_malloc"](memoryBuffer.length * 4);
|
||||
Module["HEAP32"].set(memoryBuffer, pointer >> 2);
|
||||
|
||||
let bRes = Module["_RedactPage"](this.nativeFile, pageIndex, pointer, memoryBuffer.length / 8, changesPtr, changesLen);
|
||||
changesPtr = 0; // Success or not, changesPtr is either taken or freed
|
||||
|
||||
Module["_free"](pointer);
|
||||
|
||||
return bRes == 1;
|
||||
};
|
||||
|
||||
CFile.prototype._UndoRedact = function()
|
||||
{
|
||||
return Module["_UndoRedact"](this.nativeFile) == 1;
|
||||
};
|
||||
|
||||
// FONTS
|
||||
CFile.prototype._isNeedCMap = function()
|
||||
{
|
||||
|
||||
@ -178,19 +178,6 @@ WASM_EXPORT int UnmergePages(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UnmergePages() ? 1 : 0;
|
||||
}
|
||||
WASM_EXPORT int RedactPage(CDrawingFile* pFile, int nPageIndex, int* arrRedactBox, int nLengthX8, BYTE* data, int size)
|
||||
{
|
||||
double* arrDRedactBox = new double[nLengthX8 * 8];
|
||||
for (int i = 0; i < nLengthX8 * 8; ++i)
|
||||
arrDRedactBox[i] = arrRedactBox[i] / 10000.0;
|
||||
int nRes = pFile->RedactPage(nPageIndex, arrDRedactBox, nLengthX8, data, size) ? 1 : 0;
|
||||
delete[] arrDRedactBox;
|
||||
return nRes;
|
||||
}
|
||||
WASM_EXPORT int UndoRedact(CDrawingFile* pFile)
|
||||
{
|
||||
return pFile->UndoRedact() ? 1 : 0;
|
||||
}
|
||||
|
||||
WASM_EXPORT void* GetImageBase64(CDrawingFile* pFile, int rId)
|
||||
{
|
||||
|
||||
@ -976,8 +976,6 @@ bool GetFromBase64(const std::wstring& sPath, BYTE** pBuffer, int* nBufferLen)
|
||||
if (!NSBase64::Base64Decode((const char*)pFileContent, dwFileSize, *pBuffer, nBufferLen))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
oFile.CloseFile();
|
||||
return true;
|
||||
}
|
||||
@ -1051,37 +1049,49 @@ int main(int argc, char* argv[])
|
||||
int nBufferLen = NULL;
|
||||
BYTE* pBuffer = NULL;
|
||||
|
||||
if (true && GetFromBase64(NSFile::GetProcessDirectory() + L"/split.txt", &pBuffer, &nBufferLen))
|
||||
if (GetFromBase64(NSFile::GetProcessDirectory() + L"/split1.txt", &pBuffer, &nBufferLen))
|
||||
{
|
||||
std::vector<int> arrPages = { 2 };
|
||||
std::vector<int> arrPages = { 0 };
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
if (nLength > 4)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split.pdf"))
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split1.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
|
||||
BYTE* pMallocData = (BYTE*)malloc(nLength - 4);
|
||||
memcpy(pMallocData, pSplitPages + 4, nLength - 4);
|
||||
|
||||
MergePages(pGrFile, pMallocData, nLength - 4, 0, "merge1");
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
|
||||
if (true)
|
||||
if (GetFromBase64(NSFile::GetProcessDirectory() + L"/split2.txt", &pBuffer, &nBufferLen))
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.OpenFile(NSFile::GetProcessDirectory() + L"/split.pdf"))
|
||||
{
|
||||
DWORD dwFileSize = oFile.GetFileSize();
|
||||
BYTE* pFileContent = (BYTE*)malloc(dwFileSize);
|
||||
std::vector<int> arrPages = { 0 };
|
||||
BYTE* pSplitPages = SplitPages(pGrFile, arrPages.data(), arrPages.size(), pBuffer, nBufferLen);
|
||||
int nLength = READ_INT(pSplitPages);
|
||||
|
||||
DWORD dwReaded;
|
||||
if (oFile.ReadFile(pFileContent, dwFileSize, dwReaded))
|
||||
MergePages(pGrFile, pFileContent, dwReaded, 0, "merge1");
|
||||
if (nLength > 4)
|
||||
{
|
||||
NSFile::CFileBinary oFile;
|
||||
if (oFile.CreateFileW(NSFile::GetProcessDirectory() + L"/split2.pdf"))
|
||||
oFile.WriteFile(pSplitPages + 4, nLength - 4);
|
||||
oFile.CloseFile();
|
||||
|
||||
BYTE* pMallocData = (BYTE*)malloc(nLength - 4);
|
||||
memcpy(pMallocData, pSplitPages + 4, nLength - 4);
|
||||
|
||||
MergePages(pGrFile, pMallocData, nLength - 4, 0, "merge2");
|
||||
}
|
||||
oFile.CloseFile();
|
||||
RELEASEARRAYOBJECTS(pSplitPages);
|
||||
}
|
||||
RELEASEARRAYOBJECTS(pBuffer);
|
||||
}
|
||||
|
||||
// INFO
|
||||
@ -1125,15 +1135,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
}
|
||||
|
||||
BYTE* pColor = new BYTE[12] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||
// REDACT
|
||||
if (false)
|
||||
{
|
||||
int pRect[8] = { 307499, 217499, 307499, 1124999, 1799999, 1124999, 1799999, 217499 };
|
||||
if (!RedactPage(pGrFile, nTestPage, pRect, 1, pColor, 12))
|
||||
std::cout << "Redact false" << std::endl;
|
||||
}
|
||||
|
||||
int i = nTestPage;
|
||||
//for (int i = 0; i < nPagesCount; ++i)
|
||||
{
|
||||
@ -1161,6 +1162,7 @@ int main(int argc, char* argv[])
|
||||
RELEASEARRAYOBJECTS(res);
|
||||
}
|
||||
}
|
||||
|
||||
free(pInfo);
|
||||
|
||||
// LINKS
|
||||
@ -1513,8 +1515,6 @@ int main(int argc, char* argv[])
|
||||
std::cout << "; font-actual:" << std::string((char*)(pAnnots + i), nPathLength) << "; ";
|
||||
i += nPathLength;
|
||||
}
|
||||
if (nFontFlag & (1 << 7))
|
||||
std::cout << "; dir:rtl; ";
|
||||
|
||||
nPathLength = READ_INT(pAnnots + i);
|
||||
i += 4;
|
||||
|
||||
@ -121,8 +121,7 @@ METAFILE_PATH = $$PWD/../../raster/Metafile
|
||||
$$METAFILE_PATH/svg/SvgObjects/CFont.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CStyle.h \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CObjectBase.h \
|
||||
$$METAFILE_PATH/svg/SvgUtils.h \
|
||||
$$METAFILE_PATH/svg/SvgReader.h
|
||||
$$METAFILE_PATH/svg/SvgUtils.h
|
||||
|
||||
SOURCES += \
|
||||
$$METAFILE_PATH/svg/CSvgFile.cpp \
|
||||
@ -146,8 +145,7 @@ METAFILE_PATH = $$PWD/../../raster/Metafile
|
||||
$$METAFILE_PATH/svg/SvgObjects/CPolyline.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CFont.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CObjectBase.cpp \
|
||||
$$METAFILE_PATH/svg/SvgObjects/CStyle.cpp \
|
||||
$$METAFILE_PATH/svg/SvgReader.cpp
|
||||
$$METAFILE_PATH/svg/SvgObjects/CStyle.cpp
|
||||
|
||||
CONFIG += css_calculator_without_xhtml
|
||||
|
||||
|
||||
@ -282,7 +282,8 @@ SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/JBig2/source/JBig2File.cpp
|
||||
|
||||
SOURCES += \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/PICFile.cpp \
|
||||
$$LIB_GRAPHICS_PRI_PATH/raster/PICT/pic.cpp
|
||||
|
||||
!build_xp {
|
||||
CONFIG += support_heif
|
||||
|
||||
@ -113,7 +113,10 @@ const long c_BrushTypeTensorCurveGradient = 6007;
|
||||
|
||||
const long c_BrushTextureModeStretch = 0;
|
||||
const long c_BrushTextureModeTile = 1;
|
||||
const long c_BrushTextureModeTileCenter = 2;
|
||||
const long c_BrushTextureModeTileFlipX = 2;
|
||||
const long c_BrushTextureModeTileFlipY = 3;
|
||||
const long c_BrushTextureModeTileFlipXY = 4;
|
||||
const long c_BrushTextureModeTileCenter = 5;
|
||||
// --------------------------------------------------------------
|
||||
|
||||
namespace Aggplus { class CImage; }
|
||||
@ -284,6 +287,13 @@ namespace NSStructures
|
||||
Aggplus::RectF Rect;
|
||||
Aggplus::CDoubleRect Bounds;
|
||||
|
||||
int IsScale;
|
||||
double ScaleX;
|
||||
double ScaleY;
|
||||
|
||||
double OffsetX;
|
||||
double OffsetY;
|
||||
|
||||
double LinearAngle;
|
||||
std::vector<TSubColor> m_arrSubColors;
|
||||
NSStructures::GradientInfo m_oGradientInfo;
|
||||
@ -415,6 +425,13 @@ namespace NSStructures
|
||||
Rect.Width = 0.0F;
|
||||
Rect.Height = 0.0F;
|
||||
|
||||
IsScale = FALSE;
|
||||
ScaleX = 1.0;
|
||||
ScaleY = 1.0;
|
||||
|
||||
OffsetX = 0.0;
|
||||
OffsetY = 0.0;
|
||||
|
||||
Bounds.left = 0;
|
||||
Bounds.top = 0;
|
||||
Bounds.right = 0;
|
||||
@ -454,6 +471,10 @@ namespace NSStructures
|
||||
Rect = other.Rect;
|
||||
Bounds = other.Bounds;
|
||||
|
||||
IsScale = other.IsScale;
|
||||
ScaleX = other.ScaleX;
|
||||
ScaleY = other.ScaleY;
|
||||
|
||||
LinearAngle = other.LinearAngle;
|
||||
m_arrSubColors = other.m_arrSubColors;
|
||||
m_oGradientInfo = other.m_oGradientInfo;
|
||||
|
||||
@ -50,9 +50,9 @@ TEST(BooleanOperations, NoIntersOutside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, NoIntersInside)
|
||||
@ -105,9 +105,9 @@ TEST(BooleanOperations, NoIntersInside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OneIntersOutside)
|
||||
@ -154,9 +154,9 @@ TEST(BooleanOperations, OneIntersOutside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OneIntersInside)
|
||||
@ -206,9 +206,9 @@ TEST(BooleanOperations, OneIntersInside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OverlapOutside)
|
||||
@ -258,9 +258,9 @@ TEST(BooleanOperations, OverlapOutside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, OverlapInside)
|
||||
@ -312,9 +312,9 @@ TEST(BooleanOperations, OverlapInside)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, LineIntersLine)
|
||||
@ -368,9 +368,9 @@ TEST(BooleanOperations, LineIntersLine)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CurveIntersLine)
|
||||
@ -415,9 +415,9 @@ TEST(BooleanOperations, CurveIntersLine)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CurveIntersCurve)
|
||||
@ -453,9 +453,9 @@ TEST(BooleanOperations, CurveIntersCurve)
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, RectIntersRect)
|
||||
@ -508,9 +508,9 @@ TEST(BooleanOperations, RectIntersRect)
|
||||
resultSubtract.LineTo(55.0, 25.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, EllipseIntersEllipse)
|
||||
@ -550,9 +550,9 @@ TEST(BooleanOperations, EllipseIntersEllipse)
|
||||
resultSubtract.CurveTo(303.228, 82.0, 348.0, 126.772, 348.0, 182.0);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, EllipseIntersCross)
|
||||
@ -621,9 +621,9 @@ TEST(BooleanOperations, EllipseIntersCross)
|
||||
resultSubtract.CurveTo(188.228, 60, 233, 104.772, 233, 160);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, TriangleIntersEllipse)
|
||||
@ -665,9 +665,9 @@ TEST(BooleanOperations, TriangleIntersEllipse)
|
||||
resultSubtract.CurveTo(243.078, 286.812, 260.127, 260.386, 263.419, 229.839);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, TwoVerticesInters)
|
||||
@ -715,9 +715,9 @@ TEST(BooleanOperations, TwoVerticesInters)
|
||||
resultSubtract.LineTo(-300, -300);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, RectIntersEllipse)
|
||||
@ -773,9 +773,9 @@ TEST(BooleanOperations, RectIntersEllipse)
|
||||
resultSubtract.CurveTo(257.623, 242.785, 258.883, 240.478, 260, 238.092);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, RectIntersCross)
|
||||
@ -869,9 +869,9 @@ TEST(BooleanOperations, RectIntersCross)
|
||||
resultSubtract.LineTo(-89.5, 24);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CrossIntersTriangle)
|
||||
@ -977,9 +977,9 @@ TEST(BooleanOperations, CrossIntersTriangle)
|
||||
resultSubtract.LineTo(-6, 3.5);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, CrossIntersCross)
|
||||
@ -1077,9 +1077,9 @@ TEST(BooleanOperations, CrossIntersCross)
|
||||
resultSubtract.LineTo(-72, -191);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, EllipseTouchEllipse)
|
||||
@ -1119,9 +1119,9 @@ TEST(BooleanOperations, EllipseTouchEllipse)
|
||||
resultSubtract.CurveTo(138.137, 237, 165, 210.137, 165, 177);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
TEST(BooleanOperations, TriangleOverlapTriangle)
|
||||
@ -1170,7 +1170,7 @@ TEST(BooleanOperations, TriangleOverlapTriangle)
|
||||
resultSubtract.LineTo(-200, -300);
|
||||
resultSubtract.CloseFigure();
|
||||
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection).Equals(resultIntersect));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union).Equals(resultUnite));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction).Equals(resultSubtract));
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Intersection) == resultIntersect);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Union) == resultUnite);
|
||||
EXPECT_TRUE(Aggplus::CalcBooleanOperation(path1, path2, Aggplus::Subtraction) == resultSubtract);
|
||||
}
|
||||
|
||||
@ -450,15 +450,15 @@ bool CBgraFrame::OpenFile(const std::wstring& strFileName, unsigned int nFileTyp
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
CPictFile pict_file;
|
||||
return pict_file.Open(this, strFileName, m_bIsRGBA);
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, strFileName, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CXIMAGE_SUPPORT_HEIF
|
||||
if (CXIMAGE_FORMAT_HEIF == m_nFileType)
|
||||
{
|
||||
return NSHeif::CHeifFile::Open(this, strFileName, m_bIsRGBA);
|
||||
return NSHeif::CHeifFile::Open(this, strFileName, m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -540,8 +540,8 @@ bool CBgraFrame::Decode(BYTE* pBuffer, int nSize, unsigned int nFileType)
|
||||
#if CXIMAGE_SUPPORT_PIC
|
||||
if (CXIMAGE_FORMAR_PIC == m_nFileType)
|
||||
{
|
||||
CPictFile pict_file;
|
||||
return pict_file.Open(this, pBuffer, nSize, m_bIsRGBA);
|
||||
PICT::CPictFile PIC;
|
||||
return PIC.Open(this, pBuffer, nSize, !m_bIsRGBA);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ namespace MetaFile
|
||||
virtual void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int nBlendMode) = 0;
|
||||
|
||||
virtual void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) = 0;
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) = 0;
|
||||
|
||||
virtual void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) = 0;
|
||||
|
||||
|
||||
@ -352,7 +352,7 @@ namespace MetaFile
|
||||
|
||||
}
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double _dX, double _dY, double* pDx, int iGraphicsMode, double dXScale, double dYScale, bool bUseGID)
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double _dX, double _dY, double* pDx, int iGraphicsMode, double dXScale, double dYScale)
|
||||
{
|
||||
CheckEndPath();
|
||||
const IFont* pFont = m_pFile->GetFont();
|
||||
@ -681,12 +681,11 @@ namespace MetaFile
|
||||
m_pRenderer->put_BrushColor1(m_pFile->GetTextColor());
|
||||
m_pRenderer->put_BrushAlpha1(255);
|
||||
|
||||
if (bUseGID)
|
||||
m_pRenderer->put_FontStringGID(TRUE);
|
||||
|
||||
// Рисуем сам текст
|
||||
if (NULL == pDx)
|
||||
{
|
||||
m_pRenderer->CommandDrawText(wsString, dX, dY, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int unUnicodeLen = 0;
|
||||
@ -705,9 +704,6 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
if (bUseGID)
|
||||
m_pRenderer->put_FontStringGID(FALSE);
|
||||
|
||||
if (bChangeCTM)
|
||||
m_pRenderer->ResetTransform();
|
||||
}
|
||||
|
||||
@ -999,21 +999,20 @@ namespace MetaFile
|
||||
{
|
||||
std::wstring wsText;
|
||||
for (const wchar_t& wChar : wsString)
|
||||
{
|
||||
if (wChar == L'<')
|
||||
if (wChar == L'<')
|
||||
wsText += L"<";
|
||||
else if (wChar == L'>')
|
||||
else if (wChar == L'>')
|
||||
wsText += L">";
|
||||
else if (wChar == L'&')
|
||||
else if (wChar == L'&')
|
||||
wsText += L"&";
|
||||
else if (wChar == L'\'')
|
||||
else if (wChar == L'\'')
|
||||
wsText += L"'";
|
||||
else if (wChar == L'"')
|
||||
else if (wChar == L'"')
|
||||
wsText += L""";
|
||||
else if (wChar == L'\r' || (wChar >= 0x00 && wChar <=0x1F))
|
||||
continue;
|
||||
else wsText += wChar;
|
||||
}
|
||||
|
||||
else wsText += wChar;
|
||||
return wsText;
|
||||
}
|
||||
|
||||
|
||||
@ -218,7 +218,7 @@ namespace MetaFile
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override {};
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override {};
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override {};
|
||||
|
||||
|
||||
@ -80,10 +80,10 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
void CEmfInterpretatorArray::DrawString(std::wstring &wsText, unsigned int unCharsCount, double dX, double dY, double *pDx,
|
||||
int iGraphicsMode, double dXScale, double dYScale, bool bUseGID)
|
||||
int iGraphicsMode, double dXScale, double dYScale)
|
||||
{
|
||||
for (CEmfInterpretatorBase* pInterpretator : m_arInterpretators)
|
||||
pInterpretator->DrawString(wsText, unCharsCount, dX, dY, pDx, iGraphicsMode, dXScale, dYScale, bUseGID);
|
||||
pInterpretator->DrawString(wsText, unCharsCount, dX, dY, pDx, iGraphicsMode, dXScale, dYScale);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorArray::DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints)
|
||||
|
||||
@ -36,7 +36,7 @@ namespace MetaFile
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override;
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override;
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override;
|
||||
|
||||
|
||||
@ -41,10 +41,10 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::DrawString(std::wstring &wsText, unsigned int unCharsCount, double dX, double dY, double *pDx,
|
||||
int iGraphicsMode, double dXScale, double dYScale, bool bUseGID)
|
||||
int iGraphicsMode, double dXScale, double dYScale)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->DrawString(wsText, unCharsCount, dX, dY, pDx, iGraphicsMode, dXScale, dYScale, bUseGID);
|
||||
m_pMetaFileRenderer->DrawString(wsText, unCharsCount, dX, dY, pDx, iGraphicsMode, dXScale, dYScale);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorRender::DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints)
|
||||
|
||||
@ -22,7 +22,7 @@ namespace MetaFile
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override;
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override;
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override;
|
||||
|
||||
|
||||
@ -346,7 +346,7 @@ namespace MetaFile
|
||||
if (NULL != oTEmfExtTextoutA.oEmrText.pOutputDx)
|
||||
arDx = std::vector<double>(oTEmfExtTextoutA.oEmrText.pOutputDx, oTEmfExtTextoutA.oEmrText.pOutputDx + oTEmfExtTextoutA.oEmrText.unChars);
|
||||
|
||||
WriteText(wsText, TPointD(oTEmfExtTextoutA.oEmrText.oReference.X, oTEmfExtTextoutA.oEmrText.oReference.Y), oTEmfExtTextoutA.oBounds, TPointD(oTEmfExtTextoutA.dExScale, oTEmfExtTextoutA.dEyScale), arDx, oTEmfExtTextoutA.oEmrText.unOptions & 0x00000010);
|
||||
WriteText(wsText, TPointD(oTEmfExtTextoutA.oEmrText.oReference.X, oTEmfExtTextoutA.oEmrText.oReference.Y), oTEmfExtTextoutA.oBounds, TPointD(oTEmfExtTextoutA.dExScale, oTEmfExtTextoutA.dEyScale), arDx);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorSvg::HANDLE_EMR_EXTTEXTOUTW(const TEmfExtTextoutW &oTEmfExtTextoutW)
|
||||
@ -358,7 +358,7 @@ namespace MetaFile
|
||||
if (NULL != oTEmfExtTextoutW.oEmrText.pOutputDx)
|
||||
arDx = std::vector<double>(oTEmfExtTextoutW.oEmrText.pOutputDx, oTEmfExtTextoutW.oEmrText.pOutputDx + oTEmfExtTextoutW.oEmrText.unChars);
|
||||
|
||||
WriteText(wsText, TPointD(oTEmfExtTextoutW.oEmrText.oReference.X, oTEmfExtTextoutW.oEmrText.oReference.Y), oTEmfExtTextoutW.oBounds, TPointD(oTEmfExtTextoutW.dExScale, oTEmfExtTextoutW.dEyScale), arDx, oTEmfExtTextoutW.oEmrText.unOptions & 0x00000010);
|
||||
WriteText(wsText, TPointD(oTEmfExtTextoutW.oEmrText.oReference.X, oTEmfExtTextoutW.oEmrText.oReference.Y), oTEmfExtTextoutW.oBounds, TPointD(oTEmfExtTextoutW.dExScale, oTEmfExtTextoutW.dEyScale), arDx);
|
||||
}
|
||||
|
||||
void CEmfInterpretatorSvg::HANDLE_EMR_LINETO(const TPointL &oPoint)
|
||||
|
||||
@ -202,7 +202,7 @@ namespace MetaFile
|
||||
void End() override {};
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override {};
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override {};
|
||||
|
||||
|
||||
@ -216,7 +216,7 @@ namespace MetaFile
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override {};
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override {};
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override {};
|
||||
|
||||
|
||||
@ -411,7 +411,7 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
void CEmfParserBase::DrawText(std::wstring &wsString, unsigned int unCharsCount, int _nX, int _nY,
|
||||
int *pnDx, int iGraphicsMode, TScale oScale, bool bUseGID)
|
||||
int *pnDx, int iGraphicsMode, TScale oScale)
|
||||
{
|
||||
int nX = _nX;
|
||||
int nY = _nY;
|
||||
@ -448,7 +448,7 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
m_pInterpretator->DrawString(wsString, unCharsCount, dX, dY, pdDx, iGraphicsMode, oScale.X, oScale.Y, bUseGID);
|
||||
m_pInterpretator->DrawString(wsString, unCharsCount, dX, dY, pdDx, iGraphicsMode, oScale.X, oScale.Y);
|
||||
|
||||
if (pdDx)
|
||||
delete[] pdDx;
|
||||
@ -480,7 +480,7 @@ namespace MetaFile
|
||||
}
|
||||
}
|
||||
|
||||
DrawText(wsText, oText.unChars, oText.oReference.X, oText.oReference.Y, pDx, iGraphicsMode, oScale, oText.unOptions & 0x00000010);
|
||||
DrawText(wsText, oText.unChars, oText.oReference.X, oText.oReference.Y, pDx, iGraphicsMode, oScale);
|
||||
|
||||
if (pDx)
|
||||
delete[] pDx;
|
||||
@ -550,7 +550,7 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
if (unLen)
|
||||
DrawText(wsText, unLen, oText.oReference.X, oText.oReference.Y, pDx, iGraphicsMode, oScale, oText.unOptions & 0x00000010);
|
||||
DrawText(wsText, unLen, oText.oReference.X, oText.oReference.Y, pDx, iGraphicsMode, oScale);
|
||||
|
||||
if (pDx)
|
||||
delete[] pDx;
|
||||
|
||||
@ -156,7 +156,7 @@ namespace MetaFile
|
||||
void ArcTo(int nL, int nT, int nR, int nB, double dStart, double dSweep);
|
||||
|
||||
void DrawPath(bool bStroke, bool bFill, bool bClosePath = true);
|
||||
void DrawText(std::wstring &wsString, unsigned int unCharsCount, int _nX, int _nY, int *pnDx, int iGraphicsMode, TScale oScale, bool bUseGID);
|
||||
void DrawText(std::wstring &wsString, unsigned int unCharsCount, int _nX, int _nY, int *pnDx, int iGraphicsMode, TScale oScale);
|
||||
void DrawTextA(TEmrTextA &oText, int iGraphicsMode, TScale oScale = TScale(1, 1));
|
||||
void DrawTextW(TEmrTextW &oText, int iGraphicsMode, TScale oScale = TScale(1, 1));
|
||||
|
||||
|
||||
@ -68,10 +68,6 @@ namespace MetaFile
|
||||
#ifdef METAFILE_SUPPORT_SVM
|
||||
m_oSvmFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
|
||||
#ifdef METAFILE_SUPPORT_SVG
|
||||
m_oSvgFile.SetFontManager(m_pFontManager);
|
||||
#endif
|
||||
m_lType = 0;
|
||||
}
|
||||
|
||||
@ -88,6 +84,7 @@ namespace MetaFile
|
||||
|
||||
std::wstring CMetaFile::ConvertToSvg(unsigned int unWidth, unsigned int unHeight)
|
||||
{
|
||||
|
||||
#ifdef METAFILE_SUPPORT_WMF_EMF
|
||||
if (c_lMetaWmf == m_lType)
|
||||
{
|
||||
|
||||
@ -217,23 +217,15 @@ namespace MetaFile
|
||||
m_pXmlWriter->WriteNodeEnd(wsNodeName, false, false);
|
||||
}
|
||||
|
||||
void UpdateStringByGID(std::wstring &wsValue, const std::wstring& wsFontName, const double& dFontSize, const int& nFontStyle, NSFonts::IFontManager* pFontManeger)
|
||||
{
|
||||
if (nullptr == pFontManeger)
|
||||
return;
|
||||
|
||||
pFontManeger->LoadFontByName(wsFontName, dFontSize, nFontStyle, 96, 96);
|
||||
|
||||
for (wchar_t& wChar : wsValue)
|
||||
wChar = (wchar_t)pFontManeger->GetUnicodeByGID(wChar);
|
||||
}
|
||||
|
||||
void CInterpretatorSvgBase::WriteText(const std::wstring &wsText, const TPointD &oCoord, const TRectL &oBounds, const TPointD &oScale, const std::vector<double>& arDx, bool bUseGID)
|
||||
void CInterpretatorSvgBase::WriteText(const std::wstring &wsText, const TPointD &oCoord, const TRectL &oBounds, const TPointD &oScale, const std::vector<double>& arDx)
|
||||
{
|
||||
if (NULL == m_pParser || NULL == m_pParser->GetFont())
|
||||
return;
|
||||
|
||||
std::wstring wsNormalizedText{wsText};
|
||||
const std::wstring wsNormalizedText = StringNormalization(wsText);
|
||||
|
||||
if (wsNormalizedText.empty())
|
||||
return;
|
||||
|
||||
AddClip();
|
||||
|
||||
@ -306,22 +298,6 @@ namespace MetaFile
|
||||
oFontName.WriteEncodeXmlString(pFontInfo->m_wsFontName);
|
||||
oFontName.WriteEncodeXmlString(L"\'");
|
||||
}
|
||||
|
||||
if (bUseGID)
|
||||
{
|
||||
int nStyle = 0;
|
||||
if (pFont->GetWeight() > 550)
|
||||
nStyle |= 0x01;
|
||||
if (pFont->IsItalic())
|
||||
nStyle |= 0x02;
|
||||
if (pFont->IsUnderline())
|
||||
nStyle |= (1 << 2);
|
||||
if (pFont->IsStrikeOut())
|
||||
nStyle |= (1 << 7);
|
||||
|
||||
UpdateStringByGID(wsNormalizedText, (NULL != pFontInfo) ? pFontInfo->m_wsFontName : pFont->GetFaceName(),
|
||||
dFontHeight, nStyle, m_pParser->GetFontManager());
|
||||
}
|
||||
#endif
|
||||
arNodeAttributes.Add(L"font-family", oFontName.GetData());
|
||||
}
|
||||
@ -448,7 +424,7 @@ namespace MetaFile
|
||||
arNodeAttributes.Add(L"x", wsXCoord);
|
||||
arNodeAttributes.Add(L"y", dYCoord);
|
||||
|
||||
WriteNode(L"text", arNodeAttributes, StringNormalization(wsNormalizedText));
|
||||
WriteNode(L"text", arNodeAttributes, wsNormalizedText);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -460,7 +436,7 @@ namespace MetaFile
|
||||
do
|
||||
{
|
||||
WriteNode(L"tspan", {{L"x", wsXCoord},
|
||||
{L"y", ConvertToWString(dYNewCoord)}}, StringNormalization(wsNormalizedText.substr(unStart, unPosLineBreak - unStart)));
|
||||
{L"y", ConvertToWString(dYNewCoord)}}, wsNormalizedText.substr(unStart, unPosLineBreak - unStart));
|
||||
|
||||
dYNewCoord += dFontHeight * 1.6;
|
||||
unStart = wsNormalizedText.find_first_not_of(L"\n", unPosLineBreak);
|
||||
|
||||
@ -106,7 +106,7 @@ namespace MetaFile
|
||||
void WriteNode(const std::wstring& wsNodeName, const NodeAttributes& arAttributes, const std::wstring& wsValueNode = L"");
|
||||
void WriteNodeBegin(const std::wstring& wsNodeName, const NodeAttributes& arAttributes);
|
||||
void WriteNodeEnd(const std::wstring& wsNodeName);
|
||||
void WriteText(const std::wstring& wsText, const TPointD& oCoord, const TRectL& oBounds = TRectL(), const TPointD& oScale = TPointD(1, 1), const std::vector<double>& arDx = {}, bool bUseGID = false);
|
||||
void WriteText(const std::wstring& wsText, const TPointD& oCoord, const TRectL& oBounds = TRectL(), const TPointD& oScale = TPointD(1, 1), const std::vector<double>& arDx = {});
|
||||
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
|
||||
@ -29,10 +29,10 @@ namespace MetaFile
|
||||
}
|
||||
|
||||
void CWmfInterpretatorRender::DrawString(std::wstring &wsText, unsigned int unCharsCount, double dX, double dY, double *pDx,
|
||||
int iGraphicsMode, double dXScale, double dYScale, bool bUseGID)
|
||||
int iGraphicsMode, double dXScale, double dYScale)
|
||||
{
|
||||
if (NULL != m_pMetaFileRenderer)
|
||||
m_pMetaFileRenderer->DrawString(wsText, unCharsCount, dX, dY, pDx, iGraphicsMode, dXScale, dYScale, bUseGID);
|
||||
m_pMetaFileRenderer->DrawString(wsText, unCharsCount, dX, dY, pDx, iGraphicsMode, dXScale, dYScale);
|
||||
}
|
||||
|
||||
void CWmfInterpretatorRender::DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints)
|
||||
|
||||
@ -19,7 +19,7 @@ namespace MetaFile
|
||||
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight, unsigned int unBlendMode) override;
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override;
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override;
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override;
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ namespace MetaFile
|
||||
void End() override {};
|
||||
|
||||
void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, double* pDx,
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1, bool bUseGID = false) override {};
|
||||
int iGraphicsMode = 1, double dXScale = 1, double dYScale = 1) override {};
|
||||
|
||||
void DrawDriverString(const std::wstring& wsString, const std::vector<TPointD>& arPoints) override {};
|
||||
|
||||
|
||||
@ -3,13 +3,11 @@
|
||||
#include "SvgObjects/CContainer.h"
|
||||
#include "SvgObjects/CFont.h"
|
||||
|
||||
#include "CSvgParser.h"
|
||||
|
||||
#define SVG_FILE_WIDTH 300
|
||||
#define SVG_FILE_HEIGHT 150
|
||||
|
||||
CSvgFile::CSvgFile()
|
||||
: m_pContainer(NULL), m_pFontManager(NULL)
|
||||
: m_oContainer(L"svg")
|
||||
{}
|
||||
|
||||
CSvgFile::~CSvgFile()
|
||||
@ -26,10 +24,7 @@ bool CSvgFile::ReadFromBuffer(BYTE *pBuffer, unsigned int unSize)
|
||||
bool CSvgFile::ReadFromWString(const std::wstring &wsContext)
|
||||
{
|
||||
Clear();
|
||||
|
||||
SVG::CSvgParser oSvgParser(m_pFontManager);
|
||||
|
||||
return oSvgParser.LoadFromString(wsContext, m_pContainer, this);
|
||||
return m_oParser.LoadFromString(wsContext, &m_oContainer, this);
|
||||
}
|
||||
|
||||
bool CSvgFile::OpenFromFile(const std::wstring &wsFile)
|
||||
@ -38,14 +33,58 @@ bool CSvgFile::OpenFromFile(const std::wstring &wsFile)
|
||||
|
||||
m_wsWorkingDirectory = NSFile::GetDirectoryName(wsFile);
|
||||
|
||||
SVG::CSvgParser oSvgParser(m_pFontManager);
|
||||
|
||||
return oSvgParser.LoadFromFile(wsFile, m_pContainer, this);
|
||||
return m_oParser.LoadFromFile(wsFile, &m_oContainer, this);
|
||||
}
|
||||
|
||||
bool CSvgFile::GetBounds(double &dX, double &dY, double &dWidth, double &dHeight) const
|
||||
{
|
||||
return CalculateFinalSize(true, dX, dY, dWidth, dHeight);
|
||||
if (m_oContainer.Empty())
|
||||
return false;
|
||||
|
||||
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);
|
||||
|
||||
dWidth = 0.;
|
||||
dHeight = 0.;
|
||||
|
||||
if (!oWindow.m_oWidth.Empty() && !oWindow.m_oWidth.Zero())
|
||||
{
|
||||
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
|
||||
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())
|
||||
{
|
||||
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
|
||||
dHeight = m_oContainer.GetViewBox().m_oHeight.ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (DBL_EPSILON > dWidth)
|
||||
dWidth = SVG_FILE_WIDTH;
|
||||
if (DBL_EPSILON > dHeight)
|
||||
dHeight = SVG_FILE_HEIGHT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
const SVG::CSvgCalculator *CSvgFile::GetSvgCalculator() const
|
||||
@ -55,7 +94,7 @@ const SVG::CSvgCalculator *CSvgFile::GetSvgCalculator() const
|
||||
|
||||
void CSvgFile::SetFontManager(NSFonts::IFontManager *pFontManager)
|
||||
{
|
||||
m_pFontManager = pFontManager;
|
||||
m_oParser.SetFontManager(pFontManager);
|
||||
}
|
||||
|
||||
void CSvgFile::SetWorkingDirectory(const std::wstring &wsWorkingDirectory)
|
||||
@ -68,13 +107,7 @@ bool CSvgFile::MarkObject(SVG::CObject *pObject)
|
||||
if (NULL == pObject || pObject->GetId().empty())
|
||||
return false;
|
||||
|
||||
pObject->Mark();
|
||||
|
||||
const MarkedMap::const_iterator itFound = m_mMarkedObjects.find(pObject->GetId());
|
||||
|
||||
if (m_mMarkedObjects.cend() != itFound)
|
||||
RELEASEINTERFACE(m_mMarkedObjects[pObject->GetId()])
|
||||
|
||||
pObject->AddRef();
|
||||
m_mMarkedObjects[pObject->GetId()] = pObject;
|
||||
|
||||
return true;
|
||||
@ -127,42 +160,69 @@ void CSvgFile::AddFontFace(const SVG::TFontArguments& oArguments, const std::wst
|
||||
|
||||
bool CSvgFile::Draw(IRenderer *pRenderer, double dX, double dY, double dWidth, double dHeight)
|
||||
{
|
||||
if (NULL == pRenderer || NULL == m_pContainer || m_pContainer->Empty())
|
||||
if (NULL == pRenderer || m_oContainer.Empty())
|
||||
return false;
|
||||
|
||||
double dFileX, dFileY, dFileWidth, dFileHeight;
|
||||
SVG::TRect oWindow = m_oContainer.GetWindow();
|
||||
SVG::TRect oViewBox = m_oContainer.GetViewBox();
|
||||
|
||||
if (!CalculateFinalSize(false, dFileX, dFileY, dFileWidth, dFileHeight))
|
||||
if (oWindow.m_oWidth.Empty() || oWindow.m_oWidth.Zero())
|
||||
{
|
||||
if (oViewBox.m_oWidth.Empty() || oViewBox.m_oWidth.Zero())
|
||||
oWindow.m_oWidth = SVG_FILE_WIDTH;
|
||||
else
|
||||
{
|
||||
oWindow.m_oWidth = oViewBox.m_oWidth;
|
||||
oViewBox.m_oWidth.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (oWindow.m_oHeight.Empty() || oWindow.m_oHeight.Zero())
|
||||
{
|
||||
if (oViewBox.m_oHeight.Empty() || oViewBox.m_oHeight.Zero())
|
||||
oWindow.m_oHeight = SVG_FILE_HEIGHT;
|
||||
else
|
||||
{
|
||||
oWindow.m_oHeight = oViewBox.m_oHeight;
|
||||
oViewBox.m_oHeight.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
double dViewBoxWidth = oViewBox.m_oWidth.ToDouble(NSCSS::Pixel, SVG_FILE_WIDTH);
|
||||
double dViewBoxHeight = oViewBox.m_oHeight.ToDouble(NSCSS::Pixel, SVG_FILE_HEIGHT);
|
||||
|
||||
double dWindowWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, dViewBoxWidth);
|
||||
double dWindowHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, dViewBoxHeight);
|
||||
|
||||
if (SVG::Equals(0., dWindowWidth) || SVG::Equals(0., dWindowHeight))
|
||||
return false;
|
||||
|
||||
double oldTransform[6];
|
||||
oldTransform[0] = oldTransform[3] = 1;
|
||||
oldTransform[1] = oldTransform[2] = oldTransform[4] = oldTransform[5] = 0;
|
||||
|
||||
pRenderer->GetTransform(&oldTransform[0], &oldTransform[1], &oldTransform[2], &oldTransform[3], &oldTransform[4], &oldTransform[5]);
|
||||
pRenderer->ResetTransform();
|
||||
|
||||
const double dM11 = dWidth / dFileWidth;
|
||||
const double dM22 = dHeight / dFileHeight;
|
||||
double dM11 = dWidth / dWindowWidth;
|
||||
double dM22 = dHeight / dWindowHeight;
|
||||
|
||||
double dScaleX = 1.,
|
||||
dScaleY = 1.;
|
||||
double dTranslateX = dFileX * dM11,
|
||||
dTranslateY = dFileY * dM22;
|
||||
double dScaleX = 1, dScaleY = 1;
|
||||
|
||||
const SVG::TRect oViewBox{m_pContainer->GetViewBox()};
|
||||
if (!SVG::Equals(0., dViewBoxWidth))
|
||||
dScaleX = dWindowWidth / dViewBoxWidth;
|
||||
|
||||
if (!oViewBox.m_oWidth.Empty() && !oViewBox.m_oHeight.Empty())
|
||||
{
|
||||
dScaleX = dFileWidth / oViewBox.m_oWidth .ToDouble(NSCSS::Pixel, SVG_FILE_WIDTH );
|
||||
dScaleY = dFileHeight / oViewBox.m_oHeight.ToDouble(NSCSS::Pixel, SVG_FILE_HEIGHT);
|
||||
if (!SVG::Equals(0., dViewBoxHeight))
|
||||
dScaleY = dWindowHeight / dViewBoxHeight;
|
||||
|
||||
dTranslateX -= oViewBox.m_oX.ToDouble(NSCSS::Pixel) * dScaleX * dM11;
|
||||
dTranslateY -= oViewBox.m_oY.ToDouble(NSCSS::Pixel) * dScaleY * dM22;
|
||||
}
|
||||
double dMinScale = std::min(dScaleX, dScaleY);
|
||||
|
||||
const double dMinScale = std::min(dScaleX, dScaleY);
|
||||
pRenderer->SetTransform(dM11 * dMinScale, 0, 0, dM22 * dMinScale, dTranslateX, dTranslateY);
|
||||
double dSkipX = -oViewBox.m_oX.ToDouble(NSCSS::Pixel) * dScaleX * dM11;
|
||||
double dSkipY = -oViewBox.m_oY.ToDouble(NSCSS::Pixel) * dScaleY * dM22;
|
||||
|
||||
bool bResult = m_pContainer->Draw(pRenderer, this);
|
||||
pRenderer->SetTransform(dM11 * dMinScale, 0, 0, dM22 * dMinScale, dSkipX, dSkipY);
|
||||
|
||||
bool bResult = m_oContainer.Draw(pRenderer, this);
|
||||
|
||||
pRenderer->SetTransform(oldTransform[0], oldTransform[1], oldTransform[2], oldTransform[3], oldTransform[4], oldTransform[5]);
|
||||
|
||||
@ -171,7 +231,7 @@ bool CSvgFile::Draw(IRenderer *pRenderer, double dX, double dY, double dWidth, d
|
||||
|
||||
void CSvgFile::Clear()
|
||||
{
|
||||
RELEASEOBJECT(m_pContainer);
|
||||
m_oContainer.Clear();
|
||||
m_oSvgCalculator.Clear();
|
||||
|
||||
for (MarkedMap::reference oIter : m_mMarkedObjects)
|
||||
@ -180,141 +240,3 @@ void CSvgFile::Clear()
|
||||
m_mMarkedObjects.clear();
|
||||
m_wsWorkingDirectory.clear();
|
||||
}
|
||||
|
||||
bool CSvgFile::CalculateFinalSize(bool bUseViewBox, double& dX, double& dY, double& dWidth, double& dHeight) const
|
||||
{
|
||||
if (NULL == m_pContainer || m_pContainer->Empty())
|
||||
return false;
|
||||
|
||||
const SVG::TRect oWindow = m_pContainer->GetWindow();
|
||||
const SVG::TRect oViewBox = m_pContainer->GetViewBox();
|
||||
|
||||
const double dViewBoxWidth {oViewBox.m_oWidth .ToDouble()};
|
||||
const double dViewBoxHeigth{oViewBox.m_oHeight.ToDouble()};
|
||||
|
||||
dX = 0.;
|
||||
dY = 0.;
|
||||
|
||||
dWidth = 0.;
|
||||
dHeight = 0.;
|
||||
|
||||
#define GET_PREV_WIDTH_VALUE ((NSCSS::UnitMeasure::Em == oWindow.m_oWidth.GetUnitMeasure() || NSCSS::UnitMeasure::Rem == oWindow.m_oWidth.GetUnitMeasure()) ? DEFAULT_FONT_SIZE : ((!SVG::Equals(0., dViewBoxWidth )) ? dViewBoxWidth : SVG_FILE_WIDTH))
|
||||
#define GET_PREV_HEIGHT_VALUE ((NSCSS::UnitMeasure::Em == oWindow.m_oHeight.GetUnitMeasure() || NSCSS::UnitMeasure::Rem == oWindow.m_oHeight.GetUnitMeasure()) ? DEFAULT_FONT_SIZE : ((!SVG::Equals(0., dViewBoxHeigth )) ? dViewBoxHeigth : SVG_FILE_HEIGHT))
|
||||
|
||||
if (!oWindow.m_oWidth.Empty() && !oWindow.m_oHeight.Empty())
|
||||
{
|
||||
dWidth = oWindow.m_oWidth .ToDouble(NSCSS::Pixel, GET_PREV_WIDTH_VALUE);
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, GET_PREV_HEIGHT_VALUE);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (bUseViewBox)
|
||||
{
|
||||
if (!oViewBox.m_oWidth.Empty() && !oViewBox.m_oHeight.Empty())
|
||||
{
|
||||
if (!oWindow.m_oWidth.Empty())
|
||||
{
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, GET_PREV_WIDTH_VALUE);
|
||||
const double dAspectRatio{dViewBoxWidth / dViewBoxHeigth};
|
||||
dHeight = dWidth / dAspectRatio;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!oWindow.m_oHeight.Empty())
|
||||
{
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, GET_PREV_HEIGHT_VALUE);
|
||||
const double dAspectRatio{dViewBoxWidth / dViewBoxHeigth};
|
||||
dWidth = dHeight * dAspectRatio;
|
||||
return true;
|
||||
}
|
||||
|
||||
dX = oViewBox.m_oX.ToDouble();
|
||||
dY = oViewBox.m_oY.ToDouble();
|
||||
|
||||
dWidth = dViewBoxWidth;
|
||||
dHeight = dViewBoxHeigth;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!oWindow.m_oWidth.Empty() || !oWindow.m_oHeight.Empty())
|
||||
{
|
||||
if (!oViewBox.m_oWidth.Empty() && !oViewBox.m_oHeight.Empty())
|
||||
{
|
||||
const double dAspectRatio{dViewBoxWidth / dViewBoxHeigth};
|
||||
|
||||
if (!oWindow.m_oWidth.Empty())
|
||||
{
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, GET_PREV_WIDTH_VALUE);
|
||||
dHeight = dWidth / dAspectRatio;
|
||||
}
|
||||
else if (!oWindow.m_oHeight.Empty())
|
||||
{
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, GET_PREV_HEIGHT_VALUE);
|
||||
dWidth = dHeight * dAspectRatio;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NULL != m_pContainer && !m_pContainer->Empty())
|
||||
{
|
||||
SVG::SvgMatrix oTransform;
|
||||
const SVG::TBounds oBounds{m_pContainer->GetBounds(&oTransform)};
|
||||
|
||||
const double dContentWidth {oBounds.m_dRight - oBounds.m_dLeft};
|
||||
const double dContentHeight{oBounds.m_dBottom - oBounds.m_dTop };
|
||||
|
||||
const double dAspectRatio{dContentWidth / dContentHeight};
|
||||
|
||||
if (!oWindow.m_oWidth.Empty())
|
||||
{
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, GET_PREV_WIDTH_VALUE);
|
||||
dHeight = dWidth / dAspectRatio;
|
||||
}
|
||||
else if (!oWindow.m_oHeight.Empty())
|
||||
{
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, GET_PREV_HEIGHT_VALUE);
|
||||
dWidth = dHeight * dAspectRatio;
|
||||
}
|
||||
|
||||
dX = oBounds.m_dLeft;
|
||||
dY = oBounds.m_dTop;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!oWindow.m_oWidth.Empty())
|
||||
{
|
||||
dWidth = oWindow.m_oWidth.ToDouble(NSCSS::Pixel, GET_PREV_WIDTH_VALUE);
|
||||
dHeight = SVG_FILE_HEIGHT;
|
||||
}
|
||||
else if (!oWindow.m_oHeight.Empty())
|
||||
{
|
||||
dHeight = oWindow.m_oHeight.ToDouble(NSCSS::Pixel, GET_PREV_HEIGHT_VALUE);
|
||||
dWidth = SVG_FILE_WIDTH;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (NULL != m_pContainer && !m_pContainer->Empty())
|
||||
{
|
||||
SVG::SvgMatrix oTransform;
|
||||
const SVG::TBounds oBounds{m_pContainer->GetBounds(&oTransform)};
|
||||
|
||||
dX = oBounds.m_dLeft;
|
||||
dY = oBounds.m_dTop;
|
||||
|
||||
dWidth = oBounds.m_dRight - oBounds.m_dLeft;
|
||||
dHeight = oBounds.m_dBottom - oBounds.m_dTop;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
dWidth = SVG_FILE_WIDTH;
|
||||
dHeight = SVG_FILE_HEIGHT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
#include "../../../graphics/IRenderer.h"
|
||||
#include "../../../graphics/pro/Fonts.h"
|
||||
|
||||
#include "CSvgParser.h"
|
||||
#include "SvgObjects/CStyle.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
struct TFontArguments;
|
||||
class CFont;
|
||||
class CGraphicsContainer;
|
||||
}
|
||||
|
||||
class CSvgFile
|
||||
@ -43,11 +43,9 @@ class CSvgFile
|
||||
private:
|
||||
void Clear();
|
||||
|
||||
bool CalculateFinalSize(bool bUseViewBox, double& dX, double& dY, double& dWidth, double& dHeight) const;
|
||||
|
||||
SVG::CGraphicsContainer *m_pContainer;
|
||||
SVG::CSvgParser m_oParser;
|
||||
SVG::CGraphicsContainer m_oContainer;
|
||||
SVG::CSvgCalculator m_oSvgCalculator;
|
||||
NSFonts::IFontManager *m_pFontManager;
|
||||
|
||||
typedef std::map<std::wstring, SVG::CObject*> MarkedMap;
|
||||
|
||||
|
||||
@ -24,16 +24,16 @@
|
||||
#include "SvgObjects/CMask.h"
|
||||
#include "SvgObjects/CUse.h"
|
||||
|
||||
#include "../../../../Common/3dParty/html/css/src/StaticFunctions.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CSvgParser::CSvgParser(NSFonts::IFontManager* pFontManager)
|
||||
: m_pFontManager(pFontManager)
|
||||
{}
|
||||
CSvgParser::CSvgParser()
|
||||
: m_pFontManager(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CSvgParser::~CSvgParser()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void CSvgParser::SetFontManager(NSFonts::IFontManager *pFontManager)
|
||||
{
|
||||
@ -74,7 +74,7 @@ namespace SVG
|
||||
return std::string(itEncodingValueBegin, itEncodingValueEnd);
|
||||
}
|
||||
|
||||
bool CSvgParser::LoadFromFile(const std::wstring &wsFile, CGraphicsContainer*& pContainer, CSvgFile* pFile) const
|
||||
bool CSvgParser::LoadFromFile(const std::wstring &wsFile, CGraphicsContainer* pContainer, CSvgFile* pFile) const
|
||||
{
|
||||
if (wsFile.empty() || NULL == pFile)
|
||||
return false;
|
||||
@ -102,54 +102,69 @@ namespace SVG
|
||||
else
|
||||
return false;
|
||||
|
||||
return LoadFromString(wsContent, pContainer, pFile);
|
||||
XmlUtils::IXmlDOMDocument::DisableOutput();
|
||||
bool bResult = LoadFromString(wsContent, pContainer, pFile);
|
||||
XmlUtils::IXmlDOMDocument::EnableOutput();
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
bool CSvgParser::LoadFromString(const std::wstring &wsContent, CGraphicsContainer*& pContainer, CSvgFile* pFile) const
|
||||
bool CSvgParser::LoadFromString(const std::wstring &wsContentent, CGraphicsContainer* pContainer, CSvgFile* pFile) const
|
||||
{
|
||||
if (wsContent.empty() || NULL == pFile)
|
||||
if (wsContentent.empty() || NULL == pFile)
|
||||
return false;
|
||||
|
||||
CSvgReader oReader;
|
||||
if (!oReader.ReadFromString(wsContent))
|
||||
XmlUtils::CXmlNode oXml;
|
||||
if (!oXml.FromXmlString(wsContentent))
|
||||
return false;
|
||||
|
||||
ScanStyles(oReader, pFile);
|
||||
oReader.MoveToStart();
|
||||
ScanStyles(oXml, pFile);
|
||||
|
||||
RELEASEOBJECT(pContainer);
|
||||
if (NULL != pContainer)
|
||||
pContainer->SetData(oXml);
|
||||
|
||||
pContainer = CObject::Create<CGraphicsContainer>(oReader, pFile);
|
||||
|
||||
if (NULL == pContainer)
|
||||
return false;
|
||||
|
||||
return ReadChildrens(oReader, pContainer, pFile, pContainer);
|
||||
return LoadFromXmlNode(oXml, pContainer, pFile);
|
||||
}
|
||||
|
||||
bool CSvgParser::ScanStyles(CSvgReader& oReader, CSvgFile *pFile) const
|
||||
bool CSvgParser::LoadFromXmlNode(XmlUtils::CXmlNode &oElement, CGraphicsContainer* pContainer, CSvgFile* pFile) const
|
||||
{
|
||||
if (oReader.IsEmptyNode() || NULL == pFile)
|
||||
if (NULL == pFile || !oElement.IsValid())
|
||||
return false;
|
||||
|
||||
const std::string sElementName = oReader.GetName();
|
||||
const CSvgCalculator *pSvgCalculator = pFile->GetSvgCalculator();
|
||||
|
||||
if ("style" == sElementName)
|
||||
if (NULL != pSvgCalculator)
|
||||
pSvgCalculator->SetData(pContainer);
|
||||
|
||||
return ReadChildrens(oElement, pContainer, pFile, pContainer);
|
||||
}
|
||||
|
||||
bool CSvgParser::ScanStyles(XmlUtils::CXmlNode &oElement, CSvgFile *pFile) const
|
||||
{
|
||||
if (!oElement.IsValid() || NULL == pFile)
|
||||
return false;
|
||||
|
||||
std::wstring wsElementName = oElement.GetName();
|
||||
|
||||
if (L"style" == wsElementName)
|
||||
{
|
||||
ParseStyles(oReader.GetText(), pFile);
|
||||
ParseStyles(oElement.GetText(), pFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool bScanResult = false;
|
||||
|
||||
if ("svg" == sElementName || "g" == sElementName || "defs" == sElementName)
|
||||
if (L"svg" == wsElementName || L"g" == wsElementName || L"defs" == wsElementName)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE(oReader)
|
||||
std::vector<XmlUtils::CXmlNode> arChilds;
|
||||
|
||||
oElement.GetChilds(arChilds);
|
||||
|
||||
for (XmlUtils::CXmlNode& oChild : arChilds)
|
||||
{
|
||||
if (ScanStyles(oReader, pFile))
|
||||
if (ScanStyles(oChild, pFile))
|
||||
bScanResult = true;
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
return bScanResult;
|
||||
@ -209,103 +224,155 @@ namespace SVG
|
||||
oSearchStart = oMatch.suffix().first;
|
||||
}
|
||||
}
|
||||
|
||||
template <class ObjectType>
|
||||
bool CSvgParser::ReadObject(CSvgReader& oReader, CContainer<ObjectType> *pContainer, CSvgFile *pFile, CRenderedObject *pParent) const
|
||||
bool CSvgParser::ReadObject(XmlUtils::CXmlNode &oElement, CContainer<ObjectType> *pContainer, CSvgFile *pFile, CRenderedObject *pParent) const
|
||||
{
|
||||
if (NULL == pFile)
|
||||
if (!oElement.IsValid() || NULL == pFile)
|
||||
return false;
|
||||
|
||||
const std::string sElementName = oReader.GetName();
|
||||
std::wstring wsElementName = oElement.GetName();
|
||||
|
||||
CObject *pObject = NULL;
|
||||
|
||||
if ("svg" == sElementName || "g" == sElementName || "a" == sElementName)
|
||||
if (L"svg" == wsElementName || L"g" == wsElementName || L"a" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CGraphicsContainer>(oReader, pFile, pParent);
|
||||
if (!ReadChildrens(oReader, (CGraphicsContainer*)pObject, pFile, (CGraphicsContainer*)pObject))
|
||||
pObject = new CGraphicsContainer(oElement, pParent);
|
||||
if (!ReadChildrens(oElement, (CGraphicsContainer*)pObject, pFile, (CGraphicsContainer*)pObject))
|
||||
{
|
||||
RELEASEINTERFACE(pObject);
|
||||
RELEASEOBJECT(pObject);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ("line" == sElementName)
|
||||
pObject = CObject::Create<CLine>(oReader, pFile, pParent);
|
||||
else if ("rect" == sElementName)
|
||||
pObject = CObject::Create<CRect>(oReader, pFile, pParent);
|
||||
else if ("circle" == sElementName)
|
||||
pObject = CObject::Create<CCircle>(oReader, pFile, pParent);
|
||||
else if ("ellipse" == sElementName)
|
||||
pObject = CObject::Create<CEllipse>(oReader, pFile, pParent);
|
||||
else if ("path" == sElementName)
|
||||
pObject = CObject::Create<CPath>(oReader, pFile, pParent);
|
||||
else if ("polyline" == sElementName)
|
||||
pObject = CObject::Create<CPolyline>(oReader, pFile, pParent);
|
||||
else if ("polygon" == sElementName)
|
||||
pObject = CObject::Create<CPolygon>(oReader, pFile, pParent);
|
||||
else if ("image" == sElementName)
|
||||
pObject = CObject::Create<CImage>(oReader, pFile, pParent);
|
||||
else if ("use" == sElementName)
|
||||
pObject = CObject::Create<CUse>(oReader, pFile, pParent);
|
||||
else if ("text" == sElementName)
|
||||
pObject = CObject::Create<CText>(oReader, pFile, pParent, m_pFontManager);
|
||||
else if ("tspan" == sElementName)
|
||||
pObject = CObject::Create<CTSpan>(oReader, pFile, pParent, m_pFontManager);
|
||||
else if ("textPath" == sElementName)
|
||||
pObject = CObject::Create<CTextPath>(oReader, pFile, pParent, m_pFontManager);
|
||||
else if ("switch" == sElementName)
|
||||
else if (L"line" == wsElementName)
|
||||
pObject = new CLine(oElement, pParent);
|
||||
else if (L"rect" == wsElementName)
|
||||
pObject = new CRect(oElement, pParent);
|
||||
else if (L"circle" == wsElementName)
|
||||
pObject = new CCircle(oElement, pParent);
|
||||
else if (L"ellipse" == wsElementName)
|
||||
pObject = new CEllipse(oElement, pParent);
|
||||
else if (L"path" == wsElementName)
|
||||
pObject = new CPath(oElement, pParent);
|
||||
else if (L"polyline" == wsElementName)
|
||||
pObject = new CPolyline(oElement, pParent);
|
||||
else if (L"polygon" == wsElementName)
|
||||
pObject = new CPolygon(oElement, pParent);
|
||||
else if (L"image" == wsElementName)
|
||||
pObject = new CImage(oElement, pParent);
|
||||
else if (L"use" == wsElementName)
|
||||
pObject = new CUse(oElement, pParent);
|
||||
else if (L"text" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CSwitch>(oReader, pFile, pParent);
|
||||
ReadChildrens(oReader, (CSwitch*)pObject, pFile);
|
||||
pObject = CText::Create(oElement, pParent, m_pFontManager);
|
||||
ReadChildrens(oElement, (CText*)pObject, pFile, (CText*)pObject);
|
||||
}
|
||||
else if (L"tspan" == wsElementName)
|
||||
{
|
||||
pObject = CTSpan::Create(oElement, pParent, m_pFontManager);
|
||||
ReadChildrens(oElement, (CTSpan*)pObject, pFile, (CTSpan*)pObject);
|
||||
}
|
||||
else if (L"textPath" == wsElementName)
|
||||
{
|
||||
pObject = CTextPath::Create(oElement, pParent, m_pFontManager, pFile);
|
||||
ReadChildrens(oElement, (CTextPath*)pObject, pFile);
|
||||
}
|
||||
else if (L"switch" == wsElementName)
|
||||
{
|
||||
pObject = new CSwitch(oElement, pParent);
|
||||
ReadChildrens(oElement, (CSwitch*)pObject, pFile);
|
||||
}
|
||||
//defs
|
||||
else if ("defs" == sElementName)
|
||||
return ReadChildrens<CRenderedObject>(oReader, NULL, pFile);
|
||||
else if("linearGradient" == sElementName)
|
||||
pObject = CObject::Create<CLinearGradient>(oReader, pFile);
|
||||
else if ("radialGradient" == sElementName)
|
||||
pObject = CObject::Create<CRadialGradient>(oReader, pFile);
|
||||
else if ("pattern" == sElementName)
|
||||
else if (L"defs" == wsElementName)
|
||||
return ReadChildrens<CRenderedObject>(oElement, NULL, pFile);
|
||||
else if(L"linearGradient" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CPattern>(oReader, pFile);
|
||||
ReadChildrens(oReader, (CGraphicsContainer*)(&((CPattern*)pObject)->GetContainer()), pFile);
|
||||
pObject = new CLinearGradient(oElement);
|
||||
ReadChildrens(oElement, (CLinearGradient*)pObject, pFile);
|
||||
}
|
||||
else if ("clipPath" == sElementName)
|
||||
else if (L"radialGradient" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CClipPath>(oReader, pFile);
|
||||
ReadChildrens(oReader, (CGraphicsContainer*)(&((CClipPath*)pObject)->GetContainer()), pFile);
|
||||
pObject = new CRadialGradient(oElement);
|
||||
ReadChildrens(oElement, (CRadialGradient*)pObject, pFile);
|
||||
}
|
||||
else if ("marker" == sElementName)
|
||||
else if (L"stop" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CMarker>(oReader, pFile);
|
||||
ReadChildrens(oReader, (CMarker*)pObject, pFile);
|
||||
CStopElement *pStopElement = new CStopElement(oElement);
|
||||
if (AddObject((ObjectType*)pStopElement, pContainer))
|
||||
{
|
||||
UpdateStyles(pStopElement, pFile);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
RELEASEOBJECT(pStopElement);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ("mask" == sElementName)
|
||||
else if (L"pattern" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CMask>(oReader, pFile);
|
||||
ReadChildrens(oReader, (CGraphicsContainer*)(&((CMask*)pObject)->GetContainer()), pFile);
|
||||
pObject = new CPattern(oElement, m_pFontManager);
|
||||
ReadChildrens(oElement, (CGraphicsContainer*)(&((CPattern*)pObject)->GetContainer()), pFile);
|
||||
}
|
||||
else if ("symbol" == sElementName)
|
||||
else if (L"clipPath" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CSymbol>(oReader, pFile);
|
||||
if (ReadChildrens(oReader, (CSymbol*)pObject, pFile))
|
||||
pObject = new CClipPath(oElement);
|
||||
ReadChildrens(oElement, (CGraphicsContainer*)(&((CClipPath*)pObject)->GetContainer()), pFile);
|
||||
}
|
||||
else if (L"marker" == wsElementName)
|
||||
{
|
||||
pObject = new CMarker(oElement);
|
||||
ReadChildrens(oElement, (CMarker*)pObject, pFile);
|
||||
}
|
||||
else if (L"mask" == wsElementName)
|
||||
{
|
||||
pObject = new CMask(oElement);
|
||||
ReadChildrens(oElement, (CGraphicsContainer*)(&((CMask*)pObject)->GetContainer()), pFile);
|
||||
}
|
||||
else if (L"symbol" == wsElementName)
|
||||
{
|
||||
pObject = new CSymbol(oElement);
|
||||
if (ReadChildrens(oElement, (CSymbol*)pObject, pFile) && MarkObject(pObject, pFile))
|
||||
return true;
|
||||
else
|
||||
RELEASEINTERFACE(pObject);
|
||||
RELEASEOBJECT(pObject);
|
||||
}
|
||||
else if ("font" == sElementName)
|
||||
else if (L"font" == wsElementName)
|
||||
{
|
||||
pObject = CObject::Create<CFont>(oReader, pFile);
|
||||
pObject = new CFont(oElement);
|
||||
}
|
||||
|
||||
if (NULL == pObject)
|
||||
if (NULL != pObject)
|
||||
{
|
||||
if ((MarkObject(pObject, pFile) && (AppliedObject == pObject->GetType() || NULL == pContainer)) ||
|
||||
(RendererObject == pObject->GetType() && AddObject((ObjectType*)pObject, pContainer)))
|
||||
{
|
||||
UpdateStyles(pObject, pFile);
|
||||
return true;
|
||||
}
|
||||
delete pObject;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CSvgParser::UpdateStyles(CObject *pObject, CSvgFile *pFile) const
|
||||
{
|
||||
if (NULL == pObject || NULL == pFile)
|
||||
return;
|
||||
|
||||
const CSvgCalculator *pSvgCalculator = pFile->GetSvgCalculator();
|
||||
|
||||
if (NULL != pSvgCalculator)
|
||||
pSvgCalculator->SetData(pObject);
|
||||
}
|
||||
|
||||
bool CSvgParser::MarkObject(CObject *pObject, CSvgFile *pFile) const
|
||||
{
|
||||
if (NULL == pObject || NULL == pFile)
|
||||
return false;
|
||||
|
||||
if ((RendererObject == pObject->GetType() && (AddObject((ObjectType*)pObject, pContainer) || pObject->Marked())) ||
|
||||
AppliedObject == pObject->GetType())
|
||||
return true;
|
||||
|
||||
RELEASEINTERFACE(pObject);
|
||||
return false;
|
||||
return pFile->MarkObject(pObject);
|
||||
}
|
||||
|
||||
template <class ObjectType>
|
||||
@ -315,15 +382,18 @@ namespace SVG
|
||||
}
|
||||
|
||||
template <class ObjectType>
|
||||
bool CSvgParser::ReadChildrens(CSvgReader& oReader, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject *pParent) const
|
||||
bool CSvgParser::ReadChildrens(XmlUtils::CXmlNode &oElement, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject *pParent) const
|
||||
{
|
||||
bool bResult = false;
|
||||
std::vector<XmlUtils::CXmlNode> arChilds;
|
||||
|
||||
WHILE_READ_NEXT_NODE(oReader)
|
||||
if (ReadObject(oReader, pContainer, pFile, pParent))
|
||||
bResult = true;
|
||||
END_WHILE
|
||||
oElement.GetChilds(arChilds);
|
||||
|
||||
return bResult;
|
||||
if (arChilds.empty())
|
||||
return false;
|
||||
|
||||
for (XmlUtils::CXmlNode& oChild : arChilds)
|
||||
ReadObject(oChild, pContainer, pFile, pParent);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
|
||||
#include "../../../common/Directory.h"
|
||||
#include "../../../graphics/pro/Fonts.h"
|
||||
#include "../../../xml/include/xmlutils.h"
|
||||
|
||||
#include "SvgObjects/CContainer.h"
|
||||
#include "SvgReader.h"
|
||||
|
||||
class CSvgFile;
|
||||
|
||||
@ -14,23 +14,26 @@ namespace SVG
|
||||
class CSvgParser
|
||||
{
|
||||
public:
|
||||
CSvgParser(NSFonts::IFontManager* pFontManager = NULL);
|
||||
CSvgParser();
|
||||
~CSvgParser();
|
||||
|
||||
void SetFontManager(NSFonts::IFontManager* pFontManager);
|
||||
|
||||
bool LoadFromFile(const std::wstring& wsFile, CGraphicsContainer*& pContainer, CSvgFile* pFile) const;
|
||||
bool LoadFromString(const std::wstring& wsContent, CGraphicsContainer*& pContainer, CSvgFile* pFile) const;
|
||||
bool LoadFromFile(const std::wstring& wsFile, CGraphicsContainer* pContainer, CSvgFile* pFile) const;
|
||||
bool LoadFromString(const std::wstring& wsContentent, CGraphicsContainer* pContainer, CSvgFile* pFile) const;
|
||||
bool LoadFromXmlNode(XmlUtils::CXmlNode& oElement, CGraphicsContainer* pContainer, CSvgFile* pFile) const;
|
||||
|
||||
template <class ObjectType>
|
||||
bool ReadObject(CSvgReader& oReader, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject* pParent = NULL) const;
|
||||
bool ReadObject(XmlUtils::CXmlNode& oElement, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject* pParent = NULL) const;
|
||||
private:
|
||||
template <class ObjectType>
|
||||
bool ReadChildrens(CSvgReader& oReader, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject* pParent = NULL) const;
|
||||
bool ReadChildrens(XmlUtils::CXmlNode& oElement, CContainer<ObjectType>* pContainer, CSvgFile* pFile, CRenderedObject* pParent = NULL) const;
|
||||
|
||||
bool ScanStyles(CSvgReader& oReader, CSvgFile* pFile) const;
|
||||
bool ScanStyles(XmlUtils::CXmlNode& oElement, CSvgFile* pFile) const;
|
||||
void ParseStyles(const std::wstring& wsStyles, CSvgFile *pFile) const;
|
||||
|
||||
void UpdateStyles(CObject* pObject, CSvgFile* pFile) const;
|
||||
bool MarkObject(CObject* pObject, CSvgFile* pFile) const;
|
||||
template <class ObjectType>
|
||||
bool AddObject(ObjectType* pObject, CContainer<ObjectType>* pContainer) const;
|
||||
|
||||
|
||||
@ -1,27 +1,16 @@
|
||||
#include "CCircle.h"
|
||||
|
||||
#include "CContainer.h"
|
||||
#include "CStyle.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CCircle::CCircle(CSvgReader& oReader, CRenderedObject* pParent)
|
||||
: CRenderedObject(oReader, pParent)
|
||||
CCircle::CCircle(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent)
|
||||
: CRenderedObject(oNode, pParent)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
SetAttribute(sAttributeName, oReader);
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
}
|
||||
|
||||
void CCircle::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("cx" == sName)
|
||||
m_oCx.SetValue(oReader.GetText());
|
||||
else if ("cy" == sName)
|
||||
m_oCy.SetValue(oReader.GetText());
|
||||
else if ("r" == sName)
|
||||
m_oR.SetValue(oReader.GetText());
|
||||
else
|
||||
CRenderedObject::SetAttribute(sName, oReader);
|
||||
m_oCx.SetValue(oNode.GetAttribute(L"cx"));
|
||||
m_oCy.SetValue(oNode.GetAttribute(L"cy"));
|
||||
m_oR .SetValue(oNode.GetAttribute(L"r"));
|
||||
}
|
||||
|
||||
void CCircle::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
@ -62,7 +51,7 @@ namespace SVG
|
||||
nTypePath += c_nWindingFillMode;
|
||||
}
|
||||
|
||||
TBounds CCircle::GetBounds(SvgMatrix* pTransform) const
|
||||
TBounds CCircle::GetBounds() const
|
||||
{
|
||||
TBounds oBounds;
|
||||
|
||||
@ -71,16 +60,6 @@ namespace SVG
|
||||
oBounds.m_dRight = (m_oCx + m_oR).ToDouble(NSCSS::Pixel);
|
||||
oBounds.m_dBottom = (m_oCy + m_oR).ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (nullptr != pTransform)
|
||||
{
|
||||
*pTransform += m_oTransformation.m_oTransform.GetMatrix();
|
||||
|
||||
pTransform->GetFinalValue().TransformPoint(oBounds.m_dLeft, oBounds.m_dTop );
|
||||
pTransform->GetFinalValue().TransformPoint(oBounds.m_dRight, oBounds.m_dBottom);
|
||||
|
||||
*pTransform -= m_oTransformation.m_oTransform.GetMatrix();
|
||||
}
|
||||
|
||||
return oBounds;
|
||||
}
|
||||
|
||||
|
||||
@ -7,10 +7,8 @@ namespace SVG
|
||||
{
|
||||
class CCircle : public CRenderedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CCircle(CSvgReader& oReader, CRenderedObject* pParent = NULL);
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CCircle(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
|
||||
|
||||
void SetData(const std::map<std::wstring, std::wstring>& mAttributes, unsigned short ushLevel, bool bHardMode = false) override;
|
||||
|
||||
@ -18,7 +16,7 @@ namespace SVG
|
||||
private:
|
||||
void ApplyStyle(IRenderer* pRenderer, const TSvgStyles* pStyles, const CSvgFile *pFile, int& nTypePath, const CRenderedObject* pContexObject = NULL) const override;
|
||||
|
||||
TBounds GetBounds(SvgMatrix* pTransform = nullptr) const override;
|
||||
TBounds GetBounds() const override;
|
||||
|
||||
SvgDigit m_oCx;
|
||||
SvgDigit m_oCy;
|
||||
|
||||
@ -2,19 +2,13 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CClipPath::CClipPath(CSvgReader& oReader)
|
||||
: CAppliedObject(oReader), m_enUnits(ClipU_ObjectBoundingBox)
|
||||
{}
|
||||
|
||||
void CClipPath::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
CClipPath::CClipPath(XmlUtils::CXmlNode &oNode)
|
||||
: CAppliedObject(oNode)
|
||||
{
|
||||
if ("gradientUnits" == sName)
|
||||
{
|
||||
if ("userSpaceOnUse" == oReader.GetTextA())
|
||||
m_enUnits = ClipU_UserSpaceOnUse;
|
||||
}
|
||||
if (L"userSpaceOnUse" == oNode.GetAttribute(L"gradientUnits"))
|
||||
m_enUnits = ClipU_UserSpaceOnUse;
|
||||
else
|
||||
CAppliedObject::SetAttribute(sName, oReader);
|
||||
m_enUnits = ClipU_ObjectBoundingBox;
|
||||
}
|
||||
|
||||
void CClipPath::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
@ -31,7 +25,7 @@ namespace SVG
|
||||
|
||||
ApplyClip(pRenderer, &m_oTransformation.m_oClip, pFile, oObjectBounds);
|
||||
|
||||
for (const CRenderedObject* pObject : m_oContainer)
|
||||
for (const CRenderedObject* pObject : m_oContainer.m_arObjects)
|
||||
pObject->Draw(pRenderer, pFile, CommandeModeClip);
|
||||
|
||||
return true;
|
||||
|
||||
@ -13,10 +13,8 @@ namespace SVG
|
||||
|
||||
class CClipPath : public CAppliedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CClipPath(CSvgReader& oReader);
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CClipPath(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
void SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode) override;
|
||||
|
||||
|
||||
@ -5,23 +5,30 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CGraphicsContainer::CGraphicsContainer(CSvgReader& oReader, CRenderedObject *pParent)
|
||||
: CRenderedObject(oReader, pParent)
|
||||
CGraphicsContainer::CGraphicsContainer(const std::wstring &wsName)
|
||||
: CRenderedObject(NSCSS::CNode(wsName, L"", L""))
|
||||
{}
|
||||
|
||||
void CGraphicsContainer::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
CGraphicsContainer::~CGraphicsContainer()
|
||||
{
|
||||
if ("x" == sName)
|
||||
m_oWindow.m_oX.SetValue(oReader.GetText());
|
||||
else if ("y" == sName)
|
||||
m_oWindow.m_oY.SetValue(oReader.GetText());
|
||||
else if ("width" == sName)
|
||||
m_oWindow.m_oWidth.SetValue(oReader.GetText());
|
||||
else if ("height" == sName)
|
||||
m_oWindow.m_oHeight.SetValue(oReader.GetText());
|
||||
else if ("viewBox" == sName)
|
||||
for (CRenderedObject* pObject : m_arObjects)
|
||||
pObject->m_pParent = NULL;
|
||||
}
|
||||
|
||||
void CGraphicsContainer::SetData(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
SetNodeData(oNode);
|
||||
|
||||
m_oWindow.m_oX .SetValue(oNode.GetAttribute(L"x"));
|
||||
m_oWindow.m_oY .SetValue(oNode.GetAttribute(L"y"));
|
||||
m_oWindow.m_oWidth .SetValue(oNode.GetAttribute(L"width"), 0, true);
|
||||
m_oWindow.m_oHeight.SetValue(oNode.GetAttribute(L"height"), 0, true);
|
||||
|
||||
const std::wstring wsViewBox = oNode.GetAttribute(L"viewBox");
|
||||
|
||||
if (!wsViewBox.empty())
|
||||
{
|
||||
const std::vector<double> arValues{StrUtils::ReadDoubleValues(oReader.GetText())};
|
||||
std::vector<double> arValues = StrUtils::ReadDoubleValues(wsViewBox);
|
||||
if (4 == arValues.size())
|
||||
{
|
||||
m_oViewBox.m_oX = arValues[0];
|
||||
@ -31,9 +38,19 @@ namespace SVG
|
||||
}
|
||||
}
|
||||
else
|
||||
CRenderedObject::SetAttribute(sName, oReader);
|
||||
m_oViewBox = m_oWindow;
|
||||
}
|
||||
|
||||
CGraphicsContainer::CGraphicsContainer(XmlUtils::CXmlNode& oNode, CRenderedObject *pParent)
|
||||
: CRenderedObject(oNode, pParent)
|
||||
{
|
||||
SetData(oNode);
|
||||
}
|
||||
|
||||
CGraphicsContainer::CGraphicsContainer(double dWidth, double dHeight, XmlUtils::CXmlNode& oNode, CRenderedObject *pParent)
|
||||
: CRenderedObject(oNode, pParent), m_oWindow{0, 0, dWidth, dHeight}
|
||||
{}
|
||||
|
||||
bool CGraphicsContainer::Draw(IRenderer *pRenderer, const CSvgFile *pFile, CommandeMode oMode, const TSvgStyles *pOtherStyles, const CRenderedObject* pContexObject) const
|
||||
{
|
||||
Aggplus::CMatrix oOldTransform;
|
||||
@ -59,7 +76,7 @@ namespace SVG
|
||||
return m_oViewBox;
|
||||
}
|
||||
|
||||
TBounds CGraphicsContainer::GetBounds(SvgMatrix* pTransform) const
|
||||
TBounds CGraphicsContainer::GetBounds() const
|
||||
{
|
||||
TBounds oBounds, oTempBounds;
|
||||
|
||||
@ -68,21 +85,15 @@ namespace SVG
|
||||
oBounds.m_dRight += m_oWindow.m_oWidth.ToDouble(NSCSS::Pixel);
|
||||
oBounds.m_dBottom += m_oWindow.m_oHeight.ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (nullptr != pTransform)
|
||||
*pTransform += m_oTransformation.m_oTransform.GetMatrix();
|
||||
|
||||
for (const CRenderedObject* pObject : m_arObjects)
|
||||
{
|
||||
oTempBounds = pObject->GetBounds(pTransform);
|
||||
oTempBounds = pObject->GetBounds();
|
||||
oBounds.m_dLeft = std::min(oBounds.m_dLeft, oTempBounds.m_dLeft);
|
||||
oBounds.m_dTop = std::min(oBounds.m_dTop, oTempBounds.m_dTop);
|
||||
oBounds.m_dRight = std::max(oBounds.m_dRight, oTempBounds.m_dRight);
|
||||
oBounds.m_dBottom = std::max(oBounds.m_dBottom, oTempBounds.m_dBottom);
|
||||
}
|
||||
|
||||
if (nullptr != pTransform)
|
||||
*pTransform -= m_oTransformation.m_oTransform.GetMatrix();
|
||||
|
||||
return oBounds;
|
||||
}
|
||||
|
||||
|
||||
@ -12,9 +12,8 @@ namespace SVG
|
||||
template<typename TypeObject>
|
||||
class CContainer
|
||||
{
|
||||
using const_iterator = typename std::vector<TypeObject*>::const_iterator;
|
||||
public:
|
||||
CContainer() = default;
|
||||
CContainer(){}
|
||||
virtual ~CContainer()
|
||||
{
|
||||
Clear();
|
||||
@ -62,35 +61,39 @@ namespace SVG
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const_iterator begin() const
|
||||
{
|
||||
return m_arObjects.cbegin();
|
||||
}
|
||||
|
||||
const_iterator end() const
|
||||
{
|
||||
return m_arObjects.cend();
|
||||
}
|
||||
protected:
|
||||
private:
|
||||
std::vector<TypeObject*> m_arObjects;
|
||||
|
||||
friend class CText;
|
||||
friend class CMask;
|
||||
friend class CTSpan;
|
||||
friend class CMarker;
|
||||
friend class CSwitch;
|
||||
friend class CPattern;
|
||||
friend class CGradient;
|
||||
friend class CClipPath;
|
||||
friend class CTextPath;
|
||||
friend class CLinearGradient;
|
||||
friend class CGraphicsContainer;
|
||||
};
|
||||
|
||||
class CGraphicsContainer : public CContainer<CRenderedObject>, public CRenderedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CGraphicsContainer(CSvgReader& oReader, CRenderedObject* pParent = NULL);
|
||||
public:
|
||||
virtual ~CGraphicsContainer() = default;
|
||||
CGraphicsContainer(const std::wstring& wsName = L"GraphicsContainer");
|
||||
CGraphicsContainer(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
|
||||
CGraphicsContainer(double dWidth, double dHeight, XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
|
||||
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
virtual ~CGraphicsContainer();
|
||||
|
||||
void SetData(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
bool Draw(IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pOtherStyles = NULL, const CRenderedObject* pContexObject = NULL) const override;
|
||||
|
||||
TRect GetWindow() const;
|
||||
TRect GetViewBox() const;
|
||||
TBounds GetBounds(SvgMatrix* pTransform = nullptr) const override;
|
||||
private:
|
||||
TBounds GetBounds() const override;
|
||||
|
||||
friend class CPattern;
|
||||
friend class CMarker;
|
||||
|
||||
@ -1,12 +1,18 @@
|
||||
#include "CEllipse.h"
|
||||
|
||||
#include "CStyle.h"
|
||||
#include "CContainer.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CEllipse::CEllipse(CSvgReader& oReader, CRenderedObject* pParent)
|
||||
: CRenderedObject(oReader, pParent)
|
||||
{}
|
||||
CEllipse::CEllipse(XmlUtils::CXmlNode &oNode, CRenderedObject *pParent)
|
||||
: CRenderedObject(oNode, pParent)
|
||||
{
|
||||
m_oCx.SetValue(oNode.GetAttribute(L"cx"));
|
||||
m_oCy.SetValue(oNode.GetAttribute(L"cy"));
|
||||
m_oRx.SetValue(oNode.GetAttribute(L"rx"));
|
||||
m_oRy.SetValue(oNode.GetAttribute(L"ry"));
|
||||
}
|
||||
|
||||
void CEllipse::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
@ -16,20 +22,6 @@ namespace SVG
|
||||
SetFill(mAttributes, ushLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CEllipse::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("cx" == sName)
|
||||
m_oCx.SetValue(oReader.GetText());
|
||||
else if ("cy" == sName)
|
||||
m_oCy.SetValue(oReader.GetText());
|
||||
else if ("rx" == sName)
|
||||
m_oRx.SetValue(oReader.GetText());
|
||||
else if ("ry" == sName)
|
||||
m_oRy.SetValue(oReader.GetText());
|
||||
else
|
||||
CRenderedObject::SetAttribute(sName, oReader);
|
||||
}
|
||||
|
||||
bool CEllipse::Draw(IRenderer *pRenderer, const CSvgFile *pFile, CommandeMode oMode, const TSvgStyles *pOtherStyles, const CRenderedObject* pContexObject) const
|
||||
{
|
||||
Aggplus::CMatrix oOldTransform;
|
||||
@ -64,7 +56,7 @@ namespace SVG
|
||||
nTypePath += c_nWindingFillMode;
|
||||
}
|
||||
|
||||
TBounds CEllipse::GetBounds(SvgMatrix* pTransform) const
|
||||
TBounds CEllipse::GetBounds() const
|
||||
{
|
||||
TBounds oBounds;
|
||||
|
||||
@ -73,16 +65,6 @@ namespace SVG
|
||||
oBounds.m_dRight = oBounds.m_dLeft + m_oRx.ToDouble(NSCSS::Pixel);
|
||||
oBounds.m_dBottom = oBounds.m_dTop + m_oRy.ToDouble(NSCSS::Pixel);;
|
||||
|
||||
if (nullptr != pTransform)
|
||||
{
|
||||
*pTransform += m_oTransformation.m_oTransform.GetMatrix();
|
||||
|
||||
pTransform->GetFinalValue().TransformPoint(oBounds.m_dLeft, oBounds.m_dTop );
|
||||
pTransform->GetFinalValue().TransformPoint(oBounds.m_dRight, oBounds.m_dBottom);
|
||||
|
||||
*pTransform -= m_oTransformation.m_oTransform.GetMatrix();
|
||||
}
|
||||
|
||||
return oBounds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,24 +1,23 @@
|
||||
#ifndef CELLIPSE_H
|
||||
#define CELLIPSE_H
|
||||
|
||||
|
||||
#include "CObjectBase.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
class CEllipse : public CRenderedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CEllipse(CSvgReader& oReader, CRenderedObject* pParent = NULL);
|
||||
public:
|
||||
void SetData(const std::map<std::wstring, std::wstring>& mAttributes, unsigned short ushLevel, bool bHardMode = false) override;
|
||||
CEllipse(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
|
||||
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
void SetData(const std::map<std::wstring, std::wstring>& mAttributes, unsigned short ushLevel, bool bHardMode = false) override;
|
||||
|
||||
bool Draw(IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pOtherStyles = NULL, const CRenderedObject* pContexObject = NULL) const override;
|
||||
private:
|
||||
void ApplyStyle(IRenderer* pRenderer, const TSvgStyles* pStyles, const CSvgFile *pFile, int& nTypePath, const CRenderedObject* pContexObject = NULL) const override;
|
||||
|
||||
TBounds GetBounds(SvgMatrix* pTransform = nullptr) const override;
|
||||
TBounds GetBounds() const override;
|
||||
|
||||
SvgDigit m_oCx;
|
||||
SvgDigit m_oCy;
|
||||
|
||||
@ -2,22 +2,15 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CGlyph::CGlyph(CSvgReader& oReader)
|
||||
: CPath(oReader)
|
||||
CGlyph::CGlyph(XmlUtils::CXmlNode &oNode)
|
||||
: CPath(oNode)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("unicode" == sAttributeName)
|
||||
{
|
||||
const std::wstring wsUnicode{oReader.GetText()};
|
||||
std::wstring wsUnicode(oNode.GetAttribute(L"unicode"));
|
||||
|
||||
if (!wsUnicode.empty())
|
||||
m_wchUnicode = wsUnicode[0];
|
||||
}
|
||||
else if ("horiz-adv-x" == sAttributeName)
|
||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
if (!wsUnicode.empty())
|
||||
m_wchUnicode = wsUnicode[0];
|
||||
|
||||
m_oHorizAdvX.SetValue(oNode.GetAttributeOrValue(L"horiz-adv-x"));
|
||||
}
|
||||
|
||||
wchar_t CGlyph::GetUnicode() const
|
||||
@ -25,13 +18,21 @@ namespace SVG
|
||||
return m_wchUnicode;
|
||||
}
|
||||
|
||||
CFontFace::CFontFace(CSvgReader& oReader)
|
||||
{}
|
||||
|
||||
CFont::CFont(CSvgReader& oReader)
|
||||
: CAppliedObject(oReader), m_pMissingGlyph(NULL)
|
||||
CFontFace::CFontFace(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
ParseGlyphs(oReader);
|
||||
|
||||
}
|
||||
|
||||
CFont::CFont(XmlUtils::CXmlNode &oNode)
|
||||
: CAppliedObject(oNode), m_pMissingGlyph(NULL)
|
||||
{
|
||||
ParseGlyphs(oNode);
|
||||
|
||||
m_oArguments.m_wsFontVariant = oNode.GetAttribute(L"font-variant");
|
||||
m_oArguments.m_wsFontStyle = oNode.GetAttribute(L"font-style");
|
||||
m_oArguments.m_wsFontWidght = oNode.GetAttribute(L"font-weight");
|
||||
|
||||
m_oHorizAdvX.SetValue(oNode.GetAttributeOrValue(L"horiz-adv-x"));
|
||||
}
|
||||
|
||||
CFont::~CFont()
|
||||
@ -42,20 +43,6 @@ namespace SVG
|
||||
RELEASEOBJECT(m_pMissingGlyph);
|
||||
}
|
||||
|
||||
void CFont::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("font-variant" == sName)
|
||||
m_oArguments.m_wsFontVariant = oReader.GetText();
|
||||
else if ("font-style" == sName)
|
||||
m_oArguments.m_wsFontStyle = oReader.GetText();
|
||||
else if ("font-weight" == sName)
|
||||
m_oArguments.m_wsFontWidght = oReader.GetText();
|
||||
else if ("horiz-adv-x" == sName)
|
||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
||||
else
|
||||
CAppliedObject::SetAttribute(sName, oReader);
|
||||
}
|
||||
|
||||
void CFont::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
}
|
||||
@ -128,13 +115,18 @@ namespace SVG
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFont::ParseGlyphs(CSvgReader& oReader)
|
||||
void CFont::ParseGlyphs(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
std::vector<XmlUtils::CXmlNode> arChilds;
|
||||
|
||||
if (!oNode.GetChilds(arChilds) || arChilds.empty())
|
||||
return;
|
||||
|
||||
for (XmlUtils::CXmlNode& oChild : arChilds)
|
||||
{
|
||||
if ("glyph" == sNodeName)
|
||||
if (L"glyph" == oChild.GetName())
|
||||
{
|
||||
CGlyph *pGlyph = new CGlyph(oReader);
|
||||
CGlyph *pGlyph = new CGlyph(oChild);
|
||||
|
||||
if (NULL == pGlyph)
|
||||
continue;
|
||||
@ -144,17 +136,22 @@ namespace SVG
|
||||
else
|
||||
delete pGlyph;
|
||||
}
|
||||
else if ("missing-glyph" == sNodeName)
|
||||
else if (L"missing-glyph" == oChild.GetName())
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_DEPTH_ONE_NAME(oReader, Child, "path")
|
||||
std::vector<XmlUtils::CXmlNode> arMissingGlyphChilds;
|
||||
if (!oChild.GetChilds(arMissingGlyphChilds) || arMissingGlyphChilds.empty())
|
||||
continue;
|
||||
|
||||
for (XmlUtils::CXmlNode& oChildMissingGlyph : arMissingGlyphChilds)
|
||||
{
|
||||
m_pMissingGlyph = new CPath(oReader);
|
||||
if (NULL != m_pMissingGlyph)
|
||||
break;
|
||||
if (L"path" == oChildMissingGlyph.GetName())
|
||||
{
|
||||
m_pMissingGlyph = new CPath(oChildMissingGlyph);
|
||||
if (NULL != m_pMissingGlyph)
|
||||
break;
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
}
|
||||
END_WHILE
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ namespace SVG
|
||||
class CGlyph : public CPath
|
||||
{
|
||||
public:
|
||||
CGlyph(CSvgReader& oReader);
|
||||
CGlyph(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
wchar_t GetUnicode() const;
|
||||
private:
|
||||
@ -21,7 +21,7 @@ namespace SVG
|
||||
class CFontFace
|
||||
{
|
||||
public:
|
||||
CFontFace(CSvgReader& oReader);
|
||||
CFontFace(XmlUtils::CXmlNode& oNode);
|
||||
private:
|
||||
std::wstring m_wsSrcFaceName;
|
||||
};
|
||||
@ -36,19 +36,16 @@ namespace SVG
|
||||
|
||||
class CFont : public CAppliedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CFont(CSvgReader& oReader);
|
||||
public:
|
||||
CFont(XmlUtils::CXmlNode& oNode);
|
||||
~CFont();
|
||||
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
|
||||
void SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode) override;
|
||||
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
bool Draw(const std::wstring& wsText, const double& dX, const double& dY, const double& dFontHeight, IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pStyles = NULL, const CRenderedObject* pContexObject = NULL) const;
|
||||
private:
|
||||
void ParseGlyphs(CSvgReader& oReader);
|
||||
void ParseGlyphs(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
TFontArguments m_oArguments;
|
||||
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CStopElement::CStopElement(CSvgReader& oReader)
|
||||
: CObject(oReader)
|
||||
CStopElement::CStopElement(XmlUtils::CXmlNode& oNode)
|
||||
: CObject(oNode)
|
||||
{}
|
||||
|
||||
ObjectType CStopElement::GetType() const
|
||||
{
|
||||
return DataObject;
|
||||
return AppliedObject;
|
||||
}
|
||||
|
||||
SvgDigit CStopElement::GetOffset() const
|
||||
@ -34,36 +34,20 @@ namespace SVG
|
||||
m_oColor.SetOpacity(mAttributes.at(L"stop-opacity"));
|
||||
}
|
||||
|
||||
CGradient::CGradient(CSvgReader& oReader)
|
||||
: CAppliedObject(oReader), m_enGradientUnits(GradU_ObjectBoundingBox)
|
||||
{}
|
||||
|
||||
void CGradient::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
CGradient::CGradient(XmlUtils::CXmlNode &oNode)
|
||||
: CAppliedObject(oNode)
|
||||
{
|
||||
if ("href" == sName || "xlink:href" == sName)
|
||||
m_wsXlinkHref = oReader.GetText();
|
||||
else if ("gradientTransform" == sName)
|
||||
m_oTransform.SetMatrix(oReader.GetText(), 0, true);
|
||||
else if ("gradientUnits" == sName)
|
||||
{
|
||||
if (L"userSpaceOnUse" == oReader.GetText())
|
||||
m_enGradientUnits = GradU_UserSpaceOnUse;
|
||||
}
|
||||
m_wsXlinkHref = oNode.GetAttribute(L"href", oNode.GetAttribute(L"xlink:href"));
|
||||
m_oTransform.SetMatrix(oNode.GetAttribute(L"gradientTransform"), 0, true);
|
||||
|
||||
if (L"userSpaceOnUse" == oNode.GetAttribute(L"gradientUnits"))
|
||||
m_enGradientUnits = GradU_UserSpaceOnUse;
|
||||
else
|
||||
CAppliedObject::SetAttribute(sName, oReader);
|
||||
m_enGradientUnits = GradU_ObjectBoundingBox;
|
||||
}
|
||||
|
||||
void CGradient::SetData(const std::map<std::wstring, std::wstring>& mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{}
|
||||
|
||||
void CGradient::ReadChildrens(CSvgReader& oReader, CSvgFile* pSvgFile)
|
||||
void CGradient::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
if (NULL == pSvgFile || NULL == pSvgFile->GetSvgCalculator())
|
||||
return;
|
||||
|
||||
WHILE_READ_NEXT_NODE_WITH_ONE_NAME(oReader, "stop")
|
||||
AddObject(CObject::Create<CStopElement>(oReader, pSvgFile));
|
||||
END_WHILE
|
||||
}
|
||||
|
||||
bool CGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
@ -133,22 +117,13 @@ namespace SVG
|
||||
return pRefGradient->Apply(pRenderer, pFile, oObjectBounds);
|
||||
}
|
||||
|
||||
CLinearGradient::CLinearGradient(CSvgReader& oReader)
|
||||
: CGradient(oReader)
|
||||
{}
|
||||
|
||||
void CLinearGradient::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
CLinearGradient::CLinearGradient(XmlUtils::CXmlNode& oNode)
|
||||
: CGradient(oNode)
|
||||
{
|
||||
if ("x1" == sName)
|
||||
m_oX1.SetValue(oReader.GetText());
|
||||
else if ("y1" == sName)
|
||||
m_oY1.SetValue(oReader.GetText());
|
||||
else if ("x2" == sName)
|
||||
m_oX2.SetValue(oReader.GetText());
|
||||
else if ("y2" == sName)
|
||||
m_oY2.SetValue(oReader.GetText());
|
||||
else
|
||||
CGradient::SetAttribute(sName, oReader);
|
||||
m_oX1.SetValue(oNode.GetAttribute(L"x1"));
|
||||
m_oY1.SetValue(oNode.GetAttribute(L"y1"));
|
||||
m_oX2.SetValue(oNode.GetAttribute(L"x2"));
|
||||
m_oY2.SetValue(oNode.GetAttribute(L"y2"));
|
||||
}
|
||||
|
||||
bool CLinearGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
@ -194,20 +169,12 @@ namespace SVG
|
||||
return true;
|
||||
}
|
||||
|
||||
CRadialGradient::CRadialGradient(CSvgReader& oReader)
|
||||
: CGradient(oReader)
|
||||
{}
|
||||
|
||||
void CRadialGradient::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
CRadialGradient::CRadialGradient(XmlUtils::CXmlNode& oNode)
|
||||
: CGradient(oNode)
|
||||
{
|
||||
if ("cx" == sName)
|
||||
m_oCx.SetValue(oReader.GetText());
|
||||
else if ("cy" == sName)
|
||||
m_oCy.SetValue(oReader.GetText());
|
||||
else if ("r" == sName)
|
||||
m_oR.SetValue(oReader.GetText());
|
||||
else
|
||||
CGradient::SetAttribute(sName, oReader);
|
||||
m_oCx.SetValue(oNode.GetAttribute(L"cx"));
|
||||
m_oCy.SetValue(oNode.GetAttribute(L"cy"));
|
||||
m_oR.SetValue(oNode.GetAttribute(L"r"));
|
||||
}
|
||||
|
||||
bool CRadialGradient::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
|
||||
@ -22,7 +22,7 @@ namespace SVG
|
||||
class CStopElement : public CObject
|
||||
{
|
||||
public:
|
||||
CStopElement(CSvgReader& oReader);
|
||||
CStopElement(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
@ -37,18 +37,16 @@ namespace SVG
|
||||
|
||||
class CGradient : public CContainer<CStopElement>, public CAppliedObject
|
||||
{
|
||||
protected:
|
||||
CGradient(CSvgReader& oReader);
|
||||
friend class CLinearGradient;
|
||||
friend class CRadialGradient;
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CGradient(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
void SetData(const std::map<std::wstring, std::wstring>& mAttributes, unsigned short ushLevel, bool bHardMode = false) override;
|
||||
|
||||
void ReadChildrens(CSvgReader& oReader, CSvgFile* pSvgFile) override;
|
||||
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
void ApplyTransform(IRenderer *pRenderer, const TBounds& oBounds, double& dAngle) const;
|
||||
protected:
|
||||
private:
|
||||
CGradient* GetRefGradient(const CSvgFile *pFile) const;
|
||||
bool ApplyRefGradient(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) const;
|
||||
|
||||
@ -60,10 +58,8 @@ namespace SVG
|
||||
|
||||
class CLinearGradient : public CGradient
|
||||
{
|
||||
friend class CObject;
|
||||
CLinearGradient(CSvgReader& oReader);
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CLinearGradient(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
private:
|
||||
@ -75,10 +71,8 @@ namespace SVG
|
||||
|
||||
class CRadialGradient : public CGradient
|
||||
{
|
||||
friend class CObject;
|
||||
CRadialGradient(CSvgReader& oReader);
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CRadialGradient(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
private:
|
||||
|
||||
@ -5,29 +5,18 @@
|
||||
#include "../../../BgraFrame.h"
|
||||
#include "../../../../common/Path.h"
|
||||
#include "../../../../common/ProcessEnv.h"
|
||||
#include "../../../../common/Base64.h"
|
||||
#include "../../../../common/File.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CImage::CImage(CSvgReader& oReader, CRenderedObject* pParent)
|
||||
: CRenderedObject(oReader, pParent)
|
||||
{}
|
||||
|
||||
void CImage::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
CImage::CImage(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent)
|
||||
: CRenderedObject(oNode, pParent)
|
||||
{
|
||||
if ("x" == sName)
|
||||
m_oRect.m_oX.SetValue(oReader.GetText());
|
||||
else if ("y" == sName)
|
||||
m_oRect.m_oY.SetValue(oReader.GetText());
|
||||
else if ("width" == sName)
|
||||
m_oRect.m_oWidth.SetValue(oReader.GetText());
|
||||
else if ("height" == sName)
|
||||
m_oRect.m_oHeight.SetValue(oReader.GetText());
|
||||
else if ("href" == sName || "xlink:href" == sName)
|
||||
m_wsHref = oReader.GetText(); // TODO:: В дальнейшем возможно стоит реализовать отдельный класс CHref для всех типов ссылок
|
||||
else
|
||||
CRenderedObject::SetAttribute(sName, oReader);
|
||||
m_oRect.m_oX .SetValue(oNode.GetAttribute(L"x"));
|
||||
m_oRect.m_oY .SetValue(oNode.GetAttribute(L"y"));
|
||||
m_oRect.m_oWidth .SetValue(oNode.GetAttribute(L"width"));
|
||||
m_oRect.m_oHeight.SetValue(oNode.GetAttribute(L"height"));
|
||||
|
||||
m_wsHref = oNode.GetAttribute(L"href", oNode.GetAttribute(L"xlink:href")); // TODO:: В дальнейшем возможно стоит реализовать отдельный класс CHref для всех типов ссылок
|
||||
}
|
||||
|
||||
bool CImage::Draw(IRenderer *pRenderer, const CSvgFile *pFile, CommandeMode oMode, const TSvgStyles *pOtherStyles, const CRenderedObject* pContexObject) const
|
||||
@ -66,10 +55,7 @@ namespace SVG
|
||||
std::wstring wsImageData = m_wsHref.substr(unType + 8, m_wsHref.length() - unType - 8);
|
||||
ulSize = NSBase64::Base64DecodeGetRequiredLength(wsImageData.length());
|
||||
|
||||
pBuffer = new(std::nothrow) BYTE[ulSize];
|
||||
|
||||
if (NULL == pBuffer)
|
||||
return false;
|
||||
pBuffer = new BYTE[ulSize];
|
||||
|
||||
NSBase64::Base64Decode(wsImageData.c_str(), wsImageData.length(), pBuffer, &(int&)ulSize);
|
||||
}
|
||||
@ -135,7 +121,7 @@ namespace SVG
|
||||
return true;
|
||||
}
|
||||
|
||||
TBounds CImage::GetBounds(SvgMatrix* pTransform) const
|
||||
TBounds CImage::GetBounds() const
|
||||
{
|
||||
TBounds oBounds;
|
||||
|
||||
@ -144,16 +130,6 @@ namespace SVG
|
||||
oBounds.m_dRight = oBounds.m_dLeft + m_oRect.m_oWidth.ToDouble(NSCSS::Pixel);
|
||||
oBounds.m_dBottom = oBounds.m_dTop + m_oRect.m_oHeight.ToDouble(NSCSS::Pixel);
|
||||
|
||||
if (nullptr != pTransform)
|
||||
{
|
||||
*pTransform += m_oTransformation.m_oTransform.GetMatrix();
|
||||
|
||||
pTransform->GetFinalValue().TransformPoint(oBounds.m_dLeft, oBounds.m_dTop );
|
||||
pTransform->GetFinalValue().TransformPoint(oBounds.m_dRight, oBounds.m_dBottom);
|
||||
|
||||
*pTransform -= m_oTransformation.m_oTransform.GetMatrix();
|
||||
}
|
||||
|
||||
return oBounds;
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,14 +7,12 @@ namespace SVG
|
||||
{
|
||||
class CImage : public CRenderedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CImage(CSvgReader& oReader, CRenderedObject* pParent = NULL);
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CImage(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
|
||||
|
||||
bool Draw(IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pOtherStyles = NULL, const CRenderedObject* pContexObject = NULL) const override;
|
||||
private:
|
||||
TBounds GetBounds(SvgMatrix* pTransform = nullptr) const override;
|
||||
TBounds GetBounds() const override;
|
||||
|
||||
TRect m_oRect;
|
||||
std::wstring m_wsHref;
|
||||
|
||||
@ -2,46 +2,21 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CLine::CLine(CSvgReader& oReader, CRenderedObject* pParent)
|
||||
: CPath(oReader, pParent)
|
||||
{
|
||||
AddElement(new CMoveElement(Point{0, 0}));
|
||||
AddElement(new CLineElement(Point{0, 0}));
|
||||
}
|
||||
CLine::CLine(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent)
|
||||
: CPath(oNode, pParent, false)
|
||||
{
|
||||
SvgDigit oX1;
|
||||
SvgDigit oY1;
|
||||
SvgDigit oX2;
|
||||
SvgDigit oY2;
|
||||
|
||||
void CLine::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
//TODO:: не нравится, подумать как можно сделать иначе
|
||||
if ("x1" == sName)
|
||||
{
|
||||
CMoveElement* pMoveElement{dynamic_cast<CMoveElement*>(operator[](0))};
|
||||
oX1.SetValue(oNode.GetAttribute(L"x1"));
|
||||
oY1.SetValue(oNode.GetAttribute(L"y1"));
|
||||
oX2.SetValue(oNode.GetAttribute(L"x2"));
|
||||
oY2.SetValue(oNode.GetAttribute(L"y2"));
|
||||
|
||||
if (NULL != pMoveElement)
|
||||
pMoveElement->m_oPoint.dX = oReader.GetDouble();
|
||||
}
|
||||
else if ("y1" == sName)
|
||||
{
|
||||
CMoveElement* pMoveElement{dynamic_cast<CMoveElement*>(operator[](0))};
|
||||
|
||||
if (NULL != pMoveElement)
|
||||
pMoveElement->m_oPoint.dY = oReader.GetDouble();
|
||||
}
|
||||
else if ("x2" == sName)
|
||||
{
|
||||
CLineElement* pLineElement{dynamic_cast<CLineElement*>(operator[](1))};
|
||||
|
||||
if (NULL != pLineElement)
|
||||
pLineElement->m_oPoint.dX = oReader.GetDouble();
|
||||
}
|
||||
else if ("y2" == sName)
|
||||
{
|
||||
CLineElement* pLineElement{dynamic_cast<CLineElement*>(operator[](1))};
|
||||
|
||||
if (NULL != pLineElement)
|
||||
pLineElement->m_oPoint.dY = oReader.GetDouble();
|
||||
}
|
||||
else
|
||||
CRenderedObject::SetAttribute(sName, oReader);
|
||||
AddElement(new CMoveElement(Point{oX1.ToDouble(NSCSS::Pixel), oY1.ToDouble(NSCSS::Pixel)}));
|
||||
AddElement(new CLineElement(Point{oX2.ToDouble(NSCSS::Pixel), oY2.ToDouble(NSCSS::Pixel)}));
|
||||
}
|
||||
|
||||
void CLine::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
|
||||
@ -7,10 +7,8 @@ namespace SVG
|
||||
{
|
||||
class CLine : public CPath
|
||||
{
|
||||
friend class CObject;
|
||||
CLine(CSvgReader& oReader, CRenderedObject* pParent = NULL);
|
||||
public:
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
CLine(XmlUtils::CXmlNode& oNode, CRenderedObject* pParent = NULL);
|
||||
|
||||
void SetData(const std::map<std::wstring, std::wstring>& mAttributes, unsigned short ushLevel, bool bHardMode = false) override;
|
||||
private:
|
||||
|
||||
@ -1,35 +1,26 @@
|
||||
#include "CMarker.h"
|
||||
|
||||
#include "../../../graphics/pro/Graphics.h"
|
||||
#include "../SvgUtils.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CMarker::CMarker(CSvgReader& oReader)
|
||||
: CObject(oReader), m_enUnits{EMarkerUnits::StrokeWidth}, m_enOrient{EMarkerOrient::Angle},
|
||||
m_dAngle(0.), m_oBounds{0., 0., 0., 0.}
|
||||
CMarker::CMarker(XmlUtils::CXmlNode &oNode)
|
||||
: CObject(oNode), m_dAngle(0.), m_oBounds{0., 0., 0., 0.}
|
||||
{
|
||||
m_oWindow.m_oWidth.SetValue(3);
|
||||
m_oWindow.m_oHeight.SetValue(3);
|
||||
}
|
||||
m_oWindow.m_oX .SetValue(oNode.GetAttribute(L"refX"));
|
||||
m_oWindow.m_oY .SetValue(oNode.GetAttribute(L"refY"));
|
||||
|
||||
ObjectType CMarker::GetType() const
|
||||
{
|
||||
return AppliedObject;
|
||||
}
|
||||
m_oWindow.m_oWidth .SetValue(oNode.GetAttribute(L"markerWidth", L"3"));
|
||||
m_oWindow.m_oHeight.SetValue(oNode.GetAttribute(L"markerHeight", L"3"));
|
||||
|
||||
void CMarker::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("refX" == sName)
|
||||
m_oWindow.m_oX.SetValue(oReader.GetText());
|
||||
else if ("refY" == sName)
|
||||
m_oWindow.m_oY.SetValue(oReader.GetText());
|
||||
else if ("markerWidth" == sName)
|
||||
m_oWindow.m_oWidth.SetValue(oReader.GetText());
|
||||
else if ("markerHeight" == sName)
|
||||
m_oWindow.m_oHeight.SetValue(oReader.GetText());
|
||||
else if ("viewBox" == sName)
|
||||
m_oViewBox = m_oWindow;
|
||||
|
||||
const std::wstring wsViewBox = oNode.GetAttribute(L"viewBox");
|
||||
|
||||
if (!wsViewBox.empty())
|
||||
{
|
||||
const std::vector<double> arValues{StrUtils::ReadDoubleValues(oReader.GetText())};
|
||||
std::vector<double> arValues = StrUtils::ReadDoubleValues(wsViewBox);
|
||||
if (4 == arValues.size())
|
||||
{
|
||||
m_oViewBox.m_oX = arValues[0];
|
||||
@ -38,24 +29,35 @@ namespace SVG
|
||||
m_oViewBox.m_oHeight = arValues[3];
|
||||
}
|
||||
}
|
||||
else if ("markerUnits" == sName)
|
||||
{
|
||||
if (L"userSpaceOnUse" == oReader.GetText())
|
||||
m_enUnits = EMarkerUnits::UserSpaceOnUse;
|
||||
}
|
||||
else if ("orient" == sName)
|
||||
{
|
||||
const std::wstring& wsOrient{oReader.GetText()};
|
||||
|
||||
if (L"auto" == wsOrient)
|
||||
m_enOrient = EMarkerOrient::Auto;
|
||||
else if (L"auto-start-reverse" == wsOrient)
|
||||
m_enOrient = EMarkerOrient::Auto_start_reverse;
|
||||
else if (!StrUtils::ReadAngle(wsOrient, m_dAngle))
|
||||
const std::wstring& wsUnits = oNode.GetAttribute(L"markerUnits");
|
||||
|
||||
if (L"userSpaceOnUse" == wsUnits)
|
||||
m_enUnits = EMarkerUnits::UserSpaceOnUse;
|
||||
else
|
||||
m_enUnits = EMarkerUnits::StrokeWidth;
|
||||
|
||||
const std::wstring& wsOrient = oNode.GetAttribute(L"orient");
|
||||
|
||||
if (L"auto" == wsOrient)
|
||||
m_enOrient = EMarkerOrient::Auto;
|
||||
else if (L"auto-start-reverse" == wsOrient)
|
||||
m_enOrient = EMarkerOrient::Auto_start_reverse;
|
||||
else
|
||||
{
|
||||
m_enOrient = EMarkerOrient::Angle;
|
||||
if (!StrUtils::ReadAngle(wsOrient, m_dAngle))
|
||||
StrUtils::ReadDoubleValue(wsOrient, m_dAngle);
|
||||
}
|
||||
else
|
||||
CObject::SetAttribute(sName, oReader);
|
||||
}
|
||||
|
||||
CMarker::~CMarker()
|
||||
{
|
||||
}
|
||||
|
||||
ObjectType CMarker::GetType() const
|
||||
{
|
||||
return AppliedObject;
|
||||
}
|
||||
|
||||
void CMarker::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
@ -66,11 +68,7 @@ namespace SVG
|
||||
if (NULL == oExternalData.m_pPoints || oExternalData.m_pPoints->empty() || m_arObjects.empty() || (EMarkerUnits::StrokeWidth == m_enUnits && Equals(0., oExternalData.m_dStroke)))
|
||||
return;
|
||||
|
||||
const double dMaxScale = ((EMarkerUnits::StrokeWidth == m_enUnits) ? oExternalData.m_dStroke : 1.) *
|
||||
((!m_oViewBox.m_oWidth.Empty() && !m_oViewBox.m_oHeight.Empty()) ?
|
||||
std::max((m_oWindow.m_oWidth.ToDouble(NSCSS::Pixel) / m_oViewBox.m_oWidth.ToDouble(NSCSS::Pixel)),
|
||||
(m_oWindow.m_oHeight.ToDouble(NSCSS::Pixel) / m_oViewBox.m_oHeight.ToDouble(NSCSS::Pixel))) :
|
||||
1.);
|
||||
const double dMaxScale = ((EMarkerUnits::StrokeWidth == m_enUnits) ? oExternalData.m_dStroke : 1.) * std::max((m_oWindow.m_oWidth.ToDouble(NSCSS::Pixel) / m_oViewBox.m_oWidth.ToDouble(NSCSS::Pixel)), (m_oWindow.m_oHeight.ToDouble(NSCSS::Pixel) / m_oViewBox.m_oHeight.ToDouble(NSCSS::Pixel)));
|
||||
|
||||
double dM11, dM12, dM21, dM22, dDx, dDy;
|
||||
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
|
||||
|
||||
@ -45,15 +45,12 @@ namespace SVG
|
||||
|
||||
class CMarker : public CObject, public CContainer<CRenderedObject>
|
||||
{
|
||||
friend class CObject;
|
||||
CMarker(CSvgReader& oReader);
|
||||
public:
|
||||
virtual ~CMarker() = default;
|
||||
CMarker(XmlUtils::CXmlNode& oNode);
|
||||
virtual ~CMarker();
|
||||
|
||||
ObjectType GetType() const override;
|
||||
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
|
||||
void SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode) override;
|
||||
|
||||
void Draw(IRenderer* pRenderer, const CSvgFile *pFile, const TMarkerExternData& oExternalData, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pOtherStyles = NULL, const CRenderedObject* pContexObject = NULL) const;
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CMask::CMask(CSvgReader& oReader)
|
||||
: CClipPath(oReader)
|
||||
CMask::CMask(XmlUtils::CXmlNode &oNode)
|
||||
: CClipPath(oNode)
|
||||
{}
|
||||
|
||||
bool CMask::Apply(IRenderer *pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds)
|
||||
@ -14,7 +14,7 @@ namespace SVG
|
||||
pRenderer->BeginCommand(c_nMaskType);
|
||||
pRenderer->PathCommandStart();
|
||||
|
||||
for (const CRenderedObject* pObject : m_oContainer)
|
||||
for (const CRenderedObject* pObject : m_oContainer.m_arObjects)
|
||||
pObject->Draw(pRenderer, pFile, CommandeModeMask);
|
||||
|
||||
pRenderer->EndCommand(c_nMaskType);
|
||||
|
||||
@ -7,9 +7,9 @@ namespace SVG
|
||||
{
|
||||
class CMask : public CClipPath
|
||||
{
|
||||
friend class CObject;
|
||||
CMask(CSvgReader& oReader);
|
||||
public:
|
||||
CMask(XmlUtils::CXmlNode& oNode);
|
||||
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
};
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
#include "CObjectBase.h"
|
||||
#include "../CSvgFile.h"
|
||||
|
||||
#include "../../../../../Common/3dParty/html/css/src/StaticFunctions.h"
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
TSvgStyles &TSvgStyles::operator+=(const TSvgStyles &oSvgStyles)
|
||||
@ -33,42 +31,14 @@ namespace SVG
|
||||
: m_oXmlNode(oData)
|
||||
{}
|
||||
|
||||
CObject::CObject(CSvgReader& oReader)
|
||||
CObject::CObject(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
m_oXmlNode.m_wsName = oReader.GetNameW();
|
||||
SetNodeData(oNode);
|
||||
}
|
||||
|
||||
CObject::CObject(const CObject& oObject)
|
||||
: m_oXmlNode(oObject.m_oXmlNode), m_oTransformation(oObject.m_oTransformation)
|
||||
CObject::~CObject()
|
||||
{}
|
||||
|
||||
void CObject::Mark()
|
||||
{
|
||||
this->AddRef();
|
||||
}
|
||||
|
||||
bool CObject::Marked() const
|
||||
{
|
||||
//Так как по логике кода объект может храниться только в одном контейнере и в списке маркированных элементов,
|
||||
//то хватит и такой проверки
|
||||
return 1 != m_lRef;
|
||||
}
|
||||
|
||||
void CObject::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("class" == sName)
|
||||
{
|
||||
m_oXmlNode.m_wsClass = oReader.GetText();
|
||||
std::transform(m_oXmlNode.m_wsClass.begin(), m_oXmlNode.m_wsClass.end(), m_oXmlNode.m_wsClass.begin(), std::towlower);
|
||||
}
|
||||
else if ("id" == sName)
|
||||
m_oXmlNode.m_wsId = oReader.GetText();
|
||||
else if ("style" == sName)
|
||||
m_oXmlNode.m_wsStyle = oReader.GetText();
|
||||
else
|
||||
m_oXmlNode.m_mAttributes.insert({oReader.GetNameW(), oReader.GetText()});
|
||||
}
|
||||
|
||||
void CObject::SetData(const std::wstring wsStyles, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
if (wsStyles.empty())
|
||||
@ -77,11 +47,6 @@ namespace SVG
|
||||
SetData(NSCSS::NS_STATIC_FUNCTIONS::GetRules(wsStyles), ushLevel, bHardMode);
|
||||
}
|
||||
|
||||
void CObject::ReadChildrens(CSvgReader& oReader, CSvgFile* pSvgFile)
|
||||
{
|
||||
//TODO:: реализовано в классах там, где нужно
|
||||
}
|
||||
|
||||
void CObject::SetTransform(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
if (mAttributes.end() != mAttributes.find(L"transform"))
|
||||
@ -188,6 +153,33 @@ namespace SVG
|
||||
return pDefObject->Apply(pRenderer, pFile, oBounds);
|
||||
}
|
||||
|
||||
void CObject::SetNodeData(XmlUtils::CXmlNode &oNode)
|
||||
{
|
||||
if (!oNode.IsValid())
|
||||
return;
|
||||
|
||||
std::vector<std::wstring> arProperties, arValues;
|
||||
|
||||
oNode.GetAllAttributes(arProperties, arValues);
|
||||
|
||||
m_oXmlNode.m_wsName = oNode.GetName();
|
||||
|
||||
for (unsigned int unIndex = 0; unIndex < arProperties.size(); ++unIndex)
|
||||
{
|
||||
if (L"class" == arProperties[unIndex])
|
||||
{
|
||||
m_oXmlNode.m_wsClass = arValues[unIndex];
|
||||
std::transform(m_oXmlNode.m_wsClass.begin(), m_oXmlNode.m_wsClass.end(), m_oXmlNode.m_wsClass.begin(), std::towlower);
|
||||
}
|
||||
else if (L"id" == arProperties[unIndex])
|
||||
m_oXmlNode.m_wsId = arValues[unIndex];
|
||||
else if (L"style" == arProperties[unIndex])
|
||||
m_oXmlNode.m_wsStyle = arValues[unIndex];
|
||||
else
|
||||
m_oXmlNode.m_mAttributes.insert({arProperties[unIndex], arValues[unIndex]});
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring CObject::GetId() const
|
||||
{
|
||||
return m_oXmlNode.m_wsId;
|
||||
@ -201,18 +193,16 @@ namespace SVG
|
||||
CRenderedObject::CRenderedObject(const NSCSS::CNode &oData, CRenderedObject *pParent)
|
||||
: CObject(oData), m_pParent(pParent)
|
||||
{
|
||||
SetDefaultData();
|
||||
SetDefaultStyles();
|
||||
}
|
||||
|
||||
CRenderedObject::CRenderedObject(CSvgReader& oReader, CRenderedObject *pParent)
|
||||
: CObject(oReader), m_pParent(pParent)
|
||||
CRenderedObject::CRenderedObject(XmlUtils::CXmlNode &oNode, CRenderedObject *pParent)
|
||||
: CObject(oNode), m_pParent(pParent)
|
||||
{
|
||||
SetDefaultData();
|
||||
SetDefaultStyles();
|
||||
}
|
||||
|
||||
CRenderedObject::CRenderedObject(const CRenderedObject& oRenderedObject)
|
||||
: CObject(oRenderedObject), m_oStyles(oRenderedObject.m_oStyles),
|
||||
m_pParent(oRenderedObject.m_pParent)
|
||||
CRenderedObject::~CRenderedObject()
|
||||
{}
|
||||
|
||||
ObjectType CRenderedObject::GetType() const
|
||||
@ -220,11 +210,6 @@ namespace SVG
|
||||
return RendererObject;
|
||||
}
|
||||
|
||||
void CRenderedObject::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
CObject::SetAttribute(sName, oReader);
|
||||
}
|
||||
|
||||
void CRenderedObject::SetData(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
SetTransform(mAttributes, ushLevel, bHardMode);
|
||||
@ -244,6 +229,20 @@ namespace SVG
|
||||
return arObjects;
|
||||
}
|
||||
|
||||
void CRenderedObject::SetDefaultStyles()
|
||||
{
|
||||
m_oStyles.m_oStroke.m_oLineCap.SetMapping({std::make_pair(L"butt", Aggplus::LineCapFlat), std::make_pair(L"round", Aggplus::LineCapRound), std::make_pair(L"square", Aggplus::LineCapSquare)});
|
||||
m_oStyles.m_oStroke.m_oLineCap = Aggplus::LineCapFlat;
|
||||
|
||||
m_oStyles.m_oStroke.m_oLineJoin.SetMapping({std::make_pair(L"arcs", Aggplus::LineJoinMiter), std::make_pair(L"bevel", Aggplus::LineJoinBevel), std::make_pair(L"miter", Aggplus::LineJoinMiter), std::make_pair(L"miter-clip", Aggplus::LineJoinMiterClipped), std::make_pair(L"round", Aggplus::LineJoinRound)});
|
||||
m_oStyles.m_oStroke.m_oLineCap = Aggplus::LineJoinMiter;
|
||||
|
||||
m_oStyles.m_oStroke.m_oMiterlimit = 4.;
|
||||
|
||||
m_oTransformation.m_oOpacity = 1.;
|
||||
m_oTransformation.m_bDraw = true;
|
||||
}
|
||||
|
||||
void CRenderedObject::SetStroke(const std::map<std::wstring, std::wstring> &mAttributes, unsigned short ushLevel, bool bHardMode)
|
||||
{
|
||||
if (mAttributes.end() != mAttributes.find(L"stroke"))
|
||||
@ -448,27 +447,15 @@ namespace SVG
|
||||
return false;
|
||||
}
|
||||
|
||||
void CRenderedObject::SetDefaultData()
|
||||
{
|
||||
m_oStyles.m_oStroke.m_oLineCap.SetMapping({std::make_pair(L"butt", Aggplus::LineCapFlat), std::make_pair(L"round", Aggplus::LineCapRound), std::make_pair(L"square", Aggplus::LineCapSquare)});
|
||||
m_oStyles.m_oStroke.m_oLineCap = Aggplus::LineCapFlat;
|
||||
CAppliedObject::CAppliedObject(XmlUtils::CXmlNode &oNode)
|
||||
: CObject(oNode)
|
||||
{}
|
||||
|
||||
m_oStyles.m_oStroke.m_oLineJoin.SetMapping({std::make_pair(L"arcs", Aggplus::LineJoinMiter), std::make_pair(L"bevel", Aggplus::LineJoinBevel), std::make_pair(L"miter", Aggplus::LineJoinMiter), std::make_pair(L"miter-clip", Aggplus::LineJoinMiterClipped), std::make_pair(L"round", Aggplus::LineJoinRound)});
|
||||
m_oStyles.m_oStroke.m_oLineCap = Aggplus::LineJoinMiter;
|
||||
|
||||
m_oStyles.m_oStroke.m_oMiterlimit = 4.;
|
||||
|
||||
m_oTransformation.m_oOpacity = 1.;
|
||||
m_oTransformation.m_bDraw = true;
|
||||
}
|
||||
|
||||
CAppliedObject::CAppliedObject(CSvgReader& oReader)
|
||||
: CObject(oReader)
|
||||
CAppliedObject::~CAppliedObject()
|
||||
{}
|
||||
|
||||
ObjectType CAppliedObject::GetType() const
|
||||
{
|
||||
return AppliedObject;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user