From aa4b0c884494bab0d727f384af807318173627f4 Mon Sep 17 00:00:00 2001 From: Kirill Polyakov Date: Mon, 29 Sep 2025 17:00:06 +0300 Subject: [PATCH] Fixed conversion of geometric shapes in HWP --- HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp | 149 ++++++++++++------ HwpFile/HwpDoc/Conversion/Converter2OOXML.h | 8 +- HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp | 2 + HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp | 20 ++- HwpFile/HwpDoc/Paragraph/CtrlObjElement.h | 5 +- HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp | 20 +++ HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h | 5 + HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp | 13 +- HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h | 2 + 9 files changed, 161 insertions(+), 63 deletions(-) diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp index 2482f7f979..6b536a80a1 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp @@ -15,6 +15,8 @@ #include "../Paragraph/CtrlShapeArc.h" #include "../Paragraph/CtrlShapePolygon.h" #include "../Paragraph/CtrlShapeCurve.h" +#include "../Paragraph/CtrlShapeLine.h" +#include "../Paragraph/CtrlShapeRect.h" #include "../HWPElements/HWPRecordParaShape.h" #include "../HWPElements/HWPRecordCharShape.h" @@ -332,7 +334,7 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short sh } } -void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState) +void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer *pContainer) { if (nullptr == pShape || oState.m_bInTextBox) return; @@ -346,7 +348,7 @@ void CConverter2OOXML::WriteShape(const CCtrlGeneralShape* pShape, short shParaS case EShapeType::Polygon: case EShapeType::Curve: { - WriteGeometryShape(pShape, shParaShapeID, shParaStyleID, oBuilder, oState); + WriteGeometryShape(pShape, shParaShapeID, shParaStyleID, oBuilder, oState, pContainer); break; } case EShapeType::Pic: @@ -1002,7 +1004,7 @@ VECTOR ArcToBezier(const TPoint& oStart, const TPoint& oEnd, const TPoin return {oStart, oControl1, oControl2, oEnd}; } -void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState) +void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer* pContainer) { if (nullptr == pGeneralShape) return; @@ -1027,7 +1029,7 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape oBuilder.WriteString(L""); oBuilder.WriteString(L""); - OpenDrawingNode(pGeneralShape, oBuilder); + OpenDrawingNode((nullptr != pContainer) ? pContainer : pGeneralShape, oBuilder); oBuilder.WriteString(L""); oBuilder.WriteString(L""); @@ -1041,9 +1043,20 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape case EShapeObjectType::Arc: { const CCtrlShapeArc *pShapeArc = (const CCtrlShapeArc*)pGeneralShape; - VECTOR arBezierPoints{ArcToBezier({Transform::HWPUINT2OOXML(pShapeArc->GetFirstPoint() .m_nX), Transform::HWPUINT2OOXML(pShapeArc->GetFirstPoint() .m_nY)}, - {Transform::HWPUINT2OOXML(pShapeArc->GetSecondPoint().m_nX), Transform::HWPUINT2OOXML(pShapeArc->GetSecondPoint().m_nY)}, - {Transform::HWPUINT2OOXML(pShapeArc->GetCenterPoint().m_nX), Transform::HWPUINT2OOXML(pShapeArc->GetCenterPoint().m_nY)})}; + + TPoint oStartPoint {pShapeArc->GetFirstPoint()}, + oEndPoint {pShapeArc->GetSecondPoint()}, + oCenterPoint{pShapeArc->GetCenterPoint()}; + + const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()}; + + oMatrix.ApplyToPoint(oStartPoint .m_nX, oStartPoint .m_nY); + oMatrix.ApplyToPoint(oEndPoint .m_nX, oEndPoint .m_nY); + oMatrix.ApplyToPoint(oCenterPoint.m_nX, oCenterPoint.m_nY); + + VECTOR arBezierPoints{ArcToBezier({Transform::HWPUINT2OOXML(oStartPoint .m_nX), Transform::HWPUINT2OOXML(oStartPoint .m_nY)}, + {Transform::HWPUINT2OOXML(oEndPoint .m_nX), Transform::HWPUINT2OOXML(oEndPoint .m_nY)}, + {Transform::HWPUINT2OOXML(oCenterPoint.m_nX), Transform::HWPUINT2OOXML(oCenterPoint.m_nY)})}; oBuilder.WriteString(L""); oBuilder.WriteString(L""); @@ -1065,13 +1078,55 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape } case EShapeObjectType::Line: { - oBuilder.WriteString(L""); + const CCtrlShapeLine *pShapeLine = (const CCtrlShapeLine*)pGeneralShape; + + TPoint oStartPoint{pShapeLine->GetStartX(), pShapeLine->GetStartY()}, + oEndPoint {pShapeLine->GetEndX(), pShapeLine->GetEndY() }; + + const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()}; + + oMatrix.ApplyToPoint(oStartPoint .m_nX, oStartPoint .m_nY); + oMatrix.ApplyToPoint(oEndPoint .m_nX, oEndPoint .m_nY); + + oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); + oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); + // oBuilder.WriteString(L""); break; } case EShapeObjectType::Rectangle: { - oBuilder.WriteString(L""); + const CCtrlShapeRect* pShapeRect = (const CCtrlShapeRect*)pGeneralShape; + + TPoint arPoints[4]; + + pShapeRect->GetPoints(arPoints); + + const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()}; + + for (TPoint& oPoint : arPoints) + { + oMatrix.ApplyToPoint(oPoint.m_nX, oPoint.m_nY); + + oPoint.m_nX = Transform::HWPUINT2OOXML(oPoint.m_nX); + oPoint.m_nY = Transform::HWPUINT2OOXML(oPoint.m_nY); + } + + oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); + + for (unsigned short ushIndex = 1; ushIndex < 4; ++ushIndex) + oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); + // oBuilder.WriteString(L""); break; } case EShapeObjectType::Polygon: @@ -1081,11 +1136,21 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape if (2 > arPoints.size()) break; + const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()}; + + for (TPoint& oPoint : arPoints) + { + oMatrix.ApplyToPoint(oPoint.m_nX, oPoint.m_nY); + + oPoint.m_nX = Transform::HWPUINT2OOXML(oPoint.m_nX); + oPoint.m_nY = Transform::HWPUINT2OOXML(oPoint.m_nY); + } + oBuilder.WriteString(L""); - oBuilder.WriteString(L""); + oBuilder.WriteString(L""); for (unsigned short ushIndex = 1; ushIndex < arPoints.size(); ++ushIndex) - oBuilder.WriteString(L""); + oBuilder.WriteString(L""); oBuilder.WriteString(L""); break; @@ -1097,23 +1162,34 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape if (2 > arPoints.size()) break; + const TMatrix oMatrix{pGeneralShape->GetFinalMatrix()}; + + for (TPoint& oPoint : arPoints) + { + oPoint.m_nX = Transform::HWPUINT2OOXML(oPoint.m_nX); + oPoint.m_nY = Transform::HWPUINT2OOXML(oPoint.m_nY); + + oMatrix.ApplyToPoint(oPoint.m_nX, oPoint.m_nY); + } + VECTOR arSegmentType{((const CCtrlShapeCurve*)pGeneralShape)->GetSegmentsType()}; oBuilder.WriteString(L""); - oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); for (unsigned short ushIndex = 0; ushIndex < arSegmentType.size(); ++ushIndex) { if (0x01 == arSegmentType[ushIndex]) { oBuilder.WriteString(L""); - oBuilder.WriteString(L""); - oBuilder.WriteString(L""); - oBuilder.WriteString(L""); + oBuilder.WriteString(L""); + oBuilder.WriteString(L""); + oBuilder.WriteString(L""); oBuilder.WriteString(L""); ushIndex += 2; } else - oBuilder.WriteString(L""); + oBuilder.WriteString(L""); } oBuilder.WriteString(L""); @@ -1235,7 +1311,7 @@ void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, short shPar void CConverter2OOXML::WriteContainer(const CCtrlContainer* pContainer, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState) { for (const CCtrlGeneralShape* pGeneralShape : pContainer->GetShapes()) - WriteShape(pGeneralShape, shParaShapeID, shParaStyleID, oBuilder, oState); + WriteShape(pGeneralShape, shParaShapeID, shParaStyleID, oBuilder, oState, pContainer); } void CConverter2OOXML::WriteSectionSettings(TConversionState& oState) @@ -1343,9 +1419,7 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, short shParaS oBuilder.WriteString(L""); - int nWidth{pCtrlPic->GetImageRectWidth()}, nHeight{pCtrlPic->GetIMageRectHeight()}; - - OpenDrawingNode(pCtrlPic, oBuilder, &nWidth, &nHeight); + OpenDrawingNode(pCtrlPic, oBuilder); oBuilder.WriteString(L""); oBuilder.WriteString(L""); @@ -1361,7 +1435,7 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, short shParaS if (pCtrlPic->VertFlip()) oBuilder.WriteString(L" flipV=\"1\""); - oBuilder.WriteString(L">"); + oBuilder.WriteString(L">GetFinalWidth()) + L"\" cy=\"" + std::to_wstring(pCtrlPic->GetFinalHeight()) + L"\"/>"); oBuilder.WriteString(L""); WriteBorderSettings(pCtrlPic, oBuilder); oBuilder.WriteString(L""); @@ -1539,7 +1613,7 @@ void CConverter2OOXML::WriteTextBorderStyle(short shBorderFillId, NSStringUtils: WriteBorder(pBorderFill->GetLeftBorder(), L"bdr", oBuilder); } -void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth, int* pHeight) +void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder) { if (nullptr == pCtrlShape) return; @@ -1554,7 +1628,7 @@ void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStri L"\" distR=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetRightOutMargin() / 10)) + L"\">"); - WriteShapeExtent(pCtrlShape, oBuilder, pWidth, pHeight); + WriteShapeExtent(pCtrlShape, oBuilder); } else { @@ -1567,7 +1641,7 @@ void CConverter2OOXML::OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStri L"\" simplePos=\"0\" locked=\"0\" layoutInCell=\"1\" allowOverlap=\"1\">"); WriteShapePosition(pCtrlShape, oBuilder); - WriteShapeExtent(pCtrlShape, oBuilder, pWidth, pHeight); + WriteShapeExtent(pCtrlShape, oBuilder); WriteShapeWrapMode(pCtrlShape, oBuilder); } @@ -1631,25 +1705,14 @@ void CConverter2OOXML::WriteShapePosition(const CCtrlCommon* pCtrlShape, NSStrin oBuilder.WriteString(L""); - oBuilder.WriteString(L"GetHorzOffset(); + const int nVertOffset = pCtrlShape->GetVertOffset(); - if (0 == pCtrlShape->GetHorzOffset()) - { - oBuilder.WriteString(L"margin\">"); - oBuilder.WriteString(L"left"); - } - else - { - oBuilder.WriteString(GetHRelativeFrom(pCtrlShape->GetHorzRelTo()) + L"\">"); - oBuilder.WriteString(L"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetHorzOffset())) + L""); - } - - oBuilder.WriteString(L""); - - oBuilder.WriteString(L"GetVertRelTo()) + L"\">" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetVertOffset())) + L""); + oBuilder.WriteString(L"GetHorzRelTo()) + L"\">" + std::to_wstring(Transform::HWPUINT2OOXML(nHorzOffset)) + L""); + oBuilder.WriteString(L"GetVertRelTo()) + L"\">" + std::to_wstring(Transform::HWPUINT2OOXML(nVertOffset)) + L""); } -void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth, int* pHeight) +void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder) { if (nullptr == pCtrlShape) return; @@ -1657,12 +1720,6 @@ void CConverter2OOXML::WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStr const int nFinalWidth = std::abs(pCtrlShape->GetFinalWidth()); const int nFinalHeight = std::abs(pCtrlShape->GetFinalHeight()); - if (nullptr != pWidth) - *pWidth = Transform::HWPUINT2OOXML(nFinalWidth); - - if (nullptr != pHeight) - *pHeight = Transform::HWPUINT2OOXML(nFinalHeight); - oBuilder.WriteString(L""); oBuilder.WriteString(L""); } diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h index aa3378a82f..750d555b20 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h @@ -99,7 +99,7 @@ class CConverter2OOXML void WriteCellProperties(short shBorderFillID, NSStringUtils::CStringBuilder& oBuilder); void WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder); - void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); + void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer *pContainer = nullptr); void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); void WriteOleShape(const CCtrlShapeOle* pOleShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); @@ -115,11 +115,11 @@ class CConverter2OOXML void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& sExternStyles = CRunnerStyle()); void WriteTextBorderStyle(short shBorderFillId, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); - void OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth = nullptr, int *pHeight = nullptr); + void OpenDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); void CloseDrawingNode(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); void WriteShapePosition(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); - void WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder, int* pWidth = nullptr, int *pHeight = nullptr); + void WriteShapeExtent(const CCtrlObjElement* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); void WriteShapeWrapMode(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); void WriteShapeProperty(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); @@ -134,7 +134,7 @@ class CConverter2OOXML void WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short shParaShapeID, short shParaStyleID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); void WriteCharacter(const CCtrlCharacter* pCharacter, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); - void WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); + void WriteShape(const CCtrlGeneralShape* pShape, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CCtrlContainer* pContainer = nullptr); void WriteNote(const CCtrlNote* pNote, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp b/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp index 2a70ec7d09..a55807a928 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlContainer.cpp @@ -52,6 +52,8 @@ CCtrlContainer::CCtrlContainer(const HWP_STRING& sCtrlID, CXMLReader& oReader, E m_arShapes.push_back(new CCtrlShapePic(L"cip$", oReader, eType)); else if (GetNodeName(ENode::Ole, eType) == sNodeName) m_arShapes.push_back(new CCtrlShapeOle(L"elo$", oReader, eType)); + else + CCtrlGeneralShape::ParseChildren(oReader, eType); } END_WHILE diff --git a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp index e836f72f7f..30bf8d55e6 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp @@ -329,18 +329,15 @@ void TMatrix::Multiply(const TMatrix& oMatrix) const double dM21 = m_dM21 * oMatrix.m_dM11 + m_dM22 * oMatrix.m_dM21; const double dM22 = m_dM21 * oMatrix.m_dM12 + m_dM22 * oMatrix.m_dM22; - const double dDx = m_dDX * oMatrix.m_dM11 + m_dDY * oMatrix.m_dM21 + oMatrix.m_dDX; - const double dDy = m_dDX * oMatrix.m_dM12 + m_dDY * oMatrix.m_dM22 + oMatrix.m_dDY; - m_dM11 = dM11; m_dM12 = dM12; m_dM21 = dM21; m_dM22 = dM22; - m_dDX = dDx; - m_dDY = dDy; + m_dDX += oMatrix.m_dDX; + m_dDY += oMatrix.m_dDY; } -void TMatrix::ApplyToPoint(double& dX, double& dY) +void TMatrix::ApplyToPoint(double& dX, double& dY) const { const double _dX = dX; const double _dY = dY; @@ -349,7 +346,16 @@ void TMatrix::ApplyToPoint(double& dX, double& dY) dY = _dX * m_dM12 + _dY * m_dM22 + m_dDY; } -void TMatrix::ApplyToSize(double& dW, double& dH) +void HWP::TMatrix::ApplyToPoint(int& nX, int& nY) const +{ + const double _dX = nX; + const double _dY = nY; + + nX = (int)(_dX * m_dM11 + _dY * m_dM21 + m_dDX); + nY = (int)(_dX * m_dM12 + _dY * m_dM22 + m_dDY); +} + +void TMatrix::ApplyToSize(double& dW, double& dH) const { const double _dW = dW; const double _dH = dH; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h index 5edf1103fa..b73ee4de68 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h @@ -18,8 +18,9 @@ struct TMatrix TMatrix(double dM11, double dM12, double dM21, double dM22, double dDX, double dDY); void Multiply(const TMatrix& oMatrix); - void ApplyToPoint(double& dX, double& dY); - void ApplyToSize(double& dW, double& dH); + void ApplyToPoint(double& dX, double& dY) const; + void ApplyToPoint(int& nX, int &nY) const; + void ApplyToSize(double& dW, double& dH) const; }; class CCtrlObjElement : public CCtrlCommon diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp index 0ed2fee3d3..5b2aecb563 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.cpp @@ -89,6 +89,26 @@ EShapeType CCtrlShapeLine::GetShapeType() const return EShapeType::Line; } +int HWP::CCtrlShapeLine::GetStartX() const +{ + return m_nStartX; +} + +int HWP::CCtrlShapeLine::GetStartY() const +{ + return m_nStartY; +} + +int HWP::CCtrlShapeLine::GetEndX() const +{ + return m_nEndX; +} + +int HWP::CCtrlShapeLine::GetEndY() const +{ + return m_nEndY; +} + void CCtrlShapeLine::ParseElement(CCtrlShapeLine& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) { oBuffer.SavePosition(); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h index 149926327b..38be0eba41 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeLine.h @@ -24,6 +24,11 @@ public: EShapeType GetShapeType() const override; + int GetStartX() const; + int GetStartY() const; + int GetEndX() const; + int GetEndY() const; + static void ParseElement(CCtrlShapeLine& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); static void ParseCtrl(CCtrlShapeLine& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); }; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp index 0d580ecff3..9c20daa680 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.cpp @@ -69,19 +69,19 @@ void CCtrlShapeRect::ReadFromHWPML(CXMLReader &oReader) else if ("X0" == sAttributeName) m_arPoints[0].m_nX = oReader.GetInt(); else if ("Y0" == sAttributeName) - m_arPoints[0].m_nX = oReader.GetInt(); + m_arPoints[0].m_nY = oReader.GetInt(); else if ("X1" == sAttributeName) m_arPoints[1].m_nX = oReader.GetInt(); else if ("Y1" == sAttributeName) - m_arPoints[1].m_nX = oReader.GetInt(); + m_arPoints[1].m_nY = oReader.GetInt(); else if ("X2" == sAttributeName) m_arPoints[2].m_nX = oReader.GetInt(); else if ("Y2" == sAttributeName) - m_arPoints[2].m_nX = oReader.GetInt(); + m_arPoints[2].m_nY = oReader.GetInt(); else if ("X3" == sAttributeName) m_arPoints[3].m_nX = oReader.GetInt(); else if ("Y3" == sAttributeName) - m_arPoints[3].m_nX = oReader.GetInt(); + m_arPoints[3].m_nY = oReader.GetInt(); } END_READ_ATTRIBUTES(oReader) @@ -95,6 +95,11 @@ EShapeType CCtrlShapeRect::GetShapeType() const return EShapeType::Rect; } +void CCtrlShapeRect::GetPoints(TPoint (&arPoints)[4]) const +{ + memcpy(arPoints, m_arPoints, sizeof(TPoint) * 4); +} + int CCtrlShapeRect::ParseElement(CCtrlShapeRect& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) { oBuffer.SavePosition(); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h index 2e8eeb1ecd..9a01835d87 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeRect.h @@ -22,6 +22,8 @@ public: EShapeType GetShapeType() const override; + void GetPoints(TPoint (&arPoints)[4]) const; + static int ParseElement(CCtrlShapeRect& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); static int ParseCtrl(CCtrlShapeRect& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); static int ParseListHeaderAppend(CCtrlShapeRect& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);