Commit 6bff6036 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

(2.0.0.186): ASCOfficeDocxFile2

зависание при сохранением в docx групп автофигур с chart

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58580 954022d7-b5bf-4e40-9824-e11837661b57
parent 6e33842f
...@@ -49,6 +49,7 @@ namespace Writers ...@@ -49,6 +49,7 @@ namespace Writers
CFile oFile; CFile oFile;
oFile.CreateFile(sAbsPath); oFile.CreateFile(sAbsPath);
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n")));
oFile.WriteStringUTF8(elem->content); oFile.WriteStringUTF8(elem->content);
oFile.CloseFile(); oFile.CloseFile();
......
...@@ -4721,6 +4721,7 @@ namespace BinDocxRW ...@@ -4721,6 +4721,7 @@ namespace BinDocxRW
if (pFile.IsInit() && OOX::FileTypes::Chart == pFile->type()) if (pFile.IsInit() && OOX::FileTypes::Chart == pFile->type())
{ {
OOX::Spreadsheet::CChartSpace* pChartFile = static_cast<OOX::Spreadsheet::CChartSpace*>(pFile.operator ->()); OOX::Spreadsheet::CChartSpace* pChartFile = static_cast<OOX::Spreadsheet::CChartSpace*>(pFile.operator ->());
CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath();
CString sChartPath = pChartFile->GetReadPath().GetPath(); CString sChartPath = pChartFile->GetReadPath().GetPath();
m_pOfficeDrawingConverter->SetRelsPath(sChartPath); m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
...@@ -4728,7 +4729,7 @@ namespace BinDocxRW ...@@ -4728,7 +4729,7 @@ namespace BinDocxRW
WriteDrawing(NULL, pChartDrawing, pChartFile); WriteDrawing(NULL, pChartDrawing, pChartFile);
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
m_pOfficeDrawingConverter->SetRelsPath(m_oParamsDocumentWriter.m_sDocumentPath); m_pOfficeDrawingConverter->SetRelsPath(sOldRelsPath);
} }
} }
} }
......
...@@ -98,11 +98,14 @@ namespace BinXlsxRW{ ...@@ -98,11 +98,14 @@ namespace BinXlsxRW{
long nStartPos = oBufferedStream.GetPosition(); long nStartPos = oBufferedStream.GetPosition();
BinXlsxRW::BinaryCommonWriter oBcw(oBufferedStream); BinXlsxRW::BinaryCommonWriter oBcw(oBufferedStream);
CString sOldRelsPath = m_pExternalDrawingConverter->GetRelsPath();
m_pExternalDrawingConverter->SetRelsPath(sChartPath); m_pExternalDrawingConverter->SetRelsPath(sChartPath);
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(oBufferedStream, m_pExternalDrawingConverter); BinXlsxRW::BinaryChartWriter oBinaryChartWriter(oBufferedStream, m_pExternalDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(oChart); oBinaryChartWriter.WriteCT_ChartSpace(oChart);
m_pExternalDrawingConverter->SetRelsPath(sOldRelsPath);
long nEndPos = oBufferedStream.GetPosition(); long nEndPos = oBufferedStream.GetPosition();
lDataSize = nEndPos - nStartPos; lDataSize = nEndPos - nStartPos;
bRes = true; bRes = true;
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//2 //2
//0 //0
//0 //0
//185 //186
#define INTVER 2,0,0,185 #define INTVER 2,0,0,186
#define STRVER "2,0,0,185\0" #define STRVER "2,0,0,186\0"
...@@ -828,6 +828,10 @@ HRESULT CDrawingConverter::SetRelsPath(CString& bsRelsPath) ...@@ -828,6 +828,10 @@ HRESULT CDrawingConverter::SetRelsPath(CString& bsRelsPath)
m_strCurrentRelsPath = bsRelsPath; m_strCurrentRelsPath = bsRelsPath;
return SetCurrentRelsPath(); return SetCurrentRelsPath();
} }
CString CDrawingConverter::GetRelsPath()
{
return m_strCurrentRelsPath;
}
HRESULT CDrawingConverter::SetMediaDstPath(CString& bsMediaPath) HRESULT CDrawingConverter::SetMediaDstPath(CString& bsMediaPath)
{ {
m_pBinaryWriter->m_pCommon->m_pImageManager->m_strDstMedia = (CString)bsMediaPath; m_pBinaryWriter->m_pCommon->m_pImageManager->m_strDstMedia = (CString)bsMediaPath;
......
...@@ -171,6 +171,7 @@ namespace NSBinPptxRW ...@@ -171,6 +171,7 @@ namespace NSBinPptxRW
public: public:
STDMETHOD(SetMainDocument)(BinDocxRW::CDocxSerializer* pDocument); STDMETHOD(SetMainDocument)(BinDocxRW::CDocxSerializer* pDocument);
STDMETHOD(SetRelsPath)(CString& bsRelsPath); STDMETHOD(SetRelsPath)(CString& bsRelsPath);
CString GetRelsPath();
STDMETHOD(SetMediaDstPath)(CString& bsMediaPath); STDMETHOD(SetMediaDstPath)(CString& bsMediaPath);
STDMETHOD(AddShapeType)(CString& bsXml); STDMETHOD(AddShapeType)(CString& bsXml);
......
...@@ -126,43 +126,21 @@ namespace PPTX ...@@ -126,43 +126,21 @@ namespace PPTX
BinXlsxRW::CXlsxSerializer oXlsxSerializer; BinXlsxRW::CXlsxSerializer oXlsxSerializer;
NSBinPptxRW::CDrawingConverter oDrawingConverter; NSBinPptxRW::CDrawingConverter oDrawingConverter;
NSBinPptxRW::CBinaryFileWriter* pOldWriter = oDrawingConverter.m_pBinaryWriter;
VARIANT var; oDrawingConverter.m_pBinaryWriter = pWriter;
NSCommon::smart_ptr<PPTX::FileContainer> pOldRels = *oDrawingConverter.m_pBinaryWriter->m_pCommonRels;
var.vt = VT_UNKNOWN;
pWriter->m_pCommon->m_pFontPicker->QueryInterface(IID_IUnknown, (void**)&(var.punkVal));
oDrawingConverter.SetAdditionalParam(CString(L"FontPicker"), var);
RELEASEINTERFACE((var.punkVal));
var.vt = VT_ARRAY;
NSBinPptxRW::CBinaryFileWriter oWriter;
LPSAFEARRAY pSerializeIM = oWriter.Serialize(pWriter->m_pCommon->m_pImageManager);
var.parray = pSerializeIM;
oDrawingConverter.SetAdditionalParam(CString(L"SerializeImageManager"), var);
RELEASEARRAY(pSerializeIM);
oXlsxSerializer.setDrawingConverter(&oDrawingConverter); oXlsxSerializer.setDrawingConverter(&oDrawingConverter);
var.parray = NULL;
oDrawingConverter.GetAdditionalParam(CString(L"SerializeImageManager"), &var);
if (var.parray != NULL)
{
NSBinPptxRW::CBinaryFileReader oReader;
oReader.Deserialize(pWriter->m_pCommon->m_pImageManager, var.parray);
RELEASEARRAY((var.parray));
}
long lDataSize = 0; long lDataSize = 0;
oXlsxSerializer.loadChart(strDataPath, *pWriter, lDataSize); oXlsxSerializer.loadChart(strDataPath, *pWriter, lDataSize);
*oDrawingConverter.m_pBinaryWriter->m_pCommonRels = pOldRels;
oDrawingConverter.m_pBinaryWriter = pOldWriter;
} }
void ChartRec::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const void ChartRec::toXmlWriter(NSBinPptxRW::CXmlWriter* pWriter) const
{ {
if (!id_data.is_init() || NULL == m_pData) if (!id_data.is_init() || NULL == m_bData)
return; return;
CString strData = _T("<c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" \ CString strData = _T("<c:chart xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" \
...@@ -174,7 +152,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ...@@ -174,7 +152,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"
void ChartRec::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader) void ChartRec::fromPPTY(NSBinPptxRW::CBinaryFileReader* pReader)
{ {
ULONG lLen = pReader->GetLong(); ULONG lLen = pReader->GetLong();
m_pData = pReader->GetArray(lLen); m_bData = true;
m_lChartNumber = pReader->m_lChartNumber; m_lChartNumber = pReader->m_lChartNumber;
pReader->m_lChartNumber++; pReader->m_lChartNumber++;
...@@ -183,21 +161,10 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ...@@ -183,21 +161,10 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"
BinXlsxRW::CXlsxSerializer oXlsxSerializer; BinXlsxRW::CXlsxSerializer oXlsxSerializer;
NSBinPptxRW::CDrawingConverter oDrawingConverter; NSBinPptxRW::CDrawingConverter oDrawingConverter;
VARIANT varDir; NSBinPptxRW::CImageManager2* pOldImageManager = oDrawingConverter.m_pImageManager;
varDir.vt = VT_BSTR; oDrawingConverter.m_pImageManager = pReader->m_pRels->m_pManager;
varDir.bstrVal = pReader->m_strFolder.AllocSysString(); NSBinPptxRW::CBinaryFileReader* pOldReader = oDrawingConverter.m_pReader;
oDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir2"), varDir); oDrawingConverter.m_pReader = pReader;
SysFreeString(varDir.bstrVal);
VARIANT var;
var.vt = VT_ARRAY;
NSBinPptxRW::CBinaryFileWriter oWriter;
LPSAFEARRAY pSerializeIM = oWriter.Serialize(pReader->m_pRels->m_pManager);
var.parray = pSerializeIM;
oDrawingConverter.SetAdditionalParam(CString(L"SerializeImageManager2"), var);
RELEASEARRAY(pSerializeIM);
oXlsxSerializer.setDrawingConverter(&oDrawingConverter); oXlsxSerializer.setDrawingConverter(&oDrawingConverter);
...@@ -227,16 +194,8 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" ...@@ -227,16 +194,8 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"
pReader->m_strContentTypes += (*sContentTypes); pReader->m_strContentTypes += (*sContentTypes);
RELEASEOBJECT(sContentTypes); RELEASEOBJECT(sContentTypes);
var.parray = NULL; oDrawingConverter.m_pReader = pOldReader;
oDrawingConverter.GetAdditionalParam(CString(L"SerializeImageManager2"), &var); oDrawingConverter.m_pImageManager = pOldImageManager;
if (var.parray != NULL)
{
NSBinPptxRW::CBinaryFileReader oReader;
oReader.Deserialize(pReader->m_pRels->m_pManager, var.parray);
RELEASEARRAY((var.parray));
}
id_data = new PPTX::RId((size_t)lId); id_data = new PPTX::RId((size_t)lId);
} }
......
...@@ -77,12 +77,11 @@ namespace PPTX ...@@ -77,12 +77,11 @@ namespace PPTX
public: public:
ChartRec() ChartRec()
{ {
m_pData = NULL; m_bData = false;
m_lChartNumber = 0; m_lChartNumber = 0;
} }
virtual ~ChartRec() virtual ~ChartRec()
{ {
RELEASEARRAY(m_pData);
} }
explicit ChartRec(XmlUtils::CXmlNode& node) explicit ChartRec(XmlUtils::CXmlNode& node)
{ {
...@@ -109,7 +108,7 @@ namespace PPTX ...@@ -109,7 +108,7 @@ namespace PPTX
public: public:
virtual void fromXML(XmlUtils::CXmlNode& node) virtual void fromXML(XmlUtils::CXmlNode& node)
{ {
m_pData = NULL; m_bData = false;
node.ReadAttributeBase(L"r:id", id_data); node.ReadAttributeBase(L"r:id", id_data);
FillParentPointersForChilds(); FillParentPointersForChilds();
...@@ -131,7 +130,7 @@ namespace PPTX ...@@ -131,7 +130,7 @@ namespace PPTX
nullable<PPTX::RId> id_data; nullable<PPTX::RId> id_data;
LONG m_lChartNumber; LONG m_lChartNumber;
LPSAFEARRAY m_pData; bool m_bData;
protected: protected:
virtual void FillParentPointersForChilds() virtual void FillParentPointersForChilds()
{ {
......
...@@ -1655,12 +1655,15 @@ namespace BinXlsxRW { ...@@ -1655,12 +1655,15 @@ namespace BinXlsxRW {
if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Drawings == oFile->type()) if (oFile.IsInit() && OOX::Spreadsheet::FileTypes::Drawings == oFile->type())
{ {
OOX::Spreadsheet::CDrawing* pDrawing = (OOX::Spreadsheet::CDrawing*)oFile.operator->(); OOX::Spreadsheet::CDrawing* pDrawing = (OOX::Spreadsheet::CDrawing*)oFile.operator->();
CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath();
CString sDrawingRelsPath = pDrawing->GetReadPath().GetPath(); CString sDrawingRelsPath = pDrawing->GetReadPath().GetPath();
m_pOfficeDrawingConverter->SetRelsPath(sDrawingRelsPath); m_pOfficeDrawingConverter->SetRelsPath(sDrawingRelsPath);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawings); nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawings);
WriteDrawings(pDrawing, sDrawingRelsPath); WriteDrawings(pDrawing, sDrawingRelsPath);
m_oBcw.WriteItemWithLengthEnd(nCurPos); m_oBcw.WriteItemWithLengthEnd(nCurPos);
m_pOfficeDrawingConverter->SetRelsPath(sOldRelsPath);
} }
} }
//Autofilter //Autofilter
...@@ -2426,6 +2429,7 @@ namespace BinXlsxRW { ...@@ -2426,6 +2429,7 @@ namespace BinXlsxRW {
// //
if( INVALID_FILE_ATTRIBUTES != ::GetFileAttributes( sChartPath ) ) if( INVALID_FILE_ATTRIBUTES != ::GetFileAttributes( sChartPath ) )
{ {
CString sOldRelsPath = m_pOfficeDrawingConverter->GetRelsPath();
m_pOfficeDrawingConverter->SetRelsPath(sChartPath); m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
int nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::Chart2); int nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::Chart2);
...@@ -2434,7 +2438,7 @@ namespace BinXlsxRW { ...@@ -2434,7 +2438,7 @@ namespace BinXlsxRW {
oBinaryChartWriter.WriteCT_ChartSpace(oChart); oBinaryChartWriter.WriteCT_ChartSpace(oChart);
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
m_pOfficeDrawingConverter->SetRelsPath(sDrawingRelsPath); m_pOfficeDrawingConverter->SetRelsPath(sOldRelsPath);
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment