mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
xls, ppt, pptx changes
- implicit includes have been resolved - preparation before common shapes(pri) - x2t compiled
This commit is contained in:
111
MsBinaryFile/Common/ODraw/BaseShape.cpp
Normal file
111
MsBinaryFile/Common/ODraw/BaseShape.cpp
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "BaseShape.h"
|
||||
#include "CustomShape.h"
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
CHandle_::CHandle_()
|
||||
{
|
||||
position = _T("");
|
||||
xrange = _T("");
|
||||
yrange = _T("");
|
||||
switchHandle = _T("");
|
||||
polar = _T("");
|
||||
radiusrange = _T("");
|
||||
}
|
||||
CHandle_& CHandle_::operator =(const CHandle_& oSrc)
|
||||
{
|
||||
position = oSrc.position;
|
||||
xrange = oSrc.xrange;
|
||||
yrange = oSrc.yrange;
|
||||
switchHandle = oSrc.switchHandle;
|
||||
polar = oSrc.polar;
|
||||
radiusrange = oSrc.radiusrange;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CBaseShape::CBaseShape()
|
||||
{
|
||||
}
|
||||
CBaseShape* CBaseShape::CreateByType( int ShapeType)
|
||||
{
|
||||
return CCustomShape::CreateByType((oox::MSOSPT)ShapeType);
|
||||
}
|
||||
bool CBaseShape::SetType( int ShapeType)
|
||||
{
|
||||
return ((CCustomShape*)this)->SetShapeType((oox::MSOSPT)ShapeType);
|
||||
}
|
||||
bool CBaseShape::SetProperties(CBaseShape* Shape)
|
||||
{
|
||||
if( Shape == NULL)
|
||||
return false;
|
||||
|
||||
m_oPath = Shape->m_oPath;
|
||||
m_strPath = Shape->m_strPath;
|
||||
m_strRect = Shape->m_strRect;
|
||||
|
||||
m_arAdjustments.clear();
|
||||
for(size_t i = 0; i < Shape->m_arAdjustments.size(); i++)
|
||||
m_arAdjustments.push_back(Shape->m_arAdjustments[i]);
|
||||
|
||||
m_arGuides.clear();
|
||||
for(size_t i = 0; i < Shape->m_arGuides.size(); i++)
|
||||
m_arGuides.push_back(Shape->m_arGuides[i]);
|
||||
|
||||
m_eJoin = Shape->m_eJoin;
|
||||
m_bConcentricFill = Shape->m_bConcentricFill;
|
||||
|
||||
m_arConnectors.clear();
|
||||
for(size_t i = 0; i < Shape->m_arConnectors.size(); i++)
|
||||
m_arConnectors.push_back(Shape->m_arConnectors[i]);
|
||||
|
||||
m_arConnectorAngles.clear();
|
||||
for(size_t i = 0; i < Shape->m_arConnectorAngles.size(); i++)
|
||||
m_arConnectorAngles.push_back(Shape->m_arConnectorAngles[i]);
|
||||
|
||||
m_arTextRects.clear();
|
||||
for(size_t i = 0; i < Shape->m_arTextRects.size(); i++)
|
||||
m_arTextRects.push_back(Shape->m_arTextRects[i]);
|
||||
|
||||
m_arHandles.clear();
|
||||
for(size_t i = 0; i < Shape->m_arHandles.size(); i++)
|
||||
m_arHandles.push_back(Shape->m_arHandles[i]);
|
||||
|
||||
|
||||
m_strRect = Shape->m_strRect;
|
||||
m_strTransformXml = Shape->m_strTransformXml;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -47,25 +47,9 @@ public:
|
||||
std::wstring radiusrange;
|
||||
|
||||
public:
|
||||
CHandle_()
|
||||
{
|
||||
position = _T("");
|
||||
xrange = _T("");
|
||||
yrange = _T("");
|
||||
switchHandle = _T("");
|
||||
polar = _T("");
|
||||
radiusrange = _T("");
|
||||
}
|
||||
CHandle_& operator =(const CHandle_& oSrc)
|
||||
{
|
||||
position = oSrc.position;
|
||||
xrange = oSrc.xrange;
|
||||
yrange = oSrc.yrange;
|
||||
switchHandle = oSrc.switchHandle;
|
||||
polar = oSrc.polar;
|
||||
radiusrange = oSrc.radiusrange;
|
||||
return (*this);
|
||||
}
|
||||
CHandle_();
|
||||
|
||||
CHandle_& operator =(const CHandle_& oSrc);
|
||||
};
|
||||
|
||||
class CBaseShape
|
||||
@ -93,10 +77,9 @@ public:
|
||||
LONG m_lLimoY;
|
||||
|
||||
CPath m_oPath;
|
||||
|
||||
public:
|
||||
CBaseShape()
|
||||
{
|
||||
}
|
||||
CBaseShape();
|
||||
|
||||
virtual bool LoadTextRect(const std::wstring& xml) = 0;
|
||||
virtual bool LoadPathList(const std::wstring& xml) = 0;
|
||||
@ -105,47 +88,7 @@ public:
|
||||
|
||||
bool SetType(int ShapeType);
|
||||
|
||||
virtual bool SetProperties(CBaseShape* Shape)
|
||||
{
|
||||
if( Shape == NULL)
|
||||
return false;
|
||||
|
||||
m_oPath = Shape->m_oPath;
|
||||
m_strPath = Shape->m_strPath;
|
||||
m_strRect = Shape->m_strRect;
|
||||
|
||||
m_arAdjustments.clear();
|
||||
for(size_t i = 0; i < Shape->m_arAdjustments.size(); i++)
|
||||
m_arAdjustments.push_back(Shape->m_arAdjustments[i]);
|
||||
|
||||
m_arGuides.clear();
|
||||
for(size_t i = 0; i < Shape->m_arGuides.size(); i++)
|
||||
m_arGuides.push_back(Shape->m_arGuides[i]);
|
||||
|
||||
m_eJoin = Shape->m_eJoin;
|
||||
m_bConcentricFill = Shape->m_bConcentricFill;
|
||||
|
||||
m_arConnectors.clear();
|
||||
for(size_t i = 0; i < Shape->m_arConnectors.size(); i++)
|
||||
m_arConnectors.push_back(Shape->m_arConnectors[i]);
|
||||
|
||||
m_arConnectorAngles.clear();
|
||||
for(size_t i = 0; i < Shape->m_arConnectorAngles.size(); i++)
|
||||
m_arConnectorAngles.push_back(Shape->m_arConnectorAngles[i]);
|
||||
|
||||
m_arTextRects.clear();
|
||||
for(size_t i = 0; i < Shape->m_arTextRects.size(); i++)
|
||||
m_arTextRects.push_back(Shape->m_arTextRects[i]);
|
||||
|
||||
m_arHandles.clear();
|
||||
for(size_t i = 0; i < Shape->m_arHandles.size(); i++)
|
||||
m_arHandles.push_back(Shape->m_arHandles[i]);
|
||||
|
||||
|
||||
m_strRect = Shape->m_strRect;
|
||||
m_strTransformXml = Shape->m_strTransformXml;
|
||||
return true;
|
||||
}
|
||||
virtual bool SetProperties(CBaseShape* Shape);
|
||||
|
||||
//virtual bool SetToDublicate(CBaseShape* Shape)
|
||||
//{
|
||||
|
||||
365
MsBinaryFile/Common/ODraw/CustomGeomShape.cpp
Normal file
365
MsBinaryFile/Common/ODraw/CustomGeomShape.cpp
Normal file
@ -0,0 +1,365 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CustomGeomShape.h"
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
CSegment::CSegment(RulesType eType, WORD nCount)
|
||||
{
|
||||
m_eRuler = eType;
|
||||
m_nCount = nCount;
|
||||
}
|
||||
CSegment::CSegment(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
}
|
||||
CSegment& CSegment::operator=(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
CSegment::~CSegment()
|
||||
{
|
||||
}
|
||||
|
||||
CGuide::CGuide()
|
||||
{
|
||||
m_eType = ftVal;
|
||||
|
||||
m_param_type1 = 0;
|
||||
m_param_type2 = 0;
|
||||
m_param_type3 = 0;
|
||||
|
||||
m_param_value1 = 0;
|
||||
m_param_value2 = 0;
|
||||
m_param_value3 = 0;
|
||||
|
||||
}
|
||||
CGuide::CGuide(const CGuide& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CGuide& CGuide::operator=(const CGuide& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
|
||||
m_param_type1 = oSrc.m_param_type1;
|
||||
m_param_type2 = oSrc.m_param_type2;
|
||||
m_param_type3 = oSrc.m_param_type3;
|
||||
|
||||
m_param_value1 = oSrc.m_param_value1;
|
||||
m_param_value2 = oSrc.m_param_value2;
|
||||
m_param_value3 = oSrc.m_param_value3;
|
||||
|
||||
return *this;
|
||||
}
|
||||
void CGuide::SetToFormula(NSCustomShapesConvert::CFormula& oFormula)
|
||||
{
|
||||
oFormula.m_eFormulaType = m_eType;
|
||||
|
||||
SetParam(m_param_type1, m_param_value1, oFormula.m_eType1, oFormula.m_lParam1);
|
||||
SetParam(m_param_type2, m_param_value2, oFormula.m_eType2, oFormula.m_lParam2);
|
||||
SetParam(m_param_type3, m_param_value3, oFormula.m_eType3, oFormula.m_lParam3);
|
||||
}
|
||||
void CGuide::SetParam(BYTE type, WORD param, ParamType& param_type, LONG& param_value)
|
||||
{
|
||||
if (0 == type)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = (LONG)param;
|
||||
}
|
||||
|
||||
if (0x0140 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0141 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0142 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
if (0x0143 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0147 <= param) && (param <= 0x014E))
|
||||
{
|
||||
param_type = ptAdjust;
|
||||
param_value = (LONG)(param - 0x0147);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0400 <= param) && (param <= 0x047F))
|
||||
{
|
||||
param_type = ptFormula;
|
||||
param_value = (LONG)(param - 0x0400);
|
||||
return;
|
||||
}
|
||||
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
}
|
||||
|
||||
CCustomVML::CCustomVML() : m_arVertices(), m_arSegments(), m_arGuides(), m_pAdjustValues(NULL)
|
||||
{
|
||||
m_ePath = rtCurveTo/*rtLineTo*/;
|
||||
|
||||
m_bIsPathPresent = false;
|
||||
}
|
||||
CCustomVML::CCustomVML(const CCustomVML& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CCustomVML& CCustomVML::operator=(const CCustomVML& oSrc)
|
||||
{
|
||||
m_ePath = oSrc.m_ePath;
|
||||
|
||||
m_arVertices.clear();
|
||||
m_arVertices.insert(m_arVertices.end(), oSrc.m_arVertices.begin(), oSrc.m_arVertices.end());
|
||||
|
||||
m_arSegments.clear();
|
||||
m_arSegments.insert(m_arSegments.end(), oSrc.m_arSegments.begin(), oSrc.m_arSegments.end());
|
||||
|
||||
m_arGuides.clear();
|
||||
m_arGuides.insert(m_arGuides.end(), oSrc.m_arGuides.begin(), oSrc.m_arGuides.end());
|
||||
|
||||
m_pAdjustValues = oSrc.m_pAdjustValues;
|
||||
|
||||
m_bIsPathPresent = oSrc.m_bIsPathPresent;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CCustomVML::~CCustomVML()
|
||||
{
|
||||
}
|
||||
bool CCustomVML::IsCustom()
|
||||
{
|
||||
return (!m_arVertices.empty() && (m_bIsPathPresent || !m_arSegments.empty()));
|
||||
}
|
||||
void CCustomVML::SetPath(RulesType ePath)
|
||||
{
|
||||
m_ePath = ePath;
|
||||
m_bIsPathPresent = true;
|
||||
}
|
||||
void CCustomVML::LoadAHs(unsigned char* buffer, int buffer_size)
|
||||
{
|
||||
}
|
||||
void CCustomVML::addSegment(RulesType eRuler, _UINT16 nCount)
|
||||
{
|
||||
CSegment oInfo(eRuler, nCount);
|
||||
m_arSegments.push_back(oInfo);
|
||||
}
|
||||
void CCustomVML::addGuide(CGuide & oInfo)
|
||||
{
|
||||
m_arGuides.push_back(oInfo);
|
||||
}
|
||||
void CCustomVML::addAdjust(int lIndex, int lValue)
|
||||
{
|
||||
if (NULL == m_pAdjustValues)
|
||||
return;
|
||||
|
||||
int lCount = m_pAdjustValues->size();
|
||||
|
||||
while (lCount <= lIndex)
|
||||
{
|
||||
m_pAdjustValues->push_back(0);
|
||||
lCount = m_pAdjustValues->size();
|
||||
}
|
||||
|
||||
(*m_pAdjustValues)[lIndex] = lValue;
|
||||
}
|
||||
void CCustomVML::SetAdjusts(std::vector<LONG>* pList)
|
||||
{
|
||||
m_pAdjustValues = pList;
|
||||
}
|
||||
void CCustomVML::ToCustomShape(CBaseShape* pShape, NSCustomShapesConvert::CFormulasManager& oManager)
|
||||
{
|
||||
if ((NULL == pShape) || (!IsCustom()))
|
||||
return;
|
||||
|
||||
oManager.Clear();
|
||||
// сначала заполним формулы
|
||||
for (size_t nIndex = 0; nIndex < m_arGuides.size(); ++nIndex)
|
||||
{
|
||||
NSCustomShapesConvert::CFormula oF;
|
||||
m_arGuides[nIndex].SetToFormula(oF);
|
||||
oManager.AddFormula(oF);
|
||||
}
|
||||
|
||||
oManager.Clear(m_pAdjustValues);
|
||||
|
||||
std::wstring strPath = _T("");
|
||||
|
||||
bool bBreak = false;
|
||||
|
||||
long lMinF = (_INT32)0x80000000;
|
||||
long lMaxF = (_INT32)0x8000007F;
|
||||
|
||||
int nGuideIndex_x , nGuideIndex_y;
|
||||
|
||||
if (0 == m_arSegments.size())
|
||||
{
|
||||
strPath = GetRulerVML(m_ePath);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < m_arVertices.size(); ++nIndex)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nIndex].x ) nGuideIndex_x = (DWORD)m_arVertices[nIndex].x - (DWORD)lMinF;
|
||||
if (lMaxF > m_arVertices[nIndex].y ) nGuideIndex_y = (DWORD)m_arVertices[nIndex].y - (DWORD)lMinF;
|
||||
|
||||
if (nGuideIndex_x >= 0 && nGuideIndex_x < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0 && nGuideIndex_y < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].y) + L",";
|
||||
}
|
||||
}
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nStart = 0;
|
||||
size_t nEnd = 0;
|
||||
for (size_t nS = 0; nS < m_arSegments.size(); ++nS)
|
||||
{
|
||||
if (bBreak)
|
||||
{
|
||||
if ((rtEnd != m_arSegments[nS].m_eRuler) &&
|
||||
(rtNoFill != m_arSegments[nS].m_eRuler) &&
|
||||
(rtNoStroke != m_arSegments[nS].m_eRuler) &&
|
||||
(rtClose != m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
strPath += _T("e");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rtFillColor == m_arSegments[nS].m_eRuler) || (rtLineColor == m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
if (nStart < m_arVertices.size())
|
||||
{
|
||||
if (rtFillColor == m_arSegments[nS].m_eRuler)
|
||||
{
|
||||
//m_oBrush.Color1 = (DWORD)m_arVertices[nStart].x; todooooo
|
||||
//m_oBrush.Color2 = (DWORD)m_arVertices[nStart].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_oPen.Color = (DWORD)m_arVertices[nStart].x; todooooo
|
||||
}
|
||||
}
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
strPath += GetRulerVML(m_arSegments[nS].m_eRuler);
|
||||
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
|
||||
for (size_t nV = nStart; nV < nEnd; ++nV)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nV].x ) nGuideIndex_x = (DWORD)m_arVertices[nV].x - (DWORD)lMinF;
|
||||
if (lMaxF > m_arVertices[nV].y ) nGuideIndex_y = (DWORD)m_arVertices[nV].y - (DWORD)lMinF;
|
||||
|
||||
if (nGuideIndex_x >= 0 && nGuideIndex_x < (int)m_arGuides.size() )
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0 && nGuideIndex_y < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].y) + L",";
|
||||
}
|
||||
}
|
||||
|
||||
if (nEnd != nStart)
|
||||
{
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
oManager.CalculateResults();
|
||||
pShape->LoadPathList(strPath);
|
||||
}
|
||||
}
|
||||
@ -31,9 +31,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "BaseShape.h"
|
||||
|
||||
#include "FormulaShape.h"
|
||||
|
||||
#include "../../../OOXML/SystemUtility/File.h"
|
||||
@ -46,29 +44,10 @@ namespace NSCustomShapesConvert
|
||||
RulesType m_eRuler;
|
||||
WORD m_nCount;
|
||||
|
||||
CSegment(RulesType eType = rtMoveTo, WORD nCount = 2)
|
||||
{
|
||||
m_eRuler = eType;
|
||||
m_nCount = nCount;
|
||||
}
|
||||
|
||||
CSegment(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
}
|
||||
|
||||
CSegment& operator=(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~CSegment()
|
||||
{
|
||||
}
|
||||
CSegment(RulesType eType = rtMoveTo, WORD nCount = 2);
|
||||
CSegment(const CSegment& oSrc);
|
||||
CSegment& operator=(const CSegment& oSrc);
|
||||
~CSegment();
|
||||
};
|
||||
|
||||
class CGuide
|
||||
@ -84,100 +63,14 @@ namespace NSCustomShapesConvert
|
||||
WORD m_param_value2;
|
||||
WORD m_param_value3;
|
||||
|
||||
CGuide()
|
||||
{
|
||||
m_eType = ftVal;
|
||||
CGuide();
|
||||
CGuide(const CGuide& oSrc);
|
||||
|
||||
m_param_type1 = 0;
|
||||
m_param_type2 = 0;
|
||||
m_param_type3 = 0;
|
||||
|
||||
m_param_value1 = 0;
|
||||
m_param_value2 = 0;
|
||||
m_param_value3 = 0;
|
||||
|
||||
}
|
||||
|
||||
CGuide(const CGuide& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
CGuide& operator=(const CGuide& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
|
||||
m_param_type1 = oSrc.m_param_type1;
|
||||
m_param_type2 = oSrc.m_param_type2;
|
||||
m_param_type3 = oSrc.m_param_type3;
|
||||
|
||||
m_param_value1 = oSrc.m_param_value1;
|
||||
m_param_value2 = oSrc.m_param_value2;
|
||||
m_param_value3 = oSrc.m_param_value3;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SetToFormula(NSCustomShapesConvert::CFormula& oFormula)
|
||||
{
|
||||
oFormula.m_eFormulaType = m_eType;
|
||||
|
||||
SetParam(m_param_type1, m_param_value1, oFormula.m_eType1, oFormula.m_lParam1);
|
||||
SetParam(m_param_type2, m_param_value2, oFormula.m_eType2, oFormula.m_lParam2);
|
||||
SetParam(m_param_type3, m_param_value3, oFormula.m_eType3, oFormula.m_lParam3);
|
||||
}
|
||||
CGuide& operator=(const CGuide& oSrc);
|
||||
void SetToFormula(NSCustomShapesConvert::CFormula& oFormula);
|
||||
|
||||
private:
|
||||
void SetParam(BYTE type, WORD param, ParamType& param_type, LONG& param_value)
|
||||
{
|
||||
if (0 == type)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = (LONG)param;
|
||||
}
|
||||
|
||||
if (0x0140 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0141 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0142 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
if (0x0143 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0147 <= param) && (param <= 0x014E))
|
||||
{
|
||||
param_type = ptAdjust;
|
||||
param_value = (LONG)(param - 0x0147);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0400 <= param) && (param <= 0x047F))
|
||||
{
|
||||
param_type = ptFormula;
|
||||
param_value = (LONG)(param - 0x0400);
|
||||
return;
|
||||
}
|
||||
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
}
|
||||
void SetParam(BYTE type, WORD param, ParamType& param_type, LONG& param_value);
|
||||
};
|
||||
|
||||
class CCustomVML
|
||||
@ -192,229 +85,21 @@ namespace NSCustomShapesConvert
|
||||
|
||||
bool m_bIsPathPresent;
|
||||
|
||||
CCustomVML() : m_arVertices(), m_arSegments(), m_arGuides(), m_pAdjustValues(NULL)
|
||||
{
|
||||
m_ePath = rtCurveTo/*rtLineTo*/;
|
||||
|
||||
m_bIsPathPresent = false;
|
||||
}
|
||||
|
||||
CCustomVML(const CCustomVML& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CCustomVML();
|
||||
CCustomVML(const CCustomVML& oSrc);
|
||||
CCustomVML& operator=(const CCustomVML& oSrc);
|
||||
~CCustomVML();
|
||||
|
||||
CCustomVML& operator=(const CCustomVML& oSrc)
|
||||
{
|
||||
m_ePath = oSrc.m_ePath;
|
||||
bool IsCustom();
|
||||
|
||||
m_arVertices.clear();
|
||||
m_arVertices.insert(m_arVertices.end(), oSrc.m_arVertices.begin(), oSrc.m_arVertices.end());
|
||||
void SetPath(RulesType ePath);
|
||||
void LoadAHs(unsigned char* buffer, int buffer_size);
|
||||
|
||||
m_arSegments.clear();
|
||||
m_arSegments.insert(m_arSegments.end(), oSrc.m_arSegments.begin(), oSrc.m_arSegments.end());
|
||||
void addSegment(RulesType eRuler, _UINT16 nCount);
|
||||
void addGuide(CGuide & oInfo);
|
||||
void addAdjust(int lIndex, int lValue);
|
||||
|
||||
m_arGuides.clear();
|
||||
m_arGuides.insert(m_arGuides.end(), oSrc.m_arGuides.begin(), oSrc.m_arGuides.end());
|
||||
|
||||
m_pAdjustValues = oSrc.m_pAdjustValues;
|
||||
|
||||
m_bIsPathPresent = oSrc.m_bIsPathPresent;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~CCustomVML()
|
||||
{
|
||||
}
|
||||
|
||||
bool IsCustom()
|
||||
{
|
||||
return (!m_arVertices.empty() && (m_bIsPathPresent || !m_arSegments.empty()));
|
||||
}
|
||||
|
||||
void SetPath(RulesType ePath)
|
||||
{
|
||||
m_ePath = ePath;
|
||||
m_bIsPathPresent = true;
|
||||
}
|
||||
void LoadAHs(unsigned char* buffer, int buffer_size)
|
||||
{
|
||||
}
|
||||
void addSegment(RulesType eRuler, _UINT16 nCount)
|
||||
{
|
||||
CSegment oInfo(eRuler, nCount);
|
||||
m_arSegments.push_back(oInfo);
|
||||
}
|
||||
void addGuide(CGuide & oInfo)
|
||||
{
|
||||
m_arGuides.push_back(oInfo);
|
||||
}
|
||||
void addAdjust(int lIndex, int lValue)
|
||||
{
|
||||
if (NULL == m_pAdjustValues)
|
||||
return;
|
||||
|
||||
int lCount = m_pAdjustValues->size();
|
||||
|
||||
while (lCount <= lIndex)
|
||||
{
|
||||
m_pAdjustValues->push_back(0);
|
||||
lCount = m_pAdjustValues->size();
|
||||
}
|
||||
|
||||
(*m_pAdjustValues)[lIndex] = lValue;
|
||||
}
|
||||
|
||||
void SetAdjusts(std::vector<LONG>* pList)
|
||||
{
|
||||
m_pAdjustValues = pList;
|
||||
}
|
||||
|
||||
void ToCustomShape(CBaseShape* pShape, NSCustomShapesConvert::CFormulasManager& oManager)
|
||||
{
|
||||
if ((NULL == pShape) || (!IsCustom()))
|
||||
return;
|
||||
|
||||
oManager.Clear();
|
||||
// сначала заполним формулы
|
||||
for (size_t nIndex = 0; nIndex < m_arGuides.size(); ++nIndex)
|
||||
{
|
||||
NSCustomShapesConvert::CFormula oF;
|
||||
m_arGuides[nIndex].SetToFormula(oF);
|
||||
oManager.AddFormula(oF);
|
||||
}
|
||||
|
||||
oManager.Clear(m_pAdjustValues);
|
||||
|
||||
std::wstring strPath = _T("");
|
||||
|
||||
bool bBreak = false;
|
||||
|
||||
long lMinF = (_INT32)0x80000000;
|
||||
long lMaxF = (_INT32)0x8000007F;
|
||||
|
||||
int nGuideIndex_x , nGuideIndex_y;
|
||||
|
||||
if (0 == m_arSegments.size())
|
||||
{
|
||||
strPath = GetRulerVML(m_ePath);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < m_arVertices.size(); ++nIndex)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nIndex].x ) nGuideIndex_x = (DWORD)m_arVertices[nIndex].x - (DWORD)lMinF;
|
||||
if (lMaxF > m_arVertices[nIndex].y ) nGuideIndex_y = (DWORD)m_arVertices[nIndex].y - (DWORD)lMinF;
|
||||
|
||||
if (nGuideIndex_x >= 0 && nGuideIndex_x < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0 && nGuideIndex_y < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].y) + L",";
|
||||
}
|
||||
}
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nStart = 0;
|
||||
size_t nEnd = 0;
|
||||
for (size_t nS = 0; nS < m_arSegments.size(); ++nS)
|
||||
{
|
||||
if (bBreak)
|
||||
{
|
||||
if ((rtEnd != m_arSegments[nS].m_eRuler) &&
|
||||
(rtNoFill != m_arSegments[nS].m_eRuler) &&
|
||||
(rtNoStroke != m_arSegments[nS].m_eRuler) &&
|
||||
(rtClose != m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
strPath += _T("e");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((rtFillColor == m_arSegments[nS].m_eRuler) || (rtLineColor == m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
if (nStart < m_arVertices.size())
|
||||
{
|
||||
if (rtFillColor == m_arSegments[nS].m_eRuler)
|
||||
{
|
||||
//m_oBrush.Color1 = (DWORD)m_arVertices[nStart].x; todooooo
|
||||
//m_oBrush.Color2 = (DWORD)m_arVertices[nStart].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
//m_oPen.Color = (DWORD)m_arVertices[nStart].x; todooooo
|
||||
}
|
||||
}
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
strPath += GetRulerVML(m_arSegments[nS].m_eRuler);
|
||||
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
|
||||
for (size_t nV = nStart; nV < nEnd; ++nV)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nV].x ) nGuideIndex_x = (DWORD)m_arVertices[nV].x - (DWORD)lMinF;
|
||||
if (lMaxF > m_arVertices[nV].y ) nGuideIndex_y = (DWORD)m_arVertices[nV].y - (DWORD)lMinF;
|
||||
|
||||
if (nGuideIndex_x >= 0 && nGuideIndex_x < (int)m_arGuides.size() )
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0 && nGuideIndex_y < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].y) + L",";
|
||||
}
|
||||
}
|
||||
|
||||
if (nEnd != nStart)
|
||||
{
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
oManager.CalculateResults();
|
||||
pShape->LoadPathList(strPath);
|
||||
}
|
||||
void SetAdjusts(std::vector<LONG>* pList);
|
||||
void ToCustomShape(CBaseShape* pShape, NSCustomShapesConvert::CFormulasManager& oManager);
|
||||
};
|
||||
}
|
||||
|
||||
@ -47,252 +47,345 @@ using namespace ODRAW;
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
CCustomShape* CCustomShape::CreateByType(oox::MSOSPT type)
|
||||
{
|
||||
CCustomShape* pShape = NULL;
|
||||
switch (type)
|
||||
CCustomShape::CCustomShape() : CBaseShape()
|
||||
{
|
||||
// msosptNotchedCircularArrow 0x00000064 A value that SHOULD NOT be used.
|
||||
// msosptHostControl 0x000000C9 A value that SHOULD NOT be used.
|
||||
m_eType = oox::msosptNotPrimitive;
|
||||
}
|
||||
CCustomShape::~CCustomShape()
|
||||
{
|
||||
}
|
||||
void CCustomShape::AddGuide(const std::wstring& strGuide)
|
||||
{
|
||||
m_oManager.AddFormula(strGuide);
|
||||
}
|
||||
bool CCustomShape::LoadAdjustHandlesList(const std::wstring& xml)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool CCustomShape::LoadConnectorsList(const std::wstring& xml)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool CCustomShape::LoadTextRect(const std::wstring& xml)
|
||||
{
|
||||
std::vector<std::wstring> oArray;
|
||||
NSStringUtils::ParseString(_T(";"), xml, oArray);
|
||||
|
||||
case sptNotchedCircularArrow:
|
||||
case sptHostControl:
|
||||
case 0: { pShape = new CRectangleType(); break; }
|
||||
//CREATE_BY_SPT(sptMin, CLineType)
|
||||
LONG lCount = (LONG)oArray.size();
|
||||
|
||||
CREATE_BY_SPT(sptAccentBorderCallout90, CAccentBorderCallout90Type)
|
||||
CREATE_BY_SPT(sptAccentBorderCallout1, CAccentBorderCallout1Type)
|
||||
CREATE_BY_SPT(sptAccentBorderCallout2, CAccentBorderCallout2Type)
|
||||
CREATE_BY_SPT(sptAccentBorderCallout3, CAccentBorderCallout3Type)
|
||||
if (lCount <= 0)
|
||||
return true;
|
||||
|
||||
CREATE_BY_SPT(sptAccentCallout90, CAccentCallout90Type)
|
||||
CREATE_BY_SPT(sptAccentCallout1, CAccentCallout1Type)
|
||||
CREATE_BY_SPT(sptAccentCallout2, CAccentCallout2Type)
|
||||
CREATE_BY_SPT(sptAccentCallout3, CAccentCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptBorderCallout90, CBorderCallout90Type)
|
||||
CREATE_BY_SPT(sptBorderCallout1, CBorderCallout1Type)
|
||||
CREATE_BY_SPT(sptBorderCallout2, CBorderCallout2Type)
|
||||
CREATE_BY_SPT(sptBorderCallout3, CBorderCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptCallout90, CCallout90Type)
|
||||
CREATE_BY_SPT(sptCallout1, CCallout1Type)
|
||||
CREATE_BY_SPT(sptCallout2, CCallout2Type)
|
||||
CREATE_BY_SPT(sptCallout3, CCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptActionButtonBlank, CActionButtonBlankType)
|
||||
CREATE_BY_SPT(sptActionButtonHome, CActionButtonHomeType)
|
||||
CREATE_BY_SPT(sptActionButtonHelp, CActionButtonHelpType)
|
||||
CREATE_BY_SPT(sptActionButtonInformation, CActionButtonInfoType)
|
||||
CREATE_BY_SPT(sptActionButtonBackPrevious, CActionButtonBackType)
|
||||
CREATE_BY_SPT(sptActionButtonForwardNext, CActionButtonNextType)
|
||||
CREATE_BY_SPT(sptActionButtonBeginning, CActionButtonBeginType)
|
||||
CREATE_BY_SPT(sptActionButtonEnd, CActionButtonEndType)
|
||||
CREATE_BY_SPT(sptActionButtonReturn, CActionButtonReturnType)
|
||||
CREATE_BY_SPT(sptActionButtonDocument, CActionButtonDocType)
|
||||
CREATE_BY_SPT(sptActionButtonSound, CActionButtonSoundType)
|
||||
CREATE_BY_SPT(sptActionButtonMovie, CActionButtonMovieType)
|
||||
|
||||
CREATE_BY_SPT(sptArc, CArcType)
|
||||
CREATE_BY_SPT(sptLine, CLineType)
|
||||
|
||||
CREATE_BY_SPT(sptBentArrow, CBentArrowType)
|
||||
CREATE_BY_SPT(sptBentUpArrow, CBentUpArrowType)
|
||||
CREATE_BY_SPT(sptBevel, CBevelType)
|
||||
CREATE_BY_SPT(sptBlockArc, CBlockArcType)
|
||||
CREATE_BY_SPT(sptBracePair, CBracePairType)
|
||||
CREATE_BY_SPT(sptBracketPair, CBracketPairType)
|
||||
|
||||
CREATE_BY_SPT(sptCan, CCanType)
|
||||
CREATE_BY_SPT(sptChevron, CChevronType)
|
||||
CREATE_BY_SPT(sptCircularArrow, CCircularArrowType)
|
||||
CREATE_BY_SPT(sptCloudCallout, CCloudCalloutType)
|
||||
CREATE_BY_SPT(sptCube, CCubeType)
|
||||
CREATE_BY_SPT(sptCurvedDownArrow, CCurvedDownArrowType)
|
||||
CREATE_BY_SPT(sptCurvedLeftArrow, CCurvedLeftArrowType)
|
||||
CREATE_BY_SPT(sptCurvedRightArrow, CCurvedRightArrowType)
|
||||
CREATE_BY_SPT(sptCurvedUpArrow, CCurvedUpArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptDiamond, CDiamondType)
|
||||
CREATE_BY_SPT(sptDonut, CDonutType)
|
||||
CREATE_BY_SPT(sptDownArrowCallout, CDownArrowCalloutType)
|
||||
CREATE_BY_SPT(sptDownArrow, CDownArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptEllipse, CEllipseType)
|
||||
CREATE_BY_SPT(sptEllipseRibbon, CEllipceRibbonType)
|
||||
CREATE_BY_SPT(sptEllipseRibbon2, CEllipceRibbon2Type)
|
||||
|
||||
CREATE_BY_SPT(sptFlowChartAlternateProcess, CFlowChartAlternateProcessType)
|
||||
CREATE_BY_SPT(sptFlowChartCollate, CFlowChartCollateType)
|
||||
CREATE_BY_SPT(sptFlowChartConnector, CFlowChartConnectorType)
|
||||
CREATE_BY_SPT(sptFlowChartDecision, CFlowChartDecisionType)
|
||||
CREATE_BY_SPT(sptFlowChartDisplay, CFlowChartDisplayType)
|
||||
CREATE_BY_SPT(sptFlowChartDelay, CFlowChartDelayType)
|
||||
CREATE_BY_SPT(sptFlowChartDocument, CFlowChartDocumentType)
|
||||
CREATE_BY_SPT(sptFlowChartExtract, CFlowChartExtractType)
|
||||
CREATE_BY_SPT(sptFlowChartInputOutput, CFlowChartInputOutputType)
|
||||
CREATE_BY_SPT(sptFlowChartInternalStorage, CFlowChartInternalStorageType)
|
||||
CREATE_BY_SPT(sptFlowChartMagneticDisk, CFlowChartMagneticDiskType)
|
||||
CREATE_BY_SPT(sptFlowChartMagneticDrum, CFlowChartMagneticDrumType)
|
||||
CREATE_BY_SPT(sptFlowChartMagneticTape, CFlowChartMagneticTapeType)
|
||||
CREATE_BY_SPT(sptFlowChartManualInput, CFlowChartManualInputType)
|
||||
CREATE_BY_SPT(sptFlowChartManualOperation, CFlowChartManualOperationType)
|
||||
CREATE_BY_SPT(sptFlowChartMerge, CFlowChartMergeType)
|
||||
CREATE_BY_SPT(sptFlowChartMultidocument, CFlowChartMultidocumentType)
|
||||
CREATE_BY_SPT(sptFlowChartOffpageConnector, CFlowChartOffpageConnectorType)
|
||||
CREATE_BY_SPT(sptFlowChartOnlineStorage, CFlowChartOnlineStorageType)
|
||||
CREATE_BY_SPT(sptFlowChartOr, CFlowChartOrType)
|
||||
CREATE_BY_SPT(sptFlowChartPredefinedProcess, CFlowChartPredefinedProcessType)
|
||||
CREATE_BY_SPT(sptFlowChartPreparation, CFlowChartPreparationType)
|
||||
CREATE_BY_SPT(sptFlowChartProcess, CFlowChartProcessType)
|
||||
CREATE_BY_SPT(sptFlowChartPunchedCard, CFlowChartPunchedCardType)
|
||||
CREATE_BY_SPT(sptFlowChartPunchedTape, CFlowChartPunchedTapeType)
|
||||
CREATE_BY_SPT(sptFlowChartSort, CFlowChartSortType)
|
||||
CREATE_BY_SPT(sptFlowChartSummingJunction, CFlowChartSummingJunctionType)
|
||||
CREATE_BY_SPT(sptFlowChartTerminator, CFlowChartTerminatorType)
|
||||
CREATE_BY_SPT(sptFoldedCorner, CFoldedCornerType)
|
||||
|
||||
CREATE_BY_SPT(sptHeart, CHeartType)
|
||||
CREATE_BY_SPT(sptHexagon, CHexagonType)
|
||||
CREATE_BY_SPT(sptHomePlate, CHomePlateType)
|
||||
|
||||
CREATE_BY_SPT(sptIrregularSeal1, CIrregularSealOneType)
|
||||
CREATE_BY_SPT(sptIrregularSeal2, CIrregularSealTwo)
|
||||
CREATE_BY_SPT(sptIsocelesTriangle, CIsoscelesTriangleType)
|
||||
|
||||
CREATE_BY_SPT(sptLeftArrowCallout, CLeftArrowCalloutType)
|
||||
CREATE_BY_SPT(sptLeftArrow, CLeftArrowType)
|
||||
CREATE_BY_SPT(sptLeftBrace, CLeftBraceType)
|
||||
CREATE_BY_SPT(sptLeftBracket, CLeftBracketType)
|
||||
CREATE_BY_SPT(sptLeftRightArrowCallout, CLeftRightArrowCalloutType)
|
||||
CREATE_BY_SPT(sptLeftRightArrow, CLeftRightArrowType)
|
||||
CREATE_BY_SPT(sptLeftRightUpArrow, CLeftRightUpArrow)
|
||||
CREATE_BY_SPT(sptLeftUpArrow, CLeftUpArrowType)
|
||||
CREATE_BY_SPT(sptLightningBolt, CLightningBoltType)
|
||||
|
||||
CREATE_BY_SPT(sptMoon, CMoonType)
|
||||
|
||||
CREATE_BY_SPT(sptNoSmoking, CNoSmokingType)
|
||||
CREATE_BY_SPT(sptNotchedRightArrow, CNotchedRightArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptOctagon, COctagonType)
|
||||
|
||||
CREATE_BY_SPT(sptParallelogram, CParallelogramType)
|
||||
CREATE_BY_SPT(sptPentagon, CPentagonType)
|
||||
CREATE_BY_SPT(sptPlaque, CPlaqueType)
|
||||
CREATE_BY_SPT(sptPlus, CPlusType)
|
||||
|
||||
CREATE_BY_SPT(sptQuadArrowCallout, CQuadArrowCalloutType)
|
||||
CREATE_BY_SPT(sptQuadArrow, CQuadArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptRectangle, CRectangleType)
|
||||
CREATE_BY_SPT(sptRibbon, CRibbonDownType)
|
||||
CREATE_BY_SPT(sptRibbon2, CRibbonUpType)
|
||||
CREATE_BY_SPT(sptRightArrowCallout, CRightArrowCalloutType)
|
||||
CREATE_BY_SPT(sptArrow, CRightArrowType)
|
||||
CREATE_BY_SPT(sptRightBrace, CRightBracetype)
|
||||
CREATE_BY_SPT(sptRightBracket, CRightBracketType)
|
||||
CREATE_BY_SPT(sptRightTriangle, CRightTriangleType)
|
||||
CREATE_BY_SPT(sptRoundRectangle, CRoundedRectangleType)
|
||||
|
||||
CREATE_BY_SPT(sptSeal16, CSeal16Type)
|
||||
CREATE_BY_SPT(sptSeal24, CSeal24Type)
|
||||
CREATE_BY_SPT(sptSeal32, CSeal32Type)
|
||||
CREATE_BY_SPT(sptSeal4, CSeal4Type)
|
||||
CREATE_BY_SPT(sptSeal8, CSeal8Type)
|
||||
CREATE_BY_SPT(sptSmileyFace, CSmileyFaceType)
|
||||
CREATE_BY_SPT(sptStar, CStarType)
|
||||
CREATE_BY_SPT(sptStraightConnector1, CStraightConnectorType)
|
||||
CREATE_BY_SPT(sptStripedRightArrow, CStripedRightArrowType)
|
||||
CREATE_BY_SPT(sptSun, CSunType)
|
||||
|
||||
CREATE_BY_SPT(sptTextBox, CTextboxType)
|
||||
CREATE_BY_SPT(sptTrapezoid, CTrapezoidType)
|
||||
|
||||
CREATE_BY_SPT(sptUpArrowCallout, CUpArrowCalloutType)
|
||||
CREATE_BY_SPT(sptUpArrow, CUpArrowType)
|
||||
CREATE_BY_SPT(sptUpDownArrowCallout, CUpDownArrowCalloutType)
|
||||
CREATE_BY_SPT(sptUpDownArrow, CUpDownArrowType)
|
||||
CREATE_BY_SPT(sptUturnArrow, CUturnArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptVerticalScroll, CVerticalScrollType)
|
||||
CREATE_BY_SPT(sptHorizontalScroll, CHorizontalScrollType)
|
||||
|
||||
CREATE_BY_SPT(sptWedgeEllipseCallout, CWedgeEllipseCalloutType)
|
||||
CREATE_BY_SPT(sptWedgeRectCallout, CWedgeRectCalloutType)
|
||||
CREATE_BY_SPT(sptWedgeRRectCallout, CWedgeRoundedRectCalloutType)
|
||||
|
||||
CREATE_BY_SPT(sptWave, CWaveType)
|
||||
CREATE_BY_SPT(sptDoubleWave, CWaveDoubleType)
|
||||
|
||||
case sptBentConnector2:
|
||||
case sptBentConnector3:
|
||||
case sptBentConnector4:
|
||||
case sptBentConnector5:
|
||||
{
|
||||
pShape = new CBentConnectorType();
|
||||
break;
|
||||
}
|
||||
case sptCurvedConnector2:
|
||||
case sptCurvedConnector3:
|
||||
case sptCurvedConnector4:
|
||||
case sptCurvedConnector5:
|
||||
{
|
||||
pShape = new CCurvedConnectorType();
|
||||
break;
|
||||
}
|
||||
|
||||
case sptTextPlainText:
|
||||
case sptTextStop:
|
||||
case sptTextTriangle:
|
||||
case sptTextTriangleInverted:
|
||||
case sptTextChevron:
|
||||
case sptTextChevronInverted:
|
||||
case sptTextRingInside:
|
||||
case sptTextRingOutside:
|
||||
case sptTextArchUpCurve:
|
||||
case sptTextArchDownCurve:
|
||||
case sptTextCircleCurve:
|
||||
case sptTextButtonCurve:
|
||||
case sptTextArchUpPour:
|
||||
case sptTextArchDownPour:
|
||||
case sptTextCirclePour:
|
||||
case sptTextButtonPour:
|
||||
case sptTextCurveUp:
|
||||
case sptTextCurveDown:
|
||||
case sptTextCascadeUp:
|
||||
case sptTextCascadeDown:
|
||||
case sptTextWave1:
|
||||
case sptTextWave2:
|
||||
case sptTextWave3:
|
||||
case sptTextWave4:
|
||||
case sptTextInflate:
|
||||
case sptTextDeflate:
|
||||
case sptTextInflateBottom:
|
||||
case sptTextDeflateBottom:
|
||||
case sptTextInflateTop:
|
||||
case sptTextDeflateTop:
|
||||
case sptTextDeflateInflate:
|
||||
case sptTextDeflateInflateDeflate:
|
||||
case sptTextFadeRight:
|
||||
case sptTextFadeLeft:
|
||||
case sptTextFadeUp:
|
||||
case sptTextFadeDown:
|
||||
case sptTextSlantUp:
|
||||
case sptTextSlantDown:
|
||||
case sptTextCanUp:
|
||||
case sptTextCanDown:
|
||||
m_arStringTextRects.clear();
|
||||
for (LONG i = 0; i < lCount; ++i)
|
||||
{
|
||||
pShape = new CTextboxType();
|
||||
m_arStringTextRects.push_back(oArray[i]);
|
||||
}
|
||||
|
||||
default: break;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
bool CCustomShape::LoadPathList(const std::wstring& xml)
|
||||
{
|
||||
m_strPath = xml;
|
||||
|
||||
if (NULL != pShape)
|
||||
pShape->m_eType = type;
|
||||
|
||||
return pShape;
|
||||
}
|
||||
m_oPath.FromXML(xml, m_oManager);
|
||||
return true;
|
||||
}
|
||||
bool CCustomShape::SetAdjustment(long index, long value)
|
||||
{
|
||||
if (index < (long)m_arAdjustments.size() && index >= 0)
|
||||
{
|
||||
m_arAdjustments[index] = value;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
void CCustomShape::ReCalculate()
|
||||
{
|
||||
m_oManager.Clear(&m_arAdjustments);
|
||||
|
||||
m_oManager.CalculateResults();
|
||||
|
||||
if (_T("") == m_strPath)
|
||||
return;
|
||||
|
||||
LoadPathList(m_strPath);
|
||||
}
|
||||
bool CCustomShape::SetProperties(CBaseShape* Shape)
|
||||
{
|
||||
if(Shape == NULL)
|
||||
return false;
|
||||
|
||||
m_oManager = ((CCustomShape*)Shape)->m_oManager;
|
||||
|
||||
//m_strPathLimoX = ((CCustomShape*)Shape)->m_strPathLimoX;
|
||||
//m_strPathLimoY = ((CCustomShape*)Shape)->m_strPathLimoY;
|
||||
|
||||
//m_arStringTextRects.clear();
|
||||
//m_arStringTextRects.insert(m_arStringTextRects.end(), ((CCustomShape*)Shape)->m_arStringTextRects.begin(), ((CCustomShape*)Shape)->m_arStringTextRects.end());
|
||||
|
||||
return CBaseShape::SetProperties(Shape);
|
||||
}
|
||||
bool CCustomShape::SetShapeType(oox::MSOSPT type)
|
||||
{
|
||||
CCustomShape* l_pShape = CreateByType(type);
|
||||
if(l_pShape != NULL)
|
||||
{
|
||||
m_eType = type;
|
||||
|
||||
SetProperties(l_pShape);
|
||||
delete l_pShape;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_eType = oox::msosptNotPrimitive;
|
||||
return false;
|
||||
}
|
||||
CCustomShape* CCustomShape::CreateByType(oox::MSOSPT type)
|
||||
{
|
||||
CCustomShape* pShape = NULL;
|
||||
switch (type)
|
||||
{
|
||||
// msosptNotchedCircularArrow 0x00000064 A value that SHOULD NOT be used.
|
||||
// msosptHostControl 0x000000C9 A value that SHOULD NOT be used.
|
||||
|
||||
case sptNotchedCircularArrow:
|
||||
case sptHostControl:
|
||||
case 0: { pShape = new CRectangleType(); break; }
|
||||
//CREATE_BY_SPT(sptMin, CLineType)
|
||||
|
||||
CREATE_BY_SPT(sptAccentBorderCallout90, CAccentBorderCallout90Type)
|
||||
CREATE_BY_SPT(sptAccentBorderCallout1, CAccentBorderCallout1Type)
|
||||
CREATE_BY_SPT(sptAccentBorderCallout2, CAccentBorderCallout2Type)
|
||||
CREATE_BY_SPT(sptAccentBorderCallout3, CAccentBorderCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptAccentCallout90, CAccentCallout90Type)
|
||||
CREATE_BY_SPT(sptAccentCallout1, CAccentCallout1Type)
|
||||
CREATE_BY_SPT(sptAccentCallout2, CAccentCallout2Type)
|
||||
CREATE_BY_SPT(sptAccentCallout3, CAccentCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptBorderCallout90, CBorderCallout90Type)
|
||||
CREATE_BY_SPT(sptBorderCallout1, CBorderCallout1Type)
|
||||
CREATE_BY_SPT(sptBorderCallout2, CBorderCallout2Type)
|
||||
CREATE_BY_SPT(sptBorderCallout3, CBorderCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptCallout90, CCallout90Type)
|
||||
CREATE_BY_SPT(sptCallout1, CCallout1Type)
|
||||
CREATE_BY_SPT(sptCallout2, CCallout2Type)
|
||||
CREATE_BY_SPT(sptCallout3, CCallout3Type)
|
||||
|
||||
CREATE_BY_SPT(sptActionButtonBlank, CActionButtonBlankType)
|
||||
CREATE_BY_SPT(sptActionButtonHome, CActionButtonHomeType)
|
||||
CREATE_BY_SPT(sptActionButtonHelp, CActionButtonHelpType)
|
||||
CREATE_BY_SPT(sptActionButtonInformation, CActionButtonInfoType)
|
||||
CREATE_BY_SPT(sptActionButtonBackPrevious, CActionButtonBackType)
|
||||
CREATE_BY_SPT(sptActionButtonForwardNext, CActionButtonNextType)
|
||||
CREATE_BY_SPT(sptActionButtonBeginning, CActionButtonBeginType)
|
||||
CREATE_BY_SPT(sptActionButtonEnd, CActionButtonEndType)
|
||||
CREATE_BY_SPT(sptActionButtonReturn, CActionButtonReturnType)
|
||||
CREATE_BY_SPT(sptActionButtonDocument, CActionButtonDocType)
|
||||
CREATE_BY_SPT(sptActionButtonSound, CActionButtonSoundType)
|
||||
CREATE_BY_SPT(sptActionButtonMovie, CActionButtonMovieType)
|
||||
|
||||
CREATE_BY_SPT(sptArc, CArcType)
|
||||
CREATE_BY_SPT(sptLine, CLineType)
|
||||
|
||||
CREATE_BY_SPT(sptBentArrow, CBentArrowType)
|
||||
CREATE_BY_SPT(sptBentUpArrow, CBentUpArrowType)
|
||||
CREATE_BY_SPT(sptBevel, CBevelType)
|
||||
CREATE_BY_SPT(sptBlockArc, CBlockArcType)
|
||||
CREATE_BY_SPT(sptBracePair, CBracePairType)
|
||||
CREATE_BY_SPT(sptBracketPair, CBracketPairType)
|
||||
|
||||
CREATE_BY_SPT(sptCan, CCanType)
|
||||
CREATE_BY_SPT(sptChevron, CChevronType)
|
||||
CREATE_BY_SPT(sptCircularArrow, CCircularArrowType)
|
||||
CREATE_BY_SPT(sptCloudCallout, CCloudCalloutType)
|
||||
CREATE_BY_SPT(sptCube, CCubeType)
|
||||
CREATE_BY_SPT(sptCurvedDownArrow, CCurvedDownArrowType)
|
||||
CREATE_BY_SPT(sptCurvedLeftArrow, CCurvedLeftArrowType)
|
||||
CREATE_BY_SPT(sptCurvedRightArrow, CCurvedRightArrowType)
|
||||
CREATE_BY_SPT(sptCurvedUpArrow, CCurvedUpArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptDiamond, CDiamondType)
|
||||
CREATE_BY_SPT(sptDonut, CDonutType)
|
||||
CREATE_BY_SPT(sptDownArrowCallout, CDownArrowCalloutType)
|
||||
CREATE_BY_SPT(sptDownArrow, CDownArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptEllipse, CEllipseType)
|
||||
CREATE_BY_SPT(sptEllipseRibbon, CEllipceRibbonType)
|
||||
CREATE_BY_SPT(sptEllipseRibbon2, CEllipceRibbon2Type)
|
||||
|
||||
CREATE_BY_SPT(sptFlowChartAlternateProcess, CFlowChartAlternateProcessType)
|
||||
CREATE_BY_SPT(sptFlowChartCollate, CFlowChartCollateType)
|
||||
CREATE_BY_SPT(sptFlowChartConnector, CFlowChartConnectorType)
|
||||
CREATE_BY_SPT(sptFlowChartDecision, CFlowChartDecisionType)
|
||||
CREATE_BY_SPT(sptFlowChartDisplay, CFlowChartDisplayType)
|
||||
CREATE_BY_SPT(sptFlowChartDelay, CFlowChartDelayType)
|
||||
CREATE_BY_SPT(sptFlowChartDocument, CFlowChartDocumentType)
|
||||
CREATE_BY_SPT(sptFlowChartExtract, CFlowChartExtractType)
|
||||
CREATE_BY_SPT(sptFlowChartInputOutput, CFlowChartInputOutputType)
|
||||
CREATE_BY_SPT(sptFlowChartInternalStorage, CFlowChartInternalStorageType)
|
||||
CREATE_BY_SPT(sptFlowChartMagneticDisk, CFlowChartMagneticDiskType)
|
||||
CREATE_BY_SPT(sptFlowChartMagneticDrum, CFlowChartMagneticDrumType)
|
||||
CREATE_BY_SPT(sptFlowChartMagneticTape, CFlowChartMagneticTapeType)
|
||||
CREATE_BY_SPT(sptFlowChartManualInput, CFlowChartManualInputType)
|
||||
CREATE_BY_SPT(sptFlowChartManualOperation, CFlowChartManualOperationType)
|
||||
CREATE_BY_SPT(sptFlowChartMerge, CFlowChartMergeType)
|
||||
CREATE_BY_SPT(sptFlowChartMultidocument, CFlowChartMultidocumentType)
|
||||
CREATE_BY_SPT(sptFlowChartOffpageConnector, CFlowChartOffpageConnectorType)
|
||||
CREATE_BY_SPT(sptFlowChartOnlineStorage, CFlowChartOnlineStorageType)
|
||||
CREATE_BY_SPT(sptFlowChartOr, CFlowChartOrType)
|
||||
CREATE_BY_SPT(sptFlowChartPredefinedProcess, CFlowChartPredefinedProcessType)
|
||||
CREATE_BY_SPT(sptFlowChartPreparation, CFlowChartPreparationType)
|
||||
CREATE_BY_SPT(sptFlowChartProcess, CFlowChartProcessType)
|
||||
CREATE_BY_SPT(sptFlowChartPunchedCard, CFlowChartPunchedCardType)
|
||||
CREATE_BY_SPT(sptFlowChartPunchedTape, CFlowChartPunchedTapeType)
|
||||
CREATE_BY_SPT(sptFlowChartSort, CFlowChartSortType)
|
||||
CREATE_BY_SPT(sptFlowChartSummingJunction, CFlowChartSummingJunctionType)
|
||||
CREATE_BY_SPT(sptFlowChartTerminator, CFlowChartTerminatorType)
|
||||
CREATE_BY_SPT(sptFoldedCorner, CFoldedCornerType)
|
||||
|
||||
CREATE_BY_SPT(sptHeart, CHeartType)
|
||||
CREATE_BY_SPT(sptHexagon, CHexagonType)
|
||||
CREATE_BY_SPT(sptHomePlate, CHomePlateType)
|
||||
|
||||
CREATE_BY_SPT(sptIrregularSeal1, CIrregularSealOneType)
|
||||
CREATE_BY_SPT(sptIrregularSeal2, CIrregularSealTwo)
|
||||
CREATE_BY_SPT(sptIsocelesTriangle, CIsoscelesTriangleType)
|
||||
|
||||
CREATE_BY_SPT(sptLeftArrowCallout, CLeftArrowCalloutType)
|
||||
CREATE_BY_SPT(sptLeftArrow, CLeftArrowType)
|
||||
CREATE_BY_SPT(sptLeftBrace, CLeftBraceType)
|
||||
CREATE_BY_SPT(sptLeftBracket, CLeftBracketType)
|
||||
CREATE_BY_SPT(sptLeftRightArrowCallout, CLeftRightArrowCalloutType)
|
||||
CREATE_BY_SPT(sptLeftRightArrow, CLeftRightArrowType)
|
||||
CREATE_BY_SPT(sptLeftRightUpArrow, CLeftRightUpArrow)
|
||||
CREATE_BY_SPT(sptLeftUpArrow, CLeftUpArrowType)
|
||||
CREATE_BY_SPT(sptLightningBolt, CLightningBoltType)
|
||||
|
||||
CREATE_BY_SPT(sptMoon, CMoonType)
|
||||
|
||||
CREATE_BY_SPT(sptNoSmoking, CNoSmokingType)
|
||||
CREATE_BY_SPT(sptNotchedRightArrow, CNotchedRightArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptOctagon, COctagonType)
|
||||
|
||||
CREATE_BY_SPT(sptParallelogram, CParallelogramType)
|
||||
CREATE_BY_SPT(sptPentagon, CPentagonType)
|
||||
CREATE_BY_SPT(sptPlaque, CPlaqueType)
|
||||
CREATE_BY_SPT(sptPlus, CPlusType)
|
||||
|
||||
CREATE_BY_SPT(sptQuadArrowCallout, CQuadArrowCalloutType)
|
||||
CREATE_BY_SPT(sptQuadArrow, CQuadArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptRectangle, CRectangleType)
|
||||
CREATE_BY_SPT(sptRibbon, CRibbonDownType)
|
||||
CREATE_BY_SPT(sptRibbon2, CRibbonUpType)
|
||||
CREATE_BY_SPT(sptRightArrowCallout, CRightArrowCalloutType)
|
||||
CREATE_BY_SPT(sptArrow, CRightArrowType)
|
||||
CREATE_BY_SPT(sptRightBrace, CRightBracetype)
|
||||
CREATE_BY_SPT(sptRightBracket, CRightBracketType)
|
||||
CREATE_BY_SPT(sptRightTriangle, CRightTriangleType)
|
||||
CREATE_BY_SPT(sptRoundRectangle, CRoundedRectangleType)
|
||||
|
||||
CREATE_BY_SPT(sptSeal16, CSeal16Type)
|
||||
CREATE_BY_SPT(sptSeal24, CSeal24Type)
|
||||
CREATE_BY_SPT(sptSeal32, CSeal32Type)
|
||||
CREATE_BY_SPT(sptSeal4, CSeal4Type)
|
||||
CREATE_BY_SPT(sptSeal8, CSeal8Type)
|
||||
CREATE_BY_SPT(sptSmileyFace, CSmileyFaceType)
|
||||
CREATE_BY_SPT(sptStar, CStarType)
|
||||
CREATE_BY_SPT(sptStraightConnector1, CStraightConnectorType)
|
||||
CREATE_BY_SPT(sptStripedRightArrow, CStripedRightArrowType)
|
||||
CREATE_BY_SPT(sptSun, CSunType)
|
||||
|
||||
CREATE_BY_SPT(sptTextBox, CTextboxType)
|
||||
CREATE_BY_SPT(sptTrapezoid, CTrapezoidType)
|
||||
|
||||
CREATE_BY_SPT(sptUpArrowCallout, CUpArrowCalloutType)
|
||||
CREATE_BY_SPT(sptUpArrow, CUpArrowType)
|
||||
CREATE_BY_SPT(sptUpDownArrowCallout, CUpDownArrowCalloutType)
|
||||
CREATE_BY_SPT(sptUpDownArrow, CUpDownArrowType)
|
||||
CREATE_BY_SPT(sptUturnArrow, CUturnArrowType)
|
||||
|
||||
CREATE_BY_SPT(sptVerticalScroll, CVerticalScrollType)
|
||||
CREATE_BY_SPT(sptHorizontalScroll, CHorizontalScrollType)
|
||||
|
||||
CREATE_BY_SPT(sptWedgeEllipseCallout, CWedgeEllipseCalloutType)
|
||||
CREATE_BY_SPT(sptWedgeRectCallout, CWedgeRectCalloutType)
|
||||
CREATE_BY_SPT(sptWedgeRRectCallout, CWedgeRoundedRectCalloutType)
|
||||
|
||||
CREATE_BY_SPT(sptWave, CWaveType)
|
||||
CREATE_BY_SPT(sptDoubleWave, CWaveDoubleType)
|
||||
|
||||
case sptBentConnector2:
|
||||
case sptBentConnector3:
|
||||
case sptBentConnector4:
|
||||
case sptBentConnector5:
|
||||
{
|
||||
pShape = new CBentConnectorType();
|
||||
break;
|
||||
}
|
||||
case sptCurvedConnector2:
|
||||
case sptCurvedConnector3:
|
||||
case sptCurvedConnector4:
|
||||
case sptCurvedConnector5:
|
||||
{
|
||||
pShape = new CCurvedConnectorType();
|
||||
break;
|
||||
}
|
||||
|
||||
case sptTextPlainText:
|
||||
case sptTextStop:
|
||||
case sptTextTriangle:
|
||||
case sptTextTriangleInverted:
|
||||
case sptTextChevron:
|
||||
case sptTextChevronInverted:
|
||||
case sptTextRingInside:
|
||||
case sptTextRingOutside:
|
||||
case sptTextArchUpCurve:
|
||||
case sptTextArchDownCurve:
|
||||
case sptTextCircleCurve:
|
||||
case sptTextButtonCurve:
|
||||
case sptTextArchUpPour:
|
||||
case sptTextArchDownPour:
|
||||
case sptTextCirclePour:
|
||||
case sptTextButtonPour:
|
||||
case sptTextCurveUp:
|
||||
case sptTextCurveDown:
|
||||
case sptTextCascadeUp:
|
||||
case sptTextCascadeDown:
|
||||
case sptTextWave1:
|
||||
case sptTextWave2:
|
||||
case sptTextWave3:
|
||||
case sptTextWave4:
|
||||
case sptTextInflate:
|
||||
case sptTextDeflate:
|
||||
case sptTextInflateBottom:
|
||||
case sptTextDeflateBottom:
|
||||
case sptTextInflateTop:
|
||||
case sptTextDeflateTop:
|
||||
case sptTextDeflateInflate:
|
||||
case sptTextDeflateInflateDeflate:
|
||||
case sptTextFadeRight:
|
||||
case sptTextFadeLeft:
|
||||
case sptTextFadeUp:
|
||||
case sptTextFadeDown:
|
||||
case sptTextSlantUp:
|
||||
case sptTextSlantDown:
|
||||
case sptTextCanUp:
|
||||
case sptTextCanDown:
|
||||
{
|
||||
pShape = new CTextboxType();
|
||||
}
|
||||
|
||||
default: break;
|
||||
};
|
||||
|
||||
if (NULL != pShape)
|
||||
pShape->m_eType = type;
|
||||
|
||||
return pShape;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,111 +52,22 @@ public:
|
||||
|
||||
std::vector<std::wstring> m_arStringTextRects;
|
||||
|
||||
CCustomShape() : CBaseShape()
|
||||
{
|
||||
m_eType = oox::msosptNotPrimitive;
|
||||
}
|
||||
CCustomShape();
|
||||
~CCustomShape();
|
||||
|
||||
~CCustomShape()
|
||||
{
|
||||
}
|
||||
virtual void AddGuide(const std::wstring& strGuide);
|
||||
|
||||
virtual void AddGuide(const std::wstring& strGuide)
|
||||
{
|
||||
m_oManager.AddFormula(strGuide);
|
||||
}
|
||||
virtual bool LoadAdjustHandlesList(const std::wstring& xml);
|
||||
virtual bool LoadConnectorsList(const std::wstring& xml);
|
||||
virtual bool LoadTextRect(const std::wstring& xml);
|
||||
virtual bool LoadPathList(const std::wstring& xml);
|
||||
|
||||
virtual bool LoadAdjustHandlesList(const std::wstring& xml)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool LoadConnectorsList(const std::wstring& xml)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool LoadTextRect(const std::wstring& xml)
|
||||
{
|
||||
std::vector<std::wstring> oArray;
|
||||
NSStringUtils::ParseString(_T(";"), xml, oArray);
|
||||
|
||||
LONG lCount = (LONG)oArray.size();
|
||||
|
||||
if (lCount <= 0)
|
||||
return true;
|
||||
|
||||
m_arStringTextRects.clear();
|
||||
for (LONG i = 0; i < lCount; ++i)
|
||||
{
|
||||
m_arStringTextRects.push_back(oArray[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool LoadPathList(const std::wstring& xml)
|
||||
{
|
||||
m_strPath = xml;
|
||||
|
||||
m_oPath.FromXML(xml, m_oManager);
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool SetAdjustment(long index, long value)
|
||||
{
|
||||
if (index < (long)m_arAdjustments.size() && index >= 0)
|
||||
{
|
||||
m_arAdjustments[index] = value;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
virtual void ReCalculate()
|
||||
{
|
||||
m_oManager.Clear(&m_arAdjustments);
|
||||
|
||||
m_oManager.CalculateResults();
|
||||
|
||||
if (_T("") == m_strPath)
|
||||
return;
|
||||
|
||||
LoadPathList(m_strPath);
|
||||
}
|
||||
virtual bool SetAdjustment(long index, long value);
|
||||
virtual void ReCalculate();
|
||||
|
||||
static CCustomShape* CreateByType(oox::MSOSPT type);
|
||||
|
||||
virtual bool SetProperties(CBaseShape* Shape)
|
||||
{
|
||||
if(Shape == NULL)
|
||||
return false;
|
||||
|
||||
m_oManager = ((CCustomShape*)Shape)->m_oManager;
|
||||
|
||||
//m_strPathLimoX = ((CCustomShape*)Shape)->m_strPathLimoX;
|
||||
//m_strPathLimoY = ((CCustomShape*)Shape)->m_strPathLimoY;
|
||||
|
||||
//m_arStringTextRects.clear();
|
||||
//m_arStringTextRects.insert(m_arStringTextRects.end(), ((CCustomShape*)Shape)->m_arStringTextRects.begin(), ((CCustomShape*)Shape)->m_arStringTextRects.end());
|
||||
|
||||
return CBaseShape::SetProperties(Shape);
|
||||
}
|
||||
|
||||
bool SetShapeType(oox::MSOSPT type)
|
||||
{
|
||||
CCustomShape* l_pShape = CreateByType(type);
|
||||
if(l_pShape != NULL)
|
||||
{
|
||||
m_eType = type;
|
||||
|
||||
SetProperties(l_pShape);
|
||||
delete l_pShape;
|
||||
return true;
|
||||
}
|
||||
|
||||
m_eType = oox::msosptNotPrimitive;
|
||||
return false;
|
||||
}
|
||||
virtual bool SetProperties(CBaseShape* Shape);
|
||||
bool SetShapeType(oox::MSOSPT type);
|
||||
};
|
||||
}
|
||||
|
||||
1955
MsBinaryFile/Common/ODraw/CustomShapeConvert.cpp
Normal file
1955
MsBinaryFile/Common/ODraw/CustomShapeConvert.cpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -33,134 +33,267 @@
|
||||
|
||||
#include "FormulaShape.h"
|
||||
|
||||
LONG NSCustomShapesConvert::CFormula::CalculateFormula(NSCustomShapesConvert::CFormulasManager* pManager)
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
if ((0 > m_lIndex) || (m_lIndex >= pManager->m_arResults.size()))
|
||||
return 0;
|
||||
if (0xFFFFFFFF != pManager->m_arResults[m_lIndex])
|
||||
CFormula::CFormula()
|
||||
{
|
||||
return pManager->m_arResults[m_lIndex];
|
||||
}
|
||||
|
||||
LONG lResult = 0;
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = 0;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
|
||||
LONG lGuidesCount = pManager->m_arFormulas.size();
|
||||
LONG lAdjCount = pManager->m_pAdjustments->size();
|
||||
|
||||
LONG a1 = m_lParam1;
|
||||
if (ptFormula == m_eType1)
|
||||
{
|
||||
a1 = (m_lParam1 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam1].CalculateFormula(pManager);
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
else if (ptAdjust == m_eType1)
|
||||
CFormula::CFormula(int nIndex)
|
||||
{
|
||||
a1 = (m_lParam1 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam1];
|
||||
}
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = nIndex;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
|
||||
LONG b1 = m_lParam2;
|
||||
if (ptFormula == m_eType2)
|
||||
{
|
||||
b1 = (m_lParam2 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam2].CalculateFormula(pManager);
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
else if (ptAdjust == m_eType2)
|
||||
CFormula& CFormula::operator =(const CFormula& oSrc)
|
||||
{
|
||||
b1 = (m_lParam2 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam2];
|
||||
m_eFormulaType = oSrc.m_eFormulaType;
|
||||
m_lIndex = oSrc.m_lIndex;
|
||||
|
||||
m_lParam1 = oSrc.m_lParam1;
|
||||
m_eType1 = oSrc.m_eType1;
|
||||
|
||||
m_lParam2 = oSrc.m_lParam2;
|
||||
m_eType2 = oSrc.m_eType2;
|
||||
|
||||
m_lParam3 = oSrc.m_lParam3;
|
||||
m_eType3 = oSrc.m_eType3;
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
LONG c1 = m_lParam3;
|
||||
if (ptFormula == m_eType3)
|
||||
void CFormula::FromString(std::wstring strFormula, long lShapeWidth, long lShapeHeight)
|
||||
{
|
||||
c1 = (m_lParam3 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam3].CalculateFormula(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType3)
|
||||
{
|
||||
c1 = (m_lParam3 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam3];
|
||||
}
|
||||
std::vector<std::wstring> oArrayParams;
|
||||
NSStringUtils::ParseString(_T(" "), strFormula, oArrayParams);
|
||||
size_t nCount = oArrayParams.size();
|
||||
if (nCount == 0)
|
||||
return;
|
||||
|
||||
double a = (double)a1;
|
||||
double b = (double)b1;
|
||||
double c = (double)c1;
|
||||
bool bRes = true;
|
||||
m_eFormulaType = GetFormula(oArrayParams[0], bRes);
|
||||
|
||||
double dRes = 0.0;
|
||||
|
||||
try
|
||||
{
|
||||
// теперь нужно просто посчитать
|
||||
switch (m_eFormulaType)
|
||||
ParamType ptType = ptValue;
|
||||
if (1 < nCount)
|
||||
{
|
||||
case ftSum: { dRes = a + b - c; break; }
|
||||
case ftProduct: {
|
||||
if (0 == c)
|
||||
c = 1;
|
||||
|
||||
dRes = a * b / c;
|
||||
break;
|
||||
}
|
||||
case ftMid: { dRes = (a + b) / 2.0; break; }
|
||||
case ftAbsolute: { dRes = abs(a); break; }
|
||||
|
||||
case ftMin: { dRes = (std::min)(a, b); break; }
|
||||
case ftMax: { dRes = (std::max)(a, b); break; }
|
||||
case ftIf: { dRes = (a > 0) ? b : c; break; }
|
||||
case ftSqrt: { dRes = sqrt(a); break; }
|
||||
case ftMod: { dRes = sqrt(a*a + b*b + c*c); break; }
|
||||
|
||||
case ftSin: {
|
||||
//dRes = a * sin(b);
|
||||
//dRes = a * sin(b / pow2_16);
|
||||
dRes = a * sin(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftCos: {
|
||||
//dRes = a * cos(b);
|
||||
//dRes = a * cos(b / pow2_16);
|
||||
dRes = a * cos(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftTan: {
|
||||
//dRes = a * tan(b);
|
||||
dRes = a * tan(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftAtan2: {
|
||||
dRes = 180 * pow2_16 * atan2(b,a) / M_PI;
|
||||
break;
|
||||
}
|
||||
|
||||
case ftSinatan2: { dRes = a * sin(atan2(c,b)); break; }
|
||||
case ftCosatan2: { dRes = a * cos(atan2(c,b)); break; }
|
||||
|
||||
case ftSumangle: {
|
||||
//dRes = a + b - c;
|
||||
dRes = a + b * pow2_16 - c * pow2_16;
|
||||
|
||||
/*while (23592960 < dRes)
|
||||
{
|
||||
dRes -= 23592960;
|
||||
}
|
||||
while (-23592960 > dRes)
|
||||
{
|
||||
dRes += 23592960;
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
case ftEllipse: {
|
||||
if (0 == b)
|
||||
b = 1;
|
||||
dRes = c * sqrt(1-(a*a/(b*b)));
|
||||
break;
|
||||
}
|
||||
case ftVal: { dRes = a; break; }
|
||||
default: break;
|
||||
};
|
||||
m_lParam1 = GetValue(oArrayParams[1], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType1 = ptType;
|
||||
}
|
||||
if (2 < nCount)
|
||||
{
|
||||
m_lParam2 = GetValue(oArrayParams[2], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType2 = ptType;
|
||||
}
|
||||
if (3 < nCount)
|
||||
{
|
||||
m_lParam3 = GetValue(oArrayParams[3], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType3 = ptType;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
LONG CFormula::CalculateFormula(NSCustomShapesConvert::CFormulasManager* pManager)
|
||||
{
|
||||
dRes = 0;
|
||||
if ((0 > m_lIndex) || (m_lIndex >= pManager->m_arResults.size()))
|
||||
return 0;
|
||||
if (0xFFFFFFFF != pManager->m_arResults[m_lIndex])
|
||||
{
|
||||
return pManager->m_arResults[m_lIndex];
|
||||
}
|
||||
|
||||
LONG lResult = 0;
|
||||
|
||||
LONG lGuidesCount = pManager->m_arFormulas.size();
|
||||
LONG lAdjCount = pManager->m_pAdjustments->size();
|
||||
|
||||
LONG a1 = m_lParam1;
|
||||
if (ptFormula == m_eType1)
|
||||
{
|
||||
a1 = (m_lParam1 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam1].CalculateFormula(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType1)
|
||||
{
|
||||
a1 = (m_lParam1 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam1];
|
||||
}
|
||||
|
||||
LONG b1 = m_lParam2;
|
||||
if (ptFormula == m_eType2)
|
||||
{
|
||||
b1 = (m_lParam2 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam2].CalculateFormula(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType2)
|
||||
{
|
||||
b1 = (m_lParam2 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam2];
|
||||
}
|
||||
|
||||
LONG c1 = m_lParam3;
|
||||
if (ptFormula == m_eType3)
|
||||
{
|
||||
c1 = (m_lParam3 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam3].CalculateFormula(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType3)
|
||||
{
|
||||
c1 = (m_lParam3 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam3];
|
||||
}
|
||||
|
||||
double a = (double)a1;
|
||||
double b = (double)b1;
|
||||
double c = (double)c1;
|
||||
|
||||
double dRes = 0.0;
|
||||
|
||||
try
|
||||
{
|
||||
// теперь нужно просто посчитать
|
||||
switch (m_eFormulaType)
|
||||
{
|
||||
case ftSum: { dRes = a + b - c; break; }
|
||||
case ftProduct: {
|
||||
if (0 == c)
|
||||
c = 1;
|
||||
|
||||
dRes = a * b / c;
|
||||
break;
|
||||
}
|
||||
case ftMid: { dRes = (a + b) / 2.0; break; }
|
||||
case ftAbsolute: { dRes = abs(a); break; }
|
||||
|
||||
case ftMin: { dRes = (std::min)(a, b); break; }
|
||||
case ftMax: { dRes = (std::max)(a, b); break; }
|
||||
case ftIf: { dRes = (a > 0) ? b : c; break; }
|
||||
case ftSqrt: { dRes = sqrt(a); break; }
|
||||
case ftMod: { dRes = sqrt(a*a + b*b + c*c); break; }
|
||||
|
||||
case ftSin: {
|
||||
//dRes = a * sin(b);
|
||||
//dRes = a * sin(b / pow2_16);
|
||||
dRes = a * sin(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftCos: {
|
||||
//dRes = a * cos(b);
|
||||
//dRes = a * cos(b / pow2_16);
|
||||
dRes = a * cos(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftTan: {
|
||||
//dRes = a * tan(b);
|
||||
dRes = a * tan(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftAtan2: {
|
||||
dRes = 180 * pow2_16 * atan2(b,a) / M_PI;
|
||||
break;
|
||||
}
|
||||
|
||||
case ftSinatan2: { dRes = a * sin(atan2(c,b)); break; }
|
||||
case ftCosatan2: { dRes = a * cos(atan2(c,b)); break; }
|
||||
|
||||
case ftSumangle: {
|
||||
//dRes = a + b - c;
|
||||
dRes = a + b * pow2_16 - c * pow2_16;
|
||||
|
||||
/*while (23592960 < dRes)
|
||||
{
|
||||
dRes -= 23592960;
|
||||
}
|
||||
while (-23592960 > dRes)
|
||||
{
|
||||
dRes += 23592960;
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
case ftEllipse: {
|
||||
if (0 == b)
|
||||
b = 1;
|
||||
dRes = c * sqrt(1-(a*a/(b*b)));
|
||||
break;
|
||||
}
|
||||
case ftVal: { dRes = a; break; }
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
dRes = 0;
|
||||
}
|
||||
|
||||
lResult = (LONG)dRes;
|
||||
pManager->m_arResults[m_lIndex] = lResult;
|
||||
return lResult;
|
||||
}
|
||||
|
||||
lResult = (LONG)dRes;
|
||||
pManager->m_arResults[m_lIndex] = lResult;
|
||||
return lResult;
|
||||
CFormulasManager::CFormulasManager() : m_arFormulas(), m_arResults()
|
||||
{
|
||||
m_pAdjustments = NULL;
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
}
|
||||
CFormulasManager& CFormulasManager::operator =(const CFormulasManager& oSrc)
|
||||
{
|
||||
m_pAdjustments = oSrc.m_pAdjustments;
|
||||
m_lShapeWidth = oSrc.m_lShapeWidth;
|
||||
m_lShapeHeight = oSrc.m_lShapeHeight;
|
||||
|
||||
m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults.push_back(oSrc.m_arResults[nIndex]);
|
||||
}
|
||||
m_arFormulas.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arFormulas.size(); ++nIndex)
|
||||
{
|
||||
m_arFormulas.push_back(oSrc.m_arFormulas[nIndex]);
|
||||
}
|
||||
|
||||
return (*this);
|
||||
}
|
||||
void CFormulasManager::Clear()
|
||||
{
|
||||
m_pAdjustments = NULL;
|
||||
|
||||
|
||||
m_arFormulas.clear();
|
||||
m_arResults.clear();
|
||||
}
|
||||
void CFormulasManager::Clear(std::vector<LONG>* pAdjusts)
|
||||
{
|
||||
m_pAdjustments = pAdjusts;
|
||||
|
||||
//m_arFormulas.clear();
|
||||
//m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults[nIndex] = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
void CFormulasManager::AddFormula(std::wstring strFormula)
|
||||
{
|
||||
CFormula oFormula((int)m_arFormulas.size());
|
||||
oFormula.FromString(strFormula, m_lShapeWidth, m_lShapeHeight);
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void CFormulasManager::AddFormula(CFormula oFormula)
|
||||
{
|
||||
oFormula.m_lIndex = (int)m_arFormulas.size();
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void CFormulasManager::CalculateResults()
|
||||
{
|
||||
for (size_t index = 0; index < m_arFormulas.size(); ++index)
|
||||
{
|
||||
LONG lResult = m_arFormulas[index].CalculateFormula(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,27 +214,26 @@ namespace NSCustomShapesConvert
|
||||
|
||||
struct SHandle
|
||||
{
|
||||
Aggplus::POINT gdRef;
|
||||
SPointType gdRefType;
|
||||
SPointExist bRefExist;
|
||||
SPointExist bRefPolarExist;
|
||||
Aggplus::POINT gdRef;
|
||||
SPointType gdRefType;
|
||||
SPointExist bRefExist;
|
||||
SPointExist bRefPolarExist;
|
||||
|
||||
Aggplus::POINT Max;
|
||||
SPointType MaxType;
|
||||
SPointExist bMaxExist;
|
||||
SPointExist bMaxPolarExist;
|
||||
Aggplus::POINT Max;
|
||||
SPointType MaxType;
|
||||
SPointExist bMaxExist;
|
||||
SPointExist bMaxPolarExist;
|
||||
|
||||
Aggplus::POINT Min;
|
||||
SPointType MinType;
|
||||
SPointExist bMinExist;
|
||||
SPointExist bMinPolarExist;
|
||||
Aggplus::POINT Min;
|
||||
SPointType MinType;
|
||||
SPointExist bMinExist;
|
||||
SPointExist bMinPolarExist;
|
||||
|
||||
Aggplus::POINT Pos;
|
||||
SPointType PosType;
|
||||
|
||||
Aggplus::POINT PolarCentre;
|
||||
SPointType PolarCentreType;
|
||||
Aggplus::POINT Pos;
|
||||
SPointType PosType;
|
||||
|
||||
Aggplus::POINT PolarCentre;
|
||||
SPointType PolarCentreType;
|
||||
};
|
||||
class CFormulasManager;
|
||||
class CFormula
|
||||
@ -256,74 +255,12 @@ private:
|
||||
long m_lCountRecurs;
|
||||
|
||||
public:
|
||||
CFormula()
|
||||
{
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = 0;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
CFormula();
|
||||
CFormula(int nIndex);
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
CFormula& operator =(const CFormula& oSrc);
|
||||
|
||||
CFormula(int nIndex)
|
||||
{
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = nIndex;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
|
||||
CFormula& operator =(const CFormula& oSrc)
|
||||
{
|
||||
m_eFormulaType = oSrc.m_eFormulaType;
|
||||
m_lIndex = oSrc.m_lIndex;
|
||||
|
||||
m_lParam1 = oSrc.m_lParam1;
|
||||
m_eType1 = oSrc.m_eType1;
|
||||
|
||||
m_lParam2 = oSrc.m_lParam2;
|
||||
m_eType2 = oSrc.m_eType2;
|
||||
|
||||
m_lParam3 = oSrc.m_lParam3;
|
||||
m_eType3 = oSrc.m_eType3;
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void FromString(std::wstring strFormula, long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML)
|
||||
{
|
||||
std::vector<std::wstring> oArrayParams;
|
||||
NSStringUtils::ParseString(_T(" "), strFormula, oArrayParams);
|
||||
size_t nCount = oArrayParams.size();
|
||||
if (nCount == 0)
|
||||
return;
|
||||
|
||||
bool bRes = true;
|
||||
m_eFormulaType = GetFormula(oArrayParams[0], bRes);
|
||||
|
||||
ParamType ptType = ptValue;
|
||||
if (1 < nCount)
|
||||
{
|
||||
m_lParam1 = GetValue(oArrayParams[1], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType1 = ptType;
|
||||
}
|
||||
if (2 < nCount)
|
||||
{
|
||||
m_lParam2 = GetValue(oArrayParams[2], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType2 = ptType;
|
||||
}
|
||||
if (3 < nCount)
|
||||
{
|
||||
m_lParam3 = GetValue(oArrayParams[3], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType3 = ptType;
|
||||
}
|
||||
}
|
||||
void FromString(std::wstring strFormula, long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML);
|
||||
LONG CalculateFormula(CFormulasManager* pManager);
|
||||
};
|
||||
|
||||
@ -339,71 +276,15 @@ private:
|
||||
long m_lShapeHeight;
|
||||
|
||||
public:
|
||||
CFormulasManager() : m_arFormulas(), m_arResults()
|
||||
{
|
||||
m_pAdjustments = NULL;
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
}
|
||||
CFormulasManager& operator =(const CFormulasManager& oSrc)
|
||||
{
|
||||
m_pAdjustments = oSrc.m_pAdjustments;
|
||||
m_lShapeWidth = oSrc.m_lShapeWidth;
|
||||
m_lShapeHeight = oSrc.m_lShapeHeight;
|
||||
CFormulasManager();
|
||||
CFormulasManager& operator =(const CFormulasManager& oSrc);
|
||||
|
||||
m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults.push_back(oSrc.m_arResults[nIndex]);
|
||||
}
|
||||
m_arFormulas.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arFormulas.size(); ++nIndex)
|
||||
{
|
||||
m_arFormulas.push_back(oSrc.m_arFormulas[nIndex]);
|
||||
}
|
||||
|
||||
return (*this);
|
||||
}
|
||||
void Clear();
|
||||
void Clear(std::vector<LONG>* pAdjusts);
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_pAdjustments = NULL;
|
||||
void AddFormula(std::wstring strFormula);
|
||||
void AddFormula(CFormula oFormula);
|
||||
|
||||
|
||||
m_arFormulas.clear();
|
||||
m_arResults.clear();
|
||||
}
|
||||
|
||||
void Clear(std::vector<LONG>* pAdjusts)
|
||||
{
|
||||
m_pAdjustments = pAdjusts;
|
||||
|
||||
//m_arFormulas.clear();
|
||||
//m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults[nIndex] = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
void AddFormula(std::wstring strFormula)
|
||||
{
|
||||
CFormula oFormula((int)m_arFormulas.size());
|
||||
oFormula.FromString(strFormula, m_lShapeWidth, m_lShapeHeight);
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void AddFormula(CFormula oFormula)
|
||||
{
|
||||
oFormula.m_lIndex = (int)m_arFormulas.size();
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void CalculateResults()
|
||||
{
|
||||
for (size_t index = 0; index < m_arFormulas.size(); ++index)
|
||||
{
|
||||
LONG lResult = m_arFormulas[index].CalculateFormula(this);
|
||||
}
|
||||
}
|
||||
void CalculateResults();
|
||||
};
|
||||
}
|
||||
|
||||
702
MsBinaryFile/Common/ODraw/GraphicsPath.cpp
Normal file
702
MsBinaryFile/Common/ODraw/GraphicsPath.cpp
Normal file
@ -0,0 +1,702 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "GraphicsPath.h"
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
CDoubleRect::CDoubleRect()
|
||||
{
|
||||
left = 0;
|
||||
top = 0;
|
||||
right = 0;
|
||||
bottom = 0;
|
||||
}
|
||||
CDoubleRect& CDoubleRect::operator=(const CDoubleRect& oSrc)
|
||||
{
|
||||
left = oSrc.left;
|
||||
top = oSrc.top;
|
||||
right = oSrc.right;
|
||||
bottom = oSrc.bottom;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CDoubleRect::CDoubleRect(const CDoubleRect& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
CGeomShapeInfo::CPointD::CPointD()
|
||||
{
|
||||
dX = 0;
|
||||
dY = 0;
|
||||
}
|
||||
CGeomShapeInfo::CPointD& CGeomShapeInfo::CPointD::operator= (const CPointD& oSrc)
|
||||
{
|
||||
dX = oSrc.dX;
|
||||
dY = oSrc.dY;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CGeomShapeInfo::CPointD::CPointD(const CPointD& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
CGeomShapeInfo::CGeomShapeInfo()
|
||||
{
|
||||
m_dLeft = 0;
|
||||
m_dTop = 0;
|
||||
m_dWidth = 720;
|
||||
m_dHeight = 576;
|
||||
|
||||
m_dLimoX = 0;
|
||||
m_dLimoY = 0;
|
||||
|
||||
m_oCurPoint.dX = 0;
|
||||
m_oCurPoint.dY = 0;
|
||||
|
||||
m_dRotate = 0.0;
|
||||
m_bFlipH = false;
|
||||
m_bFlipV = false;
|
||||
|
||||
m_lOriginalWidth = 0;
|
||||
m_lOriginalHeight = 0;
|
||||
}
|
||||
CGeomShapeInfo::~CGeomShapeInfo()
|
||||
{
|
||||
}
|
||||
CGeomShapeInfo& CGeomShapeInfo::operator =(const CGeomShapeInfo& oSrc)
|
||||
{
|
||||
m_dLeft = oSrc.m_dLeft;
|
||||
m_dTop = oSrc.m_dTop;
|
||||
m_dWidth = oSrc.m_dWidth;
|
||||
m_dHeight = oSrc.m_dHeight;
|
||||
|
||||
m_dLimoX = oSrc.m_dLimoX;
|
||||
m_dLimoY = oSrc.m_dLimoY;
|
||||
|
||||
m_oCurPoint = oSrc.m_oCurPoint;
|
||||
|
||||
m_dRotate = oSrc.m_dRotate;
|
||||
m_bFlipH = oSrc.m_bFlipH;
|
||||
m_bFlipV = oSrc.m_bFlipV;
|
||||
|
||||
m_lOriginalWidth = oSrc.m_lOriginalWidth;
|
||||
m_lOriginalHeight = oSrc.m_lOriginalHeight;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
CDoublePoint::CDoublePoint()
|
||||
{
|
||||
dX = 0;
|
||||
dY = 0;
|
||||
}
|
||||
CDoublePoint& CDoublePoint::operator= (const CDoublePoint& oSrc)
|
||||
{
|
||||
dX = oSrc.dX;
|
||||
dY = oSrc.dY;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CDoublePoint::CDoublePoint(const CDoublePoint& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
void CGraphicPath::InternalClear()
|
||||
{
|
||||
m_lFlags = 0;
|
||||
}
|
||||
CGraphicPath::CGraphicPath()
|
||||
{
|
||||
InternalClear();
|
||||
}
|
||||
|
||||
CGraphicPath::CPart::CPart() : m_eType(rtMoveTo), m_arPoints()
|
||||
{
|
||||
}
|
||||
CGraphicPath::CPart& CGraphicPath::CPart::operator=(const CPart& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
this->m_arPoints.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arPoints.size(); ++nIndex)
|
||||
{
|
||||
this->m_arPoints.push_back(oSrc.m_arPoints[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
CGraphicPath::CPart::~CPart()
|
||||
{
|
||||
this->m_arPoints.clear();
|
||||
}
|
||||
|
||||
void CGraphicPath::CPart::ParseString(std::wstring strDelimeters, std::wstring strSource,
|
||||
std::vector<std::wstring>& pArrayResults, bool bIsCleared)
|
||||
{
|
||||
if (bIsCleared)
|
||||
pArrayResults.clear();
|
||||
|
||||
std::wstring resToken;
|
||||
int curPos= 0;
|
||||
|
||||
boost::algorithm::split(pArrayResults, strSource, boost::algorithm::is_any_of(strDelimeters), boost::algorithm::token_compress_on);
|
||||
|
||||
}
|
||||
|
||||
void CGraphicPath::CPart::CheckLastPoint(IRenderer* pRenderer, CDoublePoint& pointCur)
|
||||
{
|
||||
if (NULL == pRenderer)
|
||||
return;
|
||||
|
||||
pRenderer->PathCommandGetCurrentPoint(&pointCur.dX, &pointCur.dY);
|
||||
}
|
||||
double CGraphicPath::CPart::GetAngle(double fCentreX, double fCentreY, double fX, double fY)
|
||||
{
|
||||
// - + (.. )
|
||||
double dX = fX - fCentreX;
|
||||
double dY = fY - fCentreY;
|
||||
|
||||
double modDX = abs(dX);
|
||||
double modDY = abs(dY);
|
||||
|
||||
if ((modDX < 0.01) && (modDY < 0.01))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ((modDX < 0.01) && (dY < 0))
|
||||
{
|
||||
return -90;
|
||||
}
|
||||
else if (modDX < 0.01)
|
||||
{
|
||||
return 90;
|
||||
}
|
||||
if ((modDY < 0.01) && (dX < 0))
|
||||
{
|
||||
return 180;
|
||||
}
|
||||
else if (modDY < 0.01)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double fAngle = atan(dY / dX);
|
||||
fAngle *= double(180 / M_PI);
|
||||
if (dX > 0 && dY > 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX > 0 && dY < 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX < 0 && dY > 0)
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return 180 + fAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return fAngle - 180;
|
||||
}
|
||||
}
|
||||
|
||||
void CGraphicPath::CPart::ApplyElliptical(bool& bIsX, double& angleStart, double& angleSweet,
|
||||
double& Left, double& Top, double& Width, double& Height, const CDoublePoint& pointCur)
|
||||
{
|
||||
// (x - y - x...)
|
||||
if (bIsX)
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = 90;
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = -90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
angleSweet = -90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = -90;
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
angleSweet = 90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = 90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
}
|
||||
bIsX = !bIsX;
|
||||
}
|
||||
|
||||
void CGraphicPath::CPart::GetSafearrayPoints(IRenderer* pRenderer, double** ppArray, size_t& nCountOut, CDoublePoint& pointCur, bool bR)
|
||||
{
|
||||
if (NULL == ppArray)
|
||||
return;
|
||||
|
||||
size_t nCount = this->m_arPoints.size();
|
||||
|
||||
nCountOut = 2 * (nCount + 1);
|
||||
|
||||
double* pArray = new double [nCountOut];
|
||||
double* pBuffer = pArray;
|
||||
|
||||
memset (pBuffer, 0, nCountOut * sizeof(double));
|
||||
|
||||
*pBuffer = pointCur.dX; ++pBuffer;
|
||||
*pBuffer = pointCur.dY; ++pBuffer;
|
||||
|
||||
if (bR)
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
*pBuffer = (this->m_arPoints[nIndex].dX + pointCur.dX); ++pBuffer;
|
||||
*pBuffer = (this->m_arPoints[nIndex].dY + pointCur.dY); ++pBuffer;
|
||||
|
||||
if (nIndex == (nCount - 1))
|
||||
{
|
||||
pointCur.dX += this->m_arPoints[nIndex].dX;
|
||||
pointCur.dY += this->m_arPoints[nIndex].dY;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
*pBuffer = this->m_arPoints[nIndex].dX; ++pBuffer;
|
||||
*pBuffer = this->m_arPoints[nIndex].dY; ++pBuffer;
|
||||
|
||||
if (nIndex == (nCount - 1))
|
||||
{
|
||||
pointCur.dX = this->m_arPoints[nIndex].dX;
|
||||
pointCur.dY = this->m_arPoints[nIndex].dY;
|
||||
}
|
||||
}
|
||||
}
|
||||
*ppArray = pArray;
|
||||
|
||||
}
|
||||
|
||||
void CGraphicPath::CPart::Draw(IRenderer* pRenderer, CDoublePoint& pointCur)
|
||||
{
|
||||
switch (m_eType)
|
||||
{
|
||||
case rtMoveTo:
|
||||
{
|
||||
if (0 < this->m_arPoints.size())
|
||||
{
|
||||
pointCur.dX = this->m_arPoints[0].dX;
|
||||
pointCur.dY = this->m_arPoints[0].dY;
|
||||
pRenderer->PathCommandMoveTo(this->m_arPoints[0].dX, this->m_arPoints[0].dY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rtLineTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandLinesTo(pArray, (int)nCount /*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtCurveTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandCurvesTo (pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtClose:
|
||||
{
|
||||
pRenderer->PathCommandClose();
|
||||
break;
|
||||
}
|
||||
case rtRMoveTo:
|
||||
{
|
||||
if (0 < this->m_arPoints.size())
|
||||
{
|
||||
pointCur.dX = this->m_arPoints[0].dX + pointCur.dX;
|
||||
pointCur.dY = this->m_arPoints[0].dY + pointCur.dY;
|
||||
pRenderer->PathCommandMoveTo(pointCur.dX, pointCur.dY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rtRLineTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur, TRUE);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandLinesTo(pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtRCurveTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur, TRUE);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandCurvesTo(pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rtAngleEllipseTo:
|
||||
{
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 3) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nLeft = this->m_arPoints[nFigure].dX - this->m_arPoints[nFigure + 1].dX / 2;
|
||||
double nTop = this->m_arPoints[nFigure].dY - this->m_arPoints[nFigure + 1].dY / 2;
|
||||
|
||||
pRenderer->PathCommandArcTo(nLeft, nTop,
|
||||
this->m_arPoints[nFigure + 1].dX, this->m_arPoints[nFigure + 1].dY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
nFigure += 3;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtAngleEllipse:
|
||||
{
|
||||
pRenderer->PathCommandStart();
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 3) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nLeft = this->m_arPoints[nFigure].dX - this->m_arPoints[nFigure + 1].dX / 2;
|
||||
double nTop = this->m_arPoints[nFigure].dY - this->m_arPoints[nFigure + 1].dY / 2;
|
||||
|
||||
pRenderer->PathCommandArcTo(nLeft, nTop,
|
||||
this->m_arPoints[nFigure + 1].dX, this->m_arPoints[nFigure + 1].dY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
nFigure += 3;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtArc:
|
||||
{
|
||||
pRenderer->PathCommandStart();
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtArcTo:
|
||||
{
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtClockwiseArcTo:
|
||||
{
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, 360 + GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtClockwiseArc:
|
||||
{
|
||||
pRenderer->PathCommandStart();
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, 360 + GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtEllipticalQuadrX:
|
||||
{
|
||||
bool bIsX = true;
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
|
||||
size_t nCount = this->m_arPoints.size();
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
double x1 = pointCur.dX;
|
||||
double y1 = pointCur.dY;
|
||||
|
||||
double x2 = this->m_arPoints[nIndex].dX;
|
||||
double y2 = this->m_arPoints[nIndex].dY;
|
||||
|
||||
double dRadX = fabs(x1 - x2);
|
||||
double dRadY = fabs(y1 - y2);
|
||||
|
||||
AddEllipticalQuadr(pRenderer, bIsX, x1, y1, x2, y2, dRadX, dRadY);
|
||||
|
||||
pointCur.dX = x2;
|
||||
pointCur.dY = y2;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtEllipticalQuadrY:
|
||||
{
|
||||
bool bIsX = false;
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
|
||||
size_t nCount = this->m_arPoints.size();
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
double x1 = pointCur.dX;
|
||||
double y1 = pointCur.dY;
|
||||
|
||||
double x2 = this->m_arPoints[nIndex].dX;
|
||||
double y2 = this->m_arPoints[nIndex].dY;
|
||||
|
||||
double dRadX = fabs(x1 - x2);
|
||||
double dRadY = fabs(y1 - y2);
|
||||
|
||||
AddEllipticalQuadr(pRenderer, bIsX, x1, y1, x2, y2, dRadX, dRadY);
|
||||
|
||||
pointCur.dX = x2;
|
||||
pointCur.dY = y2;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtQuadrBesier:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur, TRUE);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandLinesTo(pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
|
||||
void CGraphicPath::CPart::AddEllipticalQuadr(IRenderer*& pRenderer, bool& bIsX, double& x1, double& y1, double& x2, double& y2, double& dRadX, double& dRadY)
|
||||
{
|
||||
if (bIsX)
|
||||
{
|
||||
if ((x2 >= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1, 2 * dRadX, 2 * dRadY, -90, 90);
|
||||
else if ((x2 >= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1 - 2 * dRadY, 2 * dRadX, 2 * dRadY, 90, -90);
|
||||
else if ((x2 <= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1, 2 * dRadX, 2 * dRadY, -90, -90);
|
||||
else if ((x2 <= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1 - 2 * dRadY, 2 * dRadX, 2 * dRadY, 90, 90);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((x2 >= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1, y1 - dRadY, 2 * dRadX, 2 * dRadY, 180, -90);
|
||||
else if ((x2 >= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1, y1 - dRadY, 2 * dRadX, 2 * dRadY, 180, 90);
|
||||
else if ((x2 <= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - 2 * dRadX, y1 - dRadY, 2 * dRadX, 2 * dRadY, 0, 90);
|
||||
else if ((x2 <= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - 2 * dRadX, y1 - dRadY, 2 * dRadX, 2 * dRadY, 0, -90);
|
||||
}
|
||||
bIsX = !bIsX;
|
||||
}
|
||||
|
||||
|
||||
void CGraphicPath::AddRuler(const RulesType& eType)
|
||||
{
|
||||
size_t lCount = m_arParts.size();
|
||||
|
||||
CPart oPart;
|
||||
oPart.m_eType = eType;
|
||||
|
||||
m_arParts.push_back(oPart);
|
||||
}
|
||||
void CGraphicPath::AddPoint(const double& x, const double& y)
|
||||
{
|
||||
size_t lCount = m_arParts.size();
|
||||
if (0 != lCount)
|
||||
{
|
||||
CDoublePoint point;
|
||||
point.dX = x;
|
||||
point.dY = y;
|
||||
m_arParts[lCount - 1].m_arPoints.push_back(point);
|
||||
}
|
||||
}
|
||||
|
||||
void CGraphicPath::Clear()
|
||||
{
|
||||
m_arParts.clear();
|
||||
}
|
||||
}
|
||||
@ -55,32 +55,15 @@ namespace NSCustomShapesConvert
|
||||
double bottom;
|
||||
|
||||
public:
|
||||
CDoubleRect()
|
||||
{
|
||||
left = 0;
|
||||
top = 0;
|
||||
right = 0;
|
||||
bottom = 0;
|
||||
}
|
||||
CDoubleRect& operator=(const CDoubleRect& oSrc)
|
||||
{
|
||||
left = oSrc.left;
|
||||
top = oSrc.top;
|
||||
right = oSrc.right;
|
||||
bottom = oSrc.bottom;
|
||||
CDoubleRect();
|
||||
CDoubleRect& operator=(const CDoubleRect& oSrc);
|
||||
CDoubleRect(const CDoubleRect& oSrc);
|
||||
|
||||
return *this;
|
||||
}
|
||||
CDoubleRect(const CDoubleRect& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
inline bool IsEqual(const CDoubleRect& oSrc, double dEps = 0.01)
|
||||
{
|
||||
return ((fabs(left - oSrc.left) < dEps) && (fabs(top - oSrc.top) < dEps) &&
|
||||
(fabs(right - oSrc.right) < dEps) && (fabs(bottom - oSrc.bottom) < dEps));
|
||||
}
|
||||
|
||||
inline double GetWidth() const
|
||||
{
|
||||
return right - left;
|
||||
@ -106,25 +89,11 @@ namespace NSCustomShapesConvert
|
||||
public:
|
||||
double dX;
|
||||
double dY;
|
||||
|
||||
public:
|
||||
CPointD()
|
||||
{
|
||||
dX = 0;
|
||||
dY = 0;
|
||||
}
|
||||
|
||||
CPointD& operator= (const CPointD& oSrc)
|
||||
{
|
||||
dX = oSrc.dX;
|
||||
dY = oSrc.dY;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CPointD(const CPointD& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CPointD();
|
||||
CPointD& operator= (const CPointD& oSrc);
|
||||
CPointD(const CPointD& oSrc);
|
||||
};
|
||||
|
||||
public:
|
||||
@ -147,51 +116,9 @@ namespace NSCustomShapesConvert
|
||||
LONG m_lOriginalHeight;
|
||||
|
||||
public:
|
||||
CGeomShapeInfo()
|
||||
{
|
||||
m_dLeft = 0;
|
||||
m_dTop = 0;
|
||||
m_dWidth = 720;
|
||||
m_dHeight = 576;
|
||||
|
||||
m_dLimoX = 0;
|
||||
m_dLimoY = 0;
|
||||
|
||||
m_oCurPoint.dX = 0;
|
||||
m_oCurPoint.dY = 0;
|
||||
|
||||
m_dRotate = 0.0;
|
||||
m_bFlipH = false;
|
||||
m_bFlipV = false;
|
||||
|
||||
m_lOriginalWidth = 0;
|
||||
m_lOriginalHeight = 0;
|
||||
}
|
||||
~CGeomShapeInfo()
|
||||
{
|
||||
}
|
||||
|
||||
CGeomShapeInfo& operator =(const CGeomShapeInfo& oSrc)
|
||||
{
|
||||
m_dLeft = oSrc.m_dLeft;
|
||||
m_dTop = oSrc.m_dTop;
|
||||
m_dWidth = oSrc.m_dWidth;
|
||||
m_dHeight = oSrc.m_dHeight;
|
||||
|
||||
m_dLimoX = oSrc.m_dLimoX;
|
||||
m_dLimoY = oSrc.m_dLimoY;
|
||||
|
||||
m_oCurPoint = oSrc.m_oCurPoint;
|
||||
|
||||
m_dRotate = oSrc.m_dRotate;
|
||||
m_bFlipH = oSrc.m_bFlipH;
|
||||
m_bFlipV = oSrc.m_bFlipV;
|
||||
|
||||
m_lOriginalWidth = oSrc.m_lOriginalWidth;
|
||||
m_lOriginalHeight = oSrc.m_lOriginalHeight;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
CGeomShapeInfo();
|
||||
~CGeomShapeInfo();
|
||||
CGeomShapeInfo& operator =(const CGeomShapeInfo& oSrc);
|
||||
|
||||
inline void SetBounds(const CDoubleRect& oRect)
|
||||
{
|
||||
@ -217,25 +144,11 @@ namespace NSCustomShapesConvert
|
||||
public:
|
||||
double dX;
|
||||
double dY;
|
||||
|
||||
public:
|
||||
CDoublePoint()
|
||||
{
|
||||
dX = 0;
|
||||
dY = 0;
|
||||
}
|
||||
|
||||
CDoublePoint& operator= (const CDoublePoint& oSrc)
|
||||
{
|
||||
dX = oSrc.dX;
|
||||
dY = oSrc.dY;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CDoublePoint(const CDoublePoint& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CDoublePoint();
|
||||
CDoublePoint& operator= (const CDoublePoint& oSrc);
|
||||
CDoublePoint(const CDoublePoint& oSrc);
|
||||
};
|
||||
|
||||
enum RulesType
|
||||
@ -286,14 +199,10 @@ namespace NSCustomShapesConvert
|
||||
class CGraphicPath
|
||||
{
|
||||
public:
|
||||
virtual void InternalClear()
|
||||
{
|
||||
m_lFlags = 0;
|
||||
}
|
||||
CGraphicPath()
|
||||
{
|
||||
InternalClear();
|
||||
}
|
||||
virtual void InternalClear();
|
||||
|
||||
CGraphicPath();
|
||||
|
||||
class CPart
|
||||
{
|
||||
public:
|
||||
@ -301,23 +210,10 @@ namespace NSCustomShapesConvert
|
||||
std::vector<CDoublePoint> m_arPoints;
|
||||
|
||||
public:
|
||||
CPart() : m_eType(rtMoveTo), m_arPoints()
|
||||
{
|
||||
}
|
||||
CPart& operator=(const CPart& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
this->m_arPoints.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arPoints.size(); ++nIndex)
|
||||
{
|
||||
this->m_arPoints.push_back(oSrc.m_arPoints[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
~CPart()
|
||||
{
|
||||
this->m_arPoints.clear();
|
||||
}
|
||||
CPart();
|
||||
CPart& operator=(const CPart& oSrc);
|
||||
~CPart();
|
||||
|
||||
//void FromXmlNode(XmlUtils::CXmlNode& oNode)
|
||||
//{
|
||||
// std::wstring strName = oNode.GetAttribute(_T("name"));
|
||||
@ -364,76 +260,10 @@ namespace NSCustomShapesConvert
|
||||
// }
|
||||
//}
|
||||
void ParseString(std::wstring strDelimeters, std::wstring strSource,
|
||||
std::vector<std::wstring>& pArrayResults, bool bIsCleared = true)
|
||||
{
|
||||
if (bIsCleared)
|
||||
pArrayResults.clear();
|
||||
std::vector<std::wstring>& pArrayResults, bool bIsCleared = true);
|
||||
|
||||
std::wstring resToken;
|
||||
int curPos= 0;
|
||||
|
||||
boost::algorithm::split(pArrayResults, strSource, boost::algorithm::is_any_of(strDelimeters), boost::algorithm::token_compress_on);
|
||||
|
||||
}
|
||||
|
||||
void CheckLastPoint(IRenderer* pRenderer, CDoublePoint& pointCur)
|
||||
{
|
||||
if (NULL == pRenderer)
|
||||
return;
|
||||
|
||||
pRenderer->PathCommandGetCurrentPoint(&pointCur.dX, &pointCur.dY);
|
||||
}
|
||||
double GetAngle(double fCentreX, double fCentreY, double fX, double fY)
|
||||
{
|
||||
// - + (.. )
|
||||
double dX = fX - fCentreX;
|
||||
double dY = fY - fCentreY;
|
||||
|
||||
double modDX = abs(dX);
|
||||
double modDY = abs(dY);
|
||||
|
||||
if ((modDX < 0.01) && (modDY < 0.01))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ((modDX < 0.01) && (dY < 0))
|
||||
{
|
||||
return -90;
|
||||
}
|
||||
else if (modDX < 0.01)
|
||||
{
|
||||
return 90;
|
||||
}
|
||||
if ((modDY < 0.01) && (dX < 0))
|
||||
{
|
||||
return 180;
|
||||
}
|
||||
else if (modDY < 0.01)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double fAngle = atan(dY / dX);
|
||||
fAngle *= double(180 / M_PI);
|
||||
if (dX > 0 && dY > 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX > 0 && dY < 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX < 0 && dY > 0)
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return 180 + fAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return fAngle - 180;
|
||||
}
|
||||
}
|
||||
void CheckLastPoint(IRenderer* pRenderer, CDoublePoint& pointCur);
|
||||
double GetAngle(double fCentreX, double fCentreY, double fX, double fY);
|
||||
|
||||
inline double GetSweepAngle(const double& angleStart, const double& angleEnd)
|
||||
{
|
||||
@ -444,475 +274,21 @@ namespace NSCustomShapesConvert
|
||||
}
|
||||
|
||||
void ApplyElliptical(bool& bIsX, double& angleStart, double& angleSweet,
|
||||
double& Left, double& Top, double& Width, double& Height, const CDoublePoint& pointCur)
|
||||
{
|
||||
// (x - y - x...)
|
||||
if (bIsX)
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = 90;
|
||||
double& Left, double& Top, double& Width, double& Height, const CDoublePoint& pointCur);
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = -90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
angleSweet = -90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = -90;
|
||||
void GetSafearrayPoints(IRenderer* pRenderer, double** ppArray, size_t& nCountOut, CDoublePoint& pointCur, bool bR = false);
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
angleSweet = 90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = 90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
}
|
||||
bIsX = !bIsX;
|
||||
}
|
||||
void Draw(IRenderer* pRenderer, CDoublePoint& pointCur);
|
||||
|
||||
|
||||
void GetSafearrayPoints(IRenderer* pRenderer, double** ppArray, size_t& nCountOut, CDoublePoint& pointCur, bool bR = false)
|
||||
{
|
||||
if (NULL == ppArray)
|
||||
return;
|
||||
|
||||
size_t nCount = this->m_arPoints.size();
|
||||
|
||||
nCountOut = 2 * (nCount + 1);
|
||||
|
||||
double* pArray = new double [nCountOut];
|
||||
double* pBuffer = pArray;
|
||||
|
||||
memset (pBuffer, 0, nCountOut * sizeof(double));
|
||||
|
||||
*pBuffer = pointCur.dX; ++pBuffer;
|
||||
*pBuffer = pointCur.dY; ++pBuffer;
|
||||
|
||||
if (bR)
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
*pBuffer = (this->m_arPoints[nIndex].dX + pointCur.dX); ++pBuffer;
|
||||
*pBuffer = (this->m_arPoints[nIndex].dY + pointCur.dY); ++pBuffer;
|
||||
|
||||
if (nIndex == (nCount - 1))
|
||||
{
|
||||
pointCur.dX += this->m_arPoints[nIndex].dX;
|
||||
pointCur.dY += this->m_arPoints[nIndex].dY;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
*pBuffer = this->m_arPoints[nIndex].dX; ++pBuffer;
|
||||
*pBuffer = this->m_arPoints[nIndex].dY; ++pBuffer;
|
||||
|
||||
if (nIndex == (nCount - 1))
|
||||
{
|
||||
pointCur.dX = this->m_arPoints[nIndex].dX;
|
||||
pointCur.dY = this->m_arPoints[nIndex].dY;
|
||||
}
|
||||
}
|
||||
}
|
||||
*ppArray = pArray;
|
||||
|
||||
}
|
||||
|
||||
void Draw(IRenderer* pRenderer, CDoublePoint& pointCur)
|
||||
{
|
||||
switch (m_eType)
|
||||
{
|
||||
case rtMoveTo:
|
||||
{
|
||||
if (0 < this->m_arPoints.size())
|
||||
{
|
||||
pointCur.dX = this->m_arPoints[0].dX;
|
||||
pointCur.dY = this->m_arPoints[0].dY;
|
||||
pRenderer->PathCommandMoveTo(this->m_arPoints[0].dX, this->m_arPoints[0].dY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rtLineTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandLinesTo(pArray, (int)nCount /*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtCurveTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandCurvesTo (pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtClose:
|
||||
{
|
||||
pRenderer->PathCommandClose();
|
||||
break;
|
||||
}
|
||||
case rtRMoveTo:
|
||||
{
|
||||
if (0 < this->m_arPoints.size())
|
||||
{
|
||||
pointCur.dX = this->m_arPoints[0].dX + pointCur.dX;
|
||||
pointCur.dY = this->m_arPoints[0].dY + pointCur.dY;
|
||||
pRenderer->PathCommandMoveTo(pointCur.dX, pointCur.dY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rtRLineTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur, TRUE);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandLinesTo(pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtRCurveTo:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur, TRUE);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandCurvesTo(pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case rtAngleEllipseTo:
|
||||
{
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 3) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nLeft = this->m_arPoints[nFigure].dX - this->m_arPoints[nFigure + 1].dX / 2;
|
||||
double nTop = this->m_arPoints[nFigure].dY - this->m_arPoints[nFigure + 1].dY / 2;
|
||||
|
||||
pRenderer->PathCommandArcTo(nLeft, nTop,
|
||||
this->m_arPoints[nFigure + 1].dX, this->m_arPoints[nFigure + 1].dY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
nFigure += 3;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtAngleEllipse:
|
||||
{
|
||||
pRenderer->PathCommandStart();
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 3) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nLeft = this->m_arPoints[nFigure].dX - this->m_arPoints[nFigure + 1].dX / 2;
|
||||
double nTop = this->m_arPoints[nFigure].dY - this->m_arPoints[nFigure + 1].dY / 2;
|
||||
|
||||
pRenderer->PathCommandArcTo(nLeft, nTop,
|
||||
this->m_arPoints[nFigure + 1].dX, this->m_arPoints[nFigure + 1].dY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
nFigure += 3;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtArc:
|
||||
{
|
||||
pRenderer->PathCommandStart();
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtArcTo:
|
||||
{
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtClockwiseArcTo:
|
||||
{
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, 360 + GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtClockwiseArc:
|
||||
{
|
||||
pRenderer->PathCommandStart();
|
||||
int nFigure = 0;
|
||||
while ((nFigure + 4) <= (int)this->m_arPoints.size())
|
||||
{
|
||||
double nCentreX = (this->m_arPoints[nFigure].dX + this->m_arPoints[nFigure + 1].dX) / 2;
|
||||
double nCentreY = (this->m_arPoints[nFigure].dY + this->m_arPoints[nFigure + 1].dY) / 2;
|
||||
|
||||
double angleStart = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 2].dX, this->m_arPoints[nFigure + 2].dY);
|
||||
|
||||
double angleEnd = GetAngle(nCentreX, nCentreY,
|
||||
this->m_arPoints[nFigure + 3].dX, this->m_arPoints[nFigure + 3].dY);
|
||||
|
||||
pRenderer->PathCommandArcTo(this->m_arPoints[nFigure].dX, this->m_arPoints[nFigure].dY,
|
||||
this->m_arPoints[nFigure + 1].dX - this->m_arPoints[nFigure].dX,
|
||||
this->m_arPoints[nFigure + 1].dY - this->m_arPoints[nFigure].dY,
|
||||
angleStart, 360 + GetSweepAngle(angleStart, angleEnd));
|
||||
|
||||
nFigure += 4;
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
case rtEllipticalQuadrX:
|
||||
{
|
||||
bool bIsX = true;
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
|
||||
size_t nCount = this->m_arPoints.size();
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
double x1 = pointCur.dX;
|
||||
double y1 = pointCur.dY;
|
||||
|
||||
double x2 = this->m_arPoints[nIndex].dX;
|
||||
double y2 = this->m_arPoints[nIndex].dY;
|
||||
|
||||
double dRadX = fabs(x1 - x2);
|
||||
double dRadY = fabs(y1 - y2);
|
||||
|
||||
AddEllipticalQuadr(pRenderer, bIsX, x1, y1, x2, y2, dRadX, dRadY);
|
||||
|
||||
pointCur.dX = x2;
|
||||
pointCur.dY = y2;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtEllipticalQuadrY:
|
||||
{
|
||||
bool bIsX = false;
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
|
||||
size_t nCount = this->m_arPoints.size();
|
||||
for (size_t nIndex = 0; nIndex < nCount; ++nIndex)
|
||||
{
|
||||
double x1 = pointCur.dX;
|
||||
double y1 = pointCur.dY;
|
||||
|
||||
double x2 = this->m_arPoints[nIndex].dX;
|
||||
double y2 = this->m_arPoints[nIndex].dY;
|
||||
|
||||
double dRadX = fabs(x1 - x2);
|
||||
double dRadY = fabs(y1 - y2);
|
||||
|
||||
AddEllipticalQuadr(pRenderer, bIsX, x1, y1, x2, y2, dRadX, dRadY);
|
||||
|
||||
pointCur.dX = x2;
|
||||
pointCur.dY = y2;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case rtQuadrBesier:
|
||||
{
|
||||
double* pArray = NULL;
|
||||
size_t nCount = 0;
|
||||
GetSafearrayPoints(pRenderer, &pArray, nCount, pointCur, TRUE);
|
||||
|
||||
if (NULL != pArray)
|
||||
{
|
||||
pRenderer->PathCommandLinesTo(pArray, (int)nCount/*this->m_arPoints.size()*/);
|
||||
}
|
||||
|
||||
CheckLastPoint(pRenderer, pointCur);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
|
||||
inline void AddEllipticalQuadr(IRenderer*& pRenderer, bool& bIsX, double& x1, double& y1, double& x2, double& y2, double& dRadX, double& dRadY)
|
||||
{
|
||||
if (bIsX)
|
||||
{
|
||||
if ((x2 >= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1, 2 * dRadX, 2 * dRadY, -90, 90);
|
||||
else if ((x2 >= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1 - 2 * dRadY, 2 * dRadX, 2 * dRadY, 90, -90);
|
||||
else if ((x2 <= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1, 2 * dRadX, 2 * dRadY, -90, -90);
|
||||
else if ((x2 <= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - dRadX, y1 - 2 * dRadY, 2 * dRadX, 2 * dRadY, 90, 90);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((x2 >= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1, y1 - dRadY, 2 * dRadX, 2 * dRadY, 180, -90);
|
||||
else if ((x2 >= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1, y1 - dRadY, 2 * dRadX, 2 * dRadY, 180, 90);
|
||||
else if ((x2 <= x1) && (y2 >= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - 2 * dRadX, y1 - dRadY, 2 * dRadX, 2 * dRadY, 0, 90);
|
||||
else if ((x2 <= x1) && (y2 <= y1))
|
||||
pRenderer->PathCommandArcTo(x1 - 2 * dRadX, y1 - dRadY, 2 * dRadX, 2 * dRadY, 0, -90);
|
||||
}
|
||||
bIsX = !bIsX;
|
||||
}
|
||||
void AddEllipticalQuadr(IRenderer*& pRenderer, bool& bIsX, double& x1, double& y1, double& x2, double& y2, double& dRadX, double& dRadY);
|
||||
};
|
||||
|
||||
void AddRuler(const RulesType& eType)
|
||||
{
|
||||
size_t lCount = m_arParts.size();
|
||||
|
||||
CPart oPart;
|
||||
oPart.m_eType = eType;
|
||||
|
||||
m_arParts.push_back(oPart);
|
||||
}
|
||||
void AddPoint(const double& x, const double& y)
|
||||
{
|
||||
size_t lCount = m_arParts.size();
|
||||
if (0 != lCount)
|
||||
{
|
||||
CDoublePoint point;
|
||||
point.dX = x;
|
||||
point.dY = y;
|
||||
m_arParts[lCount - 1].m_arPoints.push_back(point);
|
||||
}
|
||||
}
|
||||
void AddRuler(const RulesType& eType);
|
||||
void AddPoint(const double& x, const double& y);
|
||||
|
||||
void Clear();
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_arParts.clear();
|
||||
}
|
||||
std::vector<CPart> m_arParts;
|
||||
|
||||
int m_lFlags;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
420
MsBinaryFile/Common/ODraw/PathShape.cpp
Normal file
420
MsBinaryFile/Common/ODraw/PathShape.cpp
Normal file
@ -0,0 +1,420 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "PathShape.h"
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
CSlice::CSlice(RulesType eType /*, LONG x = 0, LONG y = 0*/)
|
||||
{
|
||||
m_eRuler = eType;
|
||||
m_nCountElementsPoint = 0;
|
||||
//m_lX = x;
|
||||
//m_lY = y;
|
||||
}
|
||||
void CSlice::AddParam(LONG lParam)
|
||||
{
|
||||
long lPoint = m_nCountElementsPoint % 2;
|
||||
if (0 == lPoint)
|
||||
{
|
||||
Aggplus::POINT point;
|
||||
point.x = lParam/* - m_lX*/;
|
||||
point.y = 0;
|
||||
m_arPoints.push_back(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arPoints[m_arPoints.size() - 1].y = lParam/* - m_lY*/;
|
||||
}
|
||||
++m_nCountElementsPoint;
|
||||
}
|
||||
CSlice& CSlice::operator =(const CSlice& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_arPoints.clear();
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arPoints.size(); ++nIndex)
|
||||
{
|
||||
m_arPoints.push_back(oSrc.m_arPoints[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
double CSlice::GetAngle(double fCentreX, double fCentreY, double fX, double fY)
|
||||
{
|
||||
// - + (.. )
|
||||
double dX = fX - fCentreX;
|
||||
double dY = fY - fCentreY;
|
||||
|
||||
double modDX = abs(dX);
|
||||
double modDY = abs(dY);
|
||||
|
||||
if ((modDX < 0.01) && (modDY < 0.01))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ((modDX < 0.01) && (dY < 0))
|
||||
{
|
||||
return -90;
|
||||
}
|
||||
else if (modDX < 0.01)
|
||||
{
|
||||
return 90;
|
||||
}
|
||||
if ((modDY < 0.01) && (dX < 0))
|
||||
{
|
||||
return 180;
|
||||
}
|
||||
else if (modDY < 0.01)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double fAngle = atan(dY / dX);
|
||||
fAngle *= (180 / M_PI);
|
||||
if (dX > 0 && dY > 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX > 0 && dY < 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX < 0 && dY > 0)
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return 180 + fAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return fAngle - 180;
|
||||
}
|
||||
}
|
||||
double CSlice::GetSweepAngle(const double& angleStart, const double& angleEnd)
|
||||
{
|
||||
if (angleStart >= angleEnd)
|
||||
return angleEnd - angleStart;
|
||||
else
|
||||
return angleEnd - angleStart - 360;
|
||||
}
|
||||
void CSlice::ApplyElliptical(bool& bIsX, double& angleStart, double& angleSweet,
|
||||
double& Left, double& Top, double& Width, double& Height, const CGeomShapeInfo::CPointD& pointCur)
|
||||
{
|
||||
// (x - y - x...)
|
||||
if (bIsX)
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = 90;
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = -90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
angleSweet = -90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = -90;
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
angleSweet = 90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = 90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
}
|
||||
bIsX = !bIsX;
|
||||
}
|
||||
void CSlice::ApplyLimo(CGeomShapeInfo& pGeomInfo, double& lX, double& lY)
|
||||
{
|
||||
if ((0 == pGeomInfo.m_dLimoX) || (0 == pGeomInfo.m_dLimoY))
|
||||
return;
|
||||
|
||||
double dAspect = (double)pGeomInfo.m_dLimoX / pGeomInfo.m_dLimoY;
|
||||
double lWidth = (dAspect * pGeomInfo.m_dHeight);
|
||||
|
||||
if (lWidth < pGeomInfo.m_dWidth)
|
||||
{
|
||||
// LimoX
|
||||
double lXc = pGeomInfo.m_dLeft + pGeomInfo.m_dWidth / 2;
|
||||
if ((lX > lXc) || ((lX == lXc) && (pGeomInfo.m_oCurPoint.dX >= lXc)))
|
||||
{
|
||||
double lXNew = pGeomInfo.m_dLeft + ((lWidth / pGeomInfo.m_dWidth) * (lX - pGeomInfo.m_dLeft));
|
||||
lXNew += (pGeomInfo.m_dWidth - lWidth);
|
||||
lX = lXNew;
|
||||
}
|
||||
//if (lX >= lXc)
|
||||
//{
|
||||
// LONG lXNew = pGeomInfo->m_lLeft + (LONG)(((double)lWidth / pGeomInfo->m_lWidth) * (lX - pGeomInfo->m_lLeft));
|
||||
// if (pGeomInfo->m_oCurPoint.x >= lXc)
|
||||
// {
|
||||
// lXNew += (pGeomInfo->m_lWidth - lWidth);
|
||||
// }
|
||||
// lX = lXNew;
|
||||
//}
|
||||
}
|
||||
else if (lWidth != pGeomInfo.m_dWidth)
|
||||
{
|
||||
// LimoY
|
||||
double lHeight = (pGeomInfo.m_dWidth / dAspect);
|
||||
double lYc = pGeomInfo.m_dTop + pGeomInfo.m_dHeight / 2;
|
||||
if ((lY > lYc) || ((lY == lYc) && (pGeomInfo.m_oCurPoint.dY >= lYc)))
|
||||
{
|
||||
double lYNew = pGeomInfo.m_dTop + ((lHeight / pGeomInfo.m_dHeight) * (lY - pGeomInfo.m_dTop));
|
||||
lYNew += (pGeomInfo.m_dHeight - lHeight);
|
||||
lY = lYNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
void CSlice::Bez2_3(std::vector<CGeomShapeInfo::CPointD>& oArray, RulesType& eType)
|
||||
{
|
||||
if (rtQuadrBesier == eType)
|
||||
{
|
||||
eType = rtCurveTo;
|
||||
}
|
||||
else if (rtOOXMLQuadBezTo == eType)
|
||||
{
|
||||
eType = rtOOXMLCubicBezTo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<CGeomShapeInfo::CPointD> arOld;
|
||||
arOld.insert(arOld.end(),oArray.begin(), oArray.end());
|
||||
|
||||
oArray.clear();
|
||||
|
||||
size_t nStart = 0;
|
||||
size_t nEnd = 2;
|
||||
|
||||
size_t nCount = arOld.size();
|
||||
while (nStart < (nCount - 1))
|
||||
{
|
||||
if (2 >= (nCount - nStart))
|
||||
{
|
||||
// по идее такого быть не может
|
||||
for (size_t i = nStart; i < nCount; ++i)
|
||||
{
|
||||
oArray.push_back(arOld[i]);
|
||||
}
|
||||
|
||||
nStart = nCount;
|
||||
break;
|
||||
}
|
||||
|
||||
if (4 == (nCount - nStart))
|
||||
{
|
||||
// ничего не поделаешь... делаем кривую третьего порядка
|
||||
oArray.push_back(arOld[nStart]);
|
||||
oArray.push_back(arOld[nStart + 1]);
|
||||
oArray.push_back(arOld[nStart + 2]);
|
||||
oArray.push_back(arOld[nStart + 3]);
|
||||
|
||||
nStart += 4;
|
||||
break;
|
||||
}
|
||||
|
||||
// значит есть еще
|
||||
CGeomShapeInfo::CPointD mem1;
|
||||
mem1.dX = (arOld[nStart].dX + 2 * arOld[nStart + 1].dX) / 3.0;
|
||||
mem1.dY = (arOld[nStart].dY + 2 * arOld[nStart + 1].dY) / 3.0;
|
||||
|
||||
CGeomShapeInfo::CPointD mem2;
|
||||
mem2.dX = (2 * arOld[nStart + 1].dX + arOld[nStart + 2].dX) / 3.0;
|
||||
mem2.dY = (2 * arOld[nStart + 1].dY + arOld[nStart + 2].dY) / 3.0;
|
||||
|
||||
oArray.push_back(mem1);
|
||||
oArray.push_back(mem2);
|
||||
oArray.push_back(arOld[nStart + 2]);
|
||||
|
||||
nStart += 2;
|
||||
}
|
||||
}
|
||||
|
||||
CPartPath::CPartPath() : m_arSlices()
|
||||
{
|
||||
m_bFill = true;
|
||||
m_bStroke = true;
|
||||
|
||||
width = ShapeSizeVML;
|
||||
height = ShapeSizeVML; //43200?
|
||||
}
|
||||
void CPartPath::FromXML(std::wstring strPath, NSCustomShapesConvert::CFormulasManager& pManager)
|
||||
{
|
||||
NSStringUtils::CheckPathOn_Fill_Stroke(strPath, m_bFill, m_bStroke);
|
||||
std::vector<std::wstring> oArray;
|
||||
|
||||
NSStringUtils::ParsePath2(strPath, &oArray);
|
||||
|
||||
ParamType eParamType = ptValue;
|
||||
RulesType eRuler = rtEnd;
|
||||
LONG lValue;
|
||||
bool bRes = true;
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oArray.size(); ++nIndex)
|
||||
{
|
||||
lValue = GetValue(oArray[nIndex], eParamType, bRes);
|
||||
if (bRes)
|
||||
{
|
||||
switch (eParamType)
|
||||
{
|
||||
case ptFormula: { lValue = pManager.m_arResults[lValue]; break; }
|
||||
case ptAdjust: { lValue = (*(pManager.m_pAdjustments))[lValue]; break; }
|
||||
default: break;
|
||||
};
|
||||
if (0 != m_arSlices.size())
|
||||
{
|
||||
m_arSlices[m_arSlices.size() - 1].AddParam(lValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eRuler = GetRuler(oArray[nIndex], bRes);
|
||||
if (bRes)
|
||||
{
|
||||
if (rtNoFill == eRuler)
|
||||
{
|
||||
m_bFill = false;
|
||||
}
|
||||
else if (rtNoStroke == eRuler)
|
||||
{
|
||||
m_bStroke = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSlice oSlice(eRuler);
|
||||
m_arSlices.push_back(oSlice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CPartPath& CPartPath::operator =(const CPartPath& oSrc)
|
||||
{
|
||||
m_bFill = oSrc.m_bFill;
|
||||
m_bStroke = oSrc.m_bStroke;
|
||||
|
||||
width = oSrc.width;
|
||||
height = oSrc.height;
|
||||
|
||||
m_arSlices.clear();
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arSlices.size(); ++nIndex)
|
||||
{
|
||||
m_arSlices.push_back(oSrc.m_arSlices[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void CPath::FromXML(std::wstring strPath, NSCustomShapesConvert::CFormulasManager& pManager)
|
||||
{
|
||||
m_arParts.clear();
|
||||
std::vector<std::wstring> oArray;
|
||||
|
||||
NSStringUtils::ParseString(_T("e"), strPath, oArray);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oArray.size(); ++nIndex)
|
||||
{
|
||||
CPartPath oPath;
|
||||
m_arParts.push_back(oPath);
|
||||
m_arParts.back().FromXML(oArray[nIndex], pManager);
|
||||
}
|
||||
}
|
||||
CPath& CPath::operator =(const CPath& oSrc)
|
||||
{
|
||||
m_arParts.clear();
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arParts.size(); ++nIndex)
|
||||
{
|
||||
m_arParts.push_back(oSrc.m_arParts[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
void CPath::SetCoordsize(LONG lWidth, LONG lHeight)
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < m_arParts.size(); ++nIndex)
|
||||
{
|
||||
m_arParts[nIndex].width = lWidth;
|
||||
m_arParts[nIndex].height = lHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -237,287 +237,22 @@ namespace NSCustomShapesConvert
|
||||
//LONG m_lX;
|
||||
//LONG m_lY;
|
||||
|
||||
CSlice(RulesType eType = rtMoveTo/*, LONG x = 0, LONG y = 0*/)
|
||||
{
|
||||
m_eRuler = eType;
|
||||
m_nCountElementsPoint = 0;
|
||||
//m_lX = x;
|
||||
//m_lY = y;
|
||||
}
|
||||
CSlice(RulesType eType = rtMoveTo/*, LONG x = 0, LONG y = 0*/);
|
||||
|
||||
void AddParam(LONG lParam);
|
||||
CSlice& operator =(const CSlice& oSrc);
|
||||
|
||||
void AddParam(LONG lParam)
|
||||
{
|
||||
long lPoint = m_nCountElementsPoint % 2;
|
||||
if (0 == lPoint)
|
||||
{
|
||||
Aggplus::POINT point;
|
||||
point.x = lParam/* - m_lX*/;
|
||||
point.y = 0;
|
||||
m_arPoints.push_back(point);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_arPoints[m_arPoints.size() - 1].y = lParam/* - m_lY*/;
|
||||
}
|
||||
++m_nCountElementsPoint;
|
||||
}
|
||||
CSlice& operator =(const CSlice& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_arPoints.clear();
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arPoints.size(); ++nIndex)
|
||||
{
|
||||
m_arPoints.push_back(oSrc.m_arPoints[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
protected:
|
||||
double GetAngle(double fCentreX, double fCentreY, double fX, double fY)
|
||||
{
|
||||
// - + (.. )
|
||||
double dX = fX - fCentreX;
|
||||
double dY = fY - fCentreY;
|
||||
double GetAngle(double fCentreX, double fCentreY, double fX, double fY);
|
||||
|
||||
double modDX = abs(dX);
|
||||
double modDY = abs(dY);
|
||||
|
||||
if ((modDX < 0.01) && (modDY < 0.01))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ((modDX < 0.01) && (dY < 0))
|
||||
{
|
||||
return -90;
|
||||
}
|
||||
else if (modDX < 0.01)
|
||||
{
|
||||
return 90;
|
||||
}
|
||||
if ((modDY < 0.01) && (dX < 0))
|
||||
{
|
||||
return 180;
|
||||
}
|
||||
else if (modDY < 0.01)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double fAngle = atan(dY / dX);
|
||||
fAngle *= (180 / M_PI);
|
||||
if (dX > 0 && dY > 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX > 0 && dY < 0)
|
||||
{
|
||||
return fAngle;
|
||||
}
|
||||
else if (dX < 0 && dY > 0)
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return 180 + fAngle;
|
||||
}
|
||||
else
|
||||
{
|
||||
//return fAngle + 180;
|
||||
return fAngle - 180;
|
||||
}
|
||||
}
|
||||
|
||||
inline double GetSweepAngle(const double& angleStart, const double& angleEnd)
|
||||
{
|
||||
if (angleStart >= angleEnd)
|
||||
return angleEnd - angleStart;
|
||||
else
|
||||
return angleEnd - angleStart - 360;
|
||||
}
|
||||
double GetSweepAngle(const double& angleStart, const double& angleEnd);
|
||||
|
||||
void ApplyElliptical(bool& bIsX, double& angleStart, double& angleSweet,
|
||||
double& Left, double& Top, double& Width, double& Height, const CGeomShapeInfo::CPointD& pointCur)
|
||||
{
|
||||
// (x - y - x...)
|
||||
if (bIsX)
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = 90;
|
||||
double& Left, double& Top, double& Width, double& Height, const CGeomShapeInfo::CPointD& pointCur);
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = -90;
|
||||
angleSweet = -90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 90;
|
||||
angleSweet = -90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY - Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX - Width / 2;
|
||||
Top = pointCur.dY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = -90;
|
||||
void ApplyLimo(CGeomShapeInfo& pGeomInfo, double& lX, double& lY);
|
||||
|
||||
if ((Width < 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
Width *= -1;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width < 0) && (Height > 0))
|
||||
{
|
||||
angleStart = 0;
|
||||
angleSweet = 90;
|
||||
Width *= -1;
|
||||
Left = pointCur.dX - Width;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else if ((Width > 0) && (Height < 0))
|
||||
{
|
||||
angleStart = 180;
|
||||
angleSweet = 90;
|
||||
Height *= -1;
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
Left = pointCur.dX;
|
||||
Top = pointCur.dY - Height / 2;
|
||||
}
|
||||
}
|
||||
bIsX = !bIsX;
|
||||
}
|
||||
|
||||
void ApplyLimo(CGeomShapeInfo& pGeomInfo, double& lX, double& lY)
|
||||
{
|
||||
if ((0 == pGeomInfo.m_dLimoX) || (0 == pGeomInfo.m_dLimoY))
|
||||
return;
|
||||
|
||||
double dAspect = (double)pGeomInfo.m_dLimoX / pGeomInfo.m_dLimoY;
|
||||
double lWidth = (dAspect * pGeomInfo.m_dHeight);
|
||||
|
||||
if (lWidth < pGeomInfo.m_dWidth)
|
||||
{
|
||||
// LimoX
|
||||
double lXc = pGeomInfo.m_dLeft + pGeomInfo.m_dWidth / 2;
|
||||
if ((lX > lXc) || ((lX == lXc) && (pGeomInfo.m_oCurPoint.dX >= lXc)))
|
||||
{
|
||||
double lXNew = pGeomInfo.m_dLeft + ((lWidth / pGeomInfo.m_dWidth) * (lX - pGeomInfo.m_dLeft));
|
||||
lXNew += (pGeomInfo.m_dWidth - lWidth);
|
||||
lX = lXNew;
|
||||
}
|
||||
//if (lX >= lXc)
|
||||
//{
|
||||
// LONG lXNew = pGeomInfo->m_lLeft + (LONG)(((double)lWidth / pGeomInfo->m_lWidth) * (lX - pGeomInfo->m_lLeft));
|
||||
// if (pGeomInfo->m_oCurPoint.x >= lXc)
|
||||
// {
|
||||
// lXNew += (pGeomInfo->m_lWidth - lWidth);
|
||||
// }
|
||||
// lX = lXNew;
|
||||
//}
|
||||
}
|
||||
else if (lWidth != pGeomInfo.m_dWidth)
|
||||
{
|
||||
// LimoY
|
||||
double lHeight = (pGeomInfo.m_dWidth / dAspect);
|
||||
double lYc = pGeomInfo.m_dTop + pGeomInfo.m_dHeight / 2;
|
||||
if ((lY > lYc) || ((lY == lYc) && (pGeomInfo.m_oCurPoint.dY >= lYc)))
|
||||
{
|
||||
double lYNew = pGeomInfo.m_dTop + ((lHeight / pGeomInfo.m_dHeight) * (lY - pGeomInfo.m_dTop));
|
||||
lYNew += (pGeomInfo.m_dHeight - lHeight);
|
||||
lY = lYNew;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Bez2_3(std::vector<CGeomShapeInfo::CPointD>& oArray, RulesType& eType)
|
||||
{
|
||||
if (rtQuadrBesier == eType)
|
||||
{
|
||||
eType = rtCurveTo;
|
||||
}
|
||||
else if (rtOOXMLQuadBezTo == eType)
|
||||
{
|
||||
eType = rtOOXMLCubicBezTo;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<CGeomShapeInfo::CPointD> arOld;
|
||||
arOld.insert(arOld.end(),oArray.begin(), oArray.end());
|
||||
|
||||
oArray.clear();
|
||||
|
||||
size_t nStart = 0;
|
||||
size_t nEnd = 2;
|
||||
|
||||
size_t nCount = arOld.size();
|
||||
while (nStart < (nCount - 1))
|
||||
{
|
||||
if (2 >= (nCount - nStart))
|
||||
{
|
||||
// по идее такого быть не может
|
||||
for (size_t i = nStart; i < nCount; ++i)
|
||||
{
|
||||
oArray.push_back(arOld[i]);
|
||||
}
|
||||
|
||||
nStart = nCount;
|
||||
break;
|
||||
}
|
||||
|
||||
if (4 == (nCount - nStart))
|
||||
{
|
||||
// ничего не поделаешь... делаем кривую третьего порядка
|
||||
oArray.push_back(arOld[nStart]);
|
||||
oArray.push_back(arOld[nStart + 1]);
|
||||
oArray.push_back(arOld[nStart + 2]);
|
||||
oArray.push_back(arOld[nStart + 3]);
|
||||
|
||||
nStart += 4;
|
||||
break;
|
||||
}
|
||||
|
||||
// значит есть еще
|
||||
CGeomShapeInfo::CPointD mem1;
|
||||
mem1.dX = (arOld[nStart].dX + 2 * arOld[nStart + 1].dX) / 3.0;
|
||||
mem1.dY = (arOld[nStart].dY + 2 * arOld[nStart + 1].dY) / 3.0;
|
||||
|
||||
CGeomShapeInfo::CPointD mem2;
|
||||
mem2.dX = (2 * arOld[nStart + 1].dX + arOld[nStart + 2].dX) / 3.0;
|
||||
mem2.dY = (2 * arOld[nStart + 1].dY + arOld[nStart + 2].dY) / 3.0;
|
||||
|
||||
oArray.push_back(mem1);
|
||||
oArray.push_back(mem2);
|
||||
oArray.push_back(arOld[nStart + 2]);
|
||||
|
||||
nStart += 2;
|
||||
}
|
||||
}
|
||||
void Bez2_3(std::vector<CGeomShapeInfo::CPointD>& oArray, RulesType& eType);
|
||||
};
|
||||
|
||||
class CPartPath
|
||||
@ -530,81 +265,10 @@ namespace NSCustomShapesConvert
|
||||
std::vector<CSlice> m_arSlices;
|
||||
|
||||
public:
|
||||
CPartPath() : m_arSlices()
|
||||
{
|
||||
m_bFill = true;
|
||||
m_bStroke = true;
|
||||
|
||||
width = ShapeSizeVML;
|
||||
height = ShapeSizeVML; //43200?
|
||||
}
|
||||
void FromXML(std::wstring strPath, NSCustomShapesConvert::CFormulasManager& pManager)
|
||||
{
|
||||
NSStringUtils::CheckPathOn_Fill_Stroke(strPath, m_bFill, m_bStroke);
|
||||
std::vector<std::wstring> oArray;
|
||||
CPartPath();
|
||||
|
||||
NSStringUtils::ParsePath2(strPath, &oArray);
|
||||
|
||||
ParamType eParamType = ptValue;
|
||||
RulesType eRuler = rtEnd;
|
||||
LONG lValue;
|
||||
bool bRes = true;
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oArray.size(); ++nIndex)
|
||||
{
|
||||
lValue = GetValue(oArray[nIndex], eParamType, bRes);
|
||||
if (bRes)
|
||||
{
|
||||
switch (eParamType)
|
||||
{
|
||||
case ptFormula: { lValue = pManager.m_arResults[lValue]; break; }
|
||||
case ptAdjust: { lValue = (*(pManager.m_pAdjustments))[lValue]; break; }
|
||||
default: break;
|
||||
};
|
||||
if (0 != m_arSlices.size())
|
||||
{
|
||||
m_arSlices[m_arSlices.size() - 1].AddParam(lValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eRuler = GetRuler(oArray[nIndex], bRes);
|
||||
if (bRes)
|
||||
{
|
||||
if (rtNoFill == eRuler)
|
||||
{
|
||||
m_bFill = false;
|
||||
}
|
||||
else if (rtNoStroke == eRuler)
|
||||
{
|
||||
m_bStroke = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSlice oSlice(eRuler);
|
||||
m_arSlices.push_back(oSlice);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CPartPath& operator =(const CPartPath& oSrc)
|
||||
{
|
||||
m_bFill = oSrc.m_bFill;
|
||||
m_bStroke = oSrc.m_bStroke;
|
||||
|
||||
width = oSrc.width;
|
||||
height = oSrc.height;
|
||||
|
||||
m_arSlices.clear();
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arSlices.size(); ++nIndex)
|
||||
{
|
||||
m_arSlices.push_back(oSrc.m_arSlices[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
void FromXML(std::wstring strPath, NSCustomShapesConvert::CFormulasManager& pManager);
|
||||
CPartPath& operator =(const CPartPath& oSrc);
|
||||
};
|
||||
|
||||
class CPath
|
||||
@ -612,39 +276,9 @@ namespace NSCustomShapesConvert
|
||||
public:
|
||||
std::vector<CPartPath> m_arParts;
|
||||
|
||||
void FromXML(std::wstring strPath, NSCustomShapesConvert::CFormulasManager& pManager)
|
||||
{
|
||||
m_arParts.clear();
|
||||
std::vector<std::wstring> oArray;
|
||||
void FromXML(std::wstring strPath, NSCustomShapesConvert::CFormulasManager& pManager);
|
||||
|
||||
NSStringUtils::ParseString(_T("e"), strPath, oArray);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oArray.size(); ++nIndex)
|
||||
{
|
||||
CPartPath oPath;
|
||||
m_arParts.push_back(oPath);
|
||||
m_arParts.back().FromXML(oArray[nIndex], pManager);
|
||||
}
|
||||
}
|
||||
|
||||
CPath& operator =(const CPath& oSrc)
|
||||
{
|
||||
m_arParts.clear();
|
||||
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arParts.size(); ++nIndex)
|
||||
{
|
||||
m_arParts.push_back(oSrc.m_arParts[nIndex]);
|
||||
}
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void SetCoordsize(LONG lWidth, LONG lHeight)
|
||||
{
|
||||
for (size_t nIndex = 0; nIndex < m_arParts.size(); ++nIndex)
|
||||
{
|
||||
m_arParts[nIndex].width = lWidth;
|
||||
m_arParts[nIndex].height = lHeight;
|
||||
}
|
||||
}
|
||||
CPath& operator =(const CPath& oSrc);
|
||||
void SetCoordsize(LONG lWidth, LONG lHeight);
|
||||
};
|
||||
}
|
||||
|
||||
274
MsBinaryFile/Common/ODraw/XmlWriter.cpp
Normal file
274
MsBinaryFile/Common/ODraw/XmlWriter.cpp
Normal file
@ -0,0 +1,274 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "XmlWriter.h"
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
{
|
||||
CXmlWriter::CXmlWriter() : m_oWriter()
|
||||
{
|
||||
}
|
||||
CXmlWriter::~CXmlWriter()
|
||||
{
|
||||
}
|
||||
|
||||
std::wstring CXmlWriter::GetXmlString()
|
||||
{
|
||||
return m_oWriter.GetData();
|
||||
}
|
||||
void CXmlWriter::ClearNoAttack()
|
||||
{
|
||||
m_oWriter.ClearNoAttack();
|
||||
}
|
||||
int CXmlWriter::GetSize()
|
||||
{
|
||||
return (int)m_oWriter.GetCurSize();
|
||||
}
|
||||
|
||||
// write value
|
||||
void CXmlWriter::WriteString(const std::wstring& strValue)
|
||||
{
|
||||
m_oWriter.WriteString(strValue);
|
||||
}
|
||||
void CXmlWriter::WriteStringXML(std::wstring strValue)
|
||||
{
|
||||
m_oWriter.WriteEncodeXmlString(strValue);
|
||||
}
|
||||
void CXmlWriter::WriteDouble(const double& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
}
|
||||
void CXmlWriter::WriteLONG(const long& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void CXmlWriter::WriteINT(const int& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void CXmlWriter::WriteDWORD(const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void CXmlWriter::WriteDWORD_hex(const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void CXmlWriter::WriteBool(const bool& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const std::wstring& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
m_oWriter.WriteString(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute2(const std::wstring& strAttributeName, const std::wstring& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
m_oWriter.WriteEncodeXmlString(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const double& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteDouble(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const int& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteINT(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const bool& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteBool(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const LONG& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteLONG(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttribute(const std::wstring& strAttributeName, const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteDWORD(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void CXmlWriter::WriteAttributeDWORD_hex(const std::wstring& strAttributeName, const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteDWORD_hex(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
// document methods
|
||||
void CXmlWriter::WriteNodeBegin(std::wstring strNodeName, bool bAttributed)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen);
|
||||
m_oWriter.WriteString(strNodeName);
|
||||
|
||||
if (!bAttributed)
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
void CXmlWriter::WriteNodeEnd(std::wstring strNodeName, bool bEmptyNode, bool bEndNode)
|
||||
{
|
||||
if (bEmptyNode)
|
||||
{
|
||||
if (bEndNode)
|
||||
m_oWriter.WriteString(g_bstr_nodeclose_slash);
|
||||
else
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen_slash);
|
||||
m_oWriter.WriteString(strNodeName);
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
}
|
||||
// write node values
|
||||
void CXmlWriter::WriteNodeValue(const std::wstring& strNodeName, const std::wstring& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteString(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void CXmlWriter::WriteNodeValue(const std::wstring& strNodeName, const bool& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
|
||||
if (val)
|
||||
WriteString(_T("1"));
|
||||
else
|
||||
WriteString(_T("0"));
|
||||
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void CXmlWriter::WriteNodeValue(const std::wstring& strNodeName, const double& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteDouble(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void CXmlWriter::WriteNodeValue(const std::wstring& strNodeName, const LONG& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteLONG(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void CXmlWriter::WriteNodeValue(const std::wstring& strNodeName, const int& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteINT(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void CXmlWriter::WriteNodeValue(const std::wstring& strNodeName, const DWORD& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteDWORD(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void CXmlWriter::WriteNodeValueDWORD_hex(const std::wstring& strNodeName, const DWORD& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteDWORD_hex(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
|
||||
void CXmlWriter::StartNode(const std::wstring& name)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen);
|
||||
m_oWriter.WriteString(name);
|
||||
}
|
||||
void CXmlWriter::StartAttributes()
|
||||
{
|
||||
// none
|
||||
}
|
||||
void CXmlWriter::EndAttributes()
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
void CXmlWriter::EndNode(const std::wstring& name)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen_slash);
|
||||
m_oWriter.WriteString(name);
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
void CXmlWriter::ReplaceString(std::wstring from, std::wstring to)
|
||||
{
|
||||
// ужасная функция. вызывать ее не надо. не для этого класс писался.
|
||||
std::wstring sCur = m_oWriter.GetData();
|
||||
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = sCur .find(from, start_pos)) != std::wstring::npos)
|
||||
{
|
||||
sCur .replace(start_pos, from.length(), to);
|
||||
start_pos += to.length();
|
||||
}
|
||||
|
||||
ClearNoAttack();
|
||||
WriteString(sCur);
|
||||
}
|
||||
}
|
||||
@ -60,230 +60,47 @@ namespace NSCustomShapesConvert
|
||||
public:
|
||||
NSStringUtils::CStringBuilder m_oWriter;
|
||||
|
||||
CXmlWriter() : m_oWriter()
|
||||
{
|
||||
}
|
||||
~CXmlWriter()
|
||||
{
|
||||
}
|
||||
CXmlWriter();
|
||||
~CXmlWriter();
|
||||
|
||||
std::wstring GetXmlString()
|
||||
{
|
||||
return m_oWriter.GetData();
|
||||
}
|
||||
void ClearNoAttack()
|
||||
{
|
||||
m_oWriter.ClearNoAttack();
|
||||
}
|
||||
int GetSize()
|
||||
{
|
||||
return (int)m_oWriter.GetCurSize();
|
||||
}
|
||||
std::wstring GetXmlString();
|
||||
void ClearNoAttack();
|
||||
int GetSize();
|
||||
|
||||
// write value
|
||||
void WriteString(const std::wstring& strValue)
|
||||
{
|
||||
m_oWriter.WriteString(strValue);
|
||||
}
|
||||
void WriteStringXML(std::wstring strValue)
|
||||
{
|
||||
m_oWriter.WriteEncodeXmlString(strValue);
|
||||
}
|
||||
void WriteDouble(const double& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
}
|
||||
void WriteLONG(const long& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void WriteINT(const int& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void WriteDWORD(const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void WriteDWORD_hex(const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
|
||||
}
|
||||
void WriteBool(const bool& val)
|
||||
{
|
||||
m_oWriter.WriteString(XmlUtils::ToString(val));
|
||||
}
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
m_oWriter.WriteString(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttribute2(const std::wstring& strAttributeName, const std::wstring& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
m_oWriter.WriteEncodeXmlString(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const double& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteDouble(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const int& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteINT(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const bool& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteBool(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const LONG& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteLONG(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteDWORD(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteAttributeDWORD_hex(const std::wstring& strAttributeName, const DWORD& val)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_node_space);
|
||||
m_oWriter.WriteString(strAttributeName);
|
||||
m_oWriter.WriteString(g_bstr_node_equal);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
WriteDWORD_hex(val);
|
||||
m_oWriter.WriteString(g_bstr_node_quote);
|
||||
}
|
||||
void WriteString(const std::wstring& strValue);
|
||||
void WriteStringXML(std::wstring strValue);
|
||||
void WriteDouble(const double& val);
|
||||
void WriteLONG(const long& val);
|
||||
void WriteINT(const int& val);
|
||||
void WriteDWORD(const DWORD& val);
|
||||
void WriteDWORD_hex(const DWORD& val);
|
||||
void WriteBool(const bool& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const std::wstring& val);
|
||||
void WriteAttribute2(const std::wstring& strAttributeName, const std::wstring& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const double& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const int& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const bool& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const LONG& val);
|
||||
void WriteAttribute(const std::wstring& strAttributeName, const DWORD& val);
|
||||
void WriteAttributeDWORD_hex(const std::wstring& strAttributeName, const DWORD& val);
|
||||
// document methods
|
||||
void WriteNodeBegin(std::wstring strNodeName, bool bAttributed = false)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen);
|
||||
m_oWriter.WriteString(strNodeName);
|
||||
|
||||
if (!bAttributed)
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
void WriteNodeEnd(std::wstring strNodeName, bool bEmptyNode = false, bool bEndNode = true)
|
||||
{
|
||||
if (bEmptyNode)
|
||||
{
|
||||
if (bEndNode)
|
||||
m_oWriter.WriteString(g_bstr_nodeclose_slash);
|
||||
else
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen_slash);
|
||||
m_oWriter.WriteString(strNodeName);
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
}
|
||||
void WriteNodeBegin(std::wstring strNodeName, bool bAttributed = false);
|
||||
void WriteNodeEnd(std::wstring strNodeName, bool bEmptyNode = false, bool bEndNode = true);
|
||||
// write node values
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const std::wstring& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteString(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const bool& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
|
||||
if (val)
|
||||
WriteString(_T("1"));
|
||||
else
|
||||
WriteString(_T("0"));
|
||||
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const double& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteDouble(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const LONG& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteLONG(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const int& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteINT(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const DWORD& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteDWORD(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValueDWORD_hex(const std::wstring& strNodeName, const DWORD& val)
|
||||
{
|
||||
WriteNodeBegin(strNodeName);
|
||||
WriteDWORD_hex(val);
|
||||
WriteNodeEnd(strNodeName);
|
||||
}
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const std::wstring& val);
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const bool& val);
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const double& val);
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const LONG& val);
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const int& val);
|
||||
void WriteNodeValue(const std::wstring& strNodeName, const DWORD& val);
|
||||
void WriteNodeValueDWORD_hex(const std::wstring& strNodeName, const DWORD& val);
|
||||
|
||||
public:
|
||||
|
||||
void StartNode(const std::wstring& name)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen);
|
||||
m_oWriter.WriteString(name);
|
||||
}
|
||||
void StartAttributes()
|
||||
{
|
||||
// none
|
||||
}
|
||||
void EndAttributes()
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
void EndNode(const std::wstring& name)
|
||||
{
|
||||
m_oWriter.WriteString(g_bstr_nodeopen_slash);
|
||||
m_oWriter.WriteString(name);
|
||||
m_oWriter.WriteString(g_bstr_nodeclose);
|
||||
}
|
||||
void StartNode(const std::wstring& name);
|
||||
void StartAttributes();
|
||||
void EndAttributes();
|
||||
void EndNode(const std::wstring& name);
|
||||
|
||||
template<typename T>
|
||||
void WriteArray(const std::wstring& strName, const std::vector<T>& arr)
|
||||
@ -313,20 +130,6 @@ namespace NSCustomShapesConvert
|
||||
|
||||
// -------------------------------------------------------------------------------------
|
||||
|
||||
void ReplaceString(std::wstring from, std::wstring to)
|
||||
{
|
||||
// ужасная функция. вызывать ее не надо. не для этого класс писался.
|
||||
std::wstring sCur = m_oWriter.GetData();
|
||||
|
||||
size_t start_pos = 0;
|
||||
while((start_pos = sCur .find(from, start_pos)) != std::wstring::npos)
|
||||
{
|
||||
sCur .replace(start_pos, from.length(), to);
|
||||
start_pos += to.length();
|
||||
}
|
||||
|
||||
ClearNoAttack();
|
||||
WriteString(sCur);
|
||||
}
|
||||
void ReplaceString(std::wstring from, std::wstring to);
|
||||
};
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#define DEFINE_SHAPE_CLASS(Class, BaseClass) \
|
||||
#define DEFINE_SHAPE_CLASS(Class, BaseClass) \
|
||||
class Class : public BaseClass \
|
||||
{ \
|
||||
public: \
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
@ -29,22 +29,67 @@
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "BaseShape.h"
|
||||
#include "BinaryReader.h"
|
||||
#include "../../../../OOXML/Base/Base.h"
|
||||
|
||||
#include "CustomShape.h"
|
||||
|
||||
namespace NSCustomShapesConvert
|
||||
namespace ODRAW
|
||||
{
|
||||
CBaseShape* CBaseShape::CreateByType( int ShapeType)
|
||||
{
|
||||
return CCustomShape::CreateByType((oox::MSOSPT)ShapeType);
|
||||
}
|
||||
CBinaryReader::CBinaryReader(BYTE* pBuffer, DWORD lCount)
|
||||
{
|
||||
m_pBuffer = pBuffer;
|
||||
m_lCount = lCount;
|
||||
|
||||
bool CBaseShape::SetType( int ShapeType)
|
||||
{
|
||||
m_lOrigin = 0;
|
||||
}
|
||||
CBinaryReader::~CBinaryReader()
|
||||
{
|
||||
m_pBuffer = NULL;
|
||||
m_lCount = 0;
|
||||
}
|
||||
LONG CBinaryReader::ReadLONG() // int32 подразумевается
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 4;
|
||||
|
||||
return ((CCustomShape*)this)->SetShapeType((oox::MSOSPT)ShapeType);
|
||||
}
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(_INT32*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
DWORD CBinaryReader::ReadDWORD()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 4;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(DWORD*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
WORD CBinaryReader::ReadWORD()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 2;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(WORD*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
SHORT CBinaryReader::ReadSHORT()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 2;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(short*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
double CBinaryReader::ReadDOUBLE()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += sizeof(double);
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(SHORT*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,8 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
#include "../../../../../../DesktopEditor/common/Types.h"
|
||||
|
||||
#include "../../../../DesktopEditor/common/Types.h"
|
||||
|
||||
namespace ODRAW
|
||||
{
|
||||
@ -50,63 +51,13 @@ namespace ODRAW
|
||||
DWORD m_lOrigin;
|
||||
|
||||
public:
|
||||
CBinaryReader(BYTE* pBuffer, DWORD lCount)
|
||||
{
|
||||
m_pBuffer = pBuffer;
|
||||
m_lCount = lCount;
|
||||
CBinaryReader(BYTE* pBuffer, DWORD lCount);
|
||||
~CBinaryReader();
|
||||
|
||||
m_lOrigin = 0;
|
||||
}
|
||||
~CBinaryReader()
|
||||
{
|
||||
m_pBuffer = NULL;
|
||||
m_lCount = 0;
|
||||
}
|
||||
|
||||
LONG ReadLONG() // int32 подразумевается
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 4;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(_INT32*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
DWORD ReadDWORD()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 4;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(DWORD*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
WORD ReadWORD()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 2;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(WORD*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
SHORT ReadSHORT()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += 2;
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(short*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
double ReadDOUBLE()
|
||||
{
|
||||
DWORD lOldOrigin = m_lOrigin;
|
||||
m_lOrigin += sizeof(double);
|
||||
|
||||
BINARY_READER_CHECK_OUT_RANGE(m_lOrigin, m_lCount)
|
||||
|
||||
return *(SHORT*)(m_pBuffer + lOldOrigin);
|
||||
}
|
||||
LONG ReadLONG(); // int32 подразумевается
|
||||
DWORD ReadDWORD();
|
||||
WORD ReadWORD();
|
||||
SHORT ReadSHORT();
|
||||
double ReadDOUBLE();
|
||||
};
|
||||
}
|
||||
|
||||
907
MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.cpp
Normal file
907
MsBinaryFile/Common/Vml/PPTShape/CustomGeomShape.cpp
Normal file
@ -0,0 +1,907 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "CustomGeomShape.h"
|
||||
|
||||
namespace NSCustomVML
|
||||
{
|
||||
CSegment::CSegment(ODRAW::RulesType eType, WORD nCount)
|
||||
{
|
||||
m_eRuler = eType;
|
||||
m_nCount = nCount;
|
||||
}
|
||||
CSegment::CSegment(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
}
|
||||
CSegment& CSegment::operator=(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
CSegment::~CSegment()
|
||||
{
|
||||
}
|
||||
int CSegment::Read(WORD value)//from rtf segments
|
||||
{
|
||||
int repeate = 0;
|
||||
if (value >= 0x2000 && value < 0x20FF)
|
||||
{
|
||||
repeate = value & 0x0FFF;
|
||||
value &= 0xFF00;
|
||||
}
|
||||
|
||||
m_nCount = 0;
|
||||
switch (value)
|
||||
{
|
||||
case 0x0001: // lineto
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
m_nCount = 1;
|
||||
break;
|
||||
case 0x4000: // moveto
|
||||
m_eRuler = ODRAW::rtMoveTo;
|
||||
m_nCount = 1;
|
||||
break;
|
||||
case 0x2000: // curveto
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
m_nCount = 3;
|
||||
break;
|
||||
case 0xb300: // arcto
|
||||
m_eRuler = ODRAW::rtArc;
|
||||
m_nCount = 2;
|
||||
break;
|
||||
case 0xac00:
|
||||
case 0xaa00: // nofill
|
||||
case 0xad00:
|
||||
m_eRuler = ODRAW::rtNoFill;
|
||||
break;
|
||||
case 0xab00: // nostroke
|
||||
m_eRuler = ODRAW::rtNoStroke;
|
||||
break;
|
||||
case 0x6001: // close
|
||||
m_eRuler = ODRAW::rtClose;
|
||||
break;
|
||||
case 0x8000: // end
|
||||
m_eRuler = ODRAW::rtEnd;
|
||||
break;
|
||||
default: // given number of lineto elements
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
m_nCount = value;
|
||||
break;
|
||||
}
|
||||
return (std::max)(1, repeate);
|
||||
}
|
||||
void CSegment::Read(POLE::Stream* pStream)//from binary ms segments
|
||||
{
|
||||
WORD mem = StreamUtils::ReadWORD(pStream);
|
||||
BYTE type = mem & 0x07;
|
||||
|
||||
if (type <= 4)
|
||||
{
|
||||
m_eRuler = (ODRAW::RulesType)type;
|
||||
m_nCount = (mem >> 3) & 0x1FFF;
|
||||
return;
|
||||
}
|
||||
|
||||
mem = (mem >> 3) & 0x1FFF;
|
||||
type = mem & 0x1F;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
break;
|
||||
}
|
||||
case 0x01:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipseTo;
|
||||
break;
|
||||
}
|
||||
case 0x02:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipse;
|
||||
break;
|
||||
}
|
||||
case 0x03:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x04:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArc;
|
||||
break;
|
||||
}
|
||||
case 0x05:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x06:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArc;
|
||||
break;
|
||||
}
|
||||
case 0x07:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrX;
|
||||
break;
|
||||
}
|
||||
case 0x08:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrY;
|
||||
break;
|
||||
}
|
||||
case 0x09:
|
||||
{
|
||||
m_eRuler = ODRAW::rtQuadrBesier;
|
||||
break;
|
||||
}
|
||||
case 0x0A:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoFill;
|
||||
break;
|
||||
}
|
||||
case 0x0B:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoStroke;
|
||||
break;
|
||||
}
|
||||
case 0x15:
|
||||
{
|
||||
m_eRuler = ODRAW::rtFillColor;
|
||||
break;
|
||||
}
|
||||
case 0x16:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineColor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
}
|
||||
};
|
||||
|
||||
m_nCount = (mem >> 5) & 0x00FF;
|
||||
}
|
||||
void CSegment::Read(ODRAW::CBinaryReader& oReader)//from binary ms segments
|
||||
{
|
||||
WORD mem = oReader.ReadWORD();
|
||||
|
||||
BYTE type = (mem >> 13 & 0x07);
|
||||
if (type <= 4)
|
||||
{
|
||||
m_eRuler = (ODRAW::RulesType)type;
|
||||
m_nCount = (mem & 0x1FFF);
|
||||
m_nCount = (WORD)GetCountPoints2(m_eRuler, m_nCount);
|
||||
return;
|
||||
}
|
||||
|
||||
type = (mem >> 8) & 0x1F;
|
||||
mem = mem & 0xFF;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
break;
|
||||
}
|
||||
case 0x01:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipseTo;
|
||||
break;
|
||||
}
|
||||
case 0x02:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipse;
|
||||
break;
|
||||
}
|
||||
case 0x03:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x04:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArc;
|
||||
break;
|
||||
}
|
||||
case 0x05:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x06:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArc;
|
||||
break;
|
||||
}
|
||||
case 0x07:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrX;
|
||||
break;
|
||||
}
|
||||
case 0x08:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrY;
|
||||
break;
|
||||
}
|
||||
case 0x09:
|
||||
{
|
||||
m_eRuler = ODRAW::rtQuadrBesier;
|
||||
break;
|
||||
}
|
||||
case 0x0A:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoFill;
|
||||
break;
|
||||
}
|
||||
case 0x0B:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoStroke;
|
||||
break;
|
||||
}
|
||||
case 0x0C:
|
||||
case 0x10:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
break;
|
||||
}
|
||||
case 0x0D:
|
||||
case 0x0E:
|
||||
case 0x0F:
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
{
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
break;
|
||||
}
|
||||
case 0x15:
|
||||
{
|
||||
m_eRuler = ODRAW::rtFillColor;
|
||||
break;
|
||||
}
|
||||
case 0x16:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineColor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
}
|
||||
};
|
||||
|
||||
m_nCount = (WORD)mem;
|
||||
m_nCount = (WORD)GetCountPoints2(m_eRuler, m_nCount);
|
||||
//m_nCount = (WORD)GetCountPoints2(m_eRuler);
|
||||
}
|
||||
|
||||
CGuide::CGuide()
|
||||
{
|
||||
m_eType = NSGuidesVML::ftVal;
|
||||
|
||||
m_param_type1 = 0;
|
||||
m_param_type2 = 0;
|
||||
m_param_type3 = 0;
|
||||
|
||||
m_param_value1 = 0;
|
||||
m_param_value2 = 0;
|
||||
m_param_value3 = 0;
|
||||
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
}
|
||||
CGuide::CGuide(const CGuide& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CGuide& CGuide::operator=(const CGuide& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
|
||||
m_param_type1 = oSrc.m_param_type1;
|
||||
m_param_type2 = oSrc.m_param_type2;
|
||||
m_param_type3 = oSrc.m_param_type3;
|
||||
|
||||
m_param_value1 = oSrc.m_param_value1;
|
||||
m_param_value2 = oSrc.m_param_value2;
|
||||
m_param_value3 = oSrc.m_param_value3;
|
||||
|
||||
m_lShapeWidth = oSrc.m_lShapeWidth;
|
||||
m_lShapeHeight = oSrc.m_lShapeHeight;
|
||||
|
||||
return *this;
|
||||
}
|
||||
void CGuide::SetToFormula(NSGuidesVML::CFormula& oFormula)
|
||||
{
|
||||
oFormula.m_eFormulaType = m_eType;
|
||||
|
||||
SetParam(m_param_type1, m_param_value1, oFormula.m_eType1, oFormula.m_lParam1);
|
||||
SetParam(m_param_type2, m_param_value2, oFormula.m_eType2, oFormula.m_lParam2);
|
||||
SetParam(m_param_type3, m_param_value3, oFormula.m_eType3, oFormula.m_lParam3);
|
||||
}
|
||||
void CGuide::Read(POLE::Stream* pStream)
|
||||
{
|
||||
WORD ftType = StreamUtils::ReadWORD(pStream);
|
||||
|
||||
m_eType = NSGuidesVML::FormulaType(ftType & 0x1FFF);
|
||||
|
||||
m_param_type1 = (BYTE)(ftType & 0x04);
|
||||
m_param_type2 = (BYTE)(ftType & 0x02);
|
||||
m_param_type3 = (BYTE)(ftType & 0x01);
|
||||
|
||||
m_param_value1 = StreamUtils::ReadWORD(pStream);
|
||||
m_param_value2 = StreamUtils::ReadWORD(pStream);
|
||||
m_param_value3 = StreamUtils::ReadWORD(pStream);
|
||||
}
|
||||
void CGuide::Read(ODRAW::CBinaryReader& oReader)
|
||||
{
|
||||
WORD ftType = oReader.ReadWORD();
|
||||
|
||||
m_eType = NSGuidesVML::FormulaType(ftType & 0x1FFF);
|
||||
|
||||
m_param_type1 = (BYTE)(ftType & 0x04);
|
||||
m_param_type2 = (BYTE)(ftType & 0x02);
|
||||
m_param_type3 = (BYTE)(ftType & 0x01);
|
||||
|
||||
m_param_value1 = oReader.ReadWORD();
|
||||
m_param_value2 = oReader.ReadWORD();
|
||||
m_param_value3 = oReader.ReadWORD();
|
||||
}
|
||||
void CGuide::SetParam(BYTE type, WORD param, ParamType& param_type, LONG& param_value)
|
||||
{
|
||||
if (0 == type)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = (LONG)param;
|
||||
}
|
||||
|
||||
if (0x0140 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0141 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0142 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
if (0x0143 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0147 <= param) && (param <= 0x014E))
|
||||
{
|
||||
param_type = ptAdjust;
|
||||
param_value = (LONG)(param - 0x0147);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0400 <= param) && (param <= 0x047F))
|
||||
{
|
||||
param_type = ptFormula;
|
||||
param_value = (LONG)(param - 0x0400);
|
||||
return;
|
||||
}
|
||||
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
}
|
||||
|
||||
CCustomVML::CCustomVML() : m_pAdjustValues(NULL)
|
||||
{
|
||||
m_ePath = ODRAW::rtCurveTo/*rtLineTo*/;
|
||||
|
||||
m_bIsVerticesPresent = false;
|
||||
m_bIsPathPresent = false;
|
||||
}
|
||||
CCustomVML::CCustomVML(const CCustomVML& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
CCustomVML& CCustomVML::operator=(const CCustomVML& oSrc)
|
||||
{
|
||||
m_ePath = oSrc.m_ePath;
|
||||
|
||||
m_arVertices.clear();
|
||||
m_arVertices.insert(m_arVertices.end(), oSrc.m_arVertices.begin(), oSrc.m_arVertices.end());
|
||||
|
||||
m_arSegments.clear();
|
||||
m_arSegments.insert(m_arSegments.end(), oSrc.m_arSegments.begin(), oSrc.m_arSegments.end());
|
||||
|
||||
m_arGuides.clear();
|
||||
m_arGuides.insert(m_arGuides.end(), oSrc.m_arGuides.begin(), oSrc.m_arGuides.end());
|
||||
|
||||
m_pAdjustValues = oSrc.m_pAdjustValues;
|
||||
|
||||
m_bIsPathPresent = oSrc.m_bIsPathPresent;
|
||||
m_bIsVerticesPresent = oSrc.m_bIsVerticesPresent;
|
||||
|
||||
m_oBrush = oSrc.m_oBrush;
|
||||
m_oPen = oSrc.m_oPen;
|
||||
|
||||
return *this;
|
||||
}
|
||||
CCustomVML::~CCustomVML()
|
||||
{
|
||||
}
|
||||
bool CCustomVML::IsCustom()
|
||||
{
|
||||
return (m_bIsVerticesPresent && m_bIsPathPresent);
|
||||
}
|
||||
void CCustomVML::SetPath(ODRAW::RulesType ePath)
|
||||
{
|
||||
m_ePath = ePath;
|
||||
m_bIsPathPresent = true;
|
||||
}
|
||||
void CCustomVML::LoadVertices(std::vector<std::pair<int,int>> values)
|
||||
{
|
||||
if (!values.empty())
|
||||
m_bIsVerticesPresent = true;
|
||||
|
||||
m_arVertices.clear();
|
||||
|
||||
for (size_t ind = 0; ind < values.size(); ++ind)
|
||||
{
|
||||
Aggplus::POINT oPoint;
|
||||
|
||||
oPoint.x = values[ind].first;
|
||||
oPoint.y = values[ind].second;
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
LONG lMaxF = (LONG)0x8000007F;
|
||||
if (lMinF <= oPoint.x)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.x - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
if (lMinF <= oPoint.y)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.y - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
|
||||
m_arVertices.push_back(oPoint);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadConnectionSitesDir(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arConnectionSitesDir.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
_UINT32 v = oReader.ReadLONG();
|
||||
double val = (double)((WORD)(v >> 16) + ((WORD)(v) / 65536.0));
|
||||
m_arConnectionSitesDir.push_back(val);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadConnectionSites(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arConnectionSites.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 8);
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
}
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
Aggplus::POINT oPoint;
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
oPoint.x = (short)oReader.ReadWORD();
|
||||
oPoint.y = (short)oReader.ReadWORD();
|
||||
}
|
||||
else
|
||||
{
|
||||
oPoint.x = oReader.ReadLONG();
|
||||
oPoint.y = oReader.ReadLONG();
|
||||
}
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
LONG lMaxF = (LONG)0x8000007F;
|
||||
if (lMinF <= oPoint.x)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.x - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
if (lMinF <= oPoint.y)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.y - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
|
||||
m_arConnectionSites.push_back(oPoint);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadVertices(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
|
||||
m_arVertices.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 8);
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
}
|
||||
|
||||
if (lCount > 0)
|
||||
{
|
||||
m_bIsVerticesPresent = true;
|
||||
}
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
Aggplus::POINT oPoint;
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
oPoint.x = (short)oReader.ReadWORD();
|
||||
oPoint.y = (short)oReader.ReadWORD();
|
||||
}
|
||||
else
|
||||
{
|
||||
oPoint.x = oReader.ReadLONG();
|
||||
oPoint.y = oReader.ReadLONG();
|
||||
}
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
LONG lMaxF = (LONG)0x8000007F;
|
||||
if (lMinF <= oPoint.x)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.x - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
if (lMinF <= oPoint.y)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.y - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
|
||||
m_arVertices.push_back(oPoint);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadAHs(CProperty* pProperty)
|
||||
{
|
||||
}
|
||||
void CCustomVML::LoadSegments(std::vector<int> values)
|
||||
{
|
||||
m_arSegments.clear();
|
||||
|
||||
if (!values.empty())
|
||||
m_bIsPathPresent = true;
|
||||
|
||||
for (size_t ind = 0; ind < values.size(); ++ind)
|
||||
{
|
||||
CSegment oInfo;
|
||||
int count = oInfo.Read(values[ind]);
|
||||
|
||||
if (0 == oInfo.m_nCount)
|
||||
{
|
||||
if ((ODRAW::rtEnd != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoFill != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoStroke != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtClose != oInfo.m_eRuler))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (int i = 0 ; i < count; i++)
|
||||
m_arSegments.push_back(oInfo);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadSegments(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arSegments.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 2);
|
||||
|
||||
if (lCount > 0) m_bIsPathPresent = true;
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
CSegment oInfo;
|
||||
oInfo.Read(oReader);
|
||||
|
||||
if (0 == oInfo.m_nCount)
|
||||
{
|
||||
if ((ODRAW::rtEnd != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoFill != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoStroke != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtClose != oInfo.m_eRuler))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//if (rtClose == oInfo.m_eRuler)
|
||||
//{
|
||||
// // проводим линию
|
||||
// CSegment oInfo2(rtLineTo, 1);
|
||||
// m_arSegments.push_back(oInfo2);
|
||||
//}
|
||||
|
||||
m_arSegments.push_back(oInfo);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadGuides(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
CGuide oInfo;
|
||||
oInfo.Read(oReader);
|
||||
m_arGuides.push_back(oInfo);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadInscribe(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arInscribe.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 16);
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
lCount = (WORD)(pProperty->m_lValue / 8);
|
||||
}
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
Aggplus::RECT oRect;
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
oRect.left = (short)oReader.ReadWORD();
|
||||
oRect.right = (short)oReader.ReadWORD();
|
||||
oRect.top = (short)oReader.ReadWORD();
|
||||
oRect.bottom = (short)oReader.ReadWORD();
|
||||
}
|
||||
else
|
||||
{
|
||||
oRect.left = (short)oReader.ReadLONG();
|
||||
oRect.right = (short)oReader.ReadLONG();
|
||||
oRect.top = (short)oReader.ReadLONG();
|
||||
oRect.bottom = (short)oReader.ReadLONG();
|
||||
}
|
||||
m_arInscribe.push_back(oRect);
|
||||
}
|
||||
}
|
||||
void CCustomVML::LoadAdjusts(LONG lIndex, LONG lValue)
|
||||
{
|
||||
if (NULL == m_pAdjustValues)
|
||||
return;
|
||||
|
||||
LONG lCount = (LONG)m_pAdjustValues->size();
|
||||
|
||||
while (lCount <= lIndex)
|
||||
{
|
||||
m_pAdjustValues->push_back(0);
|
||||
lCount = (LONG)m_pAdjustValues->size();
|
||||
}
|
||||
|
||||
(*m_pAdjustValues)[lIndex] = lValue;
|
||||
}
|
||||
void CCustomVML::SetAdjusts(std::vector<LONG>* pList)
|
||||
{
|
||||
m_pAdjustValues = pList;
|
||||
}
|
||||
void CCustomVML::ToCustomShape(ODRAW::CBaseShape* pShape, NSGuidesVML::CFormulasManager& oManager)
|
||||
{
|
||||
if ((NULL == pShape) || (!IsCustom()))
|
||||
return;
|
||||
|
||||
oManager.Clear();
|
||||
// сначала заполним формулы
|
||||
for (size_t nIndex = 0; nIndex < m_arGuides.size(); ++nIndex)
|
||||
{
|
||||
NSGuidesVML::CFormula oF;
|
||||
m_arGuides[nIndex].SetToFormula(oF);
|
||||
oManager.AddFormula(oF);
|
||||
}
|
||||
|
||||
oManager.Clear(m_pAdjustValues);
|
||||
|
||||
std::wstring strPath = _T("");
|
||||
|
||||
bool bBreak = false;
|
||||
|
||||
long lMinF = (_INT32)0x80000000;
|
||||
long lMaxF = (_INT32)0x8000007F;
|
||||
|
||||
int nGuideIndex_x , nGuideIndex_y;
|
||||
|
||||
if (0 == m_arSegments.size())
|
||||
{
|
||||
strPath = GetRulerVML(m_ePath);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < m_arVertices.size(); ++nIndex)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nIndex].x ) nGuideIndex_x = (_UINT32)m_arVertices[nIndex].x - (_UINT32)lMinF;
|
||||
if (lMaxF > m_arVertices[nIndex].y ) nGuideIndex_y = (_UINT32)m_arVertices[nIndex].y - (_UINT32)lMinF;
|
||||
|
||||
if (nGuideIndex_x >= 0 )
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0)
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].y) + L",";
|
||||
}
|
||||
|
||||
}
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nStart = 0;
|
||||
size_t nEnd = 0;
|
||||
for (size_t nS = 0; nS < m_arSegments.size(); ++nS)
|
||||
{
|
||||
if (bBreak)
|
||||
{
|
||||
if ((ODRAW::rtEnd != m_arSegments[nS].m_eRuler) &&
|
||||
(ODRAW::rtNoFill != m_arSegments[nS].m_eRuler) &&
|
||||
(ODRAW::rtNoStroke != m_arSegments[nS].m_eRuler) &&
|
||||
(ODRAW::rtClose != m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
strPath += _T("e");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ODRAW::rtFillColor == m_arSegments[nS].m_eRuler) || (ODRAW::rtLineColor == m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
if (nStart < m_arVertices.size())
|
||||
{
|
||||
if (ODRAW::rtFillColor == m_arSegments[nS].m_eRuler)
|
||||
{
|
||||
m_oBrush.Color1 = (_UINT32)m_arVertices[nStart].x;
|
||||
m_oBrush.Color2 = (_UINT32)m_arVertices[nStart].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oPen.Color = (_UINT32)m_arVertices[nStart].x;
|
||||
}
|
||||
}
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
strPath += GetRulerVML(m_arSegments[nS].m_eRuler);
|
||||
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
|
||||
for (size_t nV = nStart; nV < nEnd; ++nV)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nV].x ) nGuideIndex_x = (_UINT32)m_arVertices[nV].x - (_UINT32)lMinF;
|
||||
if (lMaxF > m_arVertices[nV].y ) nGuideIndex_y = (_UINT32)m_arVertices[nV].y - (_UINT32)lMinF;
|
||||
|
||||
std::wstring str = _T("");
|
||||
if (nGuideIndex_x >= 0 && nGuideIndex_x < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0 && nGuideIndex_y < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].y) + L",";
|
||||
}
|
||||
}
|
||||
|
||||
if (nEnd != nStart)
|
||||
{
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oManager.CalculateResults();
|
||||
|
||||
pShape->LoadPathList(strPath);
|
||||
|
||||
/*std::wstring str = _T("<w:pict xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">\
|
||||
<v:shape id=\"Cloud 1\" o:spid=\"_x0000_s1026\" style=\"position:absolute;margin-left:-17.3pt;margin-top:158.4pt;width:466.95pt;height:335.65pt;z-index:251659264;visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;v-text-anchor:middle\" coordsize=\"43200,43200\" path=\"m3900,14370c3629,11657,4261,8921,5623,6907,7775,3726,11264,3017,14005,5202,15678,909,19914,22,22456,3432,23097,1683,24328,474,25749,200v1564,-302,3126,570,4084,2281c31215,267,33501,-460,35463,690v1495,876,2567,2710,2855,4886c40046,6218,41422,7998,41982,10318v407,1684,349,3513,-164,5142c43079,17694,43520,20590,43016,23322v-670,3632,-2888,6352,-5612,6882c37391,32471,36658,34621,35395,36101v-1919,2249,-4691,2538,-6840,714c27860,39948,25999,42343,23667,43106v-2748,899,-5616,-633,-7187,-3840c12772,42310,7956,40599,5804,35472,3690,35809,1705,34024,1110,31250,679,29243,1060,27077,2113,25551,619,24354,-213,22057,-5,19704,239,16949,1845,14791,3863,14507v12,-46,25,-91,37,-137xem4693,26177nfc3809,26271,2925,25993,2160,25380t4768,9519nfc6573,35092,6200,35220,5820,35280t10658,3810nfc16211,38544,15987,37961,15810,37350m28827,34751nfc28788,35398,28698,36038,28560,36660m34129,22954nfc36133,24282,37398,27058,37380,30090m41798,15354nfc41473,16386,40978,17302,40350,18030m38324,5426nfc38379,5843,38405,6266,38400,6690m29078,3952nfc29267,3369,29516,2826,29820,2340m22141,4720nfc22218,4238,22339,3771,22500,3330m14000,5192nfc14472,5568,14908,6021,15300,6540m4127,15789nfc4024,15325,3948,14851,3900,14370e\" fillcolor=\"#4f81bd\" strokecolor=\"#385d8a\" strokeweight=\"2pt\">\
|
||||
<v:path arrowok=\"t\" o:connecttype=\"custom\" o:connectlocs=\"644218,2582990;296508,2504347;951021,3443625;798923,3481220;2261969,3857168;2170271,3685475;3957142,3429021;3920490,3617390;4684958,2264964;5131230,2969101;5737698,1515041;5538928,1779093;5260814,535405;5271247,660129;3991597,389960;4093453,230897;3039341,465741;3088621,328585;1921809,512316;2100263,645328;566522,1557964;535361,1417946\" o:connectangles=\"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\"/>\
|
||||
</v:shape>\
|
||||
</w:pict>");*/
|
||||
|
||||
//pShape->LoadFromXML(str);
|
||||
}
|
||||
}
|
||||
@ -33,7 +33,7 @@
|
||||
#include "BinaryReader.h"
|
||||
#include "ElementSettings.h"
|
||||
#include "../BaseShape.h"
|
||||
#include "../../../PptFile/Drawing/Attributes.h"
|
||||
//#include "../../../PptFile/Drawing/Attributes.h"
|
||||
#include "PptFormula.h"
|
||||
#include "../GraphicsPath.h"
|
||||
|
||||
@ -46,288 +46,14 @@ namespace NSCustomVML
|
||||
WORD m_nCount;
|
||||
|
||||
public:
|
||||
CSegment(ODRAW::RulesType eType = ODRAW::rtMoveTo, WORD nCount = 2)
|
||||
{
|
||||
m_eRuler = eType;
|
||||
m_nCount = nCount;
|
||||
}
|
||||
CSegment(ODRAW::RulesType eType = ODRAW::rtMoveTo, WORD nCount = 2);
|
||||
CSegment(const CSegment& oSrc);
|
||||
CSegment& operator=(const CSegment& oSrc);
|
||||
~CSegment();
|
||||
|
||||
CSegment(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
}
|
||||
|
||||
CSegment& operator=(const CSegment& oSrc)
|
||||
{
|
||||
m_eRuler = oSrc.m_eRuler;
|
||||
m_nCount = oSrc.m_nCount;
|
||||
|
||||
return (*this);
|
||||
}
|
||||
|
||||
~CSegment()
|
||||
{
|
||||
}
|
||||
int Read(WORD value)//from rtf segments
|
||||
{
|
||||
int repeate = 0;
|
||||
if (value >= 0x2000 && value < 0x20FF)
|
||||
{
|
||||
repeate = value & 0x0FFF;
|
||||
value &= 0xFF00;
|
||||
}
|
||||
|
||||
m_nCount = 0;
|
||||
switch (value)
|
||||
{
|
||||
case 0x0001: // lineto
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
m_nCount = 1;
|
||||
break;
|
||||
case 0x4000: // moveto
|
||||
m_eRuler = ODRAW::rtMoveTo;
|
||||
m_nCount = 1;
|
||||
break;
|
||||
case 0x2000: // curveto
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
m_nCount = 3;
|
||||
break;
|
||||
case 0xb300: // arcto
|
||||
m_eRuler = ODRAW::rtArc;
|
||||
m_nCount = 2;
|
||||
break;
|
||||
case 0xac00:
|
||||
case 0xaa00: // nofill
|
||||
case 0xad00:
|
||||
m_eRuler = ODRAW::rtNoFill;
|
||||
break;
|
||||
case 0xab00: // nostroke
|
||||
m_eRuler = ODRAW::rtNoStroke;
|
||||
break;
|
||||
case 0x6001: // close
|
||||
m_eRuler = ODRAW::rtClose;
|
||||
break;
|
||||
case 0x8000: // end
|
||||
m_eRuler = ODRAW::rtEnd;
|
||||
break;
|
||||
default: // given number of lineto elements
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
m_nCount = value;
|
||||
break;
|
||||
}
|
||||
return (std::max)(1, repeate);
|
||||
}
|
||||
void Read(POLE::Stream* pStream)//from binary ms segments
|
||||
{
|
||||
WORD mem = StreamUtils::ReadWORD(pStream);
|
||||
BYTE type = mem & 0x07;
|
||||
|
||||
if (type <= 4)
|
||||
{
|
||||
m_eRuler = (ODRAW::RulesType)type;
|
||||
m_nCount = (mem >> 3) & 0x1FFF;
|
||||
return;
|
||||
}
|
||||
|
||||
mem = (mem >> 3) & 0x1FFF;
|
||||
type = mem & 0x1F;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
break;
|
||||
}
|
||||
case 0x01:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipseTo;
|
||||
break;
|
||||
}
|
||||
case 0x02:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipse;
|
||||
break;
|
||||
}
|
||||
case 0x03:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x04:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArc;
|
||||
break;
|
||||
}
|
||||
case 0x05:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x06:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArc;
|
||||
break;
|
||||
}
|
||||
case 0x07:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrX;
|
||||
break;
|
||||
}
|
||||
case 0x08:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrY;
|
||||
break;
|
||||
}
|
||||
case 0x09:
|
||||
{
|
||||
m_eRuler = ODRAW::rtQuadrBesier;
|
||||
break;
|
||||
}
|
||||
case 0x0A:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoFill;
|
||||
break;
|
||||
}
|
||||
case 0x0B:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoStroke;
|
||||
break;
|
||||
}
|
||||
case 0x15:
|
||||
{
|
||||
m_eRuler = ODRAW::rtFillColor;
|
||||
break;
|
||||
}
|
||||
case 0x16:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineColor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
}
|
||||
};
|
||||
|
||||
m_nCount = (mem >> 5) & 0x00FF;
|
||||
}
|
||||
void Read(ODRAW::CBinaryReader& oReader)//from binary ms segments
|
||||
{
|
||||
WORD mem = oReader.ReadWORD();
|
||||
|
||||
BYTE type = (mem >> 13 & 0x07);
|
||||
if (type <= 4)
|
||||
{
|
||||
m_eRuler = (ODRAW::RulesType)type;
|
||||
m_nCount = (mem & 0x1FFF);
|
||||
m_nCount = (WORD)GetCountPoints2(m_eRuler, m_nCount);
|
||||
return;
|
||||
}
|
||||
|
||||
type = (mem >> 8) & 0x1F;
|
||||
mem = mem & 0xFF;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case 0x00:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
break;
|
||||
}
|
||||
case 0x01:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipseTo;
|
||||
break;
|
||||
}
|
||||
case 0x02:
|
||||
{
|
||||
m_eRuler = ODRAW::rtAngleEllipse;
|
||||
break;
|
||||
}
|
||||
case 0x03:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x04:
|
||||
{
|
||||
m_eRuler = ODRAW::rtArc;
|
||||
break;
|
||||
}
|
||||
case 0x05:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArcTo;
|
||||
break;
|
||||
}
|
||||
case 0x06:
|
||||
{
|
||||
m_eRuler = ODRAW::rtClockwiseArc;
|
||||
break;
|
||||
}
|
||||
case 0x07:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrX;
|
||||
break;
|
||||
}
|
||||
case 0x08:
|
||||
{
|
||||
m_eRuler = ODRAW::rtEllipticalQuadrY;
|
||||
break;
|
||||
}
|
||||
case 0x09:
|
||||
{
|
||||
m_eRuler = ODRAW::rtQuadrBesier;
|
||||
break;
|
||||
}
|
||||
case 0x0A:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoFill;
|
||||
break;
|
||||
}
|
||||
case 0x0B:
|
||||
{
|
||||
m_eRuler = ODRAW::rtNoStroke;
|
||||
break;
|
||||
}
|
||||
case 0x0C:
|
||||
case 0x10:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineTo;
|
||||
break;
|
||||
}
|
||||
case 0x0D:
|
||||
case 0x0E:
|
||||
case 0x0F:
|
||||
case 0x11:
|
||||
case 0x12:
|
||||
case 0x13:
|
||||
case 0x14:
|
||||
{
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
break;
|
||||
}
|
||||
case 0x15:
|
||||
{
|
||||
m_eRuler = ODRAW::rtFillColor;
|
||||
break;
|
||||
}
|
||||
case 0x16:
|
||||
{
|
||||
m_eRuler = ODRAW::rtLineColor;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
m_eRuler = ODRAW::rtCurveTo;
|
||||
}
|
||||
};
|
||||
|
||||
m_nCount = (WORD)mem;
|
||||
m_nCount = (WORD)GetCountPoints2(m_eRuler, m_nCount);
|
||||
//m_nCount = (WORD)GetCountPoints2(m_eRuler);
|
||||
}
|
||||
int Read(WORD value); //from rtf segments
|
||||
void Read(POLE::Stream* pStream); //from binary ms segments
|
||||
void Read(ODRAW::CBinaryReader& oReader); //from binary ms segments
|
||||
};
|
||||
|
||||
class CGuide
|
||||
@ -346,135 +72,17 @@ namespace NSCustomVML
|
||||
LONG m_lShapeWidth;
|
||||
LONG m_lShapeHeight;
|
||||
|
||||
CGuide();
|
||||
CGuide(const CGuide& oSrc);
|
||||
CGuide& operator=(const CGuide& oSrc);
|
||||
|
||||
CGuide()
|
||||
{
|
||||
m_eType = NSGuidesVML::ftVal;
|
||||
void SetToFormula(NSGuidesVML::CFormula& oFormula);
|
||||
|
||||
m_param_type1 = 0;
|
||||
m_param_type2 = 0;
|
||||
m_param_type3 = 0;
|
||||
|
||||
m_param_value1 = 0;
|
||||
m_param_value2 = 0;
|
||||
m_param_value3 = 0;
|
||||
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
}
|
||||
|
||||
CGuide(const CGuide& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
CGuide& operator=(const CGuide& oSrc)
|
||||
{
|
||||
m_eType = oSrc.m_eType;
|
||||
|
||||
m_param_type1 = oSrc.m_param_type1;
|
||||
m_param_type2 = oSrc.m_param_type2;
|
||||
m_param_type3 = oSrc.m_param_type3;
|
||||
|
||||
m_param_value1 = oSrc.m_param_value1;
|
||||
m_param_value2 = oSrc.m_param_value2;
|
||||
m_param_value3 = oSrc.m_param_value3;
|
||||
|
||||
m_lShapeWidth = oSrc.m_lShapeWidth;
|
||||
m_lShapeHeight = oSrc.m_lShapeHeight;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void SetToFormula(NSGuidesVML::CFormula& oFormula)
|
||||
{
|
||||
oFormula.m_eFormulaType = m_eType;
|
||||
|
||||
SetParam(m_param_type1, m_param_value1, oFormula.m_eType1, oFormula.m_lParam1);
|
||||
SetParam(m_param_type2, m_param_value2, oFormula.m_eType2, oFormula.m_lParam2);
|
||||
SetParam(m_param_type3, m_param_value3, oFormula.m_eType3, oFormula.m_lParam3);
|
||||
}
|
||||
|
||||
void Read(POLE::Stream* pStream)
|
||||
{
|
||||
WORD ftType = StreamUtils::ReadWORD(pStream);
|
||||
|
||||
m_eType = NSGuidesVML::FormulaType(ftType & 0x1FFF);
|
||||
|
||||
m_param_type1 = (BYTE)(ftType & 0x04);
|
||||
m_param_type2 = (BYTE)(ftType & 0x02);
|
||||
m_param_type3 = (BYTE)(ftType & 0x01);
|
||||
|
||||
m_param_value1 = StreamUtils::ReadWORD(pStream);
|
||||
m_param_value2 = StreamUtils::ReadWORD(pStream);
|
||||
m_param_value3 = StreamUtils::ReadWORD(pStream);
|
||||
}
|
||||
void Read(ODRAW::CBinaryReader& oReader)
|
||||
{
|
||||
WORD ftType = oReader.ReadWORD();
|
||||
|
||||
m_eType = NSGuidesVML::FormulaType(ftType & 0x1FFF);
|
||||
|
||||
m_param_type1 = (BYTE)(ftType & 0x04);
|
||||
m_param_type2 = (BYTE)(ftType & 0x02);
|
||||
m_param_type3 = (BYTE)(ftType & 0x01);
|
||||
|
||||
m_param_value1 = oReader.ReadWORD();
|
||||
m_param_value2 = oReader.ReadWORD();
|
||||
m_param_value3 = oReader.ReadWORD();
|
||||
}
|
||||
void Read(POLE::Stream* pStream);
|
||||
void Read(ODRAW::CBinaryReader& oReader);
|
||||
|
||||
private:
|
||||
void SetParam(BYTE type, WORD param, ParamType& param_type, LONG& param_value)
|
||||
{
|
||||
if (0 == type)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = (LONG)param;
|
||||
}
|
||||
|
||||
if (0x0140 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0141 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML / 2;
|
||||
return;
|
||||
}
|
||||
if (0x0142 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
if (0x0143 == param)
|
||||
{
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0147 <= param) && (param <= 0x014E))
|
||||
{
|
||||
param_type = ptAdjust;
|
||||
param_value = (LONG)(param - 0x0147);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((0x0400 <= param) && (param <= 0x047F))
|
||||
{
|
||||
param_type = ptFormula;
|
||||
param_value = (LONG)(param - 0x0400);
|
||||
return;
|
||||
}
|
||||
|
||||
param_type = ptValue;
|
||||
param_value = ShapeSizeVML;
|
||||
}
|
||||
void SetParam(BYTE type, WORD param, ParamType& param_type, LONG& param_value);
|
||||
};
|
||||
|
||||
class CCustomVML
|
||||
@ -497,480 +105,26 @@ namespace NSCustomVML
|
||||
ODRAW::CPen m_oPen;
|
||||
|
||||
public:
|
||||
CCustomVML() : m_pAdjustValues(NULL)
|
||||
{
|
||||
m_ePath = ODRAW::rtCurveTo/*rtLineTo*/;
|
||||
|
||||
m_bIsVerticesPresent = false;
|
||||
m_bIsPathPresent = false;
|
||||
}
|
||||
|
||||
CCustomVML(const CCustomVML& oSrc)
|
||||
{
|
||||
*this = oSrc;
|
||||
}
|
||||
|
||||
CCustomVML& operator=(const CCustomVML& oSrc)
|
||||
{
|
||||
m_ePath = oSrc.m_ePath;
|
||||
|
||||
m_arVertices.clear();
|
||||
m_arVertices.insert(m_arVertices.end(), oSrc.m_arVertices.begin(), oSrc.m_arVertices.end());
|
||||
|
||||
m_arSegments.clear();
|
||||
m_arSegments.insert(m_arSegments.end(), oSrc.m_arSegments.begin(), oSrc.m_arSegments.end());
|
||||
|
||||
m_arGuides.clear();
|
||||
m_arGuides.insert(m_arGuides.end(), oSrc.m_arGuides.begin(), oSrc.m_arGuides.end());
|
||||
|
||||
m_pAdjustValues = oSrc.m_pAdjustValues;
|
||||
|
||||
m_bIsPathPresent = oSrc.m_bIsPathPresent;
|
||||
m_bIsVerticesPresent = oSrc.m_bIsVerticesPresent;
|
||||
|
||||
m_oBrush = oSrc.m_oBrush;
|
||||
m_oPen = oSrc.m_oPen;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~CCustomVML()
|
||||
{
|
||||
}
|
||||
|
||||
bool IsCustom()
|
||||
{
|
||||
return (m_bIsVerticesPresent && m_bIsPathPresent);
|
||||
}
|
||||
|
||||
void SetPath(ODRAW::RulesType ePath)
|
||||
{
|
||||
m_ePath = ePath;
|
||||
m_bIsPathPresent = true;
|
||||
}
|
||||
void LoadVertices(std::vector<std::pair<int,int>> values)
|
||||
{
|
||||
if (!values.empty())
|
||||
m_bIsVerticesPresent = true;
|
||||
|
||||
m_arVertices.clear();
|
||||
|
||||
for (size_t ind = 0; ind < values.size(); ++ind)
|
||||
{
|
||||
Aggplus::POINT oPoint;
|
||||
|
||||
oPoint.x = values[ind].first;
|
||||
oPoint.y = values[ind].second;
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
LONG lMaxF = (LONG)0x8000007F;
|
||||
if (lMinF <= oPoint.x)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.x - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
if (lMinF <= oPoint.y)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.y - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
|
||||
m_arVertices.push_back(oPoint);
|
||||
}
|
||||
}
|
||||
void LoadConnectionSitesDir(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arConnectionSitesDir.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
_UINT32 v = oReader.ReadLONG();
|
||||
double val = (double)((WORD)(v >> 16) + ((WORD)(v) / 65536.0));
|
||||
m_arConnectionSitesDir.push_back(val);
|
||||
}
|
||||
}
|
||||
void LoadConnectionSites(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arConnectionSites.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 8);
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
}
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
Aggplus::POINT oPoint;
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
oPoint.x = (short)oReader.ReadWORD();
|
||||
oPoint.y = (short)oReader.ReadWORD();
|
||||
}
|
||||
else
|
||||
{
|
||||
oPoint.x = oReader.ReadLONG();
|
||||
oPoint.y = oReader.ReadLONG();
|
||||
}
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
LONG lMaxF = (LONG)0x8000007F;
|
||||
if (lMinF <= oPoint.x)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.x - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
if (lMinF <= oPoint.y)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.y - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
|
||||
m_arConnectionSites.push_back(oPoint);
|
||||
}
|
||||
}
|
||||
void LoadVertices(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
|
||||
m_arVertices.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 8);
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
}
|
||||
|
||||
if (lCount > 0)
|
||||
{
|
||||
m_bIsVerticesPresent = true;
|
||||
}
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
Aggplus::POINT oPoint;
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
oPoint.x = (short)oReader.ReadWORD();
|
||||
oPoint.y = (short)oReader.ReadWORD();
|
||||
}
|
||||
else
|
||||
{
|
||||
oPoint.x = oReader.ReadLONG();
|
||||
oPoint.y = oReader.ReadLONG();
|
||||
}
|
||||
|
||||
LONG lMinF = (LONG)0x80000000;
|
||||
LONG lMaxF = (LONG)0x8000007F;
|
||||
if (lMinF <= oPoint.x)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.x - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
if (lMinF <= oPoint.y)
|
||||
{
|
||||
int nGuideIndex = (_UINT32)oPoint.y - 0x80000000;
|
||||
|
||||
bool b = false;
|
||||
}
|
||||
|
||||
m_arVertices.push_back(oPoint);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadAHs(CProperty* pProperty)
|
||||
{
|
||||
}
|
||||
void LoadSegments(std::vector<int> values)
|
||||
{
|
||||
m_arSegments.clear();
|
||||
|
||||
if (!values.empty())
|
||||
m_bIsPathPresent = true;
|
||||
|
||||
for (size_t ind = 0; ind < values.size(); ++ind)
|
||||
{
|
||||
CSegment oInfo;
|
||||
int count = oInfo.Read(values[ind]);
|
||||
|
||||
if (0 == oInfo.m_nCount)
|
||||
{
|
||||
if ((ODRAW::rtEnd != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoFill != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoStroke != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtClose != oInfo.m_eRuler))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (int i = 0 ; i < count; i++)
|
||||
m_arSegments.push_back(oInfo);
|
||||
}
|
||||
}
|
||||
void LoadSegments(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arSegments.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 2);
|
||||
|
||||
if (lCount > 0) m_bIsPathPresent = true;
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
CSegment oInfo;
|
||||
oInfo.Read(oReader);
|
||||
|
||||
if (0 == oInfo.m_nCount)
|
||||
{
|
||||
if ((ODRAW::rtEnd != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoFill != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtNoStroke != oInfo.m_eRuler) &&
|
||||
(ODRAW::rtClose != oInfo.m_eRuler))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
//if (rtClose == oInfo.m_eRuler)
|
||||
//{
|
||||
// // проводим линию
|
||||
// CSegment oInfo2(rtLineTo, 1);
|
||||
// m_arSegments.push_back(oInfo2);
|
||||
//}
|
||||
|
||||
m_arSegments.push_back(oInfo);
|
||||
}
|
||||
}
|
||||
void LoadGuides(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 4);
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
CGuide oInfo;
|
||||
oInfo.Read(oReader);
|
||||
m_arGuides.push_back(oInfo);
|
||||
}
|
||||
}
|
||||
void LoadInscribe(CProperty* pProperty)
|
||||
{
|
||||
ODRAW::CBinaryReader oReader(pProperty->m_pOptions, pProperty->m_lValue);
|
||||
m_arInscribe.clear();
|
||||
|
||||
WORD lCount = (WORD)(pProperty->m_lValue / 16);
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
lCount = (WORD)(pProperty->m_lValue / 8);
|
||||
}
|
||||
|
||||
for (WORD lIndex = 0; lIndex < lCount; ++lIndex)
|
||||
{
|
||||
Aggplus::RECT oRect;
|
||||
if (pProperty->m_bIsTruncated)
|
||||
{
|
||||
oRect.left = (short)oReader.ReadWORD();
|
||||
oRect.right = (short)oReader.ReadWORD();
|
||||
oRect.top = (short)oReader.ReadWORD();
|
||||
oRect.bottom = (short)oReader.ReadWORD();
|
||||
}
|
||||
else
|
||||
{
|
||||
oRect.left = (short)oReader.ReadLONG();
|
||||
oRect.right = (short)oReader.ReadLONG();
|
||||
oRect.top = (short)oReader.ReadLONG();
|
||||
oRect.bottom = (short)oReader.ReadLONG();
|
||||
}
|
||||
m_arInscribe.push_back(oRect);
|
||||
}
|
||||
}
|
||||
void LoadAdjusts(LONG lIndex, LONG lValue)
|
||||
{
|
||||
if (NULL == m_pAdjustValues)
|
||||
return;
|
||||
|
||||
LONG lCount = (LONG)m_pAdjustValues->size();
|
||||
|
||||
while (lCount <= lIndex)
|
||||
{
|
||||
m_pAdjustValues->push_back(0);
|
||||
lCount = (LONG)m_pAdjustValues->size();
|
||||
}
|
||||
|
||||
(*m_pAdjustValues)[lIndex] = lValue;
|
||||
}
|
||||
|
||||
void SetAdjusts(std::vector<LONG>* pList)
|
||||
{
|
||||
m_pAdjustValues = pList;
|
||||
}
|
||||
|
||||
void ToCustomShape(ODRAW::CBaseShape* pShape, NSGuidesVML::CFormulasManager& oManager)
|
||||
{
|
||||
if ((NULL == pShape) || (!IsCustom()))
|
||||
return;
|
||||
|
||||
oManager.Clear();
|
||||
// сначала заполним формулы
|
||||
for (size_t nIndex = 0; nIndex < m_arGuides.size(); ++nIndex)
|
||||
{
|
||||
NSGuidesVML::CFormula oF;
|
||||
m_arGuides[nIndex].SetToFormula(oF);
|
||||
oManager.AddFormula(oF);
|
||||
}
|
||||
|
||||
oManager.Clear(m_pAdjustValues);
|
||||
|
||||
std::wstring strPath = _T("");
|
||||
|
||||
bool bBreak = false;
|
||||
|
||||
long lMinF = (_INT32)0x80000000;
|
||||
long lMaxF = (_INT32)0x8000007F;
|
||||
|
||||
int nGuideIndex_x , nGuideIndex_y;
|
||||
|
||||
if (0 == m_arSegments.size())
|
||||
{
|
||||
strPath = GetRulerVML(m_ePath);
|
||||
|
||||
for (size_t nIndex = 0; nIndex < m_arVertices.size(); ++nIndex)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nIndex].x ) nGuideIndex_x = (_UINT32)m_arVertices[nIndex].x - (_UINT32)lMinF;
|
||||
if (lMaxF > m_arVertices[nIndex].y ) nGuideIndex_y = (_UINT32)m_arVertices[nIndex].y - (_UINT32)lMinF;
|
||||
|
||||
if (nGuideIndex_x >= 0 )
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0)
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nIndex].y) + L",";
|
||||
}
|
||||
|
||||
}
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t nStart = 0;
|
||||
size_t nEnd = 0;
|
||||
for (size_t nS = 0; nS < m_arSegments.size(); ++nS)
|
||||
{
|
||||
if (bBreak)
|
||||
{
|
||||
if ((ODRAW::rtEnd != m_arSegments[nS].m_eRuler) &&
|
||||
(ODRAW::rtNoFill != m_arSegments[nS].m_eRuler) &&
|
||||
(ODRAW::rtNoStroke != m_arSegments[nS].m_eRuler) &&
|
||||
(ODRAW::rtClose != m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
strPath += _T("e");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ODRAW::rtFillColor == m_arSegments[nS].m_eRuler) || (ODRAW::rtLineColor == m_arSegments[nS].m_eRuler))
|
||||
{
|
||||
if (nStart < m_arVertices.size())
|
||||
{
|
||||
if (ODRAW::rtFillColor == m_arSegments[nS].m_eRuler)
|
||||
{
|
||||
m_oBrush.Color1 = (_UINT32)m_arVertices[nStart].x;
|
||||
m_oBrush.Color2 = (_UINT32)m_arVertices[nStart].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_oPen.Color = (_UINT32)m_arVertices[nStart].x;
|
||||
}
|
||||
}
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
strPath += GetRulerVML(m_arSegments[nS].m_eRuler);
|
||||
|
||||
nEnd = nStart + m_arSegments[nS].m_nCount;
|
||||
if (nEnd > m_arVertices.size())
|
||||
nEnd = m_arVertices.size();
|
||||
|
||||
for (size_t nV = nStart; nV < nEnd; ++nV)
|
||||
{
|
||||
nGuideIndex_x = nGuideIndex_y = -1;
|
||||
|
||||
if (lMaxF > m_arVertices[nV].x ) nGuideIndex_x = (_UINT32)m_arVertices[nV].x - (_UINT32)lMinF;
|
||||
if (lMaxF > m_arVertices[nV].y ) nGuideIndex_y = (_UINT32)m_arVertices[nV].y - (_UINT32)lMinF;
|
||||
|
||||
std::wstring str = _T("");
|
||||
if (nGuideIndex_x >= 0 && nGuideIndex_x < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_x].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].x) + L",";
|
||||
}
|
||||
if (nGuideIndex_y >= 0 && nGuideIndex_y < (int)m_arGuides.size())
|
||||
{
|
||||
strPath += std::to_wstring(m_arGuides[nGuideIndex_y].m_param_value1) + L",";
|
||||
}
|
||||
else
|
||||
{
|
||||
strPath += std::to_wstring(m_arVertices[nV].y) + L",";
|
||||
}
|
||||
}
|
||||
|
||||
if (nEnd != nStart)
|
||||
{
|
||||
strPath.erase(strPath.length() - 1);
|
||||
}
|
||||
nStart = nEnd;
|
||||
|
||||
if (nEnd == m_arVertices.size())
|
||||
{
|
||||
bBreak = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
oManager.CalculateResults();
|
||||
|
||||
pShape->LoadPathList(strPath);
|
||||
|
||||
/*std::wstring str = _T("<w:pict xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\">\
|
||||
<v:shape id=\"Cloud 1\" o:spid=\"_x0000_s1026\" style=\"position:absolute;margin-left:-17.3pt;margin-top:158.4pt;width:466.95pt;height:335.65pt;z-index:251659264;visibility:visible;mso-wrap-style:square;mso-wrap-distance-left:9pt;mso-wrap-distance-top:0;mso-wrap-distance-right:9pt;mso-wrap-distance-bottom:0;mso-position-horizontal:absolute;mso-position-horizontal-relative:text;mso-position-vertical:absolute;mso-position-vertical-relative:text;v-text-anchor:middle\" coordsize=\"43200,43200\" path=\"m3900,14370c3629,11657,4261,8921,5623,6907,7775,3726,11264,3017,14005,5202,15678,909,19914,22,22456,3432,23097,1683,24328,474,25749,200v1564,-302,3126,570,4084,2281c31215,267,33501,-460,35463,690v1495,876,2567,2710,2855,4886c40046,6218,41422,7998,41982,10318v407,1684,349,3513,-164,5142c43079,17694,43520,20590,43016,23322v-670,3632,-2888,6352,-5612,6882c37391,32471,36658,34621,35395,36101v-1919,2249,-4691,2538,-6840,714c27860,39948,25999,42343,23667,43106v-2748,899,-5616,-633,-7187,-3840c12772,42310,7956,40599,5804,35472,3690,35809,1705,34024,1110,31250,679,29243,1060,27077,2113,25551,619,24354,-213,22057,-5,19704,239,16949,1845,14791,3863,14507v12,-46,25,-91,37,-137xem4693,26177nfc3809,26271,2925,25993,2160,25380t4768,9519nfc6573,35092,6200,35220,5820,35280t10658,3810nfc16211,38544,15987,37961,15810,37350m28827,34751nfc28788,35398,28698,36038,28560,36660m34129,22954nfc36133,24282,37398,27058,37380,30090m41798,15354nfc41473,16386,40978,17302,40350,18030m38324,5426nfc38379,5843,38405,6266,38400,6690m29078,3952nfc29267,3369,29516,2826,29820,2340m22141,4720nfc22218,4238,22339,3771,22500,3330m14000,5192nfc14472,5568,14908,6021,15300,6540m4127,15789nfc4024,15325,3948,14851,3900,14370e\" fillcolor=\"#4f81bd\" strokecolor=\"#385d8a\" strokeweight=\"2pt\">\
|
||||
<v:path arrowok=\"t\" o:connecttype=\"custom\" o:connectlocs=\"644218,2582990;296508,2504347;951021,3443625;798923,3481220;2261969,3857168;2170271,3685475;3957142,3429021;3920490,3617390;4684958,2264964;5131230,2969101;5737698,1515041;5538928,1779093;5260814,535405;5271247,660129;3991597,389960;4093453,230897;3039341,465741;3088621,328585;1921809,512316;2100263,645328;566522,1557964;535361,1417946\" o:connectangles=\"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0\"/>\
|
||||
</v:shape>\
|
||||
</w:pict>");*/
|
||||
|
||||
//pShape->LoadFromXML(str);
|
||||
}
|
||||
};
|
||||
CCustomVML();
|
||||
CCustomVML(const CCustomVML& oSrc);
|
||||
CCustomVML& operator=(const CCustomVML& oSrc);
|
||||
~CCustomVML();
|
||||
|
||||
bool IsCustom();
|
||||
void SetPath(ODRAW::RulesType ePath);
|
||||
|
||||
void LoadVertices(std::vector<std::pair<int,int>> values);
|
||||
void LoadConnectionSitesDir(CProperty* pProperty);
|
||||
void LoadConnectionSites(CProperty* pProperty);
|
||||
void LoadVertices(CProperty* pProperty);
|
||||
void LoadAHs(CProperty* pProperty);
|
||||
void LoadSegments(std::vector<int> values);
|
||||
void LoadSegments(CProperty* pProperty);
|
||||
void LoadGuides(CProperty* pProperty);
|
||||
void LoadInscribe(CProperty* pProperty);
|
||||
void LoadAdjusts(LONG lIndex, LONG lValue);
|
||||
|
||||
void SetAdjusts(std::vector<LONG>* pList);
|
||||
void ToCustomShape(ODRAW::CBaseShape* pShape, NSGuidesVML::CFormulasManager& oManager);
|
||||
};
|
||||
}
|
||||
|
||||
@ -37,9 +37,26 @@
|
||||
#include "../../../PptFile/Reader/Records.h"
|
||||
#include "../../../PptFile/Reader/PPTFileDefines.h"
|
||||
|
||||
#include "../../../PptFile/Records/Drawing/ArtBlip.h"
|
||||
|
||||
// это класс, использующийся для передачи свойств объектов,
|
||||
// например - указатель на картинку... (по PID'у)
|
||||
|
||||
CProperty::CProperty()
|
||||
{
|
||||
m_ePID = ODRAW::ePropertyId_left;
|
||||
m_bIsBlip = false;
|
||||
m_bComplex = false;
|
||||
m_lValue = 0;
|
||||
m_pOptions = NULL;
|
||||
|
||||
m_bIsTruncated = false;
|
||||
}
|
||||
CProperty::~CProperty()
|
||||
{
|
||||
if (m_pOptions) delete []m_pOptions;
|
||||
m_pOptions = NULL;
|
||||
}
|
||||
void CProperty::FromStream(POLE::Stream* pStream)
|
||||
{
|
||||
// читаем из стрима...
|
||||
@ -53,7 +70,6 @@ void CProperty::FromStream(POLE::Stream* pStream)
|
||||
|
||||
m_lValue = StreamUtils::ReadDWORD(pStream);
|
||||
}
|
||||
|
||||
void CProperty::ComplexFromStream(POLE::Stream* pStream)
|
||||
{
|
||||
if (m_bComplex && m_lValue > 0)
|
||||
@ -141,7 +157,14 @@ void CProperty::ComplexFromStream(POLE::Stream* pStream)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CProperties::CProperties() : m_arProperties()
|
||||
{
|
||||
}
|
||||
CProperties::~CProperties()
|
||||
{
|
||||
m_lCount = 0;
|
||||
m_arProperties.clear();
|
||||
}
|
||||
void CProperties::FromStream(POLE::Stream* pStream, long lCount)
|
||||
{
|
||||
m_lCount = lCount;
|
||||
@ -158,8 +181,6 @@ void CProperties::FromStream(POLE::Stream* pStream, long lCount)
|
||||
m_arProperties[lIndex].ComplexFromStream(pStream);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
size_t CProperties::GetLen()
|
||||
{
|
||||
size_t dwLen = 6 * m_lCount;
|
||||
|
||||
@ -31,7 +31,6 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../../../PptFile/Records/Drawing/ArtBlip.h"
|
||||
#include "../../../../OOXML/Base/Types_32.h"
|
||||
#include "../../../../Common/3dParty/pole/pole.h"
|
||||
#include "Enums.h"
|
||||
@ -52,21 +51,9 @@ public:
|
||||
// чтобы не плодить классы - это value, когда m_bComplex == true
|
||||
bool m_bIsTruncated;
|
||||
|
||||
CProperty()
|
||||
{
|
||||
m_ePID = ODRAW::ePropertyId_left;
|
||||
m_bIsBlip = false;
|
||||
m_bComplex = false;
|
||||
m_lValue = 0;
|
||||
m_pOptions = NULL;
|
||||
CProperty();
|
||||
~CProperty();
|
||||
|
||||
m_bIsTruncated = false;
|
||||
}
|
||||
~CProperty()
|
||||
{
|
||||
if (m_pOptions) delete []m_pOptions;
|
||||
m_pOptions = NULL;
|
||||
}
|
||||
void FromStream(POLE::Stream* pStream);
|
||||
void ComplexFromStream(POLE::Stream* pStream);
|
||||
};
|
||||
@ -80,14 +67,8 @@ public:
|
||||
// тем более это класс - не связанный с RecordHeader
|
||||
size_t m_lCount;
|
||||
|
||||
CProperties() : m_arProperties()
|
||||
{
|
||||
}
|
||||
~CProperties()
|
||||
{
|
||||
m_lCount = 0;
|
||||
m_arProperties.clear();
|
||||
}
|
||||
CProperties();
|
||||
~CProperties();
|
||||
|
||||
void FromStream(POLE::Stream* pStream, long lCount);
|
||||
size_t GetLen();
|
||||
|
||||
2015
MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.cpp
Normal file
2015
MsBinaryFile/Common/Vml/PPTShape/Ppt2PptxShapeConverter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -33,140 +33,282 @@
|
||||
|
||||
#include "PptFormula.h"
|
||||
|
||||
LONG NSGuidesVML::CFormula::Calculate(NSGuidesVML::CFormulasManager* pManager)
|
||||
namespace NSGuidesVML
|
||||
{
|
||||
if ((0 > m_lIndex) || (m_lIndex >= (int)pManager->m_arResults.size()))
|
||||
return 0;
|
||||
if (0xFFFFFFFF != pManager->m_arResults[m_lIndex])
|
||||
CFormula::CFormula()
|
||||
{
|
||||
return pManager->m_arResults[m_lIndex];
|
||||
}
|
||||
|
||||
LONG lResult = 0;
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = 0;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
|
||||
LONG lGuidesCount = (LONG)pManager->m_arFormulas.size();
|
||||
LONG lAdjCount = (LONG)pManager->m_pAdjustments->size();
|
||||
|
||||
LONG a1 = m_lParam1;
|
||||
if (ptFormula == m_eType1 && !pManager->m_bCalc)
|
||||
{
|
||||
pManager->m_bCalc = true;
|
||||
a1 = (m_lParam1 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam1].Calculate(pManager);
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
else if (ptAdjust == m_eType1)
|
||||
CFormula::CFormula(int nIndex)
|
||||
{
|
||||
a1 = (m_lParam1 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam1];
|
||||
}
|
||||
pManager->m_bCalc = false;
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = nIndex;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
|
||||
LONG b1 = m_lParam2;
|
||||
if (ptFormula == m_eType2 && !pManager->m_bCalc)
|
||||
{
|
||||
pManager->m_bCalc = true;
|
||||
b1 = (m_lParam2 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam2].Calculate(pManager);
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
else if (ptAdjust == m_eType2)
|
||||
CFormula& CFormula::operator =(const CFormula& oSrc)
|
||||
{
|
||||
b1 = (m_lParam2 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam2];
|
||||
m_eFormulaType = oSrc.m_eFormulaType;
|
||||
m_lIndex = oSrc.m_lIndex;
|
||||
|
||||
m_lParam1 = oSrc.m_lParam1;
|
||||
m_eType1 = oSrc.m_eType1;
|
||||
|
||||
m_lParam2 = oSrc.m_lParam2;
|
||||
m_eType2 = oSrc.m_eType2;
|
||||
|
||||
m_lParam3 = oSrc.m_lParam3;
|
||||
m_eType3 = oSrc.m_eType3;
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
return (*this);
|
||||
}
|
||||
pManager->m_bCalc = false;
|
||||
|
||||
LONG c1 = m_lParam3;
|
||||
if (ptFormula == m_eType3 && !pManager->m_bCalc)
|
||||
void CFormula::FromString(std::wstring strFormula, long lShapeWidth, long lShapeHeight)
|
||||
{
|
||||
pManager->m_bCalc = true;
|
||||
c1 = (m_lParam3 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam3].Calculate(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType3)
|
||||
{
|
||||
c1 = (m_lParam3 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam3];
|
||||
}
|
||||
pManager->m_bCalc = false;
|
||||
std::vector<std::wstring> oArrayParams;
|
||||
boost::algorithm::split(oArrayParams, strFormula, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
double a = (double)a1;
|
||||
double b = (double)b1;
|
||||
double c = (double)c1;
|
||||
int nCount = (int)oArrayParams.size();
|
||||
if (0 >= nCount)
|
||||
return;
|
||||
|
||||
double dRes = 0.0;
|
||||
bool bRes = true;
|
||||
m_eFormulaType = GetFormula(oArrayParams[0], bRes);
|
||||
|
||||
try
|
||||
{
|
||||
// теперь нужно просто посчитать
|
||||
switch (m_eFormulaType)
|
||||
ParamType ptType = ptValue;
|
||||
if (1 < nCount)
|
||||
{
|
||||
case ftSum: { dRes = a + b - c; break; }
|
||||
case ftProduct: {
|
||||
if (0 == c)
|
||||
c = 1;
|
||||
|
||||
dRes = a * b / c;
|
||||
break;
|
||||
}
|
||||
case ftMid: { dRes = (a + b) / 2.0; break; }
|
||||
case ftAbsolute: { dRes = abs(a); break; }
|
||||
|
||||
case ftMin: { dRes = (std::min)(a, b); break; }
|
||||
case ftMax: { dRes = (std::max)(a, b); break; }
|
||||
case ftIf: { dRes = (a > 0) ? b : c; break; }
|
||||
case ftSqrt: { dRes = sqrt(a); break; }
|
||||
case ftMod: { dRes = sqrt(a*a + b*b + c*c); break; }
|
||||
|
||||
case ftSin: {
|
||||
//dRes = a * sin(b);
|
||||
//dRes = a * sin(b / pow2_16);
|
||||
dRes = a * sin(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftCos: {
|
||||
//dRes = a * cos(b);
|
||||
//dRes = a * cos(b / pow2_16);
|
||||
dRes = a * cos(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftTan: {
|
||||
//dRes = a * tan(b);
|
||||
dRes = a * tan(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftAtan2: {
|
||||
dRes = 180 * pow2_16 * atan2(b,a) / M_PI;
|
||||
break;
|
||||
}
|
||||
|
||||
case ftSinatan2: { dRes = a * sin(atan2(c,b)); break; }
|
||||
case ftCosatan2: { dRes = a * cos(atan2(c,b)); break; }
|
||||
|
||||
case ftSumangle: {
|
||||
//dRes = a + b - c;
|
||||
dRes = a + b * pow2_16 - c * pow2_16;
|
||||
|
||||
/*while (23592960 < dRes)
|
||||
{
|
||||
dRes -= 23592960;
|
||||
}
|
||||
while (-23592960 > dRes)
|
||||
{
|
||||
dRes += 23592960;
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
case ftEllipse: {
|
||||
if (0 == b)
|
||||
b = 1;
|
||||
dRes = c * sqrt(1-(a*a/(b*b)));
|
||||
break;
|
||||
}
|
||||
case ftVal: { dRes = a; break; }
|
||||
default: break;
|
||||
};
|
||||
m_lParam1 = GetValue(oArrayParams[1], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType1 = ptType;
|
||||
}
|
||||
if (2 < nCount)
|
||||
{
|
||||
m_lParam2 = GetValue(oArrayParams[2], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType2 = ptType;
|
||||
}
|
||||
if (3 < nCount)
|
||||
{
|
||||
m_lParam3 = GetValue(oArrayParams[3], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType3 = ptType;
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
LONG CFormula::Calculate(NSGuidesVML::CFormulasManager* pManager)
|
||||
{
|
||||
dRes = 0;
|
||||
if ((0 > m_lIndex) || (m_lIndex >= (int)pManager->m_arResults.size()))
|
||||
return 0;
|
||||
if (0xFFFFFFFF != pManager->m_arResults[m_lIndex])
|
||||
{
|
||||
return pManager->m_arResults[m_lIndex];
|
||||
}
|
||||
|
||||
LONG lResult = 0;
|
||||
|
||||
LONG lGuidesCount = (LONG)pManager->m_arFormulas.size();
|
||||
LONG lAdjCount = (LONG)pManager->m_pAdjustments->size();
|
||||
|
||||
LONG a1 = m_lParam1;
|
||||
if (ptFormula == m_eType1 && !pManager->m_bCalc)
|
||||
{
|
||||
pManager->m_bCalc = true;
|
||||
a1 = (m_lParam1 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam1].Calculate(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType1)
|
||||
{
|
||||
a1 = (m_lParam1 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam1];
|
||||
}
|
||||
pManager->m_bCalc = false;
|
||||
|
||||
LONG b1 = m_lParam2;
|
||||
if (ptFormula == m_eType2 && !pManager->m_bCalc)
|
||||
{
|
||||
pManager->m_bCalc = true;
|
||||
b1 = (m_lParam2 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam2].Calculate(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType2)
|
||||
{
|
||||
b1 = (m_lParam2 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam2];
|
||||
}
|
||||
pManager->m_bCalc = false;
|
||||
|
||||
LONG c1 = m_lParam3;
|
||||
if (ptFormula == m_eType3 && !pManager->m_bCalc)
|
||||
{
|
||||
pManager->m_bCalc = true;
|
||||
c1 = (m_lParam3 >= lGuidesCount) ? 0 : pManager->m_arFormulas[m_lParam3].Calculate(pManager);
|
||||
}
|
||||
else if (ptAdjust == m_eType3)
|
||||
{
|
||||
c1 = (m_lParam3 >= lAdjCount) ? 0 : (*(pManager->m_pAdjustments))[m_lParam3];
|
||||
}
|
||||
pManager->m_bCalc = false;
|
||||
|
||||
double a = (double)a1;
|
||||
double b = (double)b1;
|
||||
double c = (double)c1;
|
||||
|
||||
double dRes = 0.0;
|
||||
|
||||
try
|
||||
{
|
||||
// теперь нужно просто посчитать
|
||||
switch (m_eFormulaType)
|
||||
{
|
||||
case ftSum: { dRes = a + b - c; break; }
|
||||
case ftProduct: {
|
||||
if (0 == c)
|
||||
c = 1;
|
||||
|
||||
dRes = a * b / c;
|
||||
break;
|
||||
}
|
||||
case ftMid: { dRes = (a + b) / 2.0; break; }
|
||||
case ftAbsolute: { dRes = abs(a); break; }
|
||||
|
||||
case ftMin: { dRes = (std::min)(a, b); break; }
|
||||
case ftMax: { dRes = (std::max)(a, b); break; }
|
||||
case ftIf: { dRes = (a > 0) ? b : c; break; }
|
||||
case ftSqrt: { dRes = sqrt(a); break; }
|
||||
case ftMod: { dRes = sqrt(a*a + b*b + c*c); break; }
|
||||
|
||||
case ftSin: {
|
||||
//dRes = a * sin(b);
|
||||
//dRes = a * sin(b / pow2_16);
|
||||
dRes = a * sin(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftCos: {
|
||||
//dRes = a * cos(b);
|
||||
//dRes = a * cos(b / pow2_16);
|
||||
dRes = a * cos(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftTan: {
|
||||
//dRes = a * tan(b);
|
||||
dRes = a * tan(M_PI * b / (pow2_16 * 180));
|
||||
break;
|
||||
}
|
||||
case ftAtan2: {
|
||||
dRes = 180 * pow2_16 * atan2(b,a) / M_PI;
|
||||
break;
|
||||
}
|
||||
|
||||
case ftSinatan2: { dRes = a * sin(atan2(c,b)); break; }
|
||||
case ftCosatan2: { dRes = a * cos(atan2(c,b)); break; }
|
||||
|
||||
case ftSumangle: {
|
||||
//dRes = a + b - c;
|
||||
dRes = a + b * pow2_16 - c * pow2_16;
|
||||
|
||||
/*while (23592960 < dRes)
|
||||
{
|
||||
dRes -= 23592960;
|
||||
}
|
||||
while (-23592960 > dRes)
|
||||
{
|
||||
dRes += 23592960;
|
||||
}*/
|
||||
|
||||
break;
|
||||
}
|
||||
case ftEllipse: {
|
||||
if (0 == b)
|
||||
b = 1;
|
||||
dRes = c * sqrt(1-(a*a/(b*b)));
|
||||
break;
|
||||
}
|
||||
case ftVal: { dRes = a; break; }
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
dRes = 0;
|
||||
}
|
||||
|
||||
lResult = (LONG)dRes;
|
||||
pManager->m_arResults[m_lIndex] = lResult;
|
||||
return lResult;
|
||||
}
|
||||
|
||||
lResult = (LONG)dRes;
|
||||
pManager->m_arResults[m_lIndex] = lResult;
|
||||
return lResult;
|
||||
CFormulasManager::CFormulasManager() : m_bCalc(false)
|
||||
{
|
||||
m_pAdjustments = NULL;
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
}
|
||||
CFormulasManager& CFormulasManager::operator =(const CFormulasManager& oSrc)
|
||||
{
|
||||
m_bCalc = oSrc.m_bCalc;
|
||||
m_pAdjustments = oSrc.m_pAdjustments;
|
||||
m_lShapeWidth = oSrc.m_lShapeWidth;
|
||||
m_lShapeHeight = oSrc.m_lShapeHeight;
|
||||
|
||||
m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults.push_back(oSrc.m_arResults[nIndex]);
|
||||
}
|
||||
m_arFormulas.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arFormulas.size(); ++nIndex)
|
||||
{
|
||||
m_arFormulas.push_back(oSrc.m_arFormulas[nIndex]);
|
||||
}
|
||||
|
||||
return (*this);
|
||||
}
|
||||
void CFormulasManager::Clear()
|
||||
{
|
||||
m_bCalc = false;
|
||||
m_pAdjustments = NULL;
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
|
||||
m_arFormulas.clear();
|
||||
m_arResults.clear();
|
||||
}
|
||||
void CFormulasManager::Clear(std::vector<LONG>* pAdjusts)
|
||||
{
|
||||
m_pAdjustments = pAdjusts;
|
||||
|
||||
//m_arFormulas.clear();
|
||||
//m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults[nIndex] = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
void CFormulasManager::AddFormula(std::wstring strFormula)
|
||||
{
|
||||
CFormula oFormula((int)m_arFormulas.size());
|
||||
|
||||
oFormula.FromString(strFormula, m_lShapeWidth, m_lShapeHeight);
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void CFormulasManager::AddFormula(CFormula oFormula)
|
||||
{
|
||||
oFormula.m_lIndex = (int)m_arFormulas.size();
|
||||
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void CFormulasManager::CalculateResults()
|
||||
{
|
||||
for (size_t index = 0; index < m_arFormulas.size(); ++index)
|
||||
{
|
||||
LONG lResult = m_arFormulas[index].Calculate(this);
|
||||
}
|
||||
|
||||
//m_pAdjustments = NULL;
|
||||
//m_arFormulas.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,83 +121,84 @@ namespace NSGuidesVML
|
||||
};
|
||||
|
||||
static long GetValue(std::wstring strParam, ParamType& ptType, bool& bRes,
|
||||
long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML)
|
||||
{
|
||||
ptType = ptValue;
|
||||
bRes = true;
|
||||
long val = 0;
|
||||
long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML)
|
||||
{
|
||||
ptType = ptValue;
|
||||
bRes = true;
|
||||
long val = 0;
|
||||
|
||||
if ('#' == strParam[0])
|
||||
{
|
||||
ptType = ptAdjust;
|
||||
val = XmlUtils::GetInteger(strParam.substr(1));
|
||||
}
|
||||
else if ('@' == strParam[0])
|
||||
{
|
||||
ptType = ptFormula;
|
||||
val = XmlUtils::GetInteger(strParam.substr(1));
|
||||
}
|
||||
else if (!NSStringUtils::IsNumber(strParam))
|
||||
{
|
||||
if (_T("width") == strParam)
|
||||
{
|
||||
val = lShapeWidth;
|
||||
}
|
||||
else if (_T("height") == strParam)
|
||||
{
|
||||
val = lShapeHeight;
|
||||
}
|
||||
else if (_T("pixelWidth") == strParam)
|
||||
{
|
||||
val = lShapeWidth;
|
||||
}
|
||||
else if (_T("pixelHeight") == strParam)
|
||||
{
|
||||
val = lShapeHeight;
|
||||
}
|
||||
else if (_T("pixelLineWidth") == strParam || _T("lineDrawn") == strParam)
|
||||
{
|
||||
val = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bRes = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptType = ptValue;
|
||||
val = XmlUtils::GetInteger(strParam);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
if ('#' == strParam[0])
|
||||
{
|
||||
ptType = ptAdjust;
|
||||
val = XmlUtils::GetInteger(strParam.substr(1));
|
||||
}
|
||||
else if ('@' == strParam[0])
|
||||
{
|
||||
ptType = ptFormula;
|
||||
val = XmlUtils::GetInteger(strParam.substr(1));
|
||||
}
|
||||
else if (!NSStringUtils::IsNumber(strParam))
|
||||
{
|
||||
if (_T("width") == strParam)
|
||||
{
|
||||
val = lShapeWidth;
|
||||
}
|
||||
else if (_T("height") == strParam)
|
||||
{
|
||||
val = lShapeHeight;
|
||||
}
|
||||
else if (_T("pixelWidth") == strParam)
|
||||
{
|
||||
val = lShapeWidth;
|
||||
}
|
||||
else if (_T("pixelHeight") == strParam)
|
||||
{
|
||||
val = lShapeHeight;
|
||||
}
|
||||
else if (_T("pixelLineWidth") == strParam || _T("lineDrawn") == strParam)
|
||||
{
|
||||
val = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
bRes = false;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ptType = ptValue;
|
||||
val = XmlUtils::GetInteger(strParam);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static FormulaType GetFormula(std::wstring strName, bool& bRes)
|
||||
{
|
||||
bRes = true;
|
||||
if (_T("sum") == strName) return ftSum;
|
||||
else if ((_T("prod") == strName) || (_T("product") == strName)) return ftProduct;
|
||||
else if (_T("mid") == strName) return ftMid;
|
||||
else if ((_T("absolute") == strName) || (_T("abs") == strName)) return ftAbsolute;
|
||||
else if (_T("min") == strName) return ftMin;
|
||||
else if (_T("max") == strName) return ftMax;
|
||||
else if (_T("if") == strName) return ftIf;
|
||||
else if (_T("sqrt") == strName) return ftSqrt;
|
||||
else if (_T("mod") == strName) return ftMod;
|
||||
else if (_T("sin") == strName) return ftSin;
|
||||
else if (_T("cos") == strName) return ftCos;
|
||||
else if (_T("tan") == strName) return ftTan;
|
||||
else if (_T("atan2") == strName) return ftAtan2;
|
||||
else if (_T("sinatan2") == strName) return ftSinatan2;
|
||||
else if (_T("cosatan2") == strName) return ftCosatan2;
|
||||
else if (_T("sumangle") == strName) return ftSumangle;
|
||||
else if (_T("ellipse") == strName) return ftEllipse;
|
||||
else if (_T("val") == strName) return ftVal;
|
||||
else bRes = false;
|
||||
static FormulaType GetFormula(std::wstring strName, bool& bRes)
|
||||
{
|
||||
bRes = true;
|
||||
if (_T("sum") == strName) return ftSum;
|
||||
else if ((_T("prod") == strName) || (_T("product") == strName)) return ftProduct;
|
||||
else if (_T("mid") == strName) return ftMid;
|
||||
else if ((_T("absolute") == strName) || (_T("abs") == strName)) return ftAbsolute;
|
||||
else if (_T("min") == strName) return ftMin;
|
||||
else if (_T("max") == strName) return ftMax;
|
||||
else if (_T("if") == strName) return ftIf;
|
||||
else if (_T("sqrt") == strName) return ftSqrt;
|
||||
else if (_T("mod") == strName) return ftMod;
|
||||
else if (_T("sin") == strName) return ftSin;
|
||||
else if (_T("cos") == strName) return ftCos;
|
||||
else if (_T("tan") == strName) return ftTan;
|
||||
else if (_T("atan2") == strName) return ftAtan2;
|
||||
else if (_T("sinatan2") == strName) return ftSinatan2;
|
||||
else if (_T("cosatan2") == strName) return ftCosatan2;
|
||||
else if (_T("sumangle") == strName) return ftSumangle;
|
||||
else if (_T("ellipse") == strName) return ftEllipse;
|
||||
else if (_T("val") == strName) return ftVal;
|
||||
else bRes = false;
|
||||
|
||||
return ftVal;
|
||||
}
|
||||
|
||||
return ftVal;
|
||||
}
|
||||
struct SPointType
|
||||
{
|
||||
ParamType x;
|
||||
@ -238,9 +239,11 @@ namespace NSGuidesVML
|
||||
Aggplus::POINT PolarCentre;
|
||||
SPointType PolarCentreType;
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
class CFormulasManager;
|
||||
class CFormula
|
||||
|
||||
class CFormula
|
||||
{
|
||||
public:
|
||||
FormulaType m_eFormulaType;
|
||||
@ -259,75 +262,12 @@ namespace NSGuidesVML
|
||||
long m_lCountRecurs;
|
||||
|
||||
public:
|
||||
CFormula()
|
||||
{
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = 0;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
CFormula();
|
||||
CFormula(int nIndex);
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
CFormula& operator =(const CFormula& oSrc);
|
||||
|
||||
CFormula(int nIndex)
|
||||
{
|
||||
m_eFormulaType = ftSum;
|
||||
m_lIndex = nIndex;
|
||||
m_lParam1 = 0; m_eType1 = ptValue;
|
||||
m_lParam2 = 0; m_eType2 = ptValue;
|
||||
m_lParam3 = 0; m_eType3 = ptValue;
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
}
|
||||
|
||||
CFormula& operator =(const CFormula& oSrc)
|
||||
{
|
||||
m_eFormulaType = oSrc.m_eFormulaType;
|
||||
m_lIndex = oSrc.m_lIndex;
|
||||
|
||||
m_lParam1 = oSrc.m_lParam1;
|
||||
m_eType1 = oSrc.m_eType1;
|
||||
|
||||
m_lParam2 = oSrc.m_lParam2;
|
||||
m_eType2 = oSrc.m_eType2;
|
||||
|
||||
m_lParam3 = oSrc.m_lParam3;
|
||||
m_eType3 = oSrc.m_eType3;
|
||||
|
||||
m_lCountRecurs = 0;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void FromString(std::wstring strFormula, long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML)
|
||||
{
|
||||
std::vector<std::wstring> oArrayParams;
|
||||
boost::algorithm::split(oArrayParams, strFormula, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
int nCount = (int)oArrayParams.size();
|
||||
if (0 >= nCount)
|
||||
return;
|
||||
|
||||
bool bRes = true;
|
||||
m_eFormulaType = GetFormula(oArrayParams[0], bRes);
|
||||
|
||||
ParamType ptType = ptValue;
|
||||
if (1 < nCount)
|
||||
{
|
||||
m_lParam1 = GetValue(oArrayParams[1], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType1 = ptType;
|
||||
}
|
||||
if (2 < nCount)
|
||||
{
|
||||
m_lParam2 = GetValue(oArrayParams[2], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType2 = ptType;
|
||||
}
|
||||
if (3 < nCount)
|
||||
{
|
||||
m_lParam3 = GetValue(oArrayParams[3], ptType, bRes, lShapeWidth, lShapeHeight);
|
||||
m_eType3 = ptType;
|
||||
}
|
||||
}
|
||||
void FromString(std::wstring strFormula, long lShapeWidth = ShapeSizeVML, long lShapeHeight = ShapeSizeVML);
|
||||
LONG Calculate(CFormulasManager* pManager);
|
||||
};
|
||||
|
||||
@ -344,79 +284,16 @@ namespace NSGuidesVML
|
||||
|
||||
bool m_bCalc; //status
|
||||
|
||||
CFormulasManager() : m_bCalc(false)
|
||||
{
|
||||
m_pAdjustments = NULL;
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
}
|
||||
CFormulasManager& operator =(const CFormulasManager& oSrc)
|
||||
{
|
||||
m_bCalc = oSrc.m_bCalc;
|
||||
m_pAdjustments = oSrc.m_pAdjustments;
|
||||
m_lShapeWidth = oSrc.m_lShapeWidth;
|
||||
m_lShapeHeight = oSrc.m_lShapeHeight;
|
||||
CFormulasManager();
|
||||
|
||||
m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults.push_back(oSrc.m_arResults[nIndex]);
|
||||
}
|
||||
m_arFormulas.clear();
|
||||
for (size_t nIndex = 0; nIndex < oSrc.m_arFormulas.size(); ++nIndex)
|
||||
{
|
||||
m_arFormulas.push_back(oSrc.m_arFormulas[nIndex]);
|
||||
}
|
||||
CFormulasManager& operator =(const CFormulasManager& oSrc);
|
||||
|
||||
return (*this);
|
||||
}
|
||||
void Clear();
|
||||
void Clear(std::vector<LONG>* pAdjusts);
|
||||
|
||||
void Clear()
|
||||
{
|
||||
m_bCalc = false;
|
||||
m_pAdjustments = NULL;
|
||||
m_lShapeWidth = ShapeSizeVML;
|
||||
m_lShapeHeight = ShapeSizeVML;
|
||||
void AddFormula(std::wstring strFormula);
|
||||
void AddFormula(CFormula oFormula);
|
||||
|
||||
m_arFormulas.clear();
|
||||
m_arResults.clear();
|
||||
}
|
||||
|
||||
void Clear(std::vector<LONG>* pAdjusts)
|
||||
{
|
||||
m_pAdjustments = pAdjusts;
|
||||
|
||||
//m_arFormulas.clear();
|
||||
//m_arResults.clear();
|
||||
for (size_t nIndex = 0; nIndex < m_arResults.size(); ++nIndex)
|
||||
{
|
||||
m_arResults[nIndex] = 0xFFFFFFFF;
|
||||
}
|
||||
}
|
||||
void AddFormula(std::wstring strFormula)
|
||||
{
|
||||
CFormula oFormula((int)m_arFormulas.size());
|
||||
|
||||
oFormula.FromString(strFormula, m_lShapeWidth, m_lShapeHeight);
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void AddFormula(CFormula oFormula)
|
||||
{
|
||||
oFormula.m_lIndex = (int)m_arFormulas.size();
|
||||
|
||||
m_arFormulas.push_back(oFormula);
|
||||
m_arResults.push_back(0xFFFFFFFF);
|
||||
}
|
||||
void CalculateResults()
|
||||
{
|
||||
for (size_t index = 0; index < m_arFormulas.size(); ++index)
|
||||
{
|
||||
LONG lResult = m_arFormulas[index].Calculate(this);
|
||||
}
|
||||
|
||||
//m_pAdjustments = NULL;
|
||||
//m_arFormulas.clear();
|
||||
}
|
||||
void CalculateResults();
|
||||
};
|
||||
}
|
||||
|
||||
569
MsBinaryFile/Common/Vml/PPTXShape/Pptx2PptShapeConverter.cpp
Normal file
569
MsBinaryFile/Common/Vml/PPTXShape/Pptx2PptShapeConverter.cpp
Normal file
@ -0,0 +1,569 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Pptx2PptShapeConverter.h"
|
||||
|
||||
namespace NSGuidesVML
|
||||
{
|
||||
CConverterPPTXPPT::CConverterPPTXPPT()
|
||||
{
|
||||
m_lPPTX2PPT = -1;
|
||||
m_lPPT2PPTX = -1;
|
||||
m_lIndexDst = -1;
|
||||
m_lIndexAdj = -1;
|
||||
pPPTShape = new CPPTShape();
|
||||
}
|
||||
void CConverterPPTXPPT::Convert ( CPPTXShape* pPPTXShape )
|
||||
{
|
||||
ConvertAdjastments ( pPPTXShape->m_arAdjustments, pPPTXShape->FManager.mapAdjustments );
|
||||
AddSizeGuides ((LONG)pPPTXShape->FManager.GetWidth(), (LONG)pPPTXShape->FManager.GetHeight());
|
||||
ConvertGuides ( pPPTXShape->FManager.strGuides, pPPTXShape->FManager.mapGuides);
|
||||
ConvertPath( pPPTXShape->m_strPath, pPPTXShape->FManager.strGuides, pPPTXShape->FManager.mapGuides);
|
||||
|
||||
//TODO текстовые поля
|
||||
//ConvertTextRects ( pPPTXShape->m_arStringTextRects );
|
||||
ConvertHandles ( pPPTXShape->m_arHandles );
|
||||
|
||||
//ConvertType ( pPPTXShape->m_eType );
|
||||
//------------------------------------
|
||||
int i=0;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertHandles (std::vector<CHandle_>& arHnd)
|
||||
{
|
||||
|
||||
for (size_t nIndex=0; nIndex<arHnd.size(); nIndex++)
|
||||
{
|
||||
CHandle_ oHandle;
|
||||
//TODO переименовать названия формул и прокинуть текстовые атрибуты topleft, rightbottom в полях хендла
|
||||
|
||||
pPPTShape->m_arHandles.push_back(oHandle);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertAdjastments( std::vector<long> &arAdj, std::map<std::wstring, long> &mapAdj )
|
||||
{
|
||||
int i=0;
|
||||
for( std::map<std::wstring, long>::iterator pPair = mapAdj.begin(); pPair != mapAdj.end(); i++, ++pPair)
|
||||
{
|
||||
m_arMapAdj.insert(std::pair<std::wstring, LONG>(pPair->first, ++m_lIndexAdj));
|
||||
pPPTShape->m_arAdjustments.push_back(arAdj[i]);
|
||||
}
|
||||
//это аджасменты для перевода углов tan(angle, adj)
|
||||
//тк все угла в формулах считаются в pptx
|
||||
//pptx->ppt
|
||||
pPPTShape->m_arAdjustments.push_back(3114601);
|
||||
m_lPPTX2PPT = ++m_lIndexAdj;
|
||||
//ppt->pptx
|
||||
pPPTShape->m_arAdjustments.push_back(2783638);
|
||||
m_lPPT2PPTX = ++m_lIndexAdj;
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertTextRects (std::vector<std::wstring> &arTextRects)
|
||||
{
|
||||
pPPTShape->m_arStringTextRects.insert( pPPTShape->m_arStringTextRects.end(), arTextRects.begin(), arTextRects.end());
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertType (OOXMLShapes::ShapeType eType)
|
||||
{
|
||||
switch (eType)
|
||||
{
|
||||
case OOXMLShapes::sptCRect:
|
||||
pPPTShape->m_eType = PPTShapes::sptCRect;
|
||||
break;
|
||||
case OOXMLShapes::sptCArc:
|
||||
pPPTShape->m_eType = PPTShapes::sptCRect;
|
||||
break;
|
||||
default:
|
||||
pPPTShape->m_eType = PPTShapes::sptCustom;
|
||||
}
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::AddSizeGuides (LONG lWidth, LONG lHeight)
|
||||
{
|
||||
//TODO прокинуть w и h в формулах
|
||||
NSGuidesVML::CFormula pNewFmla3;
|
||||
pNewFmla3.m_eFormulaType = ftVal;
|
||||
pNewFmla3.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla3.m_eType1 = ptValue;
|
||||
pNewFmla3.m_lParam1 = 21600;// lWidth;
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla3);
|
||||
m_arMapFormula.insert(std::pair<std::wstring, LONG>(_T("w"), m_lIndexDst));
|
||||
|
||||
pNewFmla3.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla3.m_eType1 = ptValue;
|
||||
pNewFmla3.m_lParam1 = 21600;//lHeight;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla3);
|
||||
|
||||
m_arMapFormula.insert(std::pair<std::wstring, LONG>(_T("h"), m_lIndexDst));
|
||||
|
||||
return;
|
||||
}
|
||||
LONG CConverterPPTXPPT::ConvertFmlaParam (std::wstring strParam, NSGuidesVML::ParamType &eType, std::wstring strKey, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides)
|
||||
{
|
||||
LONG lVal = 0;
|
||||
|
||||
std::map<std::wstring, LONG>::iterator NumFmla = m_arMapFormula.find(strParam);
|
||||
std::map<std::wstring, LONG>::iterator NumAdj = m_arMapAdj.find(strParam);
|
||||
std::map<std::wstring, LONG>::iterator NumGuides = mapGuides.find(strParam);
|
||||
|
||||
if (NumAdj != m_arMapAdj.end())
|
||||
{
|
||||
eType = ptAdjust;
|
||||
lVal = NumAdj->second;
|
||||
}
|
||||
else if (NumFmla == m_arMapFormula.end())
|
||||
{
|
||||
//пришло число
|
||||
if (NumGuides == mapGuides.end())
|
||||
{
|
||||
lVal = (LONG)XmlUtils::GetInteger(strParam);
|
||||
if (lVal > 65535)
|
||||
{
|
||||
ConvertFmla( ftSumangle, lVal%65536, ptValue, (int)lVal/65536, ptValue, 0, ptValue);
|
||||
eType = ptFormula;
|
||||
lVal = m_lIndexDst;
|
||||
}
|
||||
else if (lVal < 0)
|
||||
{
|
||||
ConvertFmla( ftSum, 0, ptValue, 0, ptValue, abs(lVal), ptValue);
|
||||
eType = ptFormula;
|
||||
lVal = m_lIndexDst;
|
||||
}
|
||||
else
|
||||
eType = ptValue;
|
||||
}
|
||||
else //пришла стандартная формула из набора, которую надо теперь добавить
|
||||
{
|
||||
LONG lNumGuides = NumGuides->second;
|
||||
|
||||
NSGuidesOOXML::CFormula pFormula = strGuides[lNumGuides];
|
||||
|
||||
//strKey = mapGuides.GetKeyAt(lNumGuides);
|
||||
int ind =0;
|
||||
for (std::map<std::wstring, long>::iterator p = mapGuides.begin(); p!= mapGuides.end(); ++p)
|
||||
{
|
||||
if (ind == lNumGuides)
|
||||
{
|
||||
strKey = p->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertGuid(pFormula, strKey, strGuides, mapGuides);
|
||||
eType = ptFormula;
|
||||
lVal = m_lIndexDst;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eType = ptFormula;
|
||||
std::map<std::wstring, LONG>::iterator Val = m_arMapFormula.find(strParam);
|
||||
lVal = Val->second;
|
||||
}
|
||||
return lVal;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1, LONG lParam2, ParamType eType2, LONG lParam3, ParamType eType3 )
|
||||
{
|
||||
NSGuidesVML::CFormula pNewFmla;
|
||||
pNewFmla.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla.m_eFormulaType = eFmlaType;
|
||||
|
||||
pNewFmla.m_eType1 = eType1;
|
||||
pNewFmla.m_lParam1 = lParam1;
|
||||
|
||||
pNewFmla.m_eType2 = eType2;
|
||||
pNewFmla.m_lParam2 = lParam2;
|
||||
|
||||
pNewFmla.m_eType3 = eType3;
|
||||
pNewFmla.m_lParam3 = lParam3;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla);
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1, LONG lParam2, ParamType eType2 )
|
||||
{
|
||||
CFormula pNewFmla;
|
||||
pNewFmla.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla.m_eFormulaType = eFmlaType;
|
||||
|
||||
pNewFmla.m_eType1 = eType1;
|
||||
pNewFmla.m_lParam1 = lParam1;
|
||||
|
||||
pNewFmla.m_eType2 = eType2;
|
||||
pNewFmla.m_lParam2 = lParam2;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla);
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1 )
|
||||
{
|
||||
CFormula pNewFmla;
|
||||
pNewFmla.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla.m_eFormulaType = eFmlaType;
|
||||
|
||||
pNewFmla.m_eType1 = eType1;
|
||||
pNewFmla.m_lParam1 = lParam1;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla);
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertGuid ( NSGuidesOOXML::CFormula pFormula, std::wstring strKey, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides)
|
||||
{
|
||||
LONG lParam1, lParam2, lParam3;
|
||||
NSGuidesVML::ParamType eType1, eType2, eType3;
|
||||
|
||||
lParam1 = ConvertFmlaParam(pFormula.m_lParam1, eType1, strKey, strGuides, mapGuides);
|
||||
lParam2 = ConvertFmlaParam(pFormula.m_lParam2, eType2, strKey, strGuides, mapGuides);
|
||||
lParam3 = ConvertFmlaParam(pFormula.m_lParam3, eType3, strKey, strGuides, mapGuides);
|
||||
|
||||
switch (pFormula.m_eFormulaType)
|
||||
{
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSum:
|
||||
ConvertFmla( ftSum, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLProduct:
|
||||
ConvertFmla( ftProduct, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLIf:
|
||||
ConvertFmla( ftIf, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLAbsolute:
|
||||
ConvertFmla( ftAbsolute, lParam1, eType1);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLAtan2:
|
||||
ConvertFmla( ftAtan2, lParam1, eType1, lParam2, eType2);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLCos:
|
||||
ConvertFmla( ftCos, lParam1, eType1, lParam2, eType2);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLMax:
|
||||
ConvertFmla( ftMax, lParam1, eType1, lParam2, eType2);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLMin:
|
||||
ConvertFmla( ftMin, lParam1, eType1, lParam2, eType2);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLMod:
|
||||
ConvertFmla( ftMod, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSinatan2:
|
||||
ConvertFmla( ftSinatan2, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLCosatan2:
|
||||
ConvertFmla( ftCosatan2, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSin:
|
||||
ConvertFmla( ftSin, lParam1, eType1, lParam2, eType2);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSqrt:
|
||||
ConvertFmla( ftSqrt, lParam1, eType1);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLTan:
|
||||
ConvertFmla( ftTan, lParam1, eType1, lParam2, eType2);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLVal:
|
||||
ConvertFmla( ftVal, lParam1, eType1);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLAddDivide:
|
||||
ConvertFmla( ftSum, lParam1, eType1, lParam2, eType2, 0, ptValue);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, 1, ptValue, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLPin:
|
||||
ConvertFmla( ftSum, lParam1, eType1, 0, ptValue, lParam2, eType2);
|
||||
ConvertFmla( ftSum, lParam2, eType2, 0, ptValue, lParam3, eType3);
|
||||
ConvertFmla( ftIf, m_lIndexDst, ptFormula, lParam3, eType3, lParam2, eType2);
|
||||
ConvertFmla( ftIf, m_lIndexDst-2, ptFormula, lParam1, eType1, m_lIndexDst, ptFormula);
|
||||
break;
|
||||
}
|
||||
m_arMapFormula.insert(std::pair<std::wstring, LONG>(strKey, m_lIndexDst));
|
||||
return;
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertGuides ( std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides )
|
||||
{
|
||||
//стандартные формулы для пптх будем добавлять, если только они встретятся
|
||||
for (size_t nIndex=32; nIndex < strGuides.size(); ++nIndex)
|
||||
{
|
||||
NSGuidesOOXML::CFormula pFormula = strGuides[nIndex];
|
||||
|
||||
std::wstring strKey;// = mapGuides.GetKeyAt(nIndex);
|
||||
int ind =0;
|
||||
for (std::map<std::wstring, long>::iterator p = mapGuides.begin(); p!= mapGuides.end(); ++p)
|
||||
{
|
||||
if (ind == nIndex)
|
||||
{
|
||||
strKey = p->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ConvertGuid(pFormula, strKey, strGuides, mapGuides);
|
||||
}
|
||||
}
|
||||
void CConverterPPTXPPT::ConvertPath(const std::wstring& xml, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides)
|
||||
{
|
||||
XmlUtils::CXmlNode pathLst;
|
||||
if(pathLst.FromXmlString(xml))
|
||||
{
|
||||
XmlUtils::CXmlNodes list;
|
||||
if (pathLst.GetNodes(_T("path"), list))
|
||||
{
|
||||
int nPathCount = list.GetCount();
|
||||
for (int i=0; i<nPathCount; i++)
|
||||
{
|
||||
XmlUtils::CXmlNode PathNode;
|
||||
if(list.GetAt(i, PathNode))
|
||||
{
|
||||
XmlUtils::CXmlNodes listNode;
|
||||
PathNode.GetNodes(_T("*"), listNode);
|
||||
|
||||
bool bFill = PathNode.GetAttribute(_T("fill"), _T("norm")) != _T("none");
|
||||
std::wstring stroke = PathNode.GetAttribute(_T("stroke"), _T("true"));
|
||||
bool bStroke = (stroke == _T("true")) || (stroke == _T("1"));
|
||||
|
||||
int nNodeCount = listNode.GetCount();
|
||||
for (int j=0; j<nNodeCount; j++)
|
||||
{
|
||||
XmlUtils::CXmlNode node;
|
||||
if(listNode.GetAt(j, node))
|
||||
{
|
||||
bool bNum = false; //управляем запятыми
|
||||
|
||||
std::wstring strName = node.GetName();
|
||||
if (strName == _T("moveTo"))
|
||||
pPPTShape->m_strPath += _T("m");
|
||||
else if (strName == _T("lnTo"))
|
||||
pPPTShape->m_strPath += _T("l");
|
||||
else if (strName == _T("arcTo"))
|
||||
pPPTShape->m_strPath += _T("ae");
|
||||
else if (strName == _T("cubicBezTo"))
|
||||
pPPTShape->m_strPath += _T("c");
|
||||
else if (strName == _T("quadBezTo"))
|
||||
pPPTShape->m_strPath += _T("qb");
|
||||
else
|
||||
pPPTShape->m_strPath += _T("x");
|
||||
|
||||
if (strName == _T("arcTo"))
|
||||
{
|
||||
LONG lStartX = m_lIndexDst-1, lStartY = m_lIndexDst;
|
||||
LONG lParam1, lParam2, lParam3, lParam4;
|
||||
NSGuidesVML::ParamType eType1, eType2, eType3, eType4;
|
||||
|
||||
lParam1 = ConvertFmlaParam(node.GetAttribute(_T("wR")), eType1, node.GetAttribute(_T("wR")), strGuides, mapGuides);
|
||||
lParam2 = ConvertFmlaParam(node.GetAttribute(_T("hR")), eType2, node.GetAttribute(_T("hR")), strGuides, mapGuides);
|
||||
lParam3 = ConvertFmlaParam(node.GetAttribute(_T("stAng")), eType3, node.GetAttribute(_T("stAng")), strGuides, mapGuides);
|
||||
lParam4 = ConvertFmlaParam(node.GetAttribute(_T("swAng")), eType4, node.GetAttribute(_T("swAng")), strGuides, mapGuides);
|
||||
|
||||
//stAng
|
||||
ConvertFmla( ftTan, lParam3, eType3, m_lPPTX2PPT, ptAdjust);
|
||||
//swAng
|
||||
ConvertFmla( ftTan, lParam4, eType4, m_lPPTX2PPT, ptAdjust);
|
||||
//a
|
||||
ConvertFmla( ftVal, lParam1, eType1);
|
||||
//b
|
||||
ConvertFmla( ftVal, lParam2, eType2);
|
||||
LONG lstAng = m_lIndexDst-3, lswAng = m_lIndexDst-2, la = m_lIndexDst-1, lb = m_lIndexDst;
|
||||
//радиус эллипса в stAng--------------------
|
||||
//(b*cos)^2
|
||||
ConvertFmla( ftCos, m_lIndexDst, ptFormula, m_lIndexDst-3, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
//(a*sin)^2
|
||||
ConvertFmla( ftSin, m_lIndexDst-3, ptFormula, m_lIndexDst-5, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
ConvertFmla( ftSum, m_lIndexDst-2, ptFormula, m_lIndexDst, ptFormula, 0, ptValue);
|
||||
ConvertFmla( ftSqrt, m_lIndexDst, ptFormula);
|
||||
//r
|
||||
ConvertFmla( ftProduct, la, ptFormula, lb, ptFormula, m_lIndexDst, ptFormula);
|
||||
|
||||
//r*cos(stAng)
|
||||
ConvertFmla( ftCos, m_lIndexDst, ptFormula, lstAng, ptFormula);
|
||||
//xc
|
||||
ConvertFmla( ftSum, lStartX, ptFormula, 0, ptValue, m_lIndexDst, ptFormula);
|
||||
//r*sin(stAng)
|
||||
ConvertFmla( ftSin, m_lIndexDst-2, ptFormula, lstAng, ptFormula);
|
||||
//yc
|
||||
ConvertFmla( ftSum, lStartY, ptFormula, 0, ptValue, m_lIndexDst, ptFormula);
|
||||
//endAng
|
||||
ConvertFmla( ftSum, lstAng, ptFormula, lswAng, ptFormula, 0, ptValue);
|
||||
|
||||
//радиус эллипса в endAng--------------------
|
||||
//(b*cos)^2
|
||||
ConvertFmla( ftCos, lb, ptFormula, m_lIndexDst, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
//(a*sin)^2
|
||||
ConvertFmla( ftSin, la, ptFormula, m_lIndexDst-2, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
ConvertFmla( ftSum, m_lIndexDst-2, ptFormula, m_lIndexDst, ptFormula, 0, ptValue);
|
||||
ConvertFmla( ftSqrt, m_lIndexDst, ptFormula);
|
||||
//r
|
||||
ConvertFmla( ftProduct, la, ptFormula, lb, ptFormula, m_lIndexDst, ptFormula);
|
||||
|
||||
//r*cos(endAng)
|
||||
ConvertFmla( ftCos, m_lIndexDst, ptFormula, m_lIndexDst-7, ptFormula);
|
||||
//xEnd
|
||||
ConvertFmla( ftSum, m_lIndexDst-11, ptFormula, m_lIndexDst, ptFormula, 0, ptValue);
|
||||
//r*sin(endAng)
|
||||
ConvertFmla( ftSin, m_lIndexDst-2, ptFormula, m_lIndexDst-9, ptFormula);
|
||||
//yEnd
|
||||
ConvertFmla( ftSum, m_lIndexDst-11, ptFormula, m_lIndexDst, ptFormula, 0, ptValue );
|
||||
|
||||
std::wstring xC = L"@" + std::to_wstring( m_lIndexDst-14);
|
||||
std::wstring yC = L"@" + std::to_wstring( m_lIndexDst-12);
|
||||
std::wstring wR = L"@" + std::to_wstring( la);
|
||||
std::wstring hR = L"@" + std::to_wstring( lb);
|
||||
|
||||
//360
|
||||
ConvertFmla( ftSumangle, 0, ptValue, 360, ptValue, 0, ptValue );
|
||||
//360-stAng
|
||||
ConvertFmla( ftSum, m_lIndexDst, ptFormula, 0, ptValue, lstAng, ptFormula);
|
||||
//-1
|
||||
ConvertFmla( ftSum, 0, ptValue, 0, ptValue, 1, ptValue);
|
||||
//-1*swAng
|
||||
ConvertFmla( ftProduct, lswAng, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
|
||||
std::wstring stAng = L"@" + std::to_wstring( m_lIndexDst-2);
|
||||
std::wstring swAng = L"@" + std::to_wstring( m_lIndexDst);
|
||||
//std::wstring xEnd = _T(""); xEnd.Format(_T("@%d"), m_lIndexDst-5);
|
||||
//std::wstring yEnd = _T(""); yEnd.Format(_T("@%d"), m_lIndexDst-4);
|
||||
|
||||
pPPTShape->m_strPath += xC + yC + wR + hR + stAng + swAng;
|
||||
|
||||
ConvertFmla( ftVal, m_lIndexDst - 6, ptFormula);
|
||||
ConvertFmla( ftVal, m_lIndexDst - 5, ptFormula);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtils::CXmlNodes ptList;
|
||||
node.GetNodes(_T("pt"), ptList);
|
||||
int nPtCount = ptList.GetCount();
|
||||
|
||||
for (int k=0; k<nPtCount; k++)
|
||||
{
|
||||
bool bLastPount = false;
|
||||
if ( k == nPtCount-1)
|
||||
bLastPount = true;
|
||||
|
||||
XmlUtils::CXmlNode ptNode;
|
||||
if(ptList.GetAt(k, ptNode))
|
||||
{
|
||||
std::wstring ptX = ptNode.GetAttribute(_T("x"));
|
||||
std::wstring ptY = ptNode.GetAttribute(_T("y"));
|
||||
|
||||
pPPTShape->m_strPath += ConvertPathPoint( ptX, ptY, bNum, strGuides, mapGuides, bLastPount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bFill)
|
||||
pPPTShape->m_strPath += _T("nf");
|
||||
if (!bStroke)
|
||||
pPPTShape->m_strPath += _T("ns");
|
||||
}
|
||||
pPPTShape->m_strPath += _T("e");
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
LONG CConverterPPTXPPT::ConvertArcParam (std::wstring strParam, NSGuidesVML::ParamType &eType)
|
||||
{
|
||||
LONG lVal = 0;
|
||||
|
||||
std::map<std::wstring, LONG>::iterator NumFmla = m_arMapFormula.find(strParam);
|
||||
std::map<std::wstring, LONG>::iterator NumAdj = m_arMapAdj.find(strParam);
|
||||
|
||||
if (NumAdj != m_arMapAdj.end())
|
||||
{
|
||||
eType = ptAdjust;
|
||||
lVal = NumAdj->second; //индекс в map ???
|
||||
}
|
||||
else if (NumFmla == m_arMapFormula.end())
|
||||
{
|
||||
eType = ptValue;
|
||||
lVal = (LONG)XmlUtils::GetInteger(strParam);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
eType = ptFormula;
|
||||
lVal = m_arMapFormula.find(strParam)->second;
|
||||
}
|
||||
return lVal;
|
||||
}
|
||||
std::wstring CConverterPPTXPPT::ConvertPathPoint (std::wstring strX, std::wstring strY, bool &bNum, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides, bool bLPoint)
|
||||
{
|
||||
std::wstring strRes = _T("");
|
||||
ParamType eType1, eType2;
|
||||
LONG lParam1, lParam2;
|
||||
|
||||
if (bNum)
|
||||
strRes += _T(",");
|
||||
lParam1 = ConvertFmlaParam(strX, eType1, strX, strGuides, mapGuides);
|
||||
strRes += ConvertPathParam (lParam1, eType1, bNum);
|
||||
|
||||
if (bNum)
|
||||
strRes += _T(",");
|
||||
|
||||
lParam2 = ConvertFmlaParam(strY, eType2, strY, strGuides, mapGuides);
|
||||
strRes += ConvertPathParam (lParam2, eType2, bNum);
|
||||
|
||||
if (bLPoint)
|
||||
{
|
||||
ConvertFmla( ftVal, lParam1, eType1);
|
||||
ConvertFmla( ftVal, lParam2, eType2);
|
||||
}
|
||||
return strRes;
|
||||
}
|
||||
std::wstring CConverterPPTXPPT::ConvertPathParam (LONG lParam, ParamType eType, bool &bNum)
|
||||
{
|
||||
std::wstring strRes;
|
||||
|
||||
if (eType == ptAdjust)
|
||||
strRes = L"#";
|
||||
else if (eType == ptValue)
|
||||
{
|
||||
bNum = true;
|
||||
}
|
||||
else
|
||||
strRes = L"@";
|
||||
|
||||
strRes += std::to_wstring(lParam);
|
||||
|
||||
return strRes;
|
||||
}
|
||||
}
|
||||
@ -30,14 +30,12 @@
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "PptxFormula.h"
|
||||
#include "../Path.h"
|
||||
#include "../PPTShape/PptFormula.h"
|
||||
#include "../PPTShape/PptShape.h"
|
||||
#include "../PPTXShape/PptxShape.h"
|
||||
#include "../PPTShape/Ppt2PptxShapeConverter.h"
|
||||
|
||||
namespace NSGuidesVML
|
||||
{
|
||||
|
||||
class CConverterPPTXPPT
|
||||
{
|
||||
private:
|
||||
@ -58,560 +56,39 @@ namespace NSGuidesVML
|
||||
LONG m_lPPT2PPTX;
|
||||
|
||||
public:
|
||||
|
||||
CConverterPPTXPPT ()
|
||||
{
|
||||
m_lPPTX2PPT = -1;
|
||||
m_lPPT2PPTX = -1;
|
||||
m_lIndexDst = -1;
|
||||
m_lIndexAdj = -1;
|
||||
pPPTShape = new CPPTShape();
|
||||
}
|
||||
CConverterPPTXPPT();
|
||||
|
||||
inline CPPTShape* GetConvertedShape()
|
||||
{
|
||||
return pPPTShape;
|
||||
}
|
||||
|
||||
void Convert ( CPPTXShape* pPPTXShape )
|
||||
{
|
||||
ConvertAdjastments ( pPPTXShape->m_arAdjustments, pPPTXShape->FManager.mapAdjustments );
|
||||
AddSizeGuides ((LONG)pPPTXShape->FManager.GetWidth(), (LONG)pPPTXShape->FManager.GetHeight());
|
||||
ConvertGuides ( pPPTXShape->FManager.strGuides, pPPTXShape->FManager.mapGuides);
|
||||
ConvertPath( pPPTXShape->m_strPath, pPPTXShape->FManager.strGuides, pPPTXShape->FManager.mapGuides);
|
||||
void Convert ( CPPTXShape* pPPTXShape );
|
||||
void ConvertHandles (std::vector<CHandle_>& arHnd);
|
||||
void ConvertAdjastments( std::vector<long> &arAdj, std::map<std::wstring, long> &mapAdj );
|
||||
void ConvertTextRects (std::vector<std::wstring> &arTextRects);
|
||||
void ConvertType (OOXMLShapes::ShapeType eType);
|
||||
|
||||
//TODO текстовые поля
|
||||
//ConvertTextRects ( pPPTXShape->m_arStringTextRects );
|
||||
ConvertHandles ( pPPTXShape->m_arHandles );
|
||||
void AddSizeGuides (LONG lWidth, LONG lHeight);
|
||||
|
||||
//ConvertType ( pPPTXShape->m_eType );
|
||||
//------------------------------------
|
||||
int i=0;
|
||||
}
|
||||
LONG ConvertFmlaParam (std::wstring strParam, NSGuidesVML::ParamType &eType, std::wstring strKey, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides);
|
||||
|
||||
void ConvertHandles (std::vector<CHandle_>& arHnd)
|
||||
{
|
||||
void ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1, LONG lParam2, ParamType eType2, LONG lParam3, ParamType eType3 );
|
||||
|
||||
for (size_t nIndex=0; nIndex<arHnd.size(); nIndex++)
|
||||
{
|
||||
CHandle_ oHandle;
|
||||
//TODO переименовать названия формул и прокинуть текстовые атрибуты topleft, rightbottom в полях хендла
|
||||
void ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1, LONG lParam2, ParamType eType2 );
|
||||
|
||||
pPPTShape->m_arHandles.push_back(oHandle);
|
||||
}
|
||||
void ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1 );
|
||||
|
||||
return;
|
||||
}
|
||||
void ConvertGuid ( NSGuidesOOXML::CFormula pFormula, std::wstring strKey, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides);
|
||||
|
||||
void ConvertAdjastments( std::vector<long> &arAdj, std::map<std::wstring, long> &mapAdj )
|
||||
{
|
||||
int i=0;
|
||||
for( std::map<std::wstring, long>::iterator pPair = mapAdj.begin(); pPair != mapAdj.end(); i++, ++pPair)
|
||||
{
|
||||
m_arMapAdj.insert(std::pair<std::wstring, LONG>(pPair->first, ++m_lIndexAdj));
|
||||
pPPTShape->m_arAdjustments.push_back(arAdj[i]);
|
||||
}
|
||||
//это аджасменты для перевода углов tan(angle, adj)
|
||||
//тк все угла в формулах считаются в pptx
|
||||
//pptx->ppt
|
||||
pPPTShape->m_arAdjustments.push_back(3114601);
|
||||
m_lPPTX2PPT = ++m_lIndexAdj;
|
||||
//ppt->pptx
|
||||
pPPTShape->m_arAdjustments.push_back(2783638);
|
||||
m_lPPT2PPTX = ++m_lIndexAdj;
|
||||
return;
|
||||
}
|
||||
void ConvertGuides ( std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides );
|
||||
|
||||
void ConvertTextRects (std::vector<std::wstring> &arTextRects)
|
||||
{
|
||||
pPPTShape->m_arStringTextRects.insert( pPPTShape->m_arStringTextRects.end(), arTextRects.begin(), arTextRects.end());
|
||||
return;
|
||||
}
|
||||
void ConvertPath(const std::wstring& xml, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides);
|
||||
|
||||
void ConvertType (OOXMLShapes::ShapeType eType)
|
||||
{
|
||||
switch (eType)
|
||||
{
|
||||
case OOXMLShapes::sptCRect:
|
||||
pPPTShape->m_eType = PPTShapes::sptCRect;
|
||||
break;
|
||||
case OOXMLShapes::sptCArc:
|
||||
pPPTShape->m_eType = PPTShapes::sptCRect;
|
||||
break;
|
||||
default:
|
||||
pPPTShape->m_eType = PPTShapes::sptCustom;
|
||||
}
|
||||
return;
|
||||
}
|
||||
LONG ConvertArcParam (std::wstring strParam, NSGuidesVML::ParamType &eType);
|
||||
|
||||
void AddSizeGuides (LONG lWidth, LONG lHeight)
|
||||
{
|
||||
//TODO прокинуть w и h в формулах
|
||||
NSGuidesVML::CFormula pNewFmla3;
|
||||
pNewFmla3.m_eFormulaType = ftVal;
|
||||
pNewFmla3.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla3.m_eType1 = ptValue;
|
||||
pNewFmla3.m_lParam1 = 21600;// lWidth;
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla3);
|
||||
m_arMapFormula.insert(std::pair<std::wstring, LONG>(_T("w"), m_lIndexDst));
|
||||
std::wstring ConvertPathPoint (std::wstring strX, std::wstring strY, bool &bNum, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides, bool bLPoint);
|
||||
|
||||
pNewFmla3.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla3.m_eType1 = ptValue;
|
||||
pNewFmla3.m_lParam1 = 21600;//lHeight;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla3);
|
||||
|
||||
m_arMapFormula.insert(std::pair<std::wstring, LONG>(_T("h"), m_lIndexDst));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LONG ConvertFmlaParam (std::wstring strParam, NSGuidesVML::ParamType &eType, std::wstring strKey, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides)
|
||||
{
|
||||
LONG lVal = 0;
|
||||
|
||||
std::map<std::wstring, LONG>::iterator NumFmla = m_arMapFormula.find(strParam);
|
||||
std::map<std::wstring, LONG>::iterator NumAdj = m_arMapAdj.find(strParam);
|
||||
std::map<std::wstring, LONG>::iterator NumGuides = mapGuides.find(strParam);
|
||||
|
||||
if (NumAdj != m_arMapAdj.end())
|
||||
{
|
||||
eType = ptAdjust;
|
||||
lVal = NumAdj->second;
|
||||
}
|
||||
else if (NumFmla == m_arMapFormula.end())
|
||||
{
|
||||
//пришло число
|
||||
if (NumGuides == mapGuides.end())
|
||||
{
|
||||
lVal = (LONG)XmlUtils::GetInteger(strParam);
|
||||
if (lVal > 65535)
|
||||
{
|
||||
ConvertFmla( ftSumangle, lVal%65536, ptValue, (int)lVal/65536, ptValue, 0, ptValue);
|
||||
eType = ptFormula;
|
||||
lVal = m_lIndexDst;
|
||||
}
|
||||
else if (lVal < 0)
|
||||
{
|
||||
ConvertFmla( ftSum, 0, ptValue, 0, ptValue, abs(lVal), ptValue);
|
||||
eType = ptFormula;
|
||||
lVal = m_lIndexDst;
|
||||
}
|
||||
else
|
||||
eType = ptValue;
|
||||
}
|
||||
else //пришла стандартная формула из набора, которую надо теперь добавить
|
||||
{
|
||||
LONG lNumGuides = NumGuides->second;
|
||||
|
||||
NSGuidesOOXML::CFormula pFormula = strGuides[lNumGuides];
|
||||
|
||||
//strKey = mapGuides.GetKeyAt(lNumGuides);
|
||||
int ind =0;
|
||||
for (std::map<std::wstring, long>::iterator p = mapGuides.begin(); p!= mapGuides.end(); ++p)
|
||||
{
|
||||
if (ind == lNumGuides)
|
||||
{
|
||||
strKey = p->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ConvertGuid(pFormula, strKey, strGuides, mapGuides);
|
||||
eType = ptFormula;
|
||||
lVal = m_lIndexDst;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eType = ptFormula;
|
||||
std::map<std::wstring, LONG>::iterator Val = m_arMapFormula.find(strParam);
|
||||
lVal = Val->second;
|
||||
}
|
||||
return lVal;
|
||||
}
|
||||
|
||||
void ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1, LONG lParam2, ParamType eType2, LONG lParam3, ParamType eType3 )
|
||||
{
|
||||
NSGuidesVML::CFormula pNewFmla;
|
||||
pNewFmla.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla.m_eFormulaType = eFmlaType;
|
||||
|
||||
pNewFmla.m_eType1 = eType1;
|
||||
pNewFmla.m_lParam1 = lParam1;
|
||||
|
||||
pNewFmla.m_eType2 = eType2;
|
||||
pNewFmla.m_lParam2 = lParam2;
|
||||
|
||||
pNewFmla.m_eType3 = eType3;
|
||||
pNewFmla.m_lParam3 = lParam3;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla);
|
||||
return;
|
||||
}
|
||||
|
||||
void ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1, LONG lParam2, ParamType eType2 )
|
||||
{
|
||||
CFormula pNewFmla;
|
||||
pNewFmla.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla.m_eFormulaType = eFmlaType;
|
||||
|
||||
pNewFmla.m_eType1 = eType1;
|
||||
pNewFmla.m_lParam1 = lParam1;
|
||||
|
||||
pNewFmla.m_eType2 = eType2;
|
||||
pNewFmla.m_lParam2 = lParam2;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla);
|
||||
return;
|
||||
}
|
||||
|
||||
void ConvertFmla ( FormulaType eFmlaType, LONG lParam1, ParamType eType1 )
|
||||
{
|
||||
CFormula pNewFmla;
|
||||
pNewFmla.m_lIndex = ++m_lIndexDst;
|
||||
pNewFmla.m_eFormulaType = eFmlaType;
|
||||
|
||||
pNewFmla.m_eType1 = eType1;
|
||||
pNewFmla.m_lParam1 = lParam1;
|
||||
|
||||
pPPTShape->m_oManager.m_arFormulas.push_back(pNewFmla);
|
||||
return;
|
||||
}
|
||||
|
||||
void ConvertGuid ( NSGuidesOOXML::CFormula pFormula, std::wstring strKey, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides)
|
||||
{
|
||||
LONG lParam1, lParam2, lParam3;
|
||||
NSGuidesVML::ParamType eType1, eType2, eType3;
|
||||
|
||||
lParam1 = ConvertFmlaParam(pFormula.m_lParam1, eType1, strKey, strGuides, mapGuides);
|
||||
lParam2 = ConvertFmlaParam(pFormula.m_lParam2, eType2, strKey, strGuides, mapGuides);
|
||||
lParam3 = ConvertFmlaParam(pFormula.m_lParam3, eType3, strKey, strGuides, mapGuides);
|
||||
|
||||
switch (pFormula.m_eFormulaType)
|
||||
{
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSum:
|
||||
ConvertFmla( ftSum, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLProduct:
|
||||
ConvertFmla( ftProduct, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLIf:
|
||||
ConvertFmla( ftIf, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLAbsolute:
|
||||
ConvertFmla( ftAbsolute, lParam1, eType1);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLAtan2:
|
||||
ConvertFmla( ftAtan2, lParam1, eType1, lParam2, eType2);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLCos:
|
||||
ConvertFmla( ftCos, lParam1, eType1, lParam2, eType2);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLMax:
|
||||
ConvertFmla( ftMax, lParam1, eType1, lParam2, eType2);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLMin:
|
||||
ConvertFmla( ftMin, lParam1, eType1, lParam2, eType2);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLMod:
|
||||
ConvertFmla( ftMod, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSinatan2:
|
||||
ConvertFmla( ftSinatan2, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLCosatan2:
|
||||
ConvertFmla( ftCosatan2, lParam1, eType1, lParam2, eType2, lParam3, eType3);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSin:
|
||||
ConvertFmla( ftSin, lParam1, eType1, lParam2, eType2);
|
||||
ConvertFmla( ftTan, m_lIndexDst, ptFormula, m_lPPT2PPTX, ptAdjust);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLSqrt:
|
||||
ConvertFmla( ftSqrt, lParam1, eType1);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLTan:
|
||||
ConvertFmla( ftTan, lParam1, eType1, lParam2, eType2);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLVal:
|
||||
ConvertFmla( ftVal, lParam1, eType1);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLAddDivide:
|
||||
ConvertFmla( ftSum, lParam1, eType1, lParam2, eType2, 0, ptValue);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, 1, ptValue, lParam3, eType3);
|
||||
break;
|
||||
case NSGuidesOOXML::CFormula::ftOOXMLPin:
|
||||
ConvertFmla( ftSum, lParam1, eType1, 0, ptValue, lParam2, eType2);
|
||||
ConvertFmla( ftSum, lParam2, eType2, 0, ptValue, lParam3, eType3);
|
||||
ConvertFmla( ftIf, m_lIndexDst, ptFormula, lParam3, eType3, lParam2, eType2);
|
||||
ConvertFmla( ftIf, m_lIndexDst-2, ptFormula, lParam1, eType1, m_lIndexDst, ptFormula);
|
||||
break;
|
||||
}
|
||||
m_arMapFormula.insert(std::pair<std::wstring, LONG>(strKey, m_lIndexDst));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void ConvertGuides ( std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides )
|
||||
{
|
||||
//стандартные формулы для пптх будем добавлять, если только они встретятся
|
||||
for (size_t nIndex=32; nIndex < strGuides.size(); ++nIndex)
|
||||
{
|
||||
NSGuidesOOXML::CFormula pFormula = strGuides[nIndex];
|
||||
|
||||
std::wstring strKey;// = mapGuides.GetKeyAt(nIndex);
|
||||
int ind =0;
|
||||
for (std::map<std::wstring, long>::iterator p = mapGuides.begin(); p!= mapGuides.end(); ++p)
|
||||
{
|
||||
if (ind == nIndex)
|
||||
{
|
||||
strKey = p->first;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ConvertGuid(pFormula, strKey, strGuides, mapGuides);
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertPath(const std::wstring& xml, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides)
|
||||
{
|
||||
XmlUtils::CXmlNode pathLst;
|
||||
if(pathLst.FromXmlString(xml))
|
||||
{
|
||||
XmlUtils::CXmlNodes list;
|
||||
if (pathLst.GetNodes(_T("path"), list))
|
||||
{
|
||||
int nPathCount = list.GetCount();
|
||||
for (int i=0; i<nPathCount; i++)
|
||||
{
|
||||
XmlUtils::CXmlNode PathNode;
|
||||
if(list.GetAt(i, PathNode))
|
||||
{
|
||||
XmlUtils::CXmlNodes listNode;
|
||||
PathNode.GetNodes(_T("*"), listNode);
|
||||
|
||||
bool bFill = PathNode.GetAttribute(_T("fill"), _T("norm")) != _T("none");
|
||||
std::wstring stroke = PathNode.GetAttribute(_T("stroke"), _T("true"));
|
||||
bool bStroke = (stroke == _T("true")) || (stroke == _T("1"));
|
||||
|
||||
int nNodeCount = listNode.GetCount();
|
||||
for (int j=0; j<nNodeCount; j++)
|
||||
{
|
||||
XmlUtils::CXmlNode node;
|
||||
if(listNode.GetAt(j, node))
|
||||
{
|
||||
bool bNum = false; //управляем запятыми
|
||||
|
||||
std::wstring strName = node.GetName();
|
||||
if (strName == _T("moveTo"))
|
||||
pPPTShape->m_strPath += _T("m");
|
||||
else if (strName == _T("lnTo"))
|
||||
pPPTShape->m_strPath += _T("l");
|
||||
else if (strName == _T("arcTo"))
|
||||
pPPTShape->m_strPath += _T("ae");
|
||||
else if (strName == _T("cubicBezTo"))
|
||||
pPPTShape->m_strPath += _T("c");
|
||||
else if (strName == _T("quadBezTo"))
|
||||
pPPTShape->m_strPath += _T("qb");
|
||||
else
|
||||
pPPTShape->m_strPath += _T("x");
|
||||
|
||||
if (strName == _T("arcTo"))
|
||||
{
|
||||
LONG lStartX = m_lIndexDst-1, lStartY = m_lIndexDst;
|
||||
LONG lParam1, lParam2, lParam3, lParam4;
|
||||
NSGuidesVML::ParamType eType1, eType2, eType3, eType4;
|
||||
|
||||
lParam1 = ConvertFmlaParam(node.GetAttribute(_T("wR")), eType1, node.GetAttribute(_T("wR")), strGuides, mapGuides);
|
||||
lParam2 = ConvertFmlaParam(node.GetAttribute(_T("hR")), eType2, node.GetAttribute(_T("hR")), strGuides, mapGuides);
|
||||
lParam3 = ConvertFmlaParam(node.GetAttribute(_T("stAng")), eType3, node.GetAttribute(_T("stAng")), strGuides, mapGuides);
|
||||
lParam4 = ConvertFmlaParam(node.GetAttribute(_T("swAng")), eType4, node.GetAttribute(_T("swAng")), strGuides, mapGuides);
|
||||
|
||||
//stAng
|
||||
ConvertFmla( ftTan, lParam3, eType3, m_lPPTX2PPT, ptAdjust);
|
||||
//swAng
|
||||
ConvertFmla( ftTan, lParam4, eType4, m_lPPTX2PPT, ptAdjust);
|
||||
//a
|
||||
ConvertFmla( ftVal, lParam1, eType1);
|
||||
//b
|
||||
ConvertFmla( ftVal, lParam2, eType2);
|
||||
LONG lstAng = m_lIndexDst-3, lswAng = m_lIndexDst-2, la = m_lIndexDst-1, lb = m_lIndexDst;
|
||||
//радиус эллипса в stAng--------------------
|
||||
//(b*cos)^2
|
||||
ConvertFmla( ftCos, m_lIndexDst, ptFormula, m_lIndexDst-3, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
//(a*sin)^2
|
||||
ConvertFmla( ftSin, m_lIndexDst-3, ptFormula, m_lIndexDst-5, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
ConvertFmla( ftSum, m_lIndexDst-2, ptFormula, m_lIndexDst, ptFormula, 0, ptValue);
|
||||
ConvertFmla( ftSqrt, m_lIndexDst, ptFormula);
|
||||
//r
|
||||
ConvertFmla( ftProduct, la, ptFormula, lb, ptFormula, m_lIndexDst, ptFormula);
|
||||
|
||||
//r*cos(stAng)
|
||||
ConvertFmla( ftCos, m_lIndexDst, ptFormula, lstAng, ptFormula);
|
||||
//xc
|
||||
ConvertFmla( ftSum, lStartX, ptFormula, 0, ptValue, m_lIndexDst, ptFormula);
|
||||
//r*sin(stAng)
|
||||
ConvertFmla( ftSin, m_lIndexDst-2, ptFormula, lstAng, ptFormula);
|
||||
//yc
|
||||
ConvertFmla( ftSum, lStartY, ptFormula, 0, ptValue, m_lIndexDst, ptFormula);
|
||||
//endAng
|
||||
ConvertFmla( ftSum, lstAng, ptFormula, lswAng, ptFormula, 0, ptValue);
|
||||
|
||||
//радиус эллипса в endAng--------------------
|
||||
//(b*cos)^2
|
||||
ConvertFmla( ftCos, lb, ptFormula, m_lIndexDst, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
//(a*sin)^2
|
||||
ConvertFmla( ftSin, la, ptFormula, m_lIndexDst-2, ptFormula);
|
||||
ConvertFmla( ftProduct, m_lIndexDst, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
ConvertFmla( ftSum, m_lIndexDst-2, ptFormula, m_lIndexDst, ptFormula, 0, ptValue);
|
||||
ConvertFmla( ftSqrt, m_lIndexDst, ptFormula);
|
||||
//r
|
||||
ConvertFmla( ftProduct, la, ptFormula, lb, ptFormula, m_lIndexDst, ptFormula);
|
||||
|
||||
//r*cos(endAng)
|
||||
ConvertFmla( ftCos, m_lIndexDst, ptFormula, m_lIndexDst-7, ptFormula);
|
||||
//xEnd
|
||||
ConvertFmla( ftSum, m_lIndexDst-11, ptFormula, m_lIndexDst, ptFormula, 0, ptValue);
|
||||
//r*sin(endAng)
|
||||
ConvertFmla( ftSin, m_lIndexDst-2, ptFormula, m_lIndexDst-9, ptFormula);
|
||||
//yEnd
|
||||
ConvertFmla( ftSum, m_lIndexDst-11, ptFormula, m_lIndexDst, ptFormula, 0, ptValue );
|
||||
|
||||
std::wstring xC = L"@" + std::to_wstring( m_lIndexDst-14);
|
||||
std::wstring yC = L"@" + std::to_wstring( m_lIndexDst-12);
|
||||
std::wstring wR = L"@" + std::to_wstring( la);
|
||||
std::wstring hR = L"@" + std::to_wstring( lb);
|
||||
|
||||
//360
|
||||
ConvertFmla( ftSumangle, 0, ptValue, 360, ptValue, 0, ptValue );
|
||||
//360-stAng
|
||||
ConvertFmla( ftSum, m_lIndexDst, ptFormula, 0, ptValue, lstAng, ptFormula);
|
||||
//-1
|
||||
ConvertFmla( ftSum, 0, ptValue, 0, ptValue, 1, ptValue);
|
||||
//-1*swAng
|
||||
ConvertFmla( ftProduct, lswAng, ptFormula, m_lIndexDst, ptFormula, 1, ptValue);
|
||||
|
||||
std::wstring stAng = L"@" + std::to_wstring( m_lIndexDst-2);
|
||||
std::wstring swAng = L"@" + std::to_wstring( m_lIndexDst);
|
||||
//std::wstring xEnd = _T(""); xEnd.Format(_T("@%d"), m_lIndexDst-5);
|
||||
//std::wstring yEnd = _T(""); yEnd.Format(_T("@%d"), m_lIndexDst-4);
|
||||
|
||||
pPPTShape->m_strPath += xC + yC + wR + hR + stAng + swAng;
|
||||
|
||||
ConvertFmla( ftVal, m_lIndexDst - 6, ptFormula);
|
||||
ConvertFmla( ftVal, m_lIndexDst - 5, ptFormula);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
XmlUtils::CXmlNodes ptList;
|
||||
node.GetNodes(_T("pt"), ptList);
|
||||
int nPtCount = ptList.GetCount();
|
||||
|
||||
for (int k=0; k<nPtCount; k++)
|
||||
{
|
||||
bool bLastPount = false;
|
||||
if ( k == nPtCount-1)
|
||||
bLastPount = true;
|
||||
|
||||
XmlUtils::CXmlNode ptNode;
|
||||
if(ptList.GetAt(k, ptNode))
|
||||
{
|
||||
std::wstring ptX = ptNode.GetAttribute(_T("x"));
|
||||
std::wstring ptY = ptNode.GetAttribute(_T("y"));
|
||||
|
||||
pPPTShape->m_strPath += ConvertPathPoint( ptX, ptY, bNum, strGuides, mapGuides, bLastPount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bFill)
|
||||
pPPTShape->m_strPath += _T("nf");
|
||||
if (!bStroke)
|
||||
pPPTShape->m_strPath += _T("ns");
|
||||
}
|
||||
pPPTShape->m_strPath += _T("e");
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LONG ConvertArcParam (std::wstring strParam, NSGuidesVML::ParamType &eType)
|
||||
{
|
||||
LONG lVal = 0;
|
||||
|
||||
std::map<std::wstring, LONG>::iterator NumFmla = m_arMapFormula.find(strParam);
|
||||
std::map<std::wstring, LONG>::iterator NumAdj = m_arMapAdj.find(strParam);
|
||||
|
||||
if (NumAdj != m_arMapAdj.end())
|
||||
{
|
||||
eType = ptAdjust;
|
||||
lVal = NumAdj->second; //индекс в map ???
|
||||
}
|
||||
else if (NumFmla == m_arMapFormula.end())
|
||||
{
|
||||
eType = ptValue;
|
||||
lVal = (LONG)XmlUtils::GetInteger(strParam);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
eType = ptFormula;
|
||||
lVal = m_arMapFormula.find(strParam)->second;
|
||||
}
|
||||
return lVal;
|
||||
}
|
||||
|
||||
std::wstring ConvertPathPoint (std::wstring strX, std::wstring strY, bool &bNum, std::vector<NSGuidesOOXML::CFormula> &strGuides, std::map<std::wstring, long> &mapGuides, bool bLPoint)
|
||||
{
|
||||
std::wstring strRes = _T("");
|
||||
ParamType eType1, eType2;
|
||||
LONG lParam1, lParam2;
|
||||
|
||||
if (bNum)
|
||||
strRes += _T(",");
|
||||
lParam1 = ConvertFmlaParam(strX, eType1, strX, strGuides, mapGuides);
|
||||
strRes += ConvertPathParam (lParam1, eType1, bNum);
|
||||
|
||||
if (bNum)
|
||||
strRes += _T(",");
|
||||
|
||||
lParam2 = ConvertFmlaParam(strY, eType2, strY, strGuides, mapGuides);
|
||||
strRes += ConvertPathParam (lParam2, eType2, bNum);
|
||||
|
||||
if (bLPoint)
|
||||
{
|
||||
ConvertFmla( ftVal, lParam1, eType1);
|
||||
ConvertFmla( ftVal, lParam2, eType2);
|
||||
}
|
||||
return strRes;
|
||||
}
|
||||
|
||||
std::wstring ConvertPathParam (LONG lParam, ParamType eType, bool &bNum)
|
||||
{
|
||||
std::wstring strRes;
|
||||
|
||||
if (eType == ptAdjust)
|
||||
strRes = L"#";
|
||||
else if (eType == ptValue)
|
||||
{
|
||||
bNum = true;
|
||||
}
|
||||
else
|
||||
strRes = L"@";
|
||||
|
||||
strRes += std::to_wstring(lParam);
|
||||
|
||||
return strRes;
|
||||
}
|
||||
std::wstring ConvertPathParam (LONG lParam, ParamType eType, bool &bNum);
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,60 +40,331 @@
|
||||
#define max(a,b) (((a)>(b))?(a):(b))
|
||||
#endif
|
||||
|
||||
double NSGuidesOOXML::CFormula::Calculate(NSGuidesOOXML::CFormulaManager* pManager)
|
||||
namespace NSGuidesOOXML
|
||||
{
|
||||
if ((0 == m_lIndex) || (-m_lIndex > (int)pManager->Guides->size()) || (m_lIndex > (int)pManager->Adjustments->size()))
|
||||
return 0.0;
|
||||
if((m_lIndex < 0) && (dNonDefResult > (*pManager->Guides)[-m_lIndex-1]))
|
||||
return (*pManager->Guides)[-m_lIndex-1];
|
||||
if((m_lIndex > 0) && (NonDefResult != (*pManager->Adjustments)[m_lIndex-1]))
|
||||
return (*pManager->Adjustments)[m_lIndex-1];
|
||||
|
||||
double a = pManager->GetValue(m_lParam1);
|
||||
double b = pManager->GetValue(m_lParam2);
|
||||
double c = pManager->GetValue(m_lParam3);
|
||||
//double c = (double)c1;
|
||||
|
||||
double dRes = 0.0;
|
||||
|
||||
try
|
||||
CFormula::FormulaType CFormula::GetFormula(std::wstring strName, bool& bRes)
|
||||
{
|
||||
// теперь нужно просто посчитать
|
||||
switch (m_eFormulaType)
|
||||
bRes = true;
|
||||
if (_T("+-") == strName) return ftOOXMLSum;
|
||||
else if (_T("*/") == strName) return ftOOXMLProduct;
|
||||
else if (_T("+/") == strName) return ftOOXMLAddDivide;
|
||||
else if (_T("abs") == strName) return ftOOXMLAbsolute;
|
||||
else if (_T("min") == strName) return ftOOXMLMin;
|
||||
else if (_T("max") == strName) return ftOOXMLMax;
|
||||
else if (_T("?:") == strName) return ftOOXMLIf;
|
||||
else if (_T("sqrt") == strName) return ftOOXMLSqrt;
|
||||
else if (_T("mod") == strName) return ftOOXMLMod;
|
||||
else if (_T("sin") == strName) return ftOOXMLSin;
|
||||
else if (_T("cos") == strName) return ftOOXMLCos;
|
||||
else if (_T("tan") == strName) return ftOOXMLTan;
|
||||
else if (_T("at2") == strName) return ftOOXMLAtan2;
|
||||
else if (_T("sat2") == strName) return ftOOXMLSinatan2;
|
||||
else if (_T("cat2") == strName) return ftOOXMLCosatan2;
|
||||
else if (_T("pin") == strName) return ftOOXMLPin;
|
||||
else if (_T("val") == strName) return ftOOXMLVal;
|
||||
else bRes = false;
|
||||
|
||||
return ftOOXMLVal;
|
||||
}
|
||||
|
||||
CFormula::CFormula(long ind)
|
||||
{
|
||||
m_sName = _T("");
|
||||
m_eFormulaType = ftOOXMLSum;
|
||||
m_lIndex = ind;
|
||||
m_lParam1 = _T("0");
|
||||
m_lParam2 = _T("0");
|
||||
m_lParam3 = _T("0");
|
||||
}
|
||||
CFormula& CFormula::operator =(const CFormula& src)
|
||||
{
|
||||
m_sName = src.m_sName;
|
||||
m_eFormulaType = src.m_eFormulaType;
|
||||
m_lIndex = src.m_lIndex;
|
||||
m_lParam1 = src.m_lParam1;
|
||||
m_lParam2 = src.m_lParam2;
|
||||
m_lParam3 = src.m_lParam3;
|
||||
|
||||
return *this;
|
||||
}
|
||||
void CFormula::FromString(std::wstring strFormula)
|
||||
{
|
||||
std::vector<std::wstring> oArrayParams;
|
||||
|
||||
boost::algorithm::split(oArrayParams, strFormula, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
int nCount = (int)oArrayParams.size();
|
||||
if (0 >= nCount)
|
||||
return;
|
||||
|
||||
bool bRes = true;
|
||||
m_eFormulaType = GetFormula(oArrayParams[0], bRes);
|
||||
|
||||
// ParamType ptType = ptValue;
|
||||
if (1 < nCount)
|
||||
m_lParam1 = oArrayParams[1];
|
||||
if (2 < nCount)
|
||||
m_lParam2 = oArrayParams[2];
|
||||
if (3 < nCount)
|
||||
m_lParam3 = oArrayParams[3];
|
||||
}
|
||||
double CFormula::Calculate(NSGuidesOOXML::CFormulaManager* pManager)
|
||||
{
|
||||
if ((0 == m_lIndex) || (-m_lIndex > (int)pManager->Guides->size()) || (m_lIndex > (int)pManager->Adjustments->size()))
|
||||
return 0.0;
|
||||
if((m_lIndex < 0) && (dNonDefResult > (*pManager->Guides)[-m_lIndex-1]))
|
||||
return (*pManager->Guides)[-m_lIndex-1];
|
||||
if((m_lIndex > 0) && (NonDefResult != (*pManager->Adjustments)[m_lIndex-1]))
|
||||
return (*pManager->Adjustments)[m_lIndex-1];
|
||||
|
||||
double a = pManager->GetValue(m_lParam1);
|
||||
double b = pManager->GetValue(m_lParam2);
|
||||
double c = pManager->GetValue(m_lParam3);
|
||||
//double c = (double)c1;
|
||||
|
||||
double dRes = 0.0;
|
||||
|
||||
try
|
||||
{
|
||||
case ftOOXMLSum: { dRes = a + b - c; break; }
|
||||
case ftOOXMLProduct: {/*if(0==c1)c=1.0;*/ dRes = (a * b)/c; break; }
|
||||
case ftOOXMLAddDivide: {/*if(0==c1)c=1.0;*/ dRes = (a + b)/c; break; }
|
||||
case ftOOXMLAbsolute: { dRes = abs(a); break; }
|
||||
case ftOOXMLMin: { dRes = min(a, b); break; }
|
||||
case ftOOXMLMax: { dRes = max(a, b); break; }
|
||||
case ftOOXMLIf: { dRes = (a > 0) ? b : c; break; }
|
||||
case ftOOXMLSqrt: { dRes = sqrt(a); break; }
|
||||
case ftOOXMLMod: { dRes = sqrt(a*a + b*b + c*c); break; }
|
||||
case ftOOXMLSin: { dRes = a * sin(b * RadKoef); break; }
|
||||
case ftOOXMLCos: { dRes = a * cos(b * RadKoef); break; }
|
||||
case ftOOXMLTan: { dRes = a * tan(b * RadKoef); break; }
|
||||
case ftOOXMLAtan2: { dRes = atan2(b,a)/RadKoef; break; }
|
||||
case ftOOXMLSinatan2: { dRes = a * sin(atan2(c,b)); break; }
|
||||
case ftOOXMLCosatan2: { dRes = a * cos(atan2(c,b)); break; }
|
||||
case ftOOXMLPin: { dRes = (b < a) ? a :((b > c) ? c : b);break; }
|
||||
case ftOOXMLVal: { dRes = a; break; }
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
dRes = 0.0;
|
||||
// теперь нужно просто посчитать
|
||||
switch (m_eFormulaType)
|
||||
{
|
||||
case ftOOXMLSum: { dRes = a + b - c; break; }
|
||||
case ftOOXMLProduct: {/*if(0==c1)c=1.0;*/ dRes = (a * b)/c; break; }
|
||||
case ftOOXMLAddDivide: {/*if(0==c1)c=1.0;*/ dRes = (a + b)/c; break; }
|
||||
case ftOOXMLAbsolute: { dRes = abs(a); break; }
|
||||
case ftOOXMLMin: { dRes = min(a, b); break; }
|
||||
case ftOOXMLMax: { dRes = max(a, b); break; }
|
||||
case ftOOXMLIf: { dRes = (a > 0) ? b : c; break; }
|
||||
case ftOOXMLSqrt: { dRes = sqrt(a); break; }
|
||||
case ftOOXMLMod: { dRes = sqrt(a*a + b*b + c*c); break; }
|
||||
case ftOOXMLSin: { dRes = a * sin(b * RadKoef); break; }
|
||||
case ftOOXMLCos: { dRes = a * cos(b * RadKoef); break; }
|
||||
case ftOOXMLTan: { dRes = a * tan(b * RadKoef); break; }
|
||||
case ftOOXMLAtan2: { dRes = atan2(b,a)/RadKoef; break; }
|
||||
case ftOOXMLSinatan2: { dRes = a * sin(atan2(c,b)); break; }
|
||||
case ftOOXMLCosatan2: { dRes = a * cos(atan2(c,b)); break; }
|
||||
case ftOOXMLPin: { dRes = (b < a) ? a :((b > c) ? c : b);break; }
|
||||
case ftOOXMLVal: { dRes = a; break; }
|
||||
default: break;
|
||||
};
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
dRes = 0.0;
|
||||
}
|
||||
|
||||
//long lResult = (long)dRes;
|
||||
if(m_lIndex < 0)
|
||||
{
|
||||
(*pManager->Guides)[-m_lIndex-1] = dRes;
|
||||
// переопределим формулу
|
||||
pManager->mapGuides.insert(std::pair<std::wstring, long>(m_sName, -m_lIndex-1));
|
||||
}
|
||||
else
|
||||
(*pManager->Adjustments)[m_lIndex-1] = (long)dRes;
|
||||
return dRes;
|
||||
}
|
||||
|
||||
//long lResult = (long)dRes;
|
||||
if(m_lIndex < 0)
|
||||
void CFormulaManager::SetWidthHeight(double w, double h)
|
||||
{
|
||||
(*pManager->Guides)[-m_lIndex-1] = dRes;
|
||||
// переопределим формулу
|
||||
pManager->mapGuides.insert(std::pair<std::wstring, long>(m_sName, -m_lIndex-1));
|
||||
if((w >= 0) && (h >= 0))
|
||||
{
|
||||
Clear();
|
||||
if(w > h)
|
||||
{
|
||||
h = (h * ShapeSize)/w;
|
||||
if(h < 1.0) h = 1.0;
|
||||
w = ShapeSize;
|
||||
}
|
||||
else if(w < h)
|
||||
{
|
||||
w = (w * ShapeSize)/h;
|
||||
if(w < 1.0) w = 1.0;
|
||||
h = ShapeSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = ShapeSize;
|
||||
h = ShapeSize;
|
||||
}
|
||||
m_lShapeWidth = w;
|
||||
m_lShapeHeight = h;
|
||||
}
|
||||
}
|
||||
CFormulaManager::CFormulaManager(std::vector<long>& a, std::vector<double>& g)
|
||||
{
|
||||
Adjustments = &a;
|
||||
Guides = &g;
|
||||
|
||||
m_lShapeWidth = ShapeSize;
|
||||
m_lShapeHeight = ShapeSize;
|
||||
|
||||
AddGuide(_T("3cd4"), _T("val 16200000")); //The units here are in 60,000ths of a degree. This is equivalent to 270 degrees.
|
||||
AddGuide(_T("3cd8"), _T("val 8100000")); //The units here are in 60,000ths of a degree. This is equivalent to 135 degrees.
|
||||
AddGuide(_T("5cd8"), _T("val 13500000")); //The units here are in 60,000ths of a degree. This is equivalent to 225 degrees.
|
||||
AddGuide(_T("7cd8"), _T("val 18900000")); //The units here are in 60,000ths of a degree. This is equivalent to 315 degrees.
|
||||
AddGuide(_T("b"), _T("val h")); //This is the bottom edge of the shape and since the top edge of the shape is considered the 0 point, the
|
||||
//bottom edge is thus the shape height.
|
||||
AddGuide(_T("cd2"), _T("val 10800000")); //The units here are in 60,000ths of a degree. This is equivalent to 180 degrees.
|
||||
AddGuide(_T("cd4"), _T("val 5400000")); //The units here are in 60,000ths of a degree. This is equivalent to 90 degrees.
|
||||
AddGuide(_T("cd8"), _T("val 2700000")); //The units here are in 60,000ths of a degree. This is equivalent to 45 degrees.
|
||||
AddGuide(_T("hc"), _T("*/ w 1 2")); //This is the horizontal center of the shape which is just the width divided by 2.
|
||||
AddGuide(_T("hd2"), _T("*/ h 1 2")); //This is 1/2 the shape height.
|
||||
AddGuide(_T("hd3"), _T("*/ h 1 3")); //This is 1/3 the shape height.
|
||||
AddGuide(_T("hd4"), _T("*/ h 1 4")); //This is 1/4 the shape height.
|
||||
AddGuide(_T("hd5"), _T("*/ h 1 5")); //This is 1/5 the shape height.
|
||||
AddGuide(_T("hd6"), _T("*/ h 1 6")); //This is 1/6 the shape height.
|
||||
AddGuide(_T("hd8"), _T("*/ h 1 8")); //This is 1/8 the shape height.
|
||||
AddGuide(_T("l"), _T("val 0")); //This is the left edge of the shape and the left edge of the shape is considered the horizontal 0 point.
|
||||
AddGuide(_T("ls"), _T("max w h")); //This is the longest side of the shape. This value is either the width or the height depending on which is greater.
|
||||
AddGuide(_T("r"), _T("val w")); //This is the right edge of the shape and since the left edge of the shape is considered the 0 point, the right edge
|
||||
//is thus the shape width.
|
||||
AddGuide(_T("ss"), _T("min w h")); //This is the shortest side of the shape. This value is either the width or the height depending on which is
|
||||
//smaller.
|
||||
AddGuide(_T("ssd2"), _T("*/ ss 1 2")); //This is 1/2 the shortest side of the shape.
|
||||
AddGuide(_T("ssd4"), _T("*/ ss 1 4")); //This is 1/4 the shortest side of the shape.
|
||||
AddGuide(_T("ssd6"), _T("*/ ss 1 6")); //This is 1/6 the shortest side of the shape.
|
||||
AddGuide(_T("ssd8"), _T("*/ ss 1 8")); //This is 1/8 the shortest side of the shape.
|
||||
AddGuide(_T("t"), _T("val 0")); //This is the top edge of the shape and the top edge of the shape is considered the vertical 0 point.
|
||||
AddGuide(_T("vc"), _T("*/ h 1 2")); //This is the vertical center of the shape which is just the height divided by 2.
|
||||
AddGuide(_T("wd2"), _T("*/ w 1 2")); //This is 1/2 the shape width.
|
||||
AddGuide(_T("wd4"), _T("*/ w 1 4")); //This is 1/4 the shape width.
|
||||
AddGuide(_T("wd5"), _T("*/ w 1 5")); //This is 1/5 the shape width.
|
||||
AddGuide(_T("wd6"), _T("*/ w 1 6")); //This is 1/6 the shape width.
|
||||
AddGuide(_T("wd8"), _T("*/ w 1 8")); //This is 1/8 the shape width.
|
||||
AddGuide(_T("wd10"), _T("*/ w 1 10")); //This is 1/10 the shape width.
|
||||
AddGuide(_T("wd32"), _T("*/ w 1 32")); //This is 1/32 the shape width.
|
||||
}
|
||||
CFormulaManager::~CFormulaManager()
|
||||
{
|
||||
mapAdjustments.clear();
|
||||
mapGuides.clear();
|
||||
strAdjustments.clear();
|
||||
strGuides.clear();
|
||||
Adjustments->clear();
|
||||
Guides->clear();
|
||||
}
|
||||
CFormulaManager& CFormulaManager::operator =(const CFormulaManager& manager)
|
||||
{
|
||||
m_lShapeWidth = manager.m_lShapeWidth;
|
||||
m_lShapeHeight = manager.m_lShapeWidth;
|
||||
|
||||
mapAdjustments.clear();
|
||||
for (std::map<std::wstring, long>::const_iterator pPair = manager.mapAdjustments.begin(); pPair != manager.mapAdjustments.end(); ++pPair)
|
||||
{
|
||||
mapAdjustments.insert(std::pair<std::wstring, long>(pPair->first, pPair->second));
|
||||
}
|
||||
|
||||
mapGuides.clear();
|
||||
for (std::map<std::wstring, long>::const_iterator pPair = manager.mapGuides.begin(); pPair != manager.mapGuides.end(); ++pPair)
|
||||
{
|
||||
mapGuides.insert(std::pair<std::wstring, long>(pPair->first, pPair->second));
|
||||
}
|
||||
|
||||
strAdjustments.clear();
|
||||
for(size_t i = 0; i < manager.strAdjustments.size(); i++)
|
||||
{
|
||||
strAdjustments.push_back(manager.strAdjustments[i]);
|
||||
}
|
||||
|
||||
strGuides.clear();
|
||||
for(size_t i = 0; i < manager.strGuides.size(); i++)
|
||||
{
|
||||
strGuides.push_back(manager.strGuides[i]);
|
||||
}
|
||||
|
||||
Adjustments->clear();
|
||||
for(size_t i = 0; i < manager.Adjustments->size(); i++)
|
||||
{
|
||||
Adjustments->push_back((*manager.Adjustments)[i]);
|
||||
}
|
||||
|
||||
Guides->clear();
|
||||
for(size_t i = 0; i < manager.Guides->size(); i++)
|
||||
{
|
||||
Guides->push_back((*manager.Guides)[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
void CFormulaManager::AddAdjustment(const std::wstring& name, const std::wstring& fmla)
|
||||
{
|
||||
std::map<std::wstring, long>::const_iterator pPair = mapAdjustments.find(name);
|
||||
|
||||
if(pPair != mapAdjustments.end())
|
||||
{
|
||||
strAdjustments[pPair->second].FromString(fmla);
|
||||
(*Adjustments)[pPair->second] = NonDefResult;
|
||||
|
||||
return;
|
||||
}
|
||||
CFormula formula( (int)strAdjustments.size() + 1);
|
||||
formula.m_sName = name;
|
||||
formula.FromString(fmla);
|
||||
|
||||
strAdjustments.push_back(formula);
|
||||
Adjustments->push_back(NonDefResult);
|
||||
|
||||
mapAdjustments.insert(std::pair<std::wstring, long>(name, (long)strAdjustments.size() - 1));
|
||||
}
|
||||
void CFormulaManager::AddGuide(const std::wstring& name, const std::wstring& fmla)
|
||||
{
|
||||
/*
|
||||
long num = mapGuides.FindKey(name);
|
||||
if(num >= 0)
|
||||
{
|
||||
strGuides[mapGuides.GetValueAt(num)].FromString(fmla);
|
||||
(*Guides)[mapGuides.GetValueAt(num)] = dNonDefResult;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
// формулы могут повторяться!!!
|
||||
// тогда по мере расчитывания они перетирают друг друга
|
||||
CFormula formula( -1 -(int)strGuides.size());
|
||||
formula.m_sName = name;
|
||||
formula.FromString(fmla);
|
||||
|
||||
strGuides.push_back(formula);
|
||||
Guides->push_back(dNonDefResult);
|
||||
|
||||
mapGuides.insert(std::pair<std::wstring, long>(name, (long)strGuides.size() - 1));
|
||||
}
|
||||
double CFormulaManager::GetValue(std::wstring str)
|
||||
{
|
||||
if(str == _T("w")) return m_lShapeWidth;
|
||||
if(str == _T("h")) return m_lShapeHeight;
|
||||
|
||||
std::map<std::wstring, long>::iterator numGuide = mapGuides.find(str);
|
||||
std::map<std::wstring, long>::iterator numAdj = mapAdjustments.find(str);
|
||||
|
||||
if(numGuide != mapGuides.end())
|
||||
{
|
||||
double res = (*Guides)[numGuide->second];
|
||||
if(res < dNonDefResult)
|
||||
return res;
|
||||
return strGuides[numGuide->second].Calculate(this);
|
||||
}
|
||||
if(numAdj != mapAdjustments.end())
|
||||
{
|
||||
long res = (*Adjustments)[numAdj->second];
|
||||
if(res != NonDefResult)
|
||||
return res;
|
||||
return strAdjustments[numAdj->second].Calculate(this);
|
||||
}
|
||||
return XmlUtils::GetInteger(str);
|
||||
}
|
||||
void CFormulaManager::Clear()
|
||||
{
|
||||
//for(long i = 0; i < Adjustments.size(); i++)
|
||||
// Adjustments[i] = NonDefResult;
|
||||
for(size_t i = 0; i < Guides->size(); i++)
|
||||
(*Guides)[i] = dNonDefResult;
|
||||
}
|
||||
void CFormulaManager::ReCalculateGuides()
|
||||
{
|
||||
Clear();
|
||||
for(size_t i = 0; i < strGuides.size(); i++)
|
||||
(*Guides)[i] = strGuides[i].Calculate(this);
|
||||
}
|
||||
else
|
||||
(*pManager->Adjustments)[m_lIndex-1] = (long)dRes;
|
||||
return dRes;
|
||||
}
|
||||
|
||||
@ -72,30 +72,7 @@ namespace NSGuidesOOXML
|
||||
ftOOXMLVal = 16 // a
|
||||
};
|
||||
|
||||
static FormulaType GetFormula(std::wstring strName, bool& bRes)
|
||||
{
|
||||
bRes = true;
|
||||
if (_T("+-") == strName) return ftOOXMLSum;
|
||||
else if (_T("*/") == strName) return ftOOXMLProduct;
|
||||
else if (_T("+/") == strName) return ftOOXMLAddDivide;
|
||||
else if (_T("abs") == strName) return ftOOXMLAbsolute;
|
||||
else if (_T("min") == strName) return ftOOXMLMin;
|
||||
else if (_T("max") == strName) return ftOOXMLMax;
|
||||
else if (_T("?:") == strName) return ftOOXMLIf;
|
||||
else if (_T("sqrt") == strName) return ftOOXMLSqrt;
|
||||
else if (_T("mod") == strName) return ftOOXMLMod;
|
||||
else if (_T("sin") == strName) return ftOOXMLSin;
|
||||
else if (_T("cos") == strName) return ftOOXMLCos;
|
||||
else if (_T("tan") == strName) return ftOOXMLTan;
|
||||
else if (_T("at2") == strName) return ftOOXMLAtan2;
|
||||
else if (_T("sat2") == strName) return ftOOXMLSinatan2;
|
||||
else if (_T("cat2") == strName) return ftOOXMLCosatan2;
|
||||
else if (_T("pin") == strName) return ftOOXMLPin;
|
||||
else if (_T("val") == strName) return ftOOXMLVal;
|
||||
else bRes = false;
|
||||
|
||||
return ftOOXMLVal;
|
||||
}
|
||||
static FormulaType GetFormula(std::wstring strName, bool& bRes);
|
||||
|
||||
public:
|
||||
FormulaType m_eFormulaType;
|
||||
@ -105,55 +82,16 @@ namespace NSGuidesOOXML
|
||||
std::wstring m_lParam1;
|
||||
std::wstring m_lParam2;
|
||||
std::wstring m_lParam3;
|
||||
|
||||
public:
|
||||
CFormula(long ind = 0)
|
||||
{
|
||||
m_sName = _T("");
|
||||
m_eFormulaType = ftOOXMLSum;
|
||||
m_lIndex = ind;
|
||||
m_lParam1 = _T("0");
|
||||
m_lParam2 = _T("0");
|
||||
m_lParam3 = _T("0");
|
||||
}
|
||||
|
||||
CFormula& operator =(const CFormula& src)
|
||||
{
|
||||
m_sName = src.m_sName;
|
||||
m_eFormulaType = src.m_eFormulaType;
|
||||
m_lIndex = src.m_lIndex;
|
||||
m_lParam1 = src.m_lParam1;
|
||||
m_lParam2 = src.m_lParam2;
|
||||
m_lParam3 = src.m_lParam3;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void FromString(std::wstring strFormula)
|
||||
{
|
||||
std::vector<std::wstring> oArrayParams;
|
||||
|
||||
boost::algorithm::split(oArrayParams, strFormula, boost::algorithm::is_any_of(L" "), boost::algorithm::token_compress_on);
|
||||
|
||||
int nCount = (int)oArrayParams.size();
|
||||
if (0 >= nCount)
|
||||
return;
|
||||
|
||||
bool bRes = true;
|
||||
m_eFormulaType = GetFormula(oArrayParams[0], bRes);
|
||||
|
||||
// ParamType ptType = ptValue;
|
||||
if (1 < nCount)
|
||||
m_lParam1 = oArrayParams[1];
|
||||
if (2 < nCount)
|
||||
m_lParam2 = oArrayParams[2];
|
||||
if (3 < nCount)
|
||||
m_lParam3 = oArrayParams[3];
|
||||
}
|
||||
CFormula(long ind = 0);
|
||||
CFormula& operator =(const CFormula& src);
|
||||
|
||||
void FromString(std::wstring strFormula);
|
||||
double Calculate(CFormulaManager* pManager);
|
||||
};
|
||||
|
||||
class CFormulaManager
|
||||
class CFormulaManager
|
||||
{
|
||||
private:
|
||||
double m_lShapeWidth;
|
||||
@ -166,32 +104,8 @@ public:
|
||||
std::vector<long>* Adjustments;
|
||||
std::vector<double>* Guides;
|
||||
|
||||
void SetWidthHeight(double w, double h)
|
||||
{
|
||||
if((w >= 0) && (h >= 0))
|
||||
{
|
||||
Clear();
|
||||
if(w > h)
|
||||
{
|
||||
h = (h * ShapeSize)/w;
|
||||
if(h < 1.0) h = 1.0;
|
||||
w = ShapeSize;
|
||||
}
|
||||
else if(w < h)
|
||||
{
|
||||
w = (w * ShapeSize)/h;
|
||||
if(w < 1.0) w = 1.0;
|
||||
h = ShapeSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = ShapeSize;
|
||||
h = ShapeSize;
|
||||
}
|
||||
m_lShapeWidth = w;
|
||||
m_lShapeHeight = h;
|
||||
}
|
||||
}
|
||||
void SetWidthHeight(double w, double h);
|
||||
|
||||
inline double GetWidth()
|
||||
{
|
||||
return m_lShapeWidth;
|
||||
@ -202,187 +116,16 @@ public:
|
||||
}
|
||||
|
||||
public:
|
||||
CFormulaManager(std::vector<long>& a, std::vector<double>& g)
|
||||
{
|
||||
Adjustments = &a;
|
||||
Guides = &g;
|
||||
|
||||
m_lShapeWidth = ShapeSize;
|
||||
m_lShapeHeight = ShapeSize;
|
||||
|
||||
AddGuide(_T("3cd4"), _T("val 16200000")); //The units here are in 60,000ths of a degree. This is equivalent to 270 degrees.
|
||||
AddGuide(_T("3cd8"), _T("val 8100000")); //The units here are in 60,000ths of a degree. This is equivalent to 135 degrees.
|
||||
AddGuide(_T("5cd8"), _T("val 13500000")); //The units here are in 60,000ths of a degree. This is equivalent to 225 degrees.
|
||||
AddGuide(_T("7cd8"), _T("val 18900000")); //The units here are in 60,000ths of a degree. This is equivalent to 315 degrees.
|
||||
AddGuide(_T("b"), _T("val h")); //This is the bottom edge of the shape and since the top edge of the shape is considered the 0 point, the
|
||||
//bottom edge is thus the shape height.
|
||||
AddGuide(_T("cd2"), _T("val 10800000")); //The units here are in 60,000ths of a degree. This is equivalent to 180 degrees.
|
||||
AddGuide(_T("cd4"), _T("val 5400000")); //The units here are in 60,000ths of a degree. This is equivalent to 90 degrees.
|
||||
AddGuide(_T("cd8"), _T("val 2700000")); //The units here are in 60,000ths of a degree. This is equivalent to 45 degrees.
|
||||
AddGuide(_T("hc"), _T("*/ w 1 2")); //This is the horizontal center of the shape which is just the width divided by 2.
|
||||
AddGuide(_T("hd2"), _T("*/ h 1 2")); //This is 1/2 the shape height.
|
||||
AddGuide(_T("hd3"), _T("*/ h 1 3")); //This is 1/3 the shape height.
|
||||
AddGuide(_T("hd4"), _T("*/ h 1 4")); //This is 1/4 the shape height.
|
||||
AddGuide(_T("hd5"), _T("*/ h 1 5")); //This is 1/5 the shape height.
|
||||
AddGuide(_T("hd6"), _T("*/ h 1 6")); //This is 1/6 the shape height.
|
||||
AddGuide(_T("hd8"), _T("*/ h 1 8")); //This is 1/8 the shape height.
|
||||
AddGuide(_T("l"), _T("val 0")); //This is the left edge of the shape and the left edge of the shape is considered the horizontal 0 point.
|
||||
AddGuide(_T("ls"), _T("max w h")); //This is the longest side of the shape. This value is either the width or the height depending on which is greater.
|
||||
AddGuide(_T("r"), _T("val w")); //This is the right edge of the shape and since the left edge of the shape is considered the 0 point, the right edge
|
||||
//is thus the shape width.
|
||||
AddGuide(_T("ss"), _T("min w h")); //This is the shortest side of the shape. This value is either the width or the height depending on which is
|
||||
//smaller.
|
||||
AddGuide(_T("ssd2"), _T("*/ ss 1 2")); //This is 1/2 the shortest side of the shape.
|
||||
AddGuide(_T("ssd4"), _T("*/ ss 1 4")); //This is 1/4 the shortest side of the shape.
|
||||
AddGuide(_T("ssd6"), _T("*/ ss 1 6")); //This is 1/6 the shortest side of the shape.
|
||||
AddGuide(_T("ssd8"), _T("*/ ss 1 8")); //This is 1/8 the shortest side of the shape.
|
||||
AddGuide(_T("t"), _T("val 0")); //This is the top edge of the shape and the top edge of the shape is considered the vertical 0 point.
|
||||
AddGuide(_T("vc"), _T("*/ h 1 2")); //This is the vertical center of the shape which is just the height divided by 2.
|
||||
AddGuide(_T("wd2"), _T("*/ w 1 2")); //This is 1/2 the shape width.
|
||||
AddGuide(_T("wd4"), _T("*/ w 1 4")); //This is 1/4 the shape width.
|
||||
AddGuide(_T("wd5"), _T("*/ w 1 5")); //This is 1/5 the shape width.
|
||||
AddGuide(_T("wd6"), _T("*/ w 1 6")); //This is 1/6 the shape width.
|
||||
AddGuide(_T("wd8"), _T("*/ w 1 8")); //This is 1/8 the shape width.
|
||||
AddGuide(_T("wd10"), _T("*/ w 1 10")); //This is 1/10 the shape width.
|
||||
AddGuide(_T("wd32"), _T("*/ w 1 32")); //This is 1/32 the shape width.
|
||||
}
|
||||
CFormulaManager(std::vector<long>& a, std::vector<double>& g);
|
||||
~CFormulaManager();
|
||||
|
||||
~CFormulaManager()
|
||||
{
|
||||
mapAdjustments.clear();
|
||||
mapGuides.clear();
|
||||
strAdjustments.clear();
|
||||
strGuides.clear();
|
||||
Adjustments->clear();
|
||||
Guides->clear();
|
||||
}
|
||||
CFormulaManager& operator =(const CFormulaManager& manager);
|
||||
|
||||
CFormulaManager& operator =(const CFormulaManager& manager)
|
||||
{
|
||||
m_lShapeWidth = manager.m_lShapeWidth;
|
||||
m_lShapeHeight = manager.m_lShapeWidth;
|
||||
|
||||
mapAdjustments.clear();
|
||||
for (std::map<std::wstring, long>::const_iterator pPair = manager.mapAdjustments.begin(); pPair != manager.mapAdjustments.end(); ++pPair)
|
||||
{
|
||||
mapAdjustments.insert(std::pair<std::wstring, long>(pPair->first, pPair->second));
|
||||
}
|
||||
void AddAdjustment(const std::wstring& name, const std::wstring& fmla);
|
||||
void AddGuide(const std::wstring& name, const std::wstring& fmla);
|
||||
|
||||
mapGuides.clear();
|
||||
for (std::map<std::wstring, long>::const_iterator pPair = manager.mapGuides.begin(); pPair != manager.mapGuides.end(); ++pPair)
|
||||
{
|
||||
mapGuides.insert(std::pair<std::wstring, long>(pPair->first, pPair->second));
|
||||
}
|
||||
|
||||
strAdjustments.clear();
|
||||
for(size_t i = 0; i < manager.strAdjustments.size(); i++)
|
||||
{
|
||||
strAdjustments.push_back(manager.strAdjustments[i]);
|
||||
}
|
||||
|
||||
strGuides.clear();
|
||||
for(size_t i = 0; i < manager.strGuides.size(); i++)
|
||||
{
|
||||
strGuides.push_back(manager.strGuides[i]);
|
||||
}
|
||||
|
||||
Adjustments->clear();
|
||||
for(size_t i = 0; i < manager.Adjustments->size(); i++)
|
||||
{
|
||||
Adjustments->push_back((*manager.Adjustments)[i]);
|
||||
}
|
||||
|
||||
Guides->clear();
|
||||
for(size_t i = 0; i < manager.Guides->size(); i++)
|
||||
{
|
||||
Guides->push_back((*manager.Guides)[i]);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void AddAdjustment(const std::wstring& name, const std::wstring& fmla)
|
||||
{
|
||||
std::map<std::wstring, long>::const_iterator pPair = mapAdjustments.find(name);
|
||||
|
||||
if(pPair != mapAdjustments.end())
|
||||
{
|
||||
strAdjustments[pPair->second].FromString(fmla);
|
||||
(*Adjustments)[pPair->second] = NonDefResult;
|
||||
|
||||
return;
|
||||
}
|
||||
CFormula formula( (int)strAdjustments.size() + 1);
|
||||
formula.m_sName = name;
|
||||
formula.FromString(fmla);
|
||||
|
||||
strAdjustments.push_back(formula);
|
||||
Adjustments->push_back(NonDefResult);
|
||||
|
||||
mapAdjustments.insert(std::pair<std::wstring, long>(name, (long)strAdjustments.size() - 1));
|
||||
}
|
||||
|
||||
void AddGuide(const std::wstring& name, const std::wstring& fmla)
|
||||
{
|
||||
/*
|
||||
long num = mapGuides.FindKey(name);
|
||||
if(num >= 0)
|
||||
{
|
||||
strGuides[mapGuides.GetValueAt(num)].FromString(fmla);
|
||||
(*Guides)[mapGuides.GetValueAt(num)] = dNonDefResult;
|
||||
return;
|
||||
}
|
||||
*/
|
||||
// формулы могут повторяться!!!
|
||||
// тогда по мере расчитывания они перетирают друг друга
|
||||
CFormula formula( -1 -(int)strGuides.size());
|
||||
formula.m_sName = name;
|
||||
formula.FromString(fmla);
|
||||
|
||||
strGuides.push_back(formula);
|
||||
Guides->push_back(dNonDefResult);
|
||||
|
||||
mapGuides.insert(std::pair<std::wstring, long>(name, (long)strGuides.size() - 1));
|
||||
}
|
||||
|
||||
double GetValue(std::wstring str)
|
||||
{
|
||||
if(str == _T("w")) return m_lShapeWidth;
|
||||
if(str == _T("h")) return m_lShapeHeight;
|
||||
|
||||
std::map<std::wstring, long>::iterator numGuide = mapGuides.find(str);
|
||||
std::map<std::wstring, long>::iterator numAdj = mapAdjustments.find(str);
|
||||
|
||||
if(numGuide != mapGuides.end())
|
||||
{
|
||||
double res = (*Guides)[numGuide->second];
|
||||
if(res < dNonDefResult)
|
||||
return res;
|
||||
return strGuides[numGuide->second].Calculate(this);
|
||||
}
|
||||
if(numAdj != mapAdjustments.end())
|
||||
{
|
||||
long res = (*Adjustments)[numAdj->second];
|
||||
if(res != NonDefResult)
|
||||
return res;
|
||||
return strAdjustments[numAdj->second].Calculate(this);
|
||||
}
|
||||
return XmlUtils::GetInteger(str);
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
//for(long i = 0; i < Adjustments.size(); i++)
|
||||
// Adjustments[i] = NonDefResult;
|
||||
for(size_t i = 0; i < Guides->size(); i++)
|
||||
(*Guides)[i] = dNonDefResult;
|
||||
}
|
||||
|
||||
void ReCalculateGuides()
|
||||
{
|
||||
Clear();
|
||||
for(size_t i = 0; i < strGuides.size(); i++)
|
||||
(*Guides)[i] = strGuides[i].Calculate(this);
|
||||
}
|
||||
double GetValue(std::wstring str);
|
||||
void Clear();
|
||||
void ReCalculateGuides();
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user