This commit is contained in:
Green
2025-01-24 18:18:37 +03:00
committed by Oleg Korshul
parent 08e3dfb061
commit 80b7caaf7a
5 changed files with 60 additions and 7 deletions

View File

@ -465,11 +465,23 @@ void CConverter2OOXML::WriteField(const CCtrlField* pShape, short shParaShapeID,
}
}
void CConverter2OOXML::WriteCaption(const CCtrlCommon* pCtrlCommon, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
{
if (nullptr == pCtrlCommon || !pCtrlCommon->HaveCaption())
return;
for (const CCapParagraph* pCapParagraph : pCtrlCommon->GetCaptionParas())
WriteParagraph(pCapParagraph, oBuilder, oState);
}
void CConverter2OOXML::WriteParagraph(const CHWPPargraph* pParagraph, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
{
if (nullptr == pParagraph)
return;
CloseParagraph(oBuilder, oState);
OpenParagraph(pParagraph->GetShapeID(), oBuilder, oState);
if (0 < pParagraph->GetBreakType())
{
if ((0x04 == (pParagraph->GetBreakType() & 0x04)) && (0 < oState.m_unParaIndex))
@ -897,6 +909,8 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
if (EShapeObjectType::Unknown == eShapeType)
return;
WriteCaption((const CCtrlCommon*)pGeneralShape, oBuilder, oState);
const std::wstring wsWidth = std::to_wstring(Transform::HWPUINT2OOXML(pGeneralShape->GetWidth()));
const std::wstring wsHeight = std::to_wstring(Transform::HWPUINT2OOXML(pGeneralShape->GetHeight()));
@ -1120,7 +1134,7 @@ void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
m_oDocXml.WriteString(L"</w:sectPr>");
}
void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, const TConversionState& oState)
void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
{
if (nullptr == pCtrlPic)
return;
@ -1130,6 +1144,8 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils
if (sPictureID.empty())
return;
WriteCaption((const CCtrlCommon*)pCtrlPic, oBuilder, oState);
if (!oState.m_bOpenedP)
oBuilder.WriteString(L"<w:p>");
@ -1154,7 +1170,7 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils
oBuilder.WriteString(L"</w:p>");
}
void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, const TConversionState& oState)
void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState)
{
if (nullptr == pCtrlVideo)
return;
@ -1164,6 +1180,8 @@ void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUti
if (sPictureID.empty())
return;
WriteCaption((const CCtrlCommon*)pCtrlVideo, oBuilder, oState);
if (!oState.m_bOpenedP)
oBuilder.WriteString(L"<w:p>");
@ -1320,6 +1338,8 @@ HWP_STRING CConverter2OOXML::SavePicture(const HWP_STRING& sBinItemId)
return HWP_STRING();
}
++m_ushShapeCount;
AddContentType(L"media/" + sFileName, L"image/" + NSFile::GetFileExtention(sFileName));
return AddRelationship(L"image", L"media/" + sFileName);
}
@ -1877,6 +1897,7 @@ void CConverter2OOXML::WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber,short
return;
unsigned short ushValue = 0;
HWP_STRING wsType;
//TODO:: лучше перейти не на ручной подсчет, а на автоматический в word (но там есть свои проблемы)
switch (pAutoNumber->GetNumType())
@ -1889,17 +1910,32 @@ void CConverter2OOXML::WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber,short
case ENumType::ENDNOTE:
ushValue = m_oFootnoteConverter.GetEndnoteCount(); break;
case ENumType::FIGURE:
{
wsType = L"Figure";
ushValue = m_ushShapeCount; break;
}
case ENumType::TABLE:
{
wsType = L"Table";
ushValue = m_ushTableCount; break;
}
case ENumType::EQUATION:
{
wsType = L"Equation";
ushValue = m_ushEquationCount; break;
}
}
if (0 == ushValue)
return;
if (!wsType.empty())
oBuilder.WriteString(L"<w:fldSimple w:instr=\" SEQ " + wsType + L" \\* ARABIC \">");
WriteText(std::to_wstring(ushValue), shParaShapeID, shCharShapeID, oBuilder, oState);
if (!wsType.empty())
oBuilder.WriteString(L"</w:fldSimple>");
}
HWP_STRING CConverter2OOXML::AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget)

View File

@ -125,8 +125,8 @@ class CConverter2OOXML
void WriteOleShape(const CCtrlShapeOle* pOleShape, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteSectionSettings(TConversionState& oState);
void WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, const TConversionState& oState);
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, const TConversionState& oState);
void WritePicture(const CCtrlShapePic* pCtrlPic, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
bool SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName);
HWP_STRING SavePicture(const HWP_STRING& sBinItemId);
@ -159,6 +159,8 @@ class CConverter2OOXML
void WriteField(const CCtrlField* pHyperlink, short shParaShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void CloseField(const CCtrlField* pHyperlink, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
void WriteCaption(const CCtrlCommon* pCtrlCommon, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
HWP_STRING AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget);
void AddContentType(const HWP_STRING& wsName, const HWP_STRING& wsType);
void AddDefaultContentType(const HWP_STRING& wsName);

View File

@ -129,6 +129,8 @@ LIST<CCtrl*> CHWPRecordParaText::Parse(int nTagNum, int nLevel, int nSize, CHWPS
// Пока данный вариант невозможен
else if (6 == itCurrent->length())
{
UPDATE_CURRENT_TEXT();
//TODO:: Проверить
HWP_STRING sInfo = sText.substr(itCurrent->position(), 2);
std::wregex wrReplaceRegex(L"[\\x00-\\x20]+$");

View File

@ -1,7 +1,7 @@
#include "CtrlCommon.h"
#include "../Common/Common.h"
#include "CellParagraph.h"
#include "CapParagraph.h"
namespace HWP
{
@ -337,8 +337,8 @@ namespace HWP
for (CXMLNode& oSubList : oChild.GetChilds(L"hp:subList"))
{
for (CXMLNode& oParagraph : oSubList.GetChilds(L"p"))
m_arParas.push_back(new CCellParagraph(oParagraph, nVersion));
for (CXMLNode& oParagraph : oSubList.GetChilds(L"hp:p"))
m_arCaption.push_back(new CCapParagraph(oParagraph, nVersion));
}
}
}
@ -497,6 +497,16 @@ namespace HWP
return m_nZOrder;
}
bool CCtrlCommon::HaveCaption() const
{
return !m_arCaption.empty();
}
std::vector<const CCapParagraph*> CCtrlCommon::GetCaptionParas() const
{
RETURN_VECTOR_CONST_PTR(CCapParagraph, m_arCaption);
}
int CCtrlCommon::ParseCtrl(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion)
{
HWP_STRING sCtrlId;

View File

@ -149,6 +149,9 @@ public:
HWP_BYTE GetTextFlow() const;
int GetZOrder() const;
bool HaveCaption() const;
VECTOR<const CCapParagraph*> GetCaptionParas() const;
static int ParseCtrl(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
static int ParseCaption(CCtrlCommon& oObj, int nSize, CHWPStream& oBuffer, int nOff, int nVersion);
};