mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
169 lines
3.8 KiB
C++
169 lines
3.8 KiB
C++
#include "CtrlGeneralShape.h"
|
|
|
|
#include "CtrlShapePic.h"
|
|
#include "CtrlShapeRect.h"
|
|
#include "CtrlShapeLine.h"
|
|
#include "CtrlContainer.h"
|
|
#include "CtrlShapeEllipse.h"
|
|
#include "CtrlShapePolygon.h"
|
|
#include "CtrlShapeArc.h"
|
|
#include "CtrlShapeCurve.h"
|
|
#include "CtrlEqEdit.h"
|
|
#include "CtrlShapeOle.h"
|
|
#include "CtrlShapeVideo.h"
|
|
#include "CtrlShapeTextArt.h"
|
|
|
|
namespace HWP
|
|
{
|
|
CCtrlGeneralShape::CCtrlGeneralShape()
|
|
{}
|
|
|
|
CCtrlGeneralShape::CCtrlGeneralShape(const STRING& sCtrlID)
|
|
: CCtrlObjElement(sCtrlID)
|
|
{}
|
|
|
|
CCtrlGeneralShape::CCtrlGeneralShape(const STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
|
: CCtrlObjElement(sCtrlID, nSize, oBuffer, nOff, nVersion), m_pFill(nullptr)
|
|
{}
|
|
|
|
CCtrlGeneralShape::~CCtrlGeneralShape()
|
|
{
|
|
if (nullptr != m_pFill)
|
|
delete m_pFill;
|
|
}
|
|
|
|
void CCtrlGeneralShape::SetParent(CHWPPargraph* pParent)
|
|
{
|
|
m_pParent = pParent;
|
|
}
|
|
|
|
CHWPPargraph* CCtrlGeneralShape::GetParent()
|
|
{
|
|
return m_pParent;
|
|
}
|
|
|
|
int CCtrlGeneralShape::GetSize()
|
|
{
|
|
return m_nSize;
|
|
}
|
|
|
|
CCtrlGeneralShape* CCtrlGeneralShape::Parse(CCtrlGeneralShape& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
|
{
|
|
oBuffer.SavePosition();
|
|
|
|
STRING sCtrlId;
|
|
oBuffer.ReadString(sCtrlId, 4);
|
|
|
|
CCtrlGeneralShape *pShape = nullptr;
|
|
|
|
#define CREATE_AND_PARSE_SHAPE(type)\
|
|
pShape = new type(sCtrlId); \
|
|
\
|
|
if (nullptr != pShape) \
|
|
type::ParseCtrl((type&)(*pShape), nSize - oBuffer.GetDistanceToLastPos(), oBuffer, 0, nVersion); \
|
|
else \
|
|
oBuffer.Skip(nSize - oBuffer.GetDistanceToLastPos())
|
|
|
|
if ("cip$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapePic);
|
|
}
|
|
else if ("cer$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeRect);
|
|
}
|
|
else if ("nil$" == sCtrlId ||
|
|
"loc$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeLine);
|
|
}
|
|
else if ("noc$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlContainer);
|
|
}
|
|
else if ("lle$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeEllipse);
|
|
}
|
|
else if ("lop$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapePolygon);
|
|
}
|
|
else if ("cra$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeArc);
|
|
}
|
|
else if ("ruc$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeCurve);
|
|
}
|
|
else if ("deqe" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlEqEdit);
|
|
}
|
|
else if ("elo$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeOle);
|
|
}
|
|
else if ("div$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeVideo);
|
|
}
|
|
else if ("tat$" == sCtrlId)
|
|
{
|
|
CREATE_AND_PARSE_SHAPE(CCtrlShapeTextArt);
|
|
}
|
|
|
|
oBuffer.RemoveLastSavedPos();
|
|
|
|
return pShape;
|
|
}
|
|
|
|
int CCtrlGeneralShape::ParseListHeaderApend(CCtrlGeneralShape& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
|
{
|
|
oBuffer.SavePosition();
|
|
|
|
if (nSize >= 16)
|
|
{
|
|
oBuffer.Skip(2);
|
|
oBuffer.ReadInt(oObj.m_nCaptionAttr);
|
|
oBuffer.ReadInt(oObj.m_nCaptionWidth);
|
|
oObj.m_nCaptionSpacing = oBuffer.ReadShort();
|
|
oBuffer.ReadInt(oObj.m_nCaptionMaxW);
|
|
}
|
|
|
|
if ((nSize - oBuffer.GetDistanceToLastPos(true)) == 8)
|
|
oBuffer.Skip(8);
|
|
|
|
return nSize;
|
|
}
|
|
|
|
int CCtrlGeneralShape::ParseCtrl(CCtrlGeneralShape& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
|
|
{
|
|
oBuffer.SavePosition();
|
|
|
|
CCtrlObjElement::ParseCtrl(oObj, nSize, oBuffer, nOff, nVersion);
|
|
|
|
oBuffer.ReadColor(oObj.m_nLineColor);
|
|
oObj.m_nLineThick = oBuffer.ReadShort();
|
|
|
|
oBuffer.Skip(2);
|
|
|
|
int nLineAttr;
|
|
oBuffer.ReadInt(nLineAttr);
|
|
|
|
oObj.m_eLineStyle = GetLineStyle2(nLineAttr & 0x3F);
|
|
oObj.m_eLineHead = GetLineArrowStyle(((nLineAttr >> 10) & 0x3F), CHECK_FLAG(nLineAttr >> 30, 0x1));
|
|
oObj.m_eLineHeadSz = GetLineArrowSize((nLineAttr >> 22) & 0x0F);
|
|
oObj.m_eLineTail = GetLineArrowStyle(((nLineAttr >> 16) & 0x3F), CHECK_FLAG(nLineAttr >> 31, 0x1));
|
|
oObj.m_eLineTailSz = GetLineArrowSize((nLineAttr >> 26) & 0x0F);
|
|
oBuffer.ReadByte(oObj.m_chOutline);
|
|
|
|
oObj.m_pFill = new CFill(oBuffer, 0, nSize - oBuffer.GetDistanceToLastPos() - 22);
|
|
|
|
oBuffer.Skip(22);
|
|
|
|
return oBuffer.GetDistanceToLastPos(true);
|
|
}
|
|
}
|