diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp index 9e94484d68..ab3dbe401a 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.cpp @@ -733,15 +733,15 @@ void CConverter2OOXML::WriteCellProperties(short shBorderFillID, NSStringUtils:: oBuilder.WriteString(L""); - WriteBorder(pBorderFill->GetTopBorder(), L"top", oBuilder); - WriteBorder(pBorderFill->GetLeftBorder(), L"left", oBuilder); - WriteBorder(pBorderFill->GetBottomBorder(), L"bottom", oBuilder); - WriteBorder(pBorderFill->GetRightBorder(), L"right", oBuilder); + WriteCellBorder(pBorderFill->GetTopBorder(), L"top", oBuilder); + WriteCellBorder(pBorderFill->GetLeftBorder(), L"left", oBuilder); + WriteCellBorder(pBorderFill->GetBottomBorder(), L"bottom", oBuilder); + WriteCellBorder(pBorderFill->GetRightBorder(), L"right", oBuilder); oBuilder.WriteString(L""); } -void CConverter2OOXML::WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder) +void CConverter2OOXML::WriteCellBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder) { if (0x00 == oBorder.m_chWidth || sBorderName.empty()) return; @@ -848,26 +848,7 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape oBuilder.WriteString(L""); } - oBuilder.WriteString(L"GetLineStyle()) ? (L" w=\"" + std::to_wstring(Transform::LineWidth2Pt(pGeneralShape->GetLineThick())) + L'\"') : std::wstring()) + L">"); - - switch (pGeneralShape->GetLineStyle()) - { - case ELineStyle2::NONE: oBuilder.WriteString(L""); break; - case ELineStyle2::SOLID: oBuilder.WriteString(L"GetLineColor()) + L"\"/>"); break; - 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: - oBuilder.WriteString(L""); break; //TODO:: добавить реализацию - break; - } - oBuilder.WriteString(L""); + WriteLineSettings(pGeneralShape, oBuilder); oBuilder.WriteString(L""); @@ -1037,7 +1018,9 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils oBuilder.WriteString(L""); oBuilder.WriteString(L""); oBuilder.WriteString(L"GetCurWidth())) + L"\" cy=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlPic->GetCurHeight())) + L"\"/>"); - oBuilder.WriteString(L""); + oBuilder.WriteString(L""); + WriteBorderSettings(pCtrlPic, oBuilder); + oBuilder.WriteString(L""); oBuilder.WriteString(L"00"); CloseAnchorNode(oBuilder); oBuilder.WriteString(L""); @@ -1314,7 +1297,11 @@ void CConverter2OOXML::OpenAnchorNode(const CCtrlCommon* pCtrlShape, NSStringUti oBuilder.WriteString(L"GetTextWrap() ? L"1" : L"0")) + L"\" relativeHeight=\"" + std::to_wstring(pCtrlShape->GetZOrder()) + - L"\" distT=\"0\" distB=\"0\" distL=\"0\" distR=\"0\" simplePos=\"0\" locked=\"0\" layoutInCell=\"1\" allowOverlap=\"1\">"); + L"\" distT=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetTopMargin() / 10)) + + L"\" distB=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetBottomMargin() / 10)) + + L"\" distL=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetLeftMargin() / 10)) + + L"\" distR=\"" + std::to_wstring(Transform::HWPUINT2OOXML(pCtrlShape->GetRightMargin() / 10)) + + L"\" simplePos=\"0\" locked=\"0\" layoutInCell=\"1\" allowOverlap=\"1\">"); WriteShapeProperty(pCtrlShape, oBuilder); } @@ -1367,7 +1354,15 @@ void CConverter2OOXML::WriteShapeProperty(const CCtrlCommon* pCtrlShape, NSStrin { case ETextWrap::SQUARE: { - oBuilder.WriteString(L""); + oBuilder.WriteString(L"GetTextFlow()) + { + case 0x0: default: oBuilder.WriteString(L"bothSides"); break; + case 0x1: oBuilder.WriteString(L"left"); break; + case 0x2: oBuilder.WriteString(L"right"); break; + case 0x3: oBuilder.WriteString(L"largest"); break; + } + oBuilder.WriteString(L"\"/>"); break; } case ETextWrap::TOP_AND_BOTTOM: @@ -1413,6 +1408,117 @@ void CConverter2OOXML::WriteText(const std::wstring& wsText, short shParaShapeID oBuilder.WriteString(L""); } +void CConverter2OOXML::WriteLineSettings(const CCtrlGeneralShape* pCtrlGeneralShape, NSStringUtils::CStringBuilder& oBuilder) +{ + if (nullptr == pCtrlGeneralShape) + return; + + WriteLineSettings(pCtrlGeneralShape->GetLineStyle(), pCtrlGeneralShape->GetLineColor(), pCtrlGeneralShape->GetLineThick(), 1, oBuilder); +} + +void CConverter2OOXML::WriteLineSettings(ELineStyle2 eLineStyle, int nColor, int nThick, HWP_BYTE nCompoundLineType, NSStringUtils::CStringBuilder& oBuilder) +{ + if (ELineStyle2::NONE == eLineStyle || 0 >= nThick) + { + oBuilder.WriteString(L""); + return; + } + + oBuilder.WriteString(L""); + + oBuilder.WriteString(L""); + + switch (eLineStyle) + { + case ELineStyle2::DASH: + { + oBuilder.WriteString(L""); + break; + } + case ELineStyle2::DOT: + { + oBuilder.WriteString(L""); + break; + } + case ELineStyle2::DASH_DOT: + { + oBuilder.WriteString(L""); + break; + } + case ELineStyle2::DASH_DOT_DOT: + { + oBuilder.WriteString(L""); + break; + } + case ELineStyle2::LONG_DASH: + { + oBuilder.WriteString(L""); + break; + } + case ELineStyle2::CIRCLE: + { + oBuilder.WriteString(L""); + break; + } + default: + break; + } + + switch (nCompoundLineType) + { + case 0x00: + { + oBuilder.WriteString(L""); + break; + } + case 0x01: + { + oBuilder.WriteString(L""); + break; + } + } + + oBuilder.WriteString(L""); +} + +void CConverter2OOXML::WriteBorderSettings(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder) +{ + if (nullptr == pCtrlPic) + return; + + WriteLineSettings(pCtrlPic->GetBorderLineStyle(), pCtrlPic->GetBorderColor(), pCtrlPic->GetBorderThick(), pCtrlPic->GetBorderCompoundLineType(), oBuilder); +} + bool CConverter2OOXML::GetBinBytes(const HWP_STRING& sID, CHWPStream& oBuffer, HWP_STRING& sFormat) { const CHWPDocInfo* pDocInfo = nullptr; diff --git a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h index e827b86a48..b44d0b7e45 100644 --- a/HwpFile/HwpDoc/Conversion/Converter2OOXML.h +++ b/HwpFile/HwpDoc/Conversion/Converter2OOXML.h @@ -80,7 +80,7 @@ class CConverter2OOXML void WriteTableProperties(const CCtrlTable* pTable, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); void WriteCell(const CTblCell* pCell, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, ECellCreator eCellCreator); void WriteCellProperties(short shBorderFillID, NSStringUtils::CStringBuilder& oBuilder); - void WriteBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder); + void WriteCellBorder(const TBorder& oBorder, const HWP_STRING& sBorderName, NSStringUtils::CStringBuilder& oBuilder); void WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); void WriteEqEditShape(const CCtrlEqEdit* pEqEditShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); @@ -100,6 +100,9 @@ class CConverter2OOXML void WriteShapeProperty(const CCtrlCommon* pCtrlShape, NSStringUtils::CStringBuilder& oBuilder); void WriteText(const std::wstring& wsText, short shParaShapeID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState); + void WriteLineSettings(const CCtrlGeneralShape* pCtrlGeneralShape, NSStringUtils::CStringBuilder& oBuilder); + void WriteLineSettings(ELineStyle2 eLineStyle, int nColor, int nThick, HWP_BYTE nCompoundLineType, NSStringUtils::CStringBuilder& oBuilder); + void WriteBorderSettings(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder); bool GetBinBytes(const HWP_STRING& sID, CHWPStream& oBuffer, HWP_STRING& sFormat); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp index f61c00a9f9..3748f22b48 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.cpp @@ -241,6 +241,26 @@ namespace HWP return m_arParas[unIndex]; } + short CCtrlCommon::GetLeftMargin() const + { + return m_arOutMargin[0]; + } + + short CCtrlCommon::GetTopMargin() const + { + return m_arOutMargin[2]; + } + + short CCtrlCommon::GetRightMargin() const + { + return m_arOutMargin[1]; + } + + short CCtrlCommon::GetBottomMargin() const + { + return m_arOutMargin[3]; + } + int CCtrlCommon::GetHorzOffset() const { return m_nHorzOffset; @@ -301,6 +321,11 @@ namespace HWP return m_eTextWrap; } + HWP_BYTE CCtrlCommon::GetTextFlow() const + { + return m_chTextFlow; + } + int CCtrlCommon::GetZOrder() const { return m_nZOrder; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlCommon.h b/HwpFile/HwpDoc/Paragraph/CtrlCommon.h index 6dd80ea2e2..a3fd3303da 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlCommon.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlCommon.h @@ -151,6 +151,11 @@ public: unsigned int GetCountParagraphs() const; const CHWPPargraph* GetParagraphs(unsigned int unIndex) const; + short GetLeftMargin() const; + short GetTopMargin() const; + short GetRightMargin() const; + short GetBottomMargin() const; + int GetHorzOffset() const; int GetVertOffset() const; EVRelTo GetVertRelTo() const; @@ -163,6 +168,7 @@ public: int GetWidth() const; int GetHeight() const; ETextWrap GetTextWrap() const; + HWP_BYTE GetTextFlow() const; int GetZOrder() const; static int ParseCtrl(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp index 003e7a230f..b138a73e2a 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.cpp @@ -16,16 +16,21 @@ namespace HWP { CCtrlGeneralShape::CCtrlGeneralShape() - : m_pFill(nullptr) -{} +{ + InitData(); +} CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID) - : CCtrlObjElement(sCtrlID), m_pFill(nullptr) -{} + : CCtrlObjElement(sCtrlID) +{ + InitData(); +} CCtrlGeneralShape::CCtrlGeneralShape(const CCtrlGeneralShape& oGeneralShape) : CCtrlObjElement((CCtrlObjElement)oGeneralShape) { + InitData(); + m_pParent = oGeneralShape.m_pParent; m_nLineColor = oGeneralShape.m_nLineColor; @@ -51,8 +56,10 @@ CCtrlGeneralShape::CCtrlGeneralShape(const CCtrlGeneralShape& oGeneralShape) } CCtrlGeneralShape::CCtrlGeneralShape(const HWP_STRING& sCtrlID, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) - : CCtrlObjElement(sCtrlID, nSize, oBuffer, nOff, nVersion), m_pFill(nullptr) -{} + : CCtrlObjElement(sCtrlID, nSize, oBuffer, nOff, nVersion) +{ + InitData(); +} CCtrlGeneralShape::~CCtrlGeneralShape() { @@ -60,6 +67,12 @@ CCtrlGeneralShape::~CCtrlGeneralShape() m_pFill = nullptr; } +void CCtrlGeneralShape::InitData() +{ + m_eLineStyle = ELineStyle2::NONE; + m_pFill = nullptr; +} + void CCtrlGeneralShape::SetParent(CHWPPargraph* pParent) { m_pParent = pParent; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h index a551dc7a73..cfafffd87a 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlGeneralShape.h @@ -30,6 +30,8 @@ class CCtrlGeneralShape : public CCtrlObjElement short m_shBottomSpace; int m_nMaxTxtWidth; + void InitData(); + friend class CCtrlShapeEllipse; friend class CCtrlShapePolygon; friend class CCtrlShapeRect; diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp index fdcef1852f..af3ee31fe3 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.cpp @@ -154,6 +154,26 @@ int CCtrlShapePic::GetPicHeight() const return m_nIniPicHeight; } +ELineStyle2 CCtrlShapePic::GetBorderLineStyle() const +{ + return ::HWP::GetLineStyle2((m_nBorderAttr & ((1 << 5) - 1))); +} + +HWP_BYTE CCtrlShapePic::GetBorderCompoundLineType() const +{ + return (HWP_BYTE)((m_nBorderAttr >> 6) & ((1 << 3) - 1)); +} + +int CCtrlShapePic::GetBorderColor() const +{ + return m_nBorderColor; +} + +int CCtrlShapePic::GetBorderThick() const +{ + return m_nBorderThick; +} + int CCtrlShapePic::ParseElement(CCtrlShapePic& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion) { oBuffer.SavePosition(); diff --git a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h index 835ec546aa..5d8daa9c0e 100644 --- a/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h +++ b/HwpFile/HwpDoc/Paragraph/CtrlShapePic.h @@ -135,6 +135,11 @@ public: int GetPicWidth() const; int GetPicHeight() const; + ELineStyle2 GetBorderLineStyle() const; + HWP_BYTE GetBorderCompoundLineType() const; + int GetBorderColor() const; + int GetBorderThick() const; + static int ParseElement(CCtrlShapePic& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); static int ParseCtrl(CCtrlShapePic& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion); };