diff --git a/HwpFile/HWPFile.cpp b/HwpFile/HWPFile.cpp index 365f33876c..0a126d1921 100644 --- a/HwpFile/HWPFile.cpp +++ b/HwpFile/HWPFile.cpp @@ -1,6 +1,6 @@ #include "HWPFile.h" -#include "HwpDoc/Conversion/WriterContext.h" +#include "HwpDoc/Common/WriterContext.h" #include "../DesktopEditor/common/File.h" #include "HwpDoc/Conversion/Converter2OOXML.h" diff --git a/HwpFile/HWPFile.pro b/HwpFile/HWPFile.pro index 2fca715f17..5dec88a030 100644 --- a/HwpFile/HWPFile.pro +++ b/HwpFile/HWPFile.pro @@ -19,11 +19,11 @@ DEFINES += HWPFILE_USE_DYNAMIC_LIBRARY SOURCES += \ HWPFile.cpp \ HwpDoc/Common/XMLReader.cpp \ + HwpDoc/Common/WriterContext.cpp \ HwpDoc/Conversion/Converter2OOXML.cpp \ HwpDoc/Conversion/FootnoteConverter.cpp \ HwpDoc/Conversion/NumberingConverter.cpp \ HwpDoc/Conversion/OleConverter.cpp \ - HwpDoc/Conversion/WriterContext.cpp \ HwpDoc/HWPDocInfo.cpp \ HwpDoc/HWPElements/HWPRecord.cpp \ HwpDoc/HWPElements/HWPRecordBinData.cpp \ @@ -43,10 +43,10 @@ SOURCES += \ HwpDoc/HWPElements/HWPRecordParaText.cpp \ HwpDoc/HWPElements/HWPRecordStyle.cpp \ HwpDoc/HWPElements/HwpRecordTabDef.cpp \ - HwpDoc/HWPFile_Private.cpp \ + HwpDoc/HWPFile.cpp \ HwpDoc/HWPSection.cpp \ HwpDoc/HWPStream.cpp \ - HwpDoc/HWPXFile_Private.cpp \ + HwpDoc/HWPXFile.cpp \ HwpDoc/HwpFileHeader.cpp \ HwpDoc/OLEdoc/CompoundFile.cpp \ HwpDoc/OLEdoc/DirectoryEntry.cpp \ @@ -94,13 +94,13 @@ HEADERS += \ HWPFile.h \ HwpDoc/Common/Common.h \ HwpDoc/Common/XMLNode.h \ + HwpDoc/Common/WriterContext.h \ HwpDoc/Conversion/Converter2OOXML.h \ HwpDoc/Conversion/FootnoteConverter.h \ HwpDoc/Conversion/NumberingConverter.h \ HwpDoc/Conversion/OleConverter.h \ HwpDoc/Conversion/Transform.h \ HwpDoc/Conversion/Types.h \ - HwpDoc/Conversion/WriterContext.h \ HwpDoc/Errors.h \ HwpDoc/HWPDocInfo.h \ HwpDoc/HWPElements/HWPRecord.h \ @@ -124,10 +124,10 @@ HEADERS += \ HwpDoc/HWPElements/HWPType.h \ HwpDoc/HWPElements/HwpRecordTabDef.h \ HwpDoc/HWPElements/HwpRecordTypes.h \ - HwpDoc/HWPFile_Private.h \ + HwpDoc/HWPFile.h \ HwpDoc/HWPSection.h \ HwpDoc/HWPStream.h \ - HwpDoc/HWPXFile_Private.h \ + HwpDoc/HWPXFile.h \ HwpDoc/HanType.h \ HwpDoc/HwpFileHeader.h \ HwpDoc/OLEdoc/CompoundFile.h \ diff --git a/HwpFile/HwpDoc/Common/Common.h b/HwpFile/HwpDoc/Common/Common.h index 816a7dd93e..751b2689c6 100644 --- a/HwpFile/HwpDoc/Common/Common.h +++ b/HwpFile/HwpDoc/Common/Common.h @@ -25,6 +25,17 @@ typedef char HWP_BYTE; #define CASE(value) case value : return value #define DEFAULT(value) case value: default: return value +#define STR_(value) L#value +#define IF_STRING_IN_ENUM(checked_value, value, enum_type)\ + if (STR_(checked_value) == value)\ + return enum_type::checked_value +#define ELSE_IF_STRING_IN_ENUM(checked_value, value, enum_type)\ + else if (STR_(checked_value) == value)\ + return enum_type::checked_value +#define ELSE_STRING_IN_ENUM(checked_value, enum_type)\ + else\ + return enum_type::checked_value + #define RETURN_VECTOR_CONST_PTR(type, array_values) \ std::vector arTempVector(array_values.size()); \ for (unsigned int unIndex = 0; unIndex < array_values.size(); ++unIndex) \ diff --git a/HwpFile/HwpDoc/Conversion/WriterContext.cpp b/HwpFile/HwpDoc/Common/WriterContext.cpp similarity index 88% rename from HwpFile/HwpDoc/Conversion/WriterContext.cpp rename to HwpFile/HwpDoc/Common/WriterContext.cpp index e71f3ab8e5..8f1d12c654 100644 --- a/HwpFile/HwpDoc/Conversion/WriterContext.cpp +++ b/HwpFile/HwpDoc/Common/WriterContext.cpp @@ -1,6 +1,6 @@ #include "WriterContext.h" -#include "../HWPFile_Private.h" -#include "../HWPXFile_Private.h" +#include "../HWPFile.h" +#include "../HWPXFile.h" #include #include @@ -20,6 +20,23 @@ CWriterContext::~CWriterContext() delete m_pHWPXFile; } +void CWriterContext::Clear() +{ + m_eType = EHanType::NONE; + + if (nullptr != m_pHWPFile) + { + delete m_pHWPFile; + m_pHWPFile = nullptr; + } + + if (nullptr != m_pHWPXFile) + { + delete m_pHWPXFile; + m_pHWPXFile = nullptr; + } +} + VECTOR CWriterContext::GetSections() { switch(m_eType) @@ -48,7 +65,7 @@ EHanType CWriterContext::DetectHancom(const HWP_STRING& sPathToFile) { bool bDetected = false; - CHWPFile_Private* pHwpTemp = new CHWPFile_Private(sPathToFile); + CHWPFile* pHwpTemp = new CHWPFile(sPathToFile); if (nullptr != pHwpTemp) { if (pHwpTemp->Detect()) @@ -63,7 +80,7 @@ EHanType CWriterContext::DetectHancom(const HWP_STRING& sPathToFile) if (bDetected) return EHanType::HWP; - CHWPXFile_Private* pHwpxTemp = new CHWPXFile_Private(sPathToFile); + CHWPXFile* pHwpxTemp = new CHWPXFile(sPathToFile); if (nullptr != pHwpxTemp) { if (pHwpxTemp->Detect()) @@ -106,13 +123,15 @@ bool CWriterContext::Detect() bool CWriterContext::Open(const HWP_STRING& sPathToFile, EHanType eHanType) { + Clear(); + m_eType = eHanType; switch (m_eType) { case EHanType::HWP: { - m_pHWPFile = new CHWPFile_Private(sPathToFile); + m_pHWPFile = new CHWPFile(sPathToFile); if (nullptr == m_pHWPFile) return false; @@ -121,7 +140,7 @@ bool CWriterContext::Open(const HWP_STRING& sPathToFile, EHanType eHanType) } case EHanType::HWPX: { - m_pHWPXFile = new CHWPXFile_Private(sPathToFile); + m_pHWPXFile = new CHWPXFile(sPathToFile); if (nullptr == m_pHWPXFile) return false; @@ -183,17 +202,17 @@ const CHWPRecordBorderFill* CWriterContext::GetBorderFill(short shId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= shId) + if (nullptr == pDocInfo) return nullptr; - return (CHWPRecordBorderFill*)pDocInfo->GetBorderFill(shId - 1); + return (CHWPRecordBorderFill*)pDocInfo->GetBorderFill(shId); } const CHWPRecordParaShape* CWriterContext::GetParaShape(int nId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= nId) + if (nullptr == pDocInfo) return nullptr; return (CHWPRecordParaShape*)pDocInfo->GetParaShape(nId); @@ -203,7 +222,7 @@ const CHWPRecordStyle* CWriterContext::GetParaStyle(short shId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= shId) + if (nullptr == pDocInfo) return nullptr; return (CHWPRecordStyle*)pDocInfo->GetStyle(shId); @@ -213,7 +232,7 @@ const CHWPRecordCharShape* CWriterContext::GetCharShape(int nId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= nId) + if (nullptr == pDocInfo) return nullptr; return (CHWPRecordCharShape*)pDocInfo->GetCharShape(nId); @@ -223,7 +242,7 @@ const CHWPRecordNumbering* CWriterContext::GetNumbering(short shId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= shId) + if (nullptr == pDocInfo) return nullptr; return (CHWPRecordNumbering*)pDocInfo->GetNumbering(shId); @@ -233,17 +252,17 @@ const CHWPRecordBullet* CWriterContext::GetBullet(short shId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= shId) + if (nullptr == pDocInfo) return nullptr; - return (CHWPRecordBullet*)pDocInfo->GetBullet(shId - 1); + return (CHWPRecordBullet*)pDocInfo->GetBullet(shId); } const CHwpRecordTabDef* CWriterContext::GetTabDef(short shId) { const CHWPDocInfo* pDocInfo = GetDocInfo(); - if (nullptr == pDocInfo || 0 >= shId) + if (nullptr == pDocInfo) return nullptr; return (CHwpRecordTabDef*)pDocInfo->GetTabDef(shId); diff --git a/HwpFile/HwpDoc/Conversion/WriterContext.h b/HwpFile/HwpDoc/Common/WriterContext.h similarity index 89% rename from HwpFile/HwpDoc/Conversion/WriterContext.h rename to HwpFile/HwpDoc/Common/WriterContext.h index 5ce90f22a7..e968e824bd 100644 --- a/HwpFile/HwpDoc/Conversion/WriterContext.h +++ b/HwpFile/HwpDoc/Common/WriterContext.h @@ -2,8 +2,8 @@ #define WRITERCONTEXT_H #include "../HanType.h" -#include "../HWPFile_Private.h" -#include "../HWPXFile_Private.h" +#include "../HWPFile.h" +#include "../HWPXFile.h" #include "../HWPElements/HWPRecordParaShape.h" #include "../HWPElements/HWPRecordStyle.h" @@ -17,13 +17,14 @@ namespace HWP class CWriterContext { EHanType m_eType; - CHWPFile_Private* m_pHWPFile; - CHWPXFile_Private* m_pHWPXFile; - int m_nVersion; + CHWPFile* m_pHWPFile; + CHWPXFile* m_pHWPXFile; public: CWriterContext(); ~CWriterContext(); + void Clear(); + VECTOR GetSections(); static EHanType DetectHancom(const HWP_STRING& sPathToFile); bool Detect(); diff --git a/HwpFile/HwpDoc/Common/XMLReader.cpp b/HwpFile/HwpDoc/Common/XMLReader.cpp index ede39e20ac..a1380e8d2c 100644 --- a/HwpFile/HwpDoc/Common/XMLReader.cpp +++ b/HwpFile/HwpDoc/Common/XMLReader.cpp @@ -12,7 +12,7 @@ CXMLNode::CXMLNode(const CXmlNode& oNode) bool CXMLNode::GetAttributeBool(const std::wstring& wsName) { - return L"1" == XmlUtils::CXmlNode::GetAttribute(wsName); + return L"1" == XmlUtils::CXmlNode::GetAttribute(wsName, L"0"); } int CXMLNode::GetAttributeColor(const std::wstring& wsName, const int& _default) diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp index 7f41d2e776..c155ecd658 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp @@ -12,15 +12,11 @@ #include "../Paragraph/CtrlTable.h" #include "../Paragraph/CtrlEqEdit.h" -#include "../HWPElements/HWPRecordBinData.h" #include "../HWPElements/HWPRecordParaShape.h" #include "../HWPElements/HWPRecordCharShape.h" #include "Transform.h" -#include -#include - #define DEFAULT_FONT_FAMILY std::wstring(L"Arial") #define DEFAULT_FONT_SIZE 18 #define DEFAULT_LANGUAGE std::wstring(L"en") @@ -302,7 +298,7 @@ bool CConverter2OOXML::IsRasterFormat(const HWP_STRING& sFormat) return L"png" == sFormat || L"jpg" == sFormat || L"jpeg" == sFormat; } -void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState) +void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState) { if (nullptr == pCharacter) return; @@ -316,6 +312,9 @@ void CConverter2OOXML::WriteCharacter(const CCtrlCharacter* pCharacter, NSString oState.m_bOpenedP = false; oBuilder.WriteString(L""); } + else + WriteText(L"", shParaShapeID, pCharacter->GetCharShapeId(), oBuilder, oState); + oState.m_bNeedLineBreak = false; break; } @@ -423,7 +422,7 @@ void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUt } case ECtrlObjectType::Character: { - WriteCharacter((const CCtrlCharacter*)pCtrl, oBuilder, oState); + WriteCharacter((const CCtrlCharacter*)pCtrl, pParagraph->GetShapeID(), oBuilder, oState); break; } case ECtrlObjectType::Shape: @@ -519,35 +518,33 @@ void CConverter2OOXML::WriteParaShapeProperties(short shParaShapeID, NSStringUti break; } - int nLineSpacing = 0; + int nLineSpacing = 240; HWP_STRING sType = L"auto"; - // switch(pParaShape->GetLineSpacingType()) - // { - // case 0x0: - // { - // sType = L"atLeast"; - // nLineSpacing = static_cast((double)pParaShape->GetLineSpacing()); - // nLineSpacing = 57; - // // nLineSpacing = static_cast(240. * (double)pParaShape->GetLineSpacing() / 100.); - // break; - // } - // case 0x01: - // { - // sType = L"exact"; - // nLineSpacing = static_cast(240. * (double)pParaShape->GetLineSpacing() / 100.); - // // nLineSpacing = static_cast((double)pParaShape->GetLineSpacing() / 2. * 20)/*0.352778*/; //(1pt=0.352778mm) //TODO:: проверить, как найдется пример - // break; - // } - // case 0x02: - // case 0x03: - // default: - // { - // sType = L"atLeast"; - // nLineSpacing = static_cast((double)pParaShape->GetLineSpacing()); //TODO:: проверить, как найдется пример - // break; - // } - // } + switch(pParaShape->GetLineSpacingType()) + { + case 0x0: + { + sType = L"auto"; + nLineSpacing = static_cast(240. * (double)pParaShape->GetLineSpacing() / 100. * 0.65); // TODO:: в hwp изначально межстрочный интервал меньше. Множитель 1 в hwp ≈ 0.65 MS + break; + } + case 0x01: + { + sType = L"exact"; + nLineSpacing = static_cast((double)pParaShape->GetLineSpacing() / 2. * 20)/*0.352778*/; //(1pt=0.352778mm) //TODO:: проверить, как найдется пример + break; + break; + } + case 0x02: + case 0x03: + default: + { + sType = L"atLeast"; + nLineSpacing = static_cast((double)pParaShape->GetLineSpacing()); //TODO:: проверить, как найдется пример + break; + } + } oBuilder.WriteString(L"((double)pParaShape->GetMarginPrev() / 10.)) + @@ -1260,6 +1257,8 @@ void CConverter2OOXML::WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStr oBuilder.WriteString(L"GetTextColor()) + L"\"/>"); + bool bStrike = false; + if (pCharShape->Underline()) { EUnderline eUnderlineType = pCharShape->GetUnderlineType(); @@ -1299,9 +1298,14 @@ void CConverter2OOXML::WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStr oBuilder.WriteString(L""); else oBuilder.WriteString(L""); + + bStrike = true; } } + if (!bStrike && pCharShape->StrikeOut()) + oBuilder.WriteString(L""); + double dSpacing = ((double)pCharShape->GetHeight() / 100.) * ((double)pCharShape->GetSpacing(ELang::HANGUL) / 100) * 0.8 + 0.4; dSpacing *= 20; // pt to twips (20 = 1440 / 72) @@ -1424,7 +1428,7 @@ void CConverter2OOXML::CloseParagraph(NSStringUtils::CStringBuilder& oBuilder, T std::vector SplitText(const std::wstring& wsText) { if (wsText.empty()) - return std::vector(); + return std::vector{L""}; std::vector arTexts; @@ -1434,7 +1438,7 @@ std::vector SplitText(const std::wstring& wsText) for (unsigned int unIndex = 1; unIndex < wsText.length(); ++unIndex) { - bool bCurrentIsLetter = iswalpha(wsText[unIndex]); + bool bCurrentIsLetter = iswalnum(wsText[unIndex]); if (bCurrentIsLetter != bWasLetter) { @@ -1468,9 +1472,20 @@ void CConverter2OOXML::WriteText(const std::wstring& wsText, short shParaShapeID oState.m_bNeedLineBreak = false; } - oBuilder.WriteString(L""); - oBuilder.WriteEncodeXmlString(wsTextElement); - oBuilder.WriteString(L""); + if (!wsTextElement.empty()) + { + oBuilder.WriteString(L""); + + oBuilder.WriteEncodeXmlString(wsTextElement); + oBuilder.WriteString(L""); + } + + oBuilder.WriteString(L""); } } diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h index 51700ce2fb..7e3e0784dc 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h @@ -1,7 +1,7 @@ #ifndef CONVERTER2OOXML_H #define CONVERTER2OOXML_H -#include "../HWPFile_Private.h" +#include "../HWPFile.h" #include "../../../DesktopEditor/common/StringBuilder.h" #include "../Paragraph/CtrlAutoNumber.h" @@ -17,7 +17,7 @@ #include "OleConverter.h" #include "NumberingConverter.h" -#include "WriterContext.h" +#include "../Common/WriterContext.h" namespace HWP { @@ -112,7 +112,7 @@ class CConverter2OOXML void WriteBorderSettings(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder); void WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short shParaShapeID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); - void WriteCharacter(const CCtrlCharacter* pCharacter, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); + void WriteCharacter(const CCtrlCharacter* pCharacter, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); void WriteShape(const CCtrlGeneralShape* pShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); HWP_STRING AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget); diff --git a/HwpFile/HwpDoc/HWPDocInfo.cpp b/HwpFile/HwpDoc/HWPDocInfo.cpp index 17ca1cd56e..ac484a238b 100644 --- a/HwpFile/HwpDoc/HWPDocInfo.cpp +++ b/HwpFile/HwpDoc/HWPDocInfo.cpp @@ -30,11 +30,11 @@ CHWPDocInfo::CHWPDocInfo(EHanType eHanType) : m_eHanType(eHanType), m_eCompatibleDoc(ECompatDoc::HWP) {} -CHWPDocInfo::CHWPDocInfo(CHWPXFile_Private* pHWPXFile) +CHWPDocInfo::CHWPDocInfo(CHWPXFile* pHWPXFile) : m_eHanType(EHanType::HWPX), m_pParentHWPX(pHWPXFile), m_eCompatibleDoc(ECompatDoc::UNKNOWN) {} -CHWPDocInfo::CHWPDocInfo(CHWPFile_Private* pHWPFile) +CHWPDocInfo::CHWPDocInfo(CHWPFile* pHWPFile) : m_eHanType(EHanType::HWP), m_pParentHWP(pHWPFile), m_eCompatibleDoc(ECompatDoc::HWP) {} @@ -262,7 +262,7 @@ bool CHWPDocInfo::ReadContentHpf(CXMLNode& oNode, int nVersion) } #define GET_RECORD(array_records, index) \ - if (array_records.size() <= index) \ + if (array_records.size() <= index || index < 0) \ return nullptr; \ return array_records[index] @@ -311,7 +311,7 @@ const CHWPRecord* CHWPDocInfo::GetTabDef(int nIndex) const GET_RECORD(m_arTabDefs, nIndex); } -CHWPFile_Private* CHWPDocInfo::GetParentHWP() +CHWPFile* CHWPDocInfo::GetParentHWP() { return m_pParentHWP; } diff --git a/HwpFile/HwpDoc/HWPDocInfo.h b/HwpFile/HwpDoc/HWPDocInfo.h index 2630bd3ff1..5f84717996 100644 --- a/HwpFile/HwpDoc/HWPDocInfo.h +++ b/HwpFile/HwpDoc/HWPDocInfo.h @@ -18,13 +18,13 @@ enum class ECompatDoc UNKNOWN }; -class CHWPFile_Private; -class CHWPXFile_Private; +class CHWPFile; +class CHWPXFile; class CHWPDocInfo { EHanType m_eHanType; - CHWPXFile_Private *m_pParentHWPX; - CHWPFile_Private *m_pParentHWP; + CHWPXFile *m_pParentHWPX; + CHWPFile *m_pParentHWP; VECTOR m_arRecords; std::map m_mBinDatas; @@ -40,8 +40,8 @@ class CHWPDocInfo ECompatDoc m_eCompatibleDoc; public: CHWPDocInfo(EHanType eHanType); - CHWPDocInfo(CHWPXFile_Private* pHWPXFile); - CHWPDocInfo(CHWPFile_Private* pHWPFile); + CHWPDocInfo(CHWPXFile* pHWPXFile); + CHWPDocInfo(CHWPFile* pHWPFile); ~CHWPDocInfo(); @@ -59,7 +59,7 @@ public: const CHWPRecord* GetStyle(int nIndex) const; const CHWPRecord* GetTabDef(int nIndex) const; - CHWPFile_Private* GetParentHWP(); + CHWPFile* GetParentHWP(); const CHWPRecord* GetBinData(const HWP_STRING& sID) const; EHanType GetHanType() const; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp index 7508e31d57..bac0ad4fba 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.cpp @@ -1,6 +1,6 @@ #include "HWPRecordBinData.h" -#include "../HWPFile_Private.h" +#include "../HWPFile.h" #include #include @@ -12,10 +12,9 @@ ECompressed GetCompressed(int nValue) { SWITCH(ECompressed, nValue) { - CASE(ECompressed::FOLLOW_STORAGE); + DEFAULT(ECompressed::FOLLOW_STORAGE); CASE(ECompressed::COMPRESS); CASE(ECompressed::NO_COMPRESS); - DEFAULT(ECompressed::UNKNOWN); } } @@ -23,22 +22,21 @@ EType GetType(int nValue) { SWITCH(EType, nValue) { - CASE(EType::LINK); + DEFAULT(EType::LINK); CASE(EType::EMBEDDING); CASE(EType::STORAGE); - DEFAULT(EType::UNKNOWN); } } + EState GetState(int nValue) { SWITCH(EState, nValue) { - CASE(EState::NEVER_ACCESSED); + DEFAULT(EState::NEVER_ACCESSED); CASE(EState::FOUND_FILE_BY_ACCESS); CASE(EState::ACCESS_FAILED); CASE(EState::LINK_ACCESS_IGNORED); - DEFAULT(EState::UNKNOWN); } } diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h index 417615c243..c225fa3f17 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBinData.h @@ -13,15 +13,13 @@ enum class ECompressed FOLLOW_STORAGE = 0x00, COMPRESS = 0x10, NO_COMPRESS = 0x20, - UNKNOWN }; enum class EType { LINK = 0x0, EMBEDDING = 0x1, - STORAGE = 0x2, - UNKNOWN + STORAGE = 0x2 }; enum class EState @@ -29,8 +27,7 @@ enum class EState NEVER_ACCESSED = 0x000, FOUND_FILE_BY_ACCESS = 0x100, ACCESS_FAILED = 0x200, - LINK_ACCESS_IGNORED = 0x400, - UNKNOWN + LINK_ACCESS_IGNORED = 0x400 }; class CHWPRecordBinData : public CHWPRecord diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp index 5372c44738..2569ee8618 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordBorderFill.cpp @@ -61,7 +61,7 @@ EColorFillPattern GetColorFillPattern(int nPattern) void TBorder::ReadFromNode(CXMLNode& oNode) { - m_eStyle = GetLineStyle2(oNode.GetAttributeInt(L"type")); + m_eStyle = GetLineStyle2(oNode.GetAttribute(L"type")); HWP_STRING sColor = std::regex_replace(oNode.GetAttribute(L"color"), std::wregex(L"^#([0-9A-Fa-f]+)$"), L"$1"); diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp index 18b499ef92..ec945c965b 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.cpp @@ -154,7 +154,9 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, int nTagNum, int } CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) - : CHWPRecord(EHWPTag::HWPTAG_HWP_CHAR_SHAPE, 0, 0), m_pParent(&oDocInfo) + : CHWPRecord(EHWPTag::HWPTAG_HWP_CHAR_SHAPE, 0, 0), m_pParent(&oDocInfo), + m_bItalic(false), m_bBold(false), m_bEmboss(false), m_bEngrave(false), + m_bSuperScript(false), m_bSubScript(false) { m_eUnderline = EUnderline::NONE; m_eUnderLineShape = ELineStyle1::SOLID; @@ -215,11 +217,14 @@ CHWPRecordCharShape::CHWPRecordCharShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, else if (L"hh:underline" == oChild.GetName()) { m_eUnderline = GetUnderline(oChild.GetAttributeInt(L"type")); - m_eUnderLineShape = GetLineStyle1(oChild.GetAttributeInt(L"shape")); + m_eUnderLineShape = GetLineStyle1(oChild.GetAttribute(L"shape")); m_nUnderlineColor = oChild.GetAttributeColor(L"color"); } else if (L"hh:strikeout" == oChild.GetName()) { + m_eStrikeOutShape = GetLineStyle2(oChild.GetAttribute(L"shape")); + m_nStrikeOutColor = oChild.GetAttributeColor(L"color"); + if (L"3D" == oChild.GetAttribute(L"shape")) m_eStrikeOutShape = ELineStyle2::NONE; } @@ -272,6 +277,11 @@ bool CHWPRecordCharShape::Underline() const return EUnderline::NONE != m_eUnderline; } +bool CHWPRecordCharShape::StrikeOut() const +{ + return ELineStyle2::NONE != m_eStrikeOutShape; +} + int CHWPRecordCharShape::GetHeight() const { return m_nHeight; @@ -292,6 +302,16 @@ int CHWPRecordCharShape::GetUnderlineColor() const return m_nUnderlineColor; } +ELineStyle2 CHWPRecordCharShape::GetStrikeOutType() const +{ + return m_eStrikeOutShape; +} + +int CHWPRecordCharShape::GetStrikeOutColor() const +{ + return m_nStrikeOutColor; +} + short CHWPRecordCharShape::GetRelSize(ELang eLang) const { if (ELang::MAX == eLang) diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h index 7d38894db1..41268b6923 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordCharShape.h @@ -122,12 +122,17 @@ public: bool Bold() const; bool Italic() const; bool Underline() const; + bool StrikeOut() const; int GetHeight() const; + EUnderline GetUnderlineType() const; ELineStyle1 GetUnderlineStyle() const; int GetUnderlineColor() const; + ELineStyle2 GetStrikeOutType() const; + int GetStrikeOutColor() const; + short GetRelSize(ELang eLang) const; HWP_STRING GetFontName(ELang eLang) const; short GetSpacing(ELang eLang) const; diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordIDMaping.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordIDMaping.cpp index 3d5998b389..e453c2a212 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordIDMaping.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordIDMaping.cpp @@ -1,5 +1,5 @@ #include "HWPRecordIDMaping.h" -#include "../HWPFile_Private.h" +#include "../HWPFile.h" #include "../OLEdoc/CompoundFile.h" namespace HWP diff --git a/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp b/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp index 7638eb1c69..4cb62ae319 100644 --- a/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp +++ b/HwpFile/HwpDoc/HWPElements/HWPRecordParaShape.cpp @@ -106,12 +106,11 @@ CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, int nTagNum, int } CHWPRecordParaShape::CHWPRecordParaShape(CHWPDocInfo& oDocInfo, CXMLNode& oNode, int nVersion) - : CHWPRecord(EHWPTag::HWPTAG_PARA_SHAPE, 0, 0), m_pParent(&oDocInfo) + : CHWPRecord(EHWPTag::HWPTAG_PARA_SHAPE, 0, 0), m_pParent(&oDocInfo), + m_eAlign(EHorizontalAlign::JUSTIFY), m_bWidowOrphan(false), m_bKeepWithNext(false), + m_bPageBreakBefore(false), m_eVertAlign(EVerticalAlign::BASELINE), m_eHeadingType(EHeadingType::NONE), + m_bConnect(false), m_bIgnoreMargin(false), m_bParaTailShape(false) { - m_eHeadingType = EHeadingType::NONE; - m_eAlign = EHorizontalAlign::JUSTIFY; - m_eVertAlign = EVerticalAlign::BASELINE; - m_shTabDef = oNode.GetAttributeInt(L"tabPrIDRef"); m_chCondense = (HWP_BYTE)oNode.GetAttributeInt(L"condense"); diff --git a/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp b/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp index 3e04d341ff..70321d8e49 100644 --- a/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp +++ b/HwpFile/HwpDoc/HWPElements/HwpRecordTabDef.cpp @@ -9,7 +9,7 @@ TTab::TTab(CXMLNode& oNode) { m_nPos = oNode.GetAttributeInt(L"pos"); SetType(oNode.GetAttributeInt(L"type")); - m_eLeader = GetLineStyle2(oNode.GetAttributeInt(L"leader")); + m_eLeader = GetLineStyle2(oNode.GetAttribute(L"leader")); } void TTab::SetType(int nValue) diff --git a/HwpFile/HwpDoc/HWPElements/HwpRecordTypes.h b/HwpFile/HwpDoc/HWPElements/HwpRecordTypes.h index dd4e00dd13..70d078811b 100644 --- a/HwpFile/HwpDoc/HWPElements/HwpRecordTypes.h +++ b/HwpFile/HwpDoc/HWPElements/HwpRecordTypes.h @@ -1,6 +1,8 @@ #ifndef HWPRECORDTYPES_H #define HWPRECORDTYPES_H +#include "../Common/Common.h" + namespace HWP { enum class ELineStyle1 @@ -26,31 +28,50 @@ enum class ELineStyle1 inline ELineStyle1 GetLineStyle1(int nValue) { - switch(static_cast(nValue)) + SWITCH(ELineStyle1, nValue) { - case ELineStyle1::SOLID: - case ELineStyle1::DASH: - case ELineStyle1::DOT: - case ELineStyle1::DASH_DOT: - case ELineStyle1::DASH_DOT_DOT: - case ELineStyle1::LONG_DASH: - case ELineStyle1::CIRCLE: - case ELineStyle1::DOUBLE_SLIM: - case ELineStyle1::SLIM_THICK: - case ELineStyle1::THICK_SLIM: - case ELineStyle1::SLIM_THICK_SLIM: - case ELineStyle1::WAVE: - case ELineStyle1::DOUBLE_WAVE: - case ELineStyle1::THICK_3D: - case ELineStyle1::THICK_3D_REVERS_LI: - case ELineStyle1::SOLID_3D: - case ELineStyle1::SOLID_3D_REVERS_LI: - return static_cast(nValue); - default: - return ELineStyle1::SOLID; + DEFAULT(ELineStyle1::SOLID); + CASE(ELineStyle1::DASH); + CASE(ELineStyle1::DOT); + CASE(ELineStyle1::DASH_DOT); + CASE(ELineStyle1::DASH_DOT_DOT); + CASE(ELineStyle1::LONG_DASH); + CASE(ELineStyle1::CIRCLE); + CASE(ELineStyle1::DOUBLE_SLIM); + CASE(ELineStyle1::SLIM_THICK); + CASE(ELineStyle1::THICK_SLIM); + CASE(ELineStyle1::SLIM_THICK_SLIM); + CASE(ELineStyle1::WAVE); + CASE(ELineStyle1::DOUBLE_WAVE); + CASE(ELineStyle1::THICK_3D); + CASE(ELineStyle1::THICK_3D_REVERS_LI); + CASE(ELineStyle1::SOLID_3D); + CASE(ELineStyle1::SOLID_3D_REVERS_LI); } } +inline ELineStyle1 GetLineStyle1(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(SOLID, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(DASH, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(DOT, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(DASH_DOT, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(DASH_DOT_DOT, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(LONG_DASH, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(CIRCLE, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(DOUBLE_SLIM, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(SLIM_THICK, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(THICK_SLIM, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(SLIM_THICK_SLIM, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(WAVE, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(DOUBLE_WAVE, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(THICK_3D, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(THICK_3D_REVERS_LI, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(SOLID_3D, sValue, ELineStyle1); + ELSE_IF_STRING_IN_ENUM(SOLID_3D_REVERS_LI, sValue, ELineStyle1); + ELSE_STRING_IN_ENUM(SOLID, ELineStyle1); +} + enum class ELineStyle2 { NONE, @@ -69,25 +90,40 @@ enum class ELineStyle2 inline ELineStyle2 GetLineStyle2(int nValue) { - switch(static_cast(nValue)) + SWITCH(ELineStyle2, nValue) { - case ELineStyle2::SOLID: - case ELineStyle2::DASH: - case ELineStyle2::DOT: - case ELineStyle2::DASH_DOT: - case ELineStyle2::DASH_DOT_DOT: - case ELineStyle2::LONG_DASH: - case ELineStyle2::CIRCLE: - case ELineStyle2::DOUBLE_SLIM: - case ELineStyle2::SLIM_THICK: - case ELineStyle2::THICK_SLIM: - case ELineStyle2::SLIM_THICK_SLIM: - return static_cast(nValue); - default: - return ELineStyle2::NONE; + DEFAULT(ELineStyle2::NONE); + CASE(ELineStyle2::SOLID); + CASE(ELineStyle2::DASH); + CASE(ELineStyle2::DOT); + CASE(ELineStyle2::DASH_DOT); + CASE(ELineStyle2::DASH_DOT_DOT); + CASE(ELineStyle2::LONG_DASH); + CASE(ELineStyle2::CIRCLE); + CASE(ELineStyle2::DOUBLE_SLIM); + CASE(ELineStyle2::SLIM_THICK); + CASE(ELineStyle2::THICK_SLIM); + CASE(ELineStyle2::SLIM_THICK_SLIM); } } +inline ELineStyle2 GetLineStyle2(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(NONE, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(SOLID, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(DASH, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(DOT, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(DASH_DOT, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(DASH_DOT_DOT, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(LONG_DASH, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(CIRCLE, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(DOUBLE_SLIM, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(SLIM_THICK, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(THICK_SLIM, sValue, ELineStyle2); + ELSE_IF_STRING_IN_ENUM(SLIM_THICK_SLIM, sValue, ELineStyle2); + ELSE_STRING_IN_ENUM(NONE, ELineStyle2); +} + enum class ENumberShape1 { DIGIT, @@ -109,29 +145,46 @@ enum class ENumberShape1 inline ENumberShape1 GetNumberShape1(int nValue) { - switch (static_cast(nValue)) + SWITCH(ENumberShape1, nValue) { - case ENumberShape1::DIGIT: - case ENumberShape1::CIRCLE_DIGIT: - case ENumberShape1::ROMAN_CAPITAL: - case ENumberShape1::ROMAN_SMALL: - case ENumberShape1::LATIN_CAPITAL: - case ENumberShape1::LATIN_SMALL: - case ENumberShape1::CIRCLED_LATIN_CAPITAL: - case ENumberShape1::CIRCLED_LATIN_SMALL: - case ENumberShape1::HANGLE_SYLLABLE: - case ENumberShape1::CIRCLED_HANGUL_SYLLABLE: - case ENumberShape1::HANGUL_JAMO: - case ENumberShape1::CIRCLED_HANGUL_JAMO: - case ENumberShape1::HANGUL_PHONETIC: - case ENumberShape1::IDEOGRAPH: - case ENumberShape1::CIRCLED_IDEOGRAPH: - return static_cast(nValue); - default: - return ENumberShape1::DIGIT; + DEFAULT(ENumberShape1::DIGIT); + CASE(ENumberShape1::CIRCLE_DIGIT); + CASE(ENumberShape1::ROMAN_CAPITAL); + CASE(ENumberShape1::ROMAN_SMALL); + CASE(ENumberShape1::LATIN_CAPITAL); + CASE(ENumberShape1::LATIN_SMALL); + CASE(ENumberShape1::CIRCLED_LATIN_CAPITAL); + CASE(ENumberShape1::CIRCLED_LATIN_SMALL); + CASE(ENumberShape1::HANGLE_SYLLABLE); + CASE(ENumberShape1::CIRCLED_HANGUL_SYLLABLE); + CASE(ENumberShape1::HANGUL_JAMO); + CASE(ENumberShape1::CIRCLED_HANGUL_JAMO); + CASE(ENumberShape1::HANGUL_PHONETIC); + CASE(ENumberShape1::IDEOGRAPH); + CASE(ENumberShape1::CIRCLED_IDEOGRAPH); } } +inline ENumberShape1 GetNumberShape1(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(DIGIT, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(CIRCLE_DIGIT, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(ROMAN_CAPITAL, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(ROMAN_SMALL, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(LATIN_CAPITAL, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(LATIN_SMALL, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_CAPITAL, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_SMALL, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(HANGLE_SYLLABLE, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_SYLLABLE, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(HANGUL_JAMO, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_JAMO, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(HANGUL_PHONETIC, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(IDEOGRAPH, sValue, ENumberShape1); + ELSE_IF_STRING_IN_ENUM(CIRCLED_IDEOGRAPH, sValue, ENumberShape1); + ELSE_STRING_IN_ENUM(DIGIT, ENumberShape1); +} + enum class ENumberShape2 { DIGIT, @@ -157,33 +210,54 @@ enum class ENumberShape2 inline ENumberShape2 GetNumberShape2(int nValue) { - switch (static_cast(nValue)) + SWITCH(ENumberShape2, nValue) { - case ENumberShape2::DIGIT: - case ENumberShape2::CIRCLE_DIGIT: - case ENumberShape2::ROMAN_CAPITAL: - case ENumberShape2::ROMAN_SMALL: - case ENumberShape2::LATIN_CAPITAL: - case ENumberShape2::LATIN_SMALL: - case ENumberShape2::CIRCLED_LATIN_CAPITAL: - case ENumberShape2::CIRCLED_LATIN_SMALL: - case ENumberShape2::HANGLE_SYLLABLE: - case ENumberShape2::CIRCLED_HANGUL_SYLLABLE: - case ENumberShape2::HANGUL_JAMO: - case ENumberShape2::CIRCLED_HANGUL_JAMO: - case ENumberShape2::HANGUL_PHONETIC: - case ENumberShape2::IDEOGRAPH: - case ENumberShape2::CIRCLED_IDEOGRAPH: - case ENumberShape2::DECAGON_CIRCLE: - case ENumberShape2::DECAGON_CRICLE_HANGJA: - case ENumberShape2::SYMBOL: - case ENumberShape2::USER_HWP_CHAR: - return static_cast(nValue); - default: - return ENumberShape2::DIGIT; + DEFAULT(ENumberShape2::DIGIT); + CASE(ENumberShape2::CIRCLE_DIGIT); + CASE(ENumberShape2::ROMAN_CAPITAL); + CASE(ENumberShape2::ROMAN_SMALL); + CASE(ENumberShape2::LATIN_CAPITAL); + CASE(ENumberShape2::LATIN_SMALL); + CASE(ENumberShape2::CIRCLED_LATIN_CAPITAL); + CASE(ENumberShape2::CIRCLED_LATIN_SMALL); + CASE(ENumberShape2::HANGLE_SYLLABLE); + CASE(ENumberShape2::CIRCLED_HANGUL_SYLLABLE); + CASE(ENumberShape2::HANGUL_JAMO); + CASE(ENumberShape2::CIRCLED_HANGUL_JAMO); + CASE(ENumberShape2::HANGUL_PHONETIC); + CASE(ENumberShape2::IDEOGRAPH); + CASE(ENumberShape2::CIRCLED_IDEOGRAPH); + CASE(ENumberShape2::DECAGON_CIRCLE); + CASE(ENumberShape2::DECAGON_CRICLE_HANGJA); + CASE(ENumberShape2::SYMBOL); + CASE(ENumberShape2::USER_HWP_CHAR); } } +inline ENumberShape2 GetNumberShape2(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(DIGIT, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(CIRCLE_DIGIT, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(ROMAN_CAPITAL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(ROMAN_SMALL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(LATIN_CAPITAL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(LATIN_SMALL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_CAPITAL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(CIRCLED_LATIN_SMALL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(HANGLE_SYLLABLE, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_SYLLABLE, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(HANGUL_JAMO, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(CIRCLED_HANGUL_JAMO, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(HANGUL_PHONETIC, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(IDEOGRAPH, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(CIRCLED_IDEOGRAPH, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(DECAGON_CIRCLE, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(DECAGON_CRICLE_HANGJA, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(SYMBOL, sValue, ENumberShape2); + ELSE_IF_STRING_IN_ENUM(USER_HWP_CHAR, sValue, ENumberShape2); + ELSE_STRING_IN_ENUM(DIGIT, ENumberShape2); +} + enum class ELineArrowStyle { NORMAL, @@ -216,6 +290,21 @@ inline ELineArrowStyle GetLineArrowStyle(int nNum, bool bFill) } } +inline ELineArrowStyle GetLineArrowStyle(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(NORMAL, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(ARROW, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(SPEAR, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(CONCAVE_ARROW, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(DIAMOND, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(CIRCLE, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(BOX, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(EMPTY_DIAMOND, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(EMPTY_CIRCLE, sValue, ELineArrowStyle); + ELSE_IF_STRING_IN_ENUM(EMPTY_BOX, sValue, ELineArrowStyle); + ELSE_STRING_IN_ENUM(NORMAL, ELineArrowStyle); +} + enum class ELineArrowSize { SMALL_SMALL, @@ -231,23 +320,34 @@ enum class ELineArrowSize inline ELineArrowSize GetLineArrowSize(int nValue) { - switch(static_cast(nValue)) + SWITCH(ELineArrowSize, nValue) { - case ELineArrowSize::SMALL_SMALL: - case ELineArrowSize::SMALL_MEDIUM: - case ELineArrowSize::SMALL_LARGE: - case ELineArrowSize::MEDIUM_SMALL: - case ELineArrowSize::MEDIUM_MEDIUM: - case ELineArrowSize::MEDIUM_LARGE: - case ELineArrowSize::LARGE_SMALL: - case ELineArrowSize::LARGE_MEDIUM: - case ELineArrowSize::LARGE_LARGE: - return static_cast(nValue); - default: - return ELineArrowSize::SMALL_SMALL; + DEFAULT(ELineArrowSize::SMALL_SMALL); + CASE(ELineArrowSize::SMALL_MEDIUM); + CASE(ELineArrowSize::SMALL_LARGE); + CASE(ELineArrowSize::MEDIUM_SMALL); + CASE(ELineArrowSize::MEDIUM_MEDIUM); + CASE(ELineArrowSize::MEDIUM_LARGE); + CASE(ELineArrowSize::LARGE_SMALL); + CASE(ELineArrowSize::LARGE_MEDIUM); + CASE(ELineArrowSize::LARGE_LARGE); } } +inline ELineArrowSize GetLineArrowSize(const HWP_STRING& sValue) +{ + IF_STRING_IN_ENUM(SMALL_SMALL, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(SMALL_MEDIUM, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(SMALL_LARGE, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(MEDIUM_SMALL, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(MEDIUM_MEDIUM, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(MEDIUM_LARGE, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(LARGE_SMALL, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(LARGE_MEDIUM, sValue, ELineArrowSize); + ELSE_IF_STRING_IN_ENUM(LARGE_LARGE, sValue, ELineArrowSize); + ELSE_STRING_IN_ENUM(SMALL_SMALL, ELineArrowSize); +} + } #endif // HWPRECORDTYPES_H diff --git a/HwpFile/HwpDoc/HWPFile_Private.cpp b/HwpFile/HwpDoc/HWPFile.cpp similarity index 81% rename from HwpFile/HwpDoc/HWPFile_Private.cpp rename to HwpFile/HwpDoc/HWPFile.cpp index c0e0bd535f..f42cceb715 100644 --- a/HwpFile/HwpDoc/HWPFile_Private.cpp +++ b/HwpFile/HwpDoc/HWPFile.cpp @@ -1,4 +1,4 @@ -#include "HWPFile_Private.h" +#include "HWPFile.h" #include "HWPDocInfo.h" #include "../OfficeUtils/src/OfficeUtils.h" @@ -8,17 +8,17 @@ namespace HWP { -CHWPFile_Private::CHWPFile_Private(const HWP_STRING& sFileName) +CHWPFile::CHWPFile(const HWP_STRING& sFileName) : m_sFileName(sFileName), m_oOleFile(sFileName), m_oDocInfo(this) {} -CHWPFile_Private::~CHWPFile_Private() +CHWPFile::~CHWPFile() { CLEAR_ARRAY(CHWPSection, m_arBodyTexts); CLEAR_ARRAY(CHWPSection, m_arViewTexts); } -std::vector CHWPFile_Private::GetSections() +std::vector CHWPFile::GetSections() { if (m_oFileHeader.Distributable()) { @@ -30,12 +30,12 @@ std::vector CHWPFile_Private::GetSections() } } -const CCompoundFile* CHWPFile_Private::GetOleFile() const +const CCompoundFile* CHWPFile::GetOleFile() const { return &m_oOleFile; } -bool CHWPFile_Private::Detect() +bool CHWPFile::Detect() { // read CompoundFile structure if (!m_oOleFile.Open() || !GetFileHeader()) @@ -47,7 +47,7 @@ bool CHWPFile_Private::Detect() return true; } -bool CHWPFile_Private::Open() +bool CHWPFile::Open() { if ((m_oFileHeader.SignatureEmpty() || m_oFileHeader.VersionEmpty()) && !Detect()) return false; @@ -71,12 +71,12 @@ bool CHWPFile_Private::Open() return true; } -void CHWPFile_Private::Close() +void CHWPFile::Close() { m_oOleFile.Close(); } -bool CHWPFile_Private::GetFileHeader() +bool CHWPFile::GetFileHeader() { CHWPStream oBuffer; if (!GetComponent(L"FileHeader", oBuffer)) @@ -85,12 +85,12 @@ bool CHWPFile_Private::GetFileHeader() return m_oFileHeader.Parse(oBuffer); } -const CHWPDocInfo* CHWPFile_Private::GetDocInfo() const +const CHWPDocInfo* CHWPFile::GetDocInfo() const { return &m_oDocInfo; } -bool CHWPFile_Private::GetDocInfo(int nVersion) +bool CHWPFile::GetDocInfo(int nVersion) { CHWPStream oBuffer; if (m_oFileHeader.Compressed()) @@ -109,40 +109,40 @@ bool CHWPFile_Private::GetDocInfo(int nVersion) return m_oDocInfo.Parse(oBuffer, m_nVersion); } -bool CHWPFile_Private::GetComponent(const HWP_STRING& sEntryName, CHWPStream& oBuffer) +bool CHWPFile::GetComponent(const HWP_STRING& sEntryName, CHWPStream& oBuffer) { return m_oOleFile.GetComponent(sEntryName, oBuffer); } //TODO:: написанно, что данные методы используются только для отображения в LibbreOffice // проверить и если нужны будут, то реализовать -VECTOR CHWPFile_Private::GetBinData() +VECTOR CHWPFile::GetBinData() { return VECTOR(); } -void CHWPFile_Private::SetBinData(const std::vector& arBinData) +void CHWPFile::SetBinData(const std::vector& arBinData) { } -VECTOR CHWPFile_Private::GetParas() +VECTOR CHWPFile::GetParas() { return VECTOR(); } -void CHWPFile_Private::AddParas(const std::vector& arParas) +void CHWPFile::AddParas(const std::vector& arParas) { } //------------ -void CHWPFile_Private::SaveChildEntries(const HWP_STRING& sBasePath, const HWP_STRING& sStorageName, ECompressed eCompressed) +void CHWPFile::SaveChildEntries(const HWP_STRING& sBasePath, const HWP_STRING& sStorageName, ECompressed eCompressed) { // TODO:: перенести } -CDirectoryEntry* CHWPFile_Private::FindChildEntry(const HWP_STRING& sBasePath, const CDirectoryEntry& oBaseEntry, const HWP_STRING& sEntryName) const +CDirectoryEntry* CHWPFile::FindChildEntry(const HWP_STRING& sBasePath, const CDirectoryEntry& oBaseEntry, const HWP_STRING& sEntryName) const { for (CDirectoryEntry* pEntry : m_oOleFile.GetChildEntries(&oBaseEntry)) { @@ -162,13 +162,13 @@ CDirectoryEntry* CHWPFile_Private::FindChildEntry(const HWP_STRING& sBasePath, c return nullptr; } -HWP_STRING CHWPFile_Private::SaveChildEntry(const HWP_STRING& sRootPath, const HWP_STRING& sEntryName, ECompressed eCompressed) +HWP_STRING CHWPFile::SaveChildEntry(const HWP_STRING& sRootPath, const HWP_STRING& sEntryName, ECompressed eCompressed) { //TODO:: перенести return HWP_STRING(); } -bool CHWPFile_Private::GetChildStream(const HWP_STRING& sEntryName, ECompressed eCompressed, CHWPStream& oBuffer) +bool CHWPFile::GetChildStream(const HWP_STRING& sEntryName, ECompressed eCompressed, CHWPStream& oBuffer) { // HWP_STRING sRegexStr = L".*" + HWP_STRING(FILE_SEPARATOR_STR) + L"([" + HWP_STRING(FILE_SEPARATOR_STR) + L"]+)$"; @@ -216,7 +216,7 @@ bool CHWPFile_Private::GetChildStream(const HWP_STRING& sEntryName, ECompressed return false; } -bool CHWPFile_Private::Unzip(CHWPStream& oInput, CHWPStream& oBuffer) +bool CHWPFile::Unzip(CHWPStream& oInput, CHWPStream& oBuffer) { unsigned char* pInBuffer = new(std::nothrow) unsigned char[DEFAULT_BUFFER_SIZE]; @@ -301,7 +301,7 @@ bool CHWPFile_Private::Unzip(CHWPStream& oInput, CHWPStream& oBuffer) return DEFLATE_OK == nRes || DEFLATE_STREAM_END == nRes; } -bool CHWPFile_Private::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer) +bool CHWPFile::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer) { int nHeader; oInput.ReadInt(nHeader); @@ -322,7 +322,7 @@ bool CHWPFile_Private::Decrypt(CHWPStream& oInput, CHWPStream& oBuffer) return false; } -bool CHWPFile_Private::GetBodyText(int nVersion) +bool CHWPFile::GetBodyText(int nVersion) { VECTOR arSections{m_oOleFile.GetChildEntries(L"BodyText")}; @@ -347,7 +347,7 @@ bool CHWPFile_Private::GetBodyText(int nVersion) return true; } -bool CHWPFile_Private::GetViewText(int nVersion) +bool CHWPFile::GetViewText(int nVersion) { VECTOR arSections{m_oOleFile.GetChildEntries(L"ViewText")}; diff --git a/HwpFile/HwpDoc/HWPFile_Private.h b/HwpFile/HwpDoc/HWPFile.h similarity index 89% rename from HwpFile/HwpDoc/HWPFile_Private.h rename to HwpFile/HwpDoc/HWPFile.h index f0d200d5fb..5554140515 100644 --- a/HwpFile/HwpDoc/HWPFile_Private.h +++ b/HwpFile/HwpDoc/HWPFile.h @@ -1,5 +1,5 @@ -#ifndef HWPFILE_PRIVATE_H -#define HWPFILE_PRIVATE_H +#ifndef HWPFILE_H +#define HWPFILE_H #include "HwpFileHeader.h" #include "OLEdoc/CompoundFile.h" @@ -8,7 +8,7 @@ namespace HWP { -class CHWPFile_Private +class CHWPFile { HWP_STRING m_sFileName; CCompoundFile m_oOleFile; @@ -18,8 +18,8 @@ class CHWPFile_Private VECTOR m_arBodyTexts; VECTOR m_arViewTexts; public: - CHWPFile_Private(const HWP_STRING& sFileName); - ~CHWPFile_Private(); + CHWPFile(const HWP_STRING& sFileName); + ~CHWPFile(); VECTOR GetSections(); const CCompoundFile* GetOleFile() const; @@ -50,4 +50,4 @@ private: }; } -#endif // HWPFILE_PRIVATE_H +#endif // HWPFILE_H diff --git a/HwpFile/HwpDoc/HWPXFile_Private.cpp b/HwpFile/HwpDoc/HWPXFile.cpp similarity index 81% rename from HwpFile/HwpDoc/HWPXFile_Private.cpp rename to HwpFile/HwpDoc/HWPXFile.cpp index 822b3eafff..37255d9be7 100644 --- a/HwpFile/HwpDoc/HWPXFile_Private.cpp +++ b/HwpFile/HwpDoc/HWPXFile.cpp @@ -1,23 +1,23 @@ -#include "HWPXFile_Private.h" +#include "HWPXFile.h" namespace HWP { -CHWPXFile_Private::CHWPXFile_Private(const HWP_STRING& sFileName) +CHWPXFile::CHWPXFile(const HWP_STRING& sFileName) : m_sFileName(sFileName), m_pZipFolder(nullptr), m_oDocInfo(this) {} -CHWPXFile_Private::~CHWPXFile_Private() +CHWPXFile::~CHWPXFile() { Close(); CLEAR_ARRAY(CHWPSection, m_arSections); } -VECTOR CHWPXFile_Private::GetSections() const +VECTOR CHWPXFile::GetSections() const { RETURN_VECTOR_CONST_PTR(CHWPSection, m_arSections); } -bool CHWPXFile_Private::Detect() +bool CHWPXFile::Detect() { BYTE *pBuffer = NULL; DWORD dwBufferSize = 0; @@ -30,7 +30,7 @@ bool CHWPXFile_Private::Detect() return GetFileHeader(); } -bool CHWPXFile_Private::Open() +bool CHWPXFile::Open() { if (!NSFile::CFileBinary::Exists(m_sFileName)) return false; @@ -51,7 +51,7 @@ bool CHWPXFile_Private::Open() return true; } -void CHWPXFile_Private::Close() +void CHWPXFile::Close() { if (nullptr != m_pZipFolder) { @@ -60,7 +60,7 @@ void CHWPXFile_Private::Close() } } -VECTOR CHWPXFile_Private::GetPathsToSections() const +VECTOR CHWPXFile::GetPathsToSections() const { VECTOR arPaths{m_pZipFolder->getFiles(L"Contents", false)}; @@ -111,18 +111,18 @@ VECTOR CHWPXFile_Private::GetPathsToSections() const return arResult; } -bool CHWPXFile_Private::GetFileHeader() +bool CHWPXFile::GetFileHeader() { CXMLNode oVersionXml{GetDocument(L"version.xml")}; return m_oFileHeader.Parse(oVersionXml); } -const CHWPDocInfo* CHWPXFile_Private::GetDocInfo() const +const CHWPDocInfo* CHWPXFile::GetDocInfo() const { return &m_oDocInfo; } -bool CHWPXFile_Private::GetDocInfo(int nVersion) +bool CHWPXFile::GetDocInfo(int nVersion) { CXMLNode oContent{GetDocument(L"Contents/content.hpf")}; if (m_oDocInfo.ReadContentHpf(oContent, nVersion)) @@ -134,7 +134,7 @@ bool CHWPXFile_Private::GetDocInfo(int nVersion) return false; } -bool CHWPXFile_Private::ReadSection(const HWP_STRING& sName, int nVersion) +bool CHWPXFile::ReadSection(const HWP_STRING& sName, int nVersion) { CXMLNode oRootNode{GetDocument(sName)}; @@ -149,7 +149,7 @@ bool CHWPXFile_Private::ReadSection(const HWP_STRING& sName, int nVersion) return bResult; } -CXMLNode CHWPXFile_Private::GetDocument(const HWP_STRING& sEntryName) +CXMLNode CHWPXFile::GetDocument(const HWP_STRING& sEntryName) { if (nullptr == m_pZipFolder) return CXMLNode(); diff --git a/HwpFile/HwpDoc/HWPXFile_Private.h b/HwpFile/HwpDoc/HWPXFile.h similarity index 78% rename from HwpFile/HwpDoc/HWPXFile_Private.h rename to HwpFile/HwpDoc/HWPXFile.h index ea9ff7121d..917fff213c 100644 --- a/HwpFile/HwpDoc/HWPXFile_Private.h +++ b/HwpFile/HwpDoc/HWPXFile.h @@ -1,5 +1,5 @@ -#ifndef HWPXFILE_PRIVATE_H -#define HWPXFILE_PRIVATE_H +#ifndef HWPXFILE_H +#define HWPXFILE_H #include "HWPSection.h" #include "HwpFileHeader.h" @@ -8,7 +8,7 @@ namespace HWP { -class CHWPXFile_Private +class CHWPXFile { HWP_STRING m_sFileName; CZipFolderMemory *m_pZipFolder; @@ -17,8 +17,8 @@ class CHWPXFile_Private CHWPDocInfo m_oDocInfo; VECTOR m_arSections; public: - CHWPXFile_Private(const HWP_STRING& sFileName); - ~CHWPXFile_Private(); + CHWPXFile(const HWP_STRING& sFileName); + ~CHWPXFile(); VECTOR GetSections() const; const CHWPDocInfo* GetDocInfo() const; @@ -35,4 +35,4 @@ private: }; } -#endif // HWPXFILE_PRIVATE_H +#endif // HWPXFILE_H diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCharacter.cpp b/HwpFile/HwpDoc/Paragraph/CtrlCharacter.cpp index d4c2c6f5b0..463e6fc7ef 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCharacter.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlCharacter.cpp @@ -15,6 +15,11 @@ ECtrlObjectType CCtrlCharacter::GetCtrlType() const return ECtrlObjectType::Character; } +int CCtrlCharacter::GetCharShapeId() const +{ + return m_nCharShapeID; +} + ECtrlCharType CCtrlCharacter::GetType() const { diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h b/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h index 041ec5a2c2..65d0664152 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlCharacter.h @@ -22,6 +22,7 @@ public: CCtrlCharacter(const HWP_STRING& sCtrlID, ECtrlCharType eCtrlChar, int nCharShapeID); ECtrlObjectType GetCtrlType() const override; + int GetCharShapeId() const; ECtrlCharType GetType() const; void SetCharShapeID(int nCharShapeID); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp b/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp index 4d9c7c0988..29fff497d6 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlColumnDef.cpp @@ -59,7 +59,7 @@ CCtrlColumnDef::CCtrlColumnDef(const HWP_STRING& sCtrlID, CXMLNode& oNode, int n { if (L"hp:colLine" == oChild.GetName()) { - m_eColLineStyle = GetLineStyle2(oChild.GetAttributeInt(L"type")); + m_eColLineStyle = GetLineStyle2(oChild.GetAttribute(L"type")); m_chColLineWidth = (HWP_BYTE)ConvertWidthToHWP(oChild.GetAttribute(L"width")); m_nColLineColor = oChild.GetAttributeColor(L"color"); } diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp index cf687fdaef..9e34492204 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp @@ -185,7 +185,7 @@ namespace HWP else if (L"LARGEST_ONLY" == sType) m_chTextFlow = 3; - sType = oNode.GetAttributeInt(L"textWrap"); + sType = oNode.GetAttribute(L"textWrap"); if (L"SQUARE" == sType) m_eTextWrap = ETextWrap::SQUARE; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp index 2670627b2e..8a3160f034 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp @@ -73,7 +73,7 @@ CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, CXMLNode& oNode, { m_nLineColor = oChild.GetAttributeColor(L"color"); m_nLineThick = std::abs(oChild.GetAttributeInt(L"width")); - m_eLineStyle = GetLineStyle2(oChild.GetAttributeInt(L"style")); + m_eLineStyle = GetLineStyle2(oChild.GetAttribute(L"style")); HWP_STRING sType = oChild.GetAttribute(L"headStyle"); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp index 7b60cc6e36..c036a051a9 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.cpp @@ -3,11 +3,15 @@ namespace HWP { CCtrlObjElement::CCtrlObjElement() -{} +{ + InitMatrix(); +} CCtrlObjElement::CCtrlObjElement(const HWP_STRING& sCtrlID) : CCtrlCommon(sCtrlID) -{} +{ + InitMatrix(); +} CCtrlObjElement::CCtrlObjElement(const CCtrlObjElement& oObjElement) : CCtrlCommon(oObjElement) @@ -38,11 +42,15 @@ CCtrlObjElement::CCtrlObjElement(const CCtrlObjElement& oObjElement) CCtrlObjElement::CCtrlObjElement(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) : CCtrlCommon(sCtrlID, nSize, oBuffer, nOff, nVersion) -{} +{ + InitMatrix(); +} CCtrlObjElement::CCtrlObjElement(const HWP_STRING& sCtrlID, CXMLNode& oNode, int nVersion) : CCtrlCommon(sCtrlID, oNode, nVersion) { + InitMatrix(); + m_shNGrp = oNode.GetAttributeInt(L"groupLevel"); m_arMatrix.resize(6); @@ -149,6 +157,17 @@ int CCtrlObjElement::ParseCtrl(CCtrlObjElement& oObj, int nSize, CHWPStream& oBu return oBuffer.GetDistanceToLastPos(true); } +void CCtrlObjElement::InitMatrix() +{ + m_arMatrix.resize(6); + m_arMatrix[0] = 1.; + m_arMatrix[1] = 0.; + m_arMatrix[2] = 0.; + m_arMatrix[3] = 1.; + m_arMatrix[4] = 0.; + m_arMatrix[5] = 0.; +} + void CCtrlObjElement::SetMatrix(CXMLNode& oNode, std::vector& arMatrix, int nOffset) { arMatrix[0 + nOffset] = oNode.GetAttributeDouble(L"e1"); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h index 4603f2fb09..37b944118a 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlObjElement.h @@ -24,6 +24,8 @@ class CCtrlObjElement : public CCtrlCommon VECTOR m_arMatrix; VECTOR m_arMatrixSeq; + void InitMatrix(); + void SetMatrix(CXMLNode& oNode, VECTOR& arMatrix, int nOffset); public: CCtrlObjElement(); diff --git a/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp b/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp index 6c97621279..1b487cbeb1 100644 --- a/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp +++ b/HwpFile/HwpDoc/Paragraph/HWPPargraph.cpp @@ -81,11 +81,11 @@ void CHWPPargraph::ParseHWPParagraph(CXMLNode& oNode, int nCharShapeID, int nVer } else if (L"hp:t" == oNode.GetName()) { + m_arP.push_back(new CParaText(L"____", oNode.GetText(), 0, nCharShapeID)); + for(CXMLNode& oChild : oNode.GetChilds()) { - if (L"#text" == oChild.GetName()) - m_arP.push_back(new CParaText(L"____", oChild.GetText(), 0, nCharShapeID)); - else if (L"hp:lineBreak" == oChild.GetName()) + if (L"hp:lineBreak" == oChild.GetName()) m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::LINE_BREAK)); else if (L"hp:hyphen" == oChild.GetName()) m_arP.push_back(new CCtrlCharacter(L" _", ECtrlCharType::HARD_HYPHEN)); diff --git a/HwpFile/HwpDoc/Paragraph/TblCell.cpp b/HwpFile/HwpDoc/Paragraph/TblCell.cpp index d2fc2c48e9..2d0ffd922a 100644 --- a/HwpFile/HwpDoc/Paragraph/TblCell.cpp +++ b/HwpFile/HwpDoc/Paragraph/TblCell.cpp @@ -64,7 +64,9 @@ CTblCell::CTblCell(CXMLNode& oNode, int nVersion) if (nullptr == pCellParagraphs) continue; - pCellParagraphs->AddCtrl(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK)); + if (ECtrlObjectType::Character != pCellParagraphs->GetCtrls().back()->GetCtrlType()) + pCellParagraphs->AddCtrl(new CCtrlCharacter(L" _", ECtrlCharType::PARAGRAPH_BREAK)); + m_arParas.push_back(pCellParagraphs); } } diff --git a/HwpFile/test/main.cpp b/HwpFile/test/main.cpp index 0aef72189e..d3c5c89cd2 100644 --- a/HwpFile/test/main.cpp +++ b/HwpFile/test/main.cpp @@ -4,9 +4,10 @@ int main() { - CHWPFile oFile(L"YOUR_PATH"); + CHWPFile oFile; - if (oFile.Open()) + if (oFile.OpenHWPX(L"C:/ONLYOFFICE/Files/hwpx/test_multiple_elements.hwpx")) + // if (oFile.OpenHWP(L"C:/ONLYOFFICE/Files/hwp/Examples/test_rect.hwp")) { std::cout << "Successful" << std::endl; } @@ -21,5 +22,5 @@ int main() NSDirectory::DeleteDirectory(wsTempDir); NSDirectory::CreateDirectory(wsTempDir); oFile.SetTempDirectory(wsTempDir); - oFile.ConvertToOOXML(L"YOUR_PATH.docx"); + oFile.ConvertToOOXML(L"result.docx"); }