mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix bug #74897
This commit is contained in:
@ -34,6 +34,8 @@ struct TConversionState
|
|||||||
const CCtrlPageNumPos* m_pPageNum;
|
const CCtrlPageNumPos* m_pPageNum;
|
||||||
const CCtrlNewNumber* m_pNewNumber;
|
const CCtrlNewNumber* m_pNewNumber;
|
||||||
|
|
||||||
|
VECTOR<TRelationship>* m_pRelationships;
|
||||||
|
|
||||||
enum class EBreakType
|
enum class EBreakType
|
||||||
{
|
{
|
||||||
Page,
|
Page,
|
||||||
@ -46,7 +48,7 @@ struct TConversionState
|
|||||||
|
|
||||||
TConversionState()
|
TConversionState()
|
||||||
: m_bOpenedP(false), m_bOpenedR(false), m_bIsNote(false), m_bInTable(false), m_bLastEmptyNode(false), m_bInTextBox(false), m_ushLastCharShapeId(-1), m_ushSecdIndex(0), m_unParaIndex(0),
|
: m_bOpenedP(false), m_bOpenedR(false), m_bIsNote(false), m_bInTable(false), m_bLastEmptyNode(false), m_bInTextBox(false), m_ushLastCharShapeId(-1), m_ushSecdIndex(0), m_unParaIndex(0),
|
||||||
m_pSectionDef(nullptr), m_pColumnDef(nullptr), m_pPageNum(nullptr), m_pNewNumber(nullptr), m_eBreakType(EBreakType::None)
|
m_pSectionDef(nullptr), m_pColumnDef(nullptr), m_pPageNum(nullptr), m_pNewNumber(nullptr), m_pRelationships(nullptr), m_eBreakType(EBreakType::None)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -415,7 +415,7 @@ void CConverter2OOXML::WriteField(const CCtrlField* pShape, short shParaShapeID,
|
|||||||
if (wsHref.empty())
|
if (wsHref.empty())
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const HWP_STRING wsID = AddRelationship(L"hyperlink", wsHref);
|
const HWP_STRING wsID = AddRelationship(L"hyperlink", wsHref, &oState);
|
||||||
|
|
||||||
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||||
oBuilder.WriteString(L"<w:hyperlink r:id=\"" + wsID + L"\">");
|
oBuilder.WriteString(L"<w:hyperlink r:id=\"" + wsID + L"\">");
|
||||||
@ -832,6 +832,7 @@ void CConverter2OOXML::WriteCell(const CTblCell* pCell, NSStringUtils::CStringBu
|
|||||||
{
|
{
|
||||||
NSStringUtils::CStringBuilder oCellBuilder;
|
NSStringUtils::CStringBuilder oCellBuilder;
|
||||||
TConversionState oCellState;
|
TConversionState oCellState;
|
||||||
|
oCellState.m_pRelationships = oState.m_pRelationships;
|
||||||
|
|
||||||
WriteParagraph(pParagraph, oCellBuilder, oCellState);
|
WriteParagraph(pParagraph, oCellBuilder, oCellState);
|
||||||
|
|
||||||
@ -1057,7 +1058,7 @@ void CConverter2OOXML::WriteGeometryShape(const CCtrlGeneralShape* pGeneralShape
|
|||||||
oBuilder.WriteString(L"<a:solidFill><a:srgbClr val=\"" + Transform::IntColorToHEX(pFill->GetFaceColor()) + L"\"/></a:solidFill>");
|
oBuilder.WriteString(L"<a:solidFill><a:srgbClr val=\"" + Transform::IntColorToHEX(pFill->GetFaceColor()) + L"\"/></a:solidFill>");
|
||||||
else if (pFill->ImageFill())
|
else if (pFill->ImageFill())
|
||||||
{
|
{
|
||||||
const HWP_STRING sPictureId = SavePicture(pFill->GetBinItemID());
|
const HWP_STRING sPictureId = SavePicture(pFill->GetBinItemID(), oState);
|
||||||
|
|
||||||
if (!sPictureId.empty())
|
if (!sPictureId.empty())
|
||||||
oBuilder.WriteString(L"<a:blipFill><a:blip r:embed=\"" + sPictureId + L"\"><a:extLst><a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/></a:ext></a:extLst></a:blip><a:srcRect/><a:stretch><a:fillRect/></a:stretch></a:blipFill>");
|
oBuilder.WriteString(L"<a:blipFill><a:blip r:embed=\"" + sPictureId + L"\"><a:extLst><a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/></a:ext></a:extLst></a:blip><a:srcRect/><a:stretch><a:fillRect/></a:stretch></a:blipFill>");
|
||||||
@ -1136,7 +1137,7 @@ void CConverter2OOXML::WriteOleShape(const CCtrlShapeOle* pOleShape, short shPar
|
|||||||
|
|
||||||
const std::wstring wsWidth = std::to_wstring(Transform::HWPUINT2OOXML(pOleShape->GetWidth()));
|
const std::wstring wsWidth = std::to_wstring(Transform::HWPUINT2OOXML(pOleShape->GetWidth()));
|
||||||
const std::wstring wsHeight = std::to_wstring(Transform::HWPUINT2OOXML(pOleShape->GetHeight()));
|
const std::wstring wsHeight = std::to_wstring(Transform::HWPUINT2OOXML(pOleShape->GetHeight()));
|
||||||
const std::wstring wsRelID = AddRelationship(L"chart", L"charts/chart" + std::to_wstring(unChartIndex) + L".xml");
|
const std::wstring wsRelID = AddRelationship(L"chart", L"charts/chart" + std::to_wstring(unChartIndex) + L".xml", &oState);
|
||||||
|
|
||||||
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
OpenParagraph(shParaShapeID, shParaStyleID, oBuilder, oState);
|
||||||
|
|
||||||
@ -1183,7 +1184,7 @@ void CConverter2OOXML::WriteSectionSettings(TConversionState& oState)
|
|||||||
{\
|
{\
|
||||||
const std::wstring wsType = id.substr(0, 6);\
|
const std::wstring wsType = id.substr(0, 6);\
|
||||||
AddContentType(id, L"application/vnd.openxmlformats-officedocument.wordprocessingml." + wsType + L"+xml");\
|
AddContentType(id, L"application/vnd.openxmlformats-officedocument.wordprocessingml." + wsType + L"+xml");\
|
||||||
m_oDocXml.WriteString(L"<w:" + wsType + L"Reference w:type=\"default\" r:id=\"" + AddRelationship(wsType, id) + L"\"/>");\
|
m_oDocXml.WriteString(L"<w:" + wsType + L"Reference w:type=\"default\" r:id=\"" + AddRelationship(wsType, id, &oState) + L"\"/>");\
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nullptr != oState.m_pPageNum)
|
if (nullptr != oState.m_pPageNum)
|
||||||
@ -1244,7 +1245,7 @@ void CConverter2OOXML::WritePicture(const CCtrlShapePic* pCtrlPic, short shParaS
|
|||||||
if (nullptr == pCtrlPic)
|
if (nullptr == pCtrlPic)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HWP_STRING sPictureID = SavePicture(pCtrlPic->GetBinDataID());
|
HWP_STRING sPictureID = SavePicture(pCtrlPic->GetBinDataID(), oState);
|
||||||
|
|
||||||
if (sPictureID.empty())
|
if (sPictureID.empty())
|
||||||
return;
|
return;
|
||||||
@ -1288,7 +1289,7 @@ void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shPar
|
|||||||
if (nullptr == pCtrlVideo || 1 != pCtrlVideo->GetVideoType())
|
if (nullptr == pCtrlVideo || 1 != pCtrlVideo->GetVideoType())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
HWP_STRING sPictureID = SavePicture(pCtrlVideo->GetThumnailBinID());
|
HWP_STRING sPictureID = SavePicture(pCtrlVideo->GetThumnailBinID(), oState);
|
||||||
|
|
||||||
if (sPictureID.empty())
|
if (sPictureID.empty())
|
||||||
return;
|
return;
|
||||||
@ -1307,7 +1308,7 @@ void CConverter2OOXML::WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shPar
|
|||||||
oBuilder.WriteString(L"<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
oBuilder.WriteString(L"<a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
||||||
oBuilder.WriteString(L"<pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
oBuilder.WriteString(L"<pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">");
|
||||||
oBuilder.WriteString(L"<pic:nvPicPr><pic:cNvPr id=\"" + std::to_wstring(m_ushShapeCount) + L"\" name=\"Video " + std::to_wstring(m_ushShapeCount) + L"\" descr=\"" + pCtrlVideo->GetDesc() + L"\">");
|
oBuilder.WriteString(L"<pic:nvPicPr><pic:cNvPr id=\"" + std::to_wstring(m_ushShapeCount) + L"\" name=\"Video " + std::to_wstring(m_ushShapeCount) + L"\" descr=\"" + pCtrlVideo->GetDesc() + L"\">");
|
||||||
oBuilder.WriteString(L"<a:hlinkClick r:id=\"" + AddRelationship(L"hyperlink", pCtrlVideo->GetWebUrl()) + L"\"/></pic:cNvPr>");
|
oBuilder.WriteString(L"<a:hlinkClick r:id=\"" + AddRelationship(L"hyperlink", pCtrlVideo->GetWebUrl(), &oState) + L"\"/></pic:cNvPr>");
|
||||||
oBuilder.WriteString(L"<pic:cNvPicPr/></pic:nvPicPr>");
|
oBuilder.WriteString(L"<pic:cNvPicPr/></pic:nvPicPr>");
|
||||||
oBuilder.WriteString(L"<pic:blipFill><a:blip r:embed=\"" + sPictureID + L"\"><a:extLst>");
|
oBuilder.WriteString(L"<pic:blipFill><a:blip r:embed=\"" + sPictureID + L"\"><a:extLst>");
|
||||||
oBuilder.WriteString(L"<a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/></a:ext>");
|
oBuilder.WriteString(L"<a:ext uri=\"{28A0092B-C50C-407E-A947-70E740481C1C}\"><a14:useLocalDpi xmlns:a14=\"http://schemas.microsoft.com/office/drawing/2010/main\" val=\"0\"/></a:ext>");
|
||||||
@ -1430,7 +1431,7 @@ bool CConverter2OOXML::SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
HWP_STRING CConverter2OOXML::SavePicture(const HWP_STRING& sBinItemId)
|
HWP_STRING CConverter2OOXML::SavePicture(const HWP_STRING& sBinItemId, TConversionState& oState)
|
||||||
{
|
{
|
||||||
if (nullptr == m_pContext)
|
if (nullptr == m_pContext)
|
||||||
return HWP_STRING();
|
return HWP_STRING();
|
||||||
@ -1463,7 +1464,7 @@ HWP_STRING CConverter2OOXML::SavePicture(const HWP_STRING& sBinItemId)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddContentType(L"media/" + sFileName, L"image/" + NSFile::GetFileExtention(sFileName));
|
AddContentType(L"media/" + sFileName, L"image/" + NSFile::GetFileExtention(sFileName));
|
||||||
return AddRelationship(L"image", L"media/" + sFileName);
|
return AddRelationship(L"image", L"media/" + sFileName, &oState);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConverter2OOXML::WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& sExternStyles)
|
void CConverter2OOXML::WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& sExternStyles)
|
||||||
@ -2111,14 +2112,21 @@ void CConverter2OOXML::WriteAutoNumber(const CCtrlAutoNumber* pAutoNumber, short
|
|||||||
oBuilder.WriteString(L"</w:fldSimple>");
|
oBuilder.WriteString(L"</w:fldSimple>");
|
||||||
}
|
}
|
||||||
|
|
||||||
HWP_STRING CConverter2OOXML::AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget)
|
HWP_STRING CConverter2OOXML::AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget, TConversionState* pState)
|
||||||
{
|
{
|
||||||
if (wsType.empty() || wsTarget.empty())
|
if (wsType.empty() || wsTarget.empty())
|
||||||
return HWP_STRING();
|
return HWP_STRING();
|
||||||
|
|
||||||
VECTOR<TRelationship>::const_iterator itFound = std::find_if(m_arRelationships.cbegin(), m_arRelationships.cend(), [wsTarget](const TRelationship& oRelationship){ return wsTarget == oRelationship.m_wsTarget; });
|
VECTOR<TRelationship> *pRelationships = nullptr;
|
||||||
|
|
||||||
if (m_arRelationships.cend() != itFound)
|
if (nullptr != pState && nullptr != pState->m_pRelationships)
|
||||||
|
pRelationships = pState->m_pRelationships;
|
||||||
|
else
|
||||||
|
pRelationships = &m_arRelationships;
|
||||||
|
|
||||||
|
VECTOR<TRelationship>::const_iterator itFound = std::find_if(pRelationships->cbegin(), pRelationships->cend(), [wsTarget](const TRelationship& oRelationship){ return wsTarget == oRelationship.m_wsTarget; });
|
||||||
|
|
||||||
|
if (pRelationships->cend() != itFound)
|
||||||
return itFound->m_wsID;
|
return itFound->m_wsID;
|
||||||
|
|
||||||
if (L"hyperlink" == wsType)
|
if (L"hyperlink" == wsType)
|
||||||
@ -2126,12 +2134,12 @@ HWP_STRING CConverter2OOXML::AddRelationship(const HWP_STRING& wsType, const HWP
|
|||||||
NSStringUtils::CStringBuilder oBuilder;
|
NSStringUtils::CStringBuilder oBuilder;
|
||||||
oBuilder.WriteEncodeXmlString(wsTarget);
|
oBuilder.WriteEncodeXmlString(wsTarget);
|
||||||
|
|
||||||
m_arRelationships.push_back({L"rId" + std::to_wstring(m_arRelationships.size() + 1), wsType, oBuilder.GetData()});
|
pRelationships->push_back({L"rId" + std::to_wstring(pRelationships->size() + 1), wsType, oBuilder.GetData()});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_arRelationships.push_back({L"rId" + std::to_wstring(m_arRelationships.size() + 1), wsType, wsTarget});
|
pRelationships->push_back({L"rId" + std::to_wstring(pRelationships->size() + 1), wsType, wsTarget});
|
||||||
|
|
||||||
return m_arRelationships.back().m_wsID;
|
return pRelationships->back().m_wsID;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConverter2OOXML::AddContentType(const HWP_STRING& wsName, const HWP_STRING& wsType)
|
void CConverter2OOXML::AddContentType(const HWP_STRING& wsName, const HWP_STRING& wsType)
|
||||||
|
|||||||
@ -22,15 +22,9 @@
|
|||||||
|
|
||||||
#include "../Common/WriterContext.h"
|
#include "../Common/WriterContext.h"
|
||||||
|
|
||||||
|
|
||||||
namespace HWP
|
namespace HWP
|
||||||
{
|
{
|
||||||
struct TRelationship
|
|
||||||
{
|
|
||||||
HWP_STRING m_wsID;
|
|
||||||
HWP_STRING m_wsType;
|
|
||||||
HWP_STRING m_wsTarget;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TContentType
|
struct TContentType
|
||||||
{
|
{
|
||||||
@ -96,7 +90,7 @@ class CConverter2OOXML
|
|||||||
void WritePicture(const CCtrlShapePic* pCtrlPic, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
void WritePicture(const CCtrlShapePic* pCtrlPic, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||||
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
void WriteVideo(const CCtrlShapeVideo* pCtrlVideo, short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||||
bool SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName);
|
bool SaveSVGFile(const HWP_STRING& sSVG, HWP_STRING& sFileName);
|
||||||
HWP_STRING SavePicture(const HWP_STRING& sBinItemId);
|
HWP_STRING SavePicture(const HWP_STRING& sBinItemId, TConversionState& oState);
|
||||||
|
|
||||||
void WriteParaShapeProperties(short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
void WriteParaShapeProperties(short shParaShapeID, short shParaStyleID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||||
void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& sExternStyles = CRunnerStyle());
|
void WriteRunnerStyle(short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState, const CRunnerStyle& sExternStyles = CRunnerStyle());
|
||||||
@ -132,7 +126,7 @@ class CConverter2OOXML
|
|||||||
|
|
||||||
void WriteEmptyParagraph(short shParaShapeID, short shParaStyleID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
void WriteEmptyParagraph(short shParaShapeID, short shParaStyleID, short shCharShapeID, NSStringUtils::CStringBuilder& oBuilder, TConversionState& oState);
|
||||||
|
|
||||||
HWP_STRING AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget);
|
HWP_STRING AddRelationship(const HWP_STRING& wsType, const HWP_STRING& wsTarget, TConversionState* pState = nullptr);
|
||||||
void AddContentType(const HWP_STRING& wsName, const HWP_STRING& wsType);
|
void AddContentType(const HWP_STRING& wsName, const HWP_STRING& wsType);
|
||||||
void AddDefaultContentType(const HWP_STRING& wsName);
|
void AddDefaultContentType(const HWP_STRING& wsName);
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -54,6 +54,9 @@ std::wstring CFootnoteConverter::CreateHeadOrFoot(const CCtrlHeadFoot* pCtrlHead
|
|||||||
|
|
||||||
TConversionState oState;
|
TConversionState oState;
|
||||||
|
|
||||||
|
VECTOR<TRelationship> arRelationships;
|
||||||
|
oState.m_pRelationships = &arRelationships;
|
||||||
|
|
||||||
for (const CHWPPargraph* pParagraphs : pCtrlHeadFoot->GetParagraphs())
|
for (const CHWPPargraph* pParagraphs : pCtrlHeadFoot->GetParagraphs())
|
||||||
oConverter.WriteParagraph(pParagraphs, oNewDocumentBuilder, oState);
|
oConverter.WriteParagraph(pParagraphs, oNewDocumentBuilder, oState);
|
||||||
|
|
||||||
@ -106,6 +109,27 @@ std::wstring CFootnoteConverter::CreateHeadOrFoot(const CCtrlHeadFoot* pCtrlHead
|
|||||||
|
|
||||||
oFile.CloseFile();
|
oFile.CloseFile();
|
||||||
|
|
||||||
|
// TODO:: пока это копия из Converter2OOXML
|
||||||
|
NSFile::CFileBinary oRelsWriter;
|
||||||
|
if (oRelsWriter.CreateFileW(oConverter.GetTempDirectory() + L"/word/_rels/" + wsFileName + L".rels"))
|
||||||
|
{
|
||||||
|
oRelsWriter.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">");
|
||||||
|
|
||||||
|
for (const TRelationship& oRelationship : arRelationships)
|
||||||
|
{
|
||||||
|
oRelsWriter.WriteStringUTF8(L"<Relationship Id=\"" + oRelationship.m_wsID + L"\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/" + oRelationship.m_wsType + L"\" Target=\"" + oRelationship.m_wsTarget + L'\"');
|
||||||
|
|
||||||
|
if (L"hyperlink" == oRelationship.m_wsType)
|
||||||
|
oRelsWriter.WriteStringUTF8(L" TargetMode=\"External\"/>");
|
||||||
|
else
|
||||||
|
oRelsWriter.WriteStringUTF8(L"/>");
|
||||||
|
}
|
||||||
|
|
||||||
|
oRelsWriter.WriteStringUTF8(L"</Relationships>");
|
||||||
|
|
||||||
|
oRelsWriter.CloseFile();
|
||||||
|
}
|
||||||
|
|
||||||
return wsFileName;
|
return wsFileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -52,6 +52,12 @@ namespace HWP
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct TRelationship
|
||||||
|
{
|
||||||
|
std::wstring m_wsID;
|
||||||
|
std::wstring m_wsType;
|
||||||
|
std::wstring m_wsTarget;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TYPES_H
|
#endif // TYPES_H
|
||||||
|
|||||||
Reference in New Issue
Block a user