From 6026841c0055b9021e888e4a00f14107bd694093 Mon Sep 17 00:00:00 2001 From: Green Date: Tue, 21 Jan 2025 13:01:02 +0300 Subject: [PATCH] Refactoring --- .../HwpDoc/HWPElements/HWPRecordCharShape.cpp | 37 +++++++++++++------ .../HwpDoc/HWPElements/HWPRecordCharShape.h | 18 +-------- HwpFile/HwpDoc/HWPXFile.cpp | 2 + HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h | 4 +- HwpFile/HwpDoc/Paragraph/CtrlCommon.h | 4 +- HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp | 20 +++++++++- HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h | 13 +------ 7 files changed, 54 insertions(+), 44 deletions(-) diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp index ec945c965b..2623b9efad 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp @@ -3,6 +3,31 @@ namespace HWP { +EAccent GetAccent(int nValue) +{ + SWITCH(EAccent, nValue) + { + DEFAULT(EAccent::NONE); + CASE(EAccent::DOT); + CASE(EAccent::RING); + CASE(EAccent::CARON); + CASE(EAccent::TILDE); + CASE(EAccent::ARAEA); + CASE(EAccent::TWOARAEA); + } +} + +EAccent GetAccent(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(DOT, sValue, EAccent); + ELSE_IF_STRING_IN_ENUM(RING, sValue, EAccent); + ELSE_IF_STRING_IN_ENUM(CARON, sValue, EAccent); + ELSE_IF_STRING_IN_ENUM(TILDE, sValue, EAccent); + ELSE_IF_STRING_IN_ENUM(ARAEA, sValue, EAccent); + ELSE_IF_STRING_IN_ENUM(TWOARAEA, sValue, EAccent); + ELSE_STRING_IN_ENUM(NONE, EAccent); +} + ELang GetLang(int nValue) { switch (static_cast(nValue)) @@ -162,7 +187,6 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, m_eUnderLineShape = ELineStyle1::SOLID; m_eOutline = EOutline::NONE; m_eShadow = EShadow::NONE; - m_eSymMark = EAccent::NONE; m_eStrikeOutShape = ELineStyle2::NONE; m_nHeight = oNode.GetAttributeInt(L"height", 1000); @@ -171,16 +195,7 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, m_bUseFontSpace = oNode.GetAttributeBool(L"useFontSpace"); m_bUseKerning = oNode.GetAttributeBool(L"useKerning"); - HWP_STRING sMarkType = oNode.GetAttribute(L"symMark"); - - if (L"DOT_ABOVE" == sMarkType) - m_eSymMark = EAccent::DOT; - else if (L"RING_ABOVE" == sMarkType) - m_eSymMark = EAccent::RING; - else if (L"TILDE" == sMarkType) - m_eSymMark = EAccent::TILDE; - else - m_eSymMark = EAccent::NONE; + m_eSymMark = GetAccent(oNode.GetAttribute(L"symMark")); m_shBorderFillIDRef = oNode.GetAttributeInt(L"borderFillIDRef"); diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h index 41268b6923..89c0c49132 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h @@ -59,22 +59,8 @@ enum class EAccent TWOARAEA }; -inline EAccent GetAccent(int nValue) -{ - switch(static_cast(nValue)) - { - case EAccent::NONE: - case EAccent::DOT: - case EAccent::RING: - case EAccent::CARON: - case EAccent::TILDE: - case EAccent::ARAEA: - case EAccent::TWOARAEA: - return static_cast(nValue); - default: - return EAccent::NONE; - } -} +EAccent GetAccent(int nValue); +EAccent GetAccent(const HWP_STRING& sValue); #define MAX_ELEMENTS (int)ELang::MAX diff --git a/HwpFile/HwpDoc/HWPXFile.cpp b/HwpFile/HwpDoc/HWPXFile.cpp index 8bf8351478..56a88f441c 100644 --- a/HwpFile/HwpDoc/HWPXFile.cpp +++ b/HwpFile/HwpDoc/HWPXFile.cpp @@ -1,5 +1,7 @@ #include "HWPXFile.h" +#include + namespace HWP { CHWPXFile::CHWPXFile(const HWP_STRING& sFileName) diff --git a/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h b/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h index 8d4dc0a92a..1d28a62ae6 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlAutoNumber.h @@ -21,8 +21,8 @@ enum class ENumType TOTAL_PAGE }; -inline ENumType GetNumType(int nValue); -inline ENumType GetNumType(const HWP_STRING& sValue); +ENumType GetNumType(int nValue); +ENumType GetNumType(const HWP_STRING& sValue); class CCtrlAutoNumber : public CCtrl { diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.h b/HwpFile/HwpDoc/Paragraph/CtrlCommon.h index 272a16b28f..13d10e606a 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.h @@ -48,8 +48,8 @@ enum class EVertAlign OUTSIDE }; -inline EVertAlign GetVertAlign(int nValue); -inline EVertAlign GetVertAlign(const HWP_STRING& sValue); +EVertAlign GetVertAlign(int nValue); +EVertAlign GetVertAlign(const HWP_STRING& sValue); enum class EHorzAlign { diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp index 5ee874b8e0..30f534d17c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.cpp @@ -2,6 +2,23 @@ namespace HWP { +EArcType GetArcType(int nValue) +{ + SWITCH(EArcType, nValue) + { + DEFAULT(EArcType::NORMAL); + CASE(EArcType::PIE); + CASE(EArcType::CHORD); + } +} + +EArcType GetArcType(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(PIE, sValue, EArcType); + ELSE_IF_STRING_IN_ENUM(CHORD, sValue, EArcType); + ELSE_STRING_IN_ENUM(NORMAL, EArcType); +} + CCtrlShapeEllipse::CCtrlShapeEllipse() {} @@ -22,7 +39,7 @@ CCtrlShapeEllipse::CCtrlShapeEllipse(const HWP_STRING& sCtrlID, CXMLNode& oNode, { m_bIntervalDirty = oNode.GetAttributeBool(L"intervalDirty"); m_bHasArcProperty = oNode.GetAttributeBool(L"hasArcPr"); - m_eArcType = GetArcType(oNode.GetAttributeInt(L"arcType")); + m_eArcType = GetArcType(oNode.GetAttribute(L"arcType")); for (CXMLNode& oChild : oNode.GetChilds()) { @@ -133,5 +150,4 @@ int CCtrlShapeEllipse::ParseListHeaderAppend(CCtrlShapeEllipse& oObj, int nSize, return oBuffer.GetDistanceToLastPos(true); } - } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h index 8bfaebaf21..ad0b28ba7c 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapeEllipse.h @@ -12,17 +12,8 @@ enum class EArcType CHORD }; -inline EArcType GetArcType(int nValue) -{ - switch(static_cast(nValue)) - { - case EArcType::NORMAL: - default: - return EArcType::NORMAL; - case EArcType::PIE: return EArcType::PIE; - case EArcType::CHORD: return EArcType::CHORD; - } -} +EArcType GetArcType(int nValue); +EArcType GetArcType(const HWP_STRING& sValue); class CCtrlShapeEllipse : public CCtrlGeneralShape {