Refactoring

This commit is contained in:
Green
2025-01-21 13:01:02 +03:00
parent adad3a05ba
commit 6026841c00
7 changed files with 54 additions and 44 deletions

View File

@ -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<ELang>(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");

View File

@ -59,22 +59,8 @@ enum class EAccent
TWOARAEA
};
inline EAccent GetAccent(int nValue)
{
switch(static_cast<EAccent>(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<EAccent>(nValue);
default:
return EAccent::NONE;
}
}
EAccent GetAccent(int nValue);
EAccent GetAccent(const HWP_STRING& sValue);
#define MAX_ELEMENTS (int)ELang::MAX

View File

@ -1,5 +1,7 @@
#include "HWPXFile.h"
#include <cwctype>
namespace HWP
{
CHWPXFile::CHWPXFile(const HWP_STRING& sFileName)

View File

@ -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
{

View File

@ -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
{

View File

@ -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);
}
}

View File

@ -12,17 +12,8 @@ enum class EArcType
CHORD
};
inline EArcType GetArcType(int nValue)
{
switch(static_cast<EArcType>(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
{