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

NSBinPptxRW::CDrawingConverter изменен интерфейс BSTR->CString

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@58427 954022d7-b5bf-4e40-9824-e11837661b57
parent 3aaccc52
This diff is collapsed.
......@@ -2389,9 +2389,7 @@ namespace BinDocxRW
if(NULL != m_pTheme)
{
int nStart = m_oBcw.WriteItemStart(c_oSerOtherTableTypes::DocxTheme);
BSTR bstrThemePath = m_pTheme->m_oReadPath.GetPath().AllocSysString();
m_oParamsWriter.m_pOfficeDrawingConverter->GetThemeBinary(bstrThemePath);
SysFreeString(bstrThemePath);
m_oParamsWriter.m_pOfficeDrawingConverter->GetThemeBinary(m_pTheme->m_oReadPath.GetPath());
m_oBcw.WriteItemEnd(nStart);
}
};
......@@ -2455,15 +2453,11 @@ namespace BinDocxRW
}
void prepareOfficeDrawingConverter(NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter, CString& sDocumentPath, std::vector<CString>& aShapeTypes)
{
BSTR bstrDocumentPath = sDocumentPath.AllocSysString();
pOfficeDrawingConverter->SetRelsPath(bstrDocumentPath);
SysFreeString(bstrDocumentPath);
pOfficeDrawingConverter->SetRelsPath(sDocumentPath);
for(int i = 0, length = aShapeTypes.size(); i < length; ++i)
{
CString& sShapeType = aShapeTypes[i];
BSTR bstrShapeType = sShapeType.AllocSysString();
pOfficeDrawingConverter->AddShapeType(bstrShapeType);
SysFreeString(bstrShapeType);
pOfficeDrawingConverter->AddShapeType(sShapeType);
}
}
void Write(std::vector<OOX::WritingElement*>& aElems)
......@@ -4703,17 +4697,13 @@ namespace BinDocxRW
{
OOX::Spreadsheet::CChartSpace* pChartFile = static_cast<OOX::Spreadsheet::CChartSpace*>(pFile.operator ->());
CString sChartPath = pChartFile->GetReadPath().GetPath();
BSTR bstrChartPath = sChartPath.AllocSysString();
m_pOfficeDrawingConverter->SetRelsPath(bstrChartPath);
SysFreeString(bstrChartPath);
m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
int nCurPos = m_oBcw.WriteItemStart(c_oSerRunType::pptxDrawing);
WriteDrawing(NULL, pChartDrawing, pChartFile);
m_oBcw.WriteItemEnd(nCurPos);
BSTR bstrDocumentRels = m_oParamsDocumentWriter.m_sDocumentPath.AllocSysString();
m_pOfficeDrawingConverter->SetRelsPath(bstrDocumentRels);
SysFreeString(bstrDocumentRels);
m_pOfficeDrawingConverter->SetRelsPath(m_oParamsDocumentWriter.m_sDocumentPath);
}
}
}
......@@ -4732,18 +4722,16 @@ namespace BinDocxRW
//pptxdata
if(NULL != pXml)
{
BSTR bstrXml = pXml->AllocSysString();
BSTR bstrOutputXml = NULL;
CString* bstrOutputXml = NULL;
m_oBcw.m_oStream.WriteBYTE(c_oSerImageType2::PptxData);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Variable);
nCurPos = m_oBcw.WriteItemWithLengthStart();
HRESULT hRes = m_pOfficeDrawingConverter->AddObject(bstrXml, &bstrOutputXml);
HRESULT hRes = m_pOfficeDrawingConverter->AddObject(*pXml, &bstrOutputXml);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
if(S_OK == hRes && NULL != bstrOutputXml)
{
CString sOutputXml(bstrOutputXml);
CString sDrawingXml;
sDrawingXml.Format(_T("<root xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"><w:drawing>%s</w:drawing></root>"), sOutputXml);
sDrawingXml.Format(_T("<root xmlns:wpc=\"http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp14=\"http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" xmlns:wpg=\"http://schemas.microsoft.com/office/word/2010/wordprocessingGroup\" xmlns:wpi=\"http://schemas.microsoft.com/office/word/2010/wordprocessingInk\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\" xmlns:wps=\"http://schemas.microsoft.com/office/word/2010/wordprocessingShape\"><w:drawing>%s</w:drawing></root>"), *bstrOutputXml);
XmlUtils::CXmlLiteReader oReader;
oReader.FromString(sDrawingXml);
oReader.ReadNextNode();//root
......@@ -4752,8 +4740,7 @@ namespace BinDocxRW
pDrawing->fromXML2(oReader, true);
bDeleteDrawing = true;
}
SysFreeString(bstrOutputXml);
SysFreeString(bstrXml);
RELEASEOBJECT(bstrOutputXml);
}
//chart
if(NULL != pChart)
......
......@@ -58,17 +58,13 @@ bool BinDocxRW::CDocxSerializer::saveToFile(CString& sSrcFileName, CString& sDst
//pEmbeddedFontsManager
}
BSTR bstrFontDir = m_sFontDir.AllocSysString();
oDrawingConverter.SetFontDir(bstrFontDir);
SysFreeString(bstrFontDir);
oDrawingConverter.SetFontDir(m_sFontDir);
VARIANT vt;
vt.vt = VT_UNKNOWN;
vt.punkVal = pFontPicker;
oDrawingConverter.SetAdditionalParam(_T("FontPicker"), vt);
oDrawingConverter.SetAdditionalParam(CString(_T("FontPicker")), vt);
oDrawingConverter.SetMainDocument(this);
BSTR bstrMediaDir = mediaDir.AllocSysString();
oDrawingConverter.SetMediaDstPath(bstrMediaDir);
SysFreeString(bstrMediaDir);
oDrawingConverter.SetMediaDstPath(mediaDir);
ParamsWriter oParamsWriter(oBufferedStream, fp, &oDrawingConverter, pEmbeddedFontsManager);
m_oBinaryFileWriter = new BinaryFileWriter(oParamsWriter);
m_oBinaryFileWriter->intoBindoc(sDstPath);
......@@ -172,9 +168,7 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
}
}
oDrawingConverter.SetMainDocument(this);
BSTR bstrMediaPath = sMediaPath.AllocSysString();
oDrawingConverter.SetMediaDstPath(bstrMediaPath);
SysFreeString(bstrMediaPath);
oDrawingConverter.SetMediaDstPath(sMediaPath);
m_pCurFileWriter = new Writers::FileWriter(sDstPath, m_sFontDir, nVersion, m_bSaveChartAsImg, &oDrawingConverter, sThemePath);
//
......@@ -188,14 +182,14 @@ bool BinDocxRW::CDocxSerializer::loadFromFile(CString& sSrcFileName, CString& sD
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = sFileInDir.AllocSysString();
oDrawingConverter.SetAdditionalParam(L"SourceFileDir", var);
oDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir"), var);
RELEASESYSSTRING(var.bstrVal);
BinaryFileReader oBinaryFileReader(sFileInDir, oBufferedStream, *m_pCurFileWriter);
oBinaryFileReader.ReadFile();
VARIANT vt;
oDrawingConverter.GetAdditionalParam(_T("ContentTypes"), &vt);
oDrawingConverter.GetAdditionalParam(CString(_T("ContentTypes")), &vt);
if(VT_BSTR == vt.vt)
m_pCurFileWriter->m_oContentTypesWriter.AddOverrideRaw(CString(vt.bstrVal));
......
......@@ -19,9 +19,7 @@ namespace BinXlsxRW{
bool CXlsxSerializer::loadFromFile(CString& sSrcFileName, CString& sDstPath, CString& sXMLOptions, CString& sMediaDir)
{
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter;
BSTR bstrMediaDir = sMediaDir.AllocSysString();
oOfficeDrawingConverter.SetMediaDstPath(bstrMediaDir);
SysFreeString(bstrMediaDir);
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
//
TCHAR tFolder[256];
......@@ -34,7 +32,7 @@ namespace BinXlsxRW{
VARIANT var;
var.vt = VT_BSTR;
var.bstrVal = sFileInDir.AllocSysString();
oOfficeDrawingConverter.SetAdditionalParam(L"SourceFileDir2", var);
oOfficeDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir2"), var);
RELEASESYSSTRING(var.bstrVal);
BinXlsxRW::BinaryFileReader oBinaryFileReader;
......@@ -80,13 +78,11 @@ namespace BinXlsxRW{
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter;
BSTR bstrFontDir = m_sFontDir.AllocSysString();
oOfficeDrawingConverter.SetFontDir(bstrFontDir);
SysFreeString(bstrFontDir);
oOfficeDrawingConverter.SetFontDir(m_sFontDir);
VARIANT vt;
vt.vt = VT_UNKNOWN;
vt.punkVal = pFontPicker;
oOfficeDrawingConverter.SetAdditionalParam(_T("FontPicker"), vt);
oOfficeDrawingConverter.SetAdditionalParam(CString(_T("FontPicker")), vt);
BinXlsxRW::BinaryFileWriter oBinaryFileWriter(fp);
oBinaryFileWriter.Open(sSrcPath, sDstFileName, pEmbeddedFontsManager, &oOfficeDrawingConverter, sXMLOptions);
......@@ -103,9 +99,7 @@ namespace BinXlsxRW{
long nStartPos = oBufferedStream.GetPosition();
BinXlsxRW::BinaryCommonWriter oBcw(oBufferedStream);
BSTR bstrChartPath = sChartPath.AllocSysString();
m_pExternalDrawingConverter->SetRelsPath(bstrChartPath);
SysFreeString(bstrChartPath);
m_pExternalDrawingConverter->SetRelsPath(sChartPath);
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(oBufferedStream, m_pExternalDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(oChart);
......@@ -161,9 +155,7 @@ namespace BinXlsxRW{
CString sRelsPath;
sRelsPath.Format(_T("%s\\%s.rels"), sRelsDir, sFilename + sExt);
BSTR bstrRelsPath = sRelsPath.AllocSysString();
m_pExternalDrawingConverter->SaveDstContentRels(bstrRelsPath);
SysFreeString(bstrRelsPath);
m_pExternalDrawingConverter->SaveDstContentRels(sRelsPath);
CString sContentType(sContentTypePath);
sContentType.Append(sFilename);
......
......@@ -170,37 +170,37 @@ namespace NSBinPptxRW
~CDrawingConverter();
public:
STDMETHOD(SetMainDocument)(BinDocxRW::CDocxSerializer* pDocument);
STDMETHOD(SetRelsPath)(BSTR bsRelsPath);
STDMETHOD(SetMediaDstPath)(BSTR bsMediaPath);
STDMETHOD(SetRelsPath)(CString& bsRelsPath);
STDMETHOD(SetMediaDstPath)(CString& bsMediaPath);
STDMETHOD(AddShapeType)(BSTR bsXml);
STDMETHOD(AddObject)(BSTR bsXml, BSTR* pMainProps);
STDMETHOD(GetThemeBinary)(BSTR bsThemeFilePath);
STDMETHOD(AddShapeType)(CString& bsXml);
STDMETHOD(AddObject)(CString& bsXml, CString** pMainProps);
STDMETHOD(GetThemeBinary)(CString& bsThemeFilePath);
STDMETHOD(SaveThemeXml)(LONG lStart, LONG lLength, BSTR bsThemePath);
STDMETHOD(SaveObject)(LONG lStart, LONG lLength, BSTR bsMainProps, BSTR* bsXml);
STDMETHOD(SaveObjectEx)(LONG lStart, LONG lLength, BSTR bsMainProps, LONG lDocType, BSTR* bsXml);
STDMETHOD(SaveThemeXml)(LONG lStart, LONG lLength, CString& bsThemePath);
STDMETHOD(SaveObject)(LONG lStart, LONG lLength, CString& bsMainProps, CString** bsXml);
STDMETHOD(SaveObjectEx)(LONG lStart, LONG lLength, CString& bsMainProps, LONG lDocType, CString** bsXml);
STDMETHOD(GetRecordBinary)(LONG lRecordType, BSTR bsXml);
STDMETHOD(GetRecordXml)(LONG lStart, LONG lLength, LONG lRecType, LONG lDocType, BSTR* bsXml);
STDMETHOD(GetRecordBinary)(LONG lRecordType, CString& bsXml);
STDMETHOD(GetRecordXml)(LONG lStart, LONG lLength, LONG lRecType, LONG lDocType, CString** bsXml);
STDMETHOD(SetDstContentRels)();
STDMETHOD(SaveDstContentRels)(BSTR bsRelsPath);
STDMETHOD(WriteRels)(BSTR bsType, BSTR bsTarget, BSTR bsTargetMode, LONG* lId);
STDMETHOD(LoadClrMap)(BSTR bsXml);
STDMETHOD(SaveDstContentRels)(CString& bsRelsPath);
STDMETHOD(WriteRels)(CString& bsType, CString& bsTarget, CString& bsTargetMode, LONG* lId);
STDMETHOD(LoadClrMap)(CString& bsXml);
STDMETHOD(GetTxBodyBinary)(BSTR bsXml);
STDMETHOD(GetTxBodyXml)(LONG lStart, LONG lLength, BSTR *pbstrXml);
STDMETHOD(SetFontDir)(BSTR bsFontDir);
STDMETHOD(GetTxBodyBinary)(CString& bsXml);
STDMETHOD(GetTxBodyXml)(LONG lStart, LONG lLength, CString** pbstrXml);
STDMETHOD(SetFontDir)(CString& bsFontDir);
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue);
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue);
STDMETHOD(SetAdditionalParam)(CString& ParamName, VARIANT ParamValue);
STDMETHOD(GetAdditionalParam)(CString& ParamName, VARIANT* ParamValue);
protected:
bool ParceObject(CString& strXml, BSTR* pMainProps);
void SendMainProps(CString& strMainProps, BSTR*& pMainProps);
bool ParceObject(CString& strXml, CString** pMainProps);
void SendMainProps(CString& strMainProps, CString**& pMainProps);
PPTX::Logic::SpTreeElem doc_LoadShape(XmlUtils::CXmlNode& oNode, BSTR*& pMainProps, bool bIsTop = true);
PPTX::Logic::SpTreeElem doc_LoadGroup(XmlUtils::CXmlNode& oNode, BSTR*& pMainProps, bool bIsTop = true);
PPTX::Logic::SpTreeElem doc_LoadShape(XmlUtils::CXmlNode& oNode, CString**& pMainProps, bool bIsTop = true);
PPTX::Logic::SpTreeElem doc_LoadGroup(XmlUtils::CXmlNode& oNode, CString**& pMainProps, bool bIsTop = true);
CString GetVMLShapeXml(CPPTShape* pPPTShape);
CString GetVMLShapeXml(PPTX::Logic::SpTreeElem& oElem);
......@@ -211,9 +211,9 @@ namespace NSBinPptxRW
void LoadCoordSize(XmlUtils::CXmlNode& oNode, ::CShape* pShape);
CString GetDrawingMainProps(XmlUtils::CXmlNode& oNode, PPTX::CCSS& oCssStyles, CSpTreeElemProps& oProps);
void ConvertMainPropsToVML(BSTR bsMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
void ConvertShapeVML(PPTX::Logic::SpTreeElem& oShape, BSTR bsMainProps, NSBinPptxRW::CXmlWriter& oWriter);
void ConvertGroupVML(PPTX::Logic::SpTreeElem& oGroup, BSTR bsMainProps, NSBinPptxRW::CXmlWriter& oWriter);
void ConvertMainPropsToVML(CString& bsMainProps, NSBinPptxRW::CXmlWriter& oWriter, PPTX::Logic::SpTreeElem& oElem);
void ConvertShapeVML(PPTX::Logic::SpTreeElem& oShape, CString& bsMainProps, NSBinPptxRW::CXmlWriter& oWriter);
void ConvertGroupVML(PPTX::Logic::SpTreeElem& oGroup, CString& bsMainProps, NSBinPptxRW::CXmlWriter& oWriter);
void Clear();
HRESULT SetCurrentRelsPath();
......
......@@ -139,16 +139,16 @@ public:
}
STDMETHOD(SetRelsPath)(BSTR bsRelsPath)
{
return m_oDrawingConverter.SetRelsPath(bsRelsPath);
return m_oDrawingConverter.SetRelsPath(CString(bsRelsPath));
}
STDMETHOD(SetMediaDstPath)(BSTR bsMediaPath)
{
return m_oDrawingConverter.SetMediaDstPath(bsMediaPath);
return m_oDrawingConverter.SetMediaDstPath(CString(bsMediaPath));
}
STDMETHOD(AddShapeType)(BSTR bsXml)
{
return m_oDrawingConverter.AddShapeType(bsXml);
return m_oDrawingConverter.AddShapeType(CString(bsXml));
}
STDMETHOD(AddObject)(BSTR bsXml, BSTR* pMainProps, SAFEARRAY** ppBinary)
{
......@@ -192,16 +192,16 @@ public:
}
STDMETHOD(SaveDstContentRels)(BSTR bsRelsPath)
{
return m_oDrawingConverter.SaveDstContentRels(bsRelsPath);
return m_oDrawingConverter.SaveDstContentRels(CString(bsRelsPath));
}
STDMETHOD(WriteRels)(BSTR bsType, BSTR bsTarget, BSTR bsTargetMode, LONG* lId)
{
return m_oDrawingConverter.WriteRels(bsType, bsTarget, bsTargetMode, lId);
return m_oDrawingConverter.WriteRels(CString(bsType), CString(bsTarget), CString(bsTargetMode), lId);
}
STDMETHOD(LoadClrMap)(BSTR bsXml)
{
return m_oDrawingConverter.LoadClrMap(bsXml);
return m_oDrawingConverter.LoadClrMap(CString(bsXml));
}
STDMETHOD(GetTxBodyBinary)(BSTR bsXml, SAFEARRAY** ppBinary)
......@@ -214,15 +214,15 @@ public:
}
STDMETHOD(SetFontDir)(BSTR bsFontDir)
{
return m_oDrawingConverter.SetFontDir(bsFontDir);
return m_oDrawingConverter.SetFontDir(CString(bsFontDir));
}
STDMETHOD(SetAdditionalParam)(BSTR ParamName, VARIANT ParamValue)
{
return m_oDrawingConverter.SetAdditionalParam(ParamName, ParamValue);
return m_oDrawingConverter.SetAdditionalParam(CString(ParamName), ParamValue);
}
STDMETHOD(GetAdditionalParam)(BSTR ParamName, VARIANT* ParamValue)
{
return m_oDrawingConverter.GetAdditionalParam(ParamName, ParamValue);
return m_oDrawingConverter.GetAdditionalParam(CString(ParamName), ParamValue);
}
};
......@@ -1009,14 +1009,14 @@ namespace NSBinPptxRW
return m_lNextRelsID - 1;
}
int CRelsGenerator::WriteRels(const BSTR& bsType, const BSTR& bsTarget, const BSTR& bsTargetMode)
int CRelsGenerator::WriteRels(const CString& bsType, const CString& bsTarget, const CString& bsTargetMode)
{
CString strRid = _T("");
strRid.Format(_T("rId%d"), m_lNextRelsID++);
CString strType = _T("Type=\"") + (CString)bsType + _T("\" ");
CString strTarget = _T("Target=\"") + (CString)bsTarget + _T("\" ");
CString strTargetMode = (NULL == bsTargetMode) ? _T("") : (_T("TargetMode=\"") + (CString)bsTargetMode + _T("\""));
CString strType = _T("Type=\"") + bsType + _T("\" ");
CString strTarget = _T("Target=\"") + bsTarget + _T("\" ");
CString strTargetMode = bsTargetMode.IsEmpty() ? _T("") : (_T("TargetMode=\"") + (CString)bsTargetMode + _T("\""));
CString strRels = _T("<Relationship Id=\"") + strRid + _T("\" ") + strType + strTarget + strTargetMode + _T("/>");
m_pWriter->WriteString(strRels);
......
......@@ -387,7 +387,7 @@ namespace NSBinPptxRW
int WriteImage(const CString& strImagePath, CString strBase64Image);
int WriteChart(int nChartNumber, LONG lDocType);
int WriteRels(const BSTR& bsType, const BSTR& bsTarget, const BSTR& bsTargetMode);
int WriteRels(const CString& bsType, const CString& bsTarget, const CString& bsTargetMode);
int WriteHyperlink(const CString& strLink, const bool& bIsActionInit);
};
......
......@@ -131,7 +131,7 @@ namespace PPTX
var.vt = VT_UNKNOWN;
pWriter->m_pCommon->m_pFontPicker->QueryInterface(IID_IUnknown, (void**)&(var.punkVal));
oDrawingConverter.SetAdditionalParam(L"FontPicker", var);
oDrawingConverter.SetAdditionalParam(CString(L"FontPicker"), var);
RELEASEINTERFACE((var.punkVal));
var.vt = VT_ARRAY;
......@@ -139,14 +139,14 @@ namespace PPTX
NSBinPptxRW::CBinaryFileWriter oWriter;
LPSAFEARRAY pSerializeIM = oWriter.Serialize(pWriter->m_pCommon->m_pImageManager);
var.parray = pSerializeIM;
oDrawingConverter.SetAdditionalParam(L"SerializeImageManager", var);
oDrawingConverter.SetAdditionalParam(CString(L"SerializeImageManager"), var);
RELEASEARRAY(pSerializeIM);
oXlsxSerializer.setDrawingConverter(&oDrawingConverter);
var.parray = NULL;
oDrawingConverter.GetAdditionalParam(L"SerializeImageManager", &var);
oDrawingConverter.GetAdditionalParam(CString(L"SerializeImageManager"), &var);
if (var.parray != NULL)
{
......@@ -186,7 +186,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"
VARIANT varDir;
varDir.vt = VT_BSTR;
varDir.bstrVal = pReader->m_strFolder.AllocSysString();
oDrawingConverter.SetAdditionalParam(L"SourceFileDir2", varDir);
oDrawingConverter.SetAdditionalParam(CString(L"SourceFileDir2"), varDir);
SysFreeString(varDir.bstrVal);
VARIANT var;
......@@ -195,7 +195,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"
NSBinPptxRW::CBinaryFileWriter oWriter;
LPSAFEARRAY pSerializeIM = oWriter.Serialize(pReader->m_pRels->m_pManager);
var.parray = pSerializeIM;
oDrawingConverter.SetAdditionalParam(L"SerializeImageManager2", var);
oDrawingConverter.SetAdditionalParam(CString(L"SerializeImageManager2"), var);
RELEASEARRAY(pSerializeIM);
......@@ -228,7 +228,7 @@ xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"
RELEASEOBJECT(sContentTypes);
var.parray = NULL;
oDrawingConverter.GetAdditionalParam(L"SerializeImageManager2", &var);
oDrawingConverter.GetAdditionalParam(CString(L"SerializeImageManager2"), &var);
if (var.parray != NULL)
{
......
......@@ -1671,9 +1671,7 @@ namespace BinXlsxRW {
{
OOX::Spreadsheet::CDrawing* pDrawing = (OOX::Spreadsheet::CDrawing*)oFile.operator->();
CString sDrawingRelsPath = pDrawing->GetReadPath().GetPath();
BSTR bstrDrawing = sDrawingRelsPath.AllocSysString();
m_pOfficeDrawingConverter->SetRelsPath(bstrDrawing);
SysFreeString(bstrDrawing);
m_pOfficeDrawingConverter->SetRelsPath(sDrawingRelsPath);
nCurPos = m_oBcw.WriteItemStart(c_oSerWorksheetsTypes::Drawings);
WriteDrawings(pDrawing, sDrawingRelsPath);
......@@ -2336,10 +2334,10 @@ namespace BinXlsxRW {
WriteExt(pCellAnchor.m_oExt.get());
m_oBcw.WriteItemEnd(nCurPos);
}
BSTR bstrXml = NULL;
CString bstrXml;
//Pic, Sp, GraphicFrame
if(pCellAnchor.m_oXml.IsInit())
bstrXml = pCellAnchor.m_oXml->AllocSysString();
bstrXml = *pCellAnchor.m_oXml;
else if(pCellAnchor.m_oGraphicFrame.IsInit())
{
if(pCellAnchor.m_oGraphicFrame->m_oChartGraphic.IsInit() && pCellAnchor.m_oGraphicFrame->m_oChartGraphic->m_oGraphicData.IsInit() && pCellAnchor.m_oGraphicFrame->m_oChartGraphic->m_oGraphicData->m_oChart.IsInit())
......@@ -2349,17 +2347,16 @@ namespace BinXlsxRW {
m_oBcw.WriteItemEnd(nCurPos);
}
else if(pCellAnchor.m_oGraphicFrame->m_sXml.IsInit())
bstrXml = pCellAnchor.m_oGraphicFrame->m_sXml->AllocSysString();
bstrXml = *pCellAnchor.m_oGraphicFrame->m_sXml;
}
if(NULL != bstrXml)
if(!bstrXml.IsEmpty())
{
BSTR bstrOutputXml = NULL;
CString* bstrOutputXml = NULL;
m_oBcw.m_oStream.WriteBYTE(c_oSer_DrawingType::pptxDrawing);
int nCurPos = m_oBcw.WriteItemWithLengthStart();
HRESULT hRes = m_pOfficeDrawingConverter->AddObject(bstrXml, &bstrOutputXml);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
SysFreeString(bstrOutputXml);
SysFreeString(bstrXml);
RELEASEOBJECT(bstrOutputXml);
}
};
void WriteFromTo(const OOX::Spreadsheet::CFromTo& oFromTo)
......@@ -2444,9 +2441,7 @@ namespace BinXlsxRW {
//
if( INVALID_FILE_ATTRIBUTES != ::GetFileAttributes( sChartPath ) )
{
BSTR bstrChartPath = sChartPath.AllocSysString();
m_pOfficeDrawingConverter->SetRelsPath(bstrChartPath);
SysFreeString(bstrChartPath);
m_pOfficeDrawingConverter->SetRelsPath(sChartPath);
int nCurPos = m_oBcw.WriteItemStart(c_oSer_DrawingType::Chart2);
OOX::Spreadsheet::CChartSpace oChart(oNormalizedPath);
......@@ -2454,9 +2449,7 @@ namespace BinXlsxRW {
oBinaryChartWriter.WriteCT_ChartSpace(oChart);
m_oBcw.WriteItemEnd(nCurPos);
bstrChartPath = sDrawingRelsPath.AllocSysString();
m_pOfficeDrawingConverter->SetRelsPath(bstrChartPath);
SysFreeString(bstrChartPath);
m_pOfficeDrawingConverter->SetRelsPath(sDrawingRelsPath);
}
}
}
......@@ -3203,9 +3196,7 @@ namespace BinXlsxRW {
#ifdef DEFAULT_TABLE_STYLES
long nThemeStartPos = m_oBcw.m_oStream.GetPosition();
#endif
BSTR bstrThemePath = m_pTheme->m_oReadPath.GetPath().AllocSysString();
m_pOfficeDrawingConverter->GetThemeBinary(bstrThemePath);
SysFreeString(bstrThemePath);
m_pOfficeDrawingConverter->GetThemeBinary(m_pTheme->m_oReadPath.GetPath());
#ifdef DEFAULT_TABLE_STYLES
long nThemeLength = m_oBcw.m_oStream.GetPosition() - nThemeStartPos;
writeTheme(m_oBcw.m_oStream.GetBuffer(), nThemeStartPos, nThemeLength, CString(_T("c:\\defaultTheme.bin")));
......@@ -3261,9 +3252,7 @@ namespace BinXlsxRW {
CString mediaDir = path.GetDirectory() + gc_sMediaDirName;
CreateDirectoryW(mediaDir, NULL);
BSTR bstrMediaDir = mediaDir.AllocSysString();
pOfficeDrawingConverter->SetMediaDstPath(bstrMediaDir);
SysFreeString(bstrMediaDir);
pOfficeDrawingConverter->SetMediaDstPath(mediaDir);
//mime-type
CString mimePath = path.GetDirectory() + gc_sMimeName;
......
......@@ -812,13 +812,13 @@ namespace BinXlsxRW{
if(length > 0)
{
long nCurPos = m_oBufferedStream.GetPos();
BSTR bstrXml = NULL;
CString* bstrXml = NULL;
HRESULT hRes = m_pOfficeDrawingConverter->GetRecordXml(nCurPos, length, nRecordType, XMLWRITER_DOC_TYPE_CHART, &bstrXml);
if (S_OK == hRes && NULL != bstrXml)
{
*pNewElem = bstrXml;
SysFreeString(bstrXml);
*pNewElem = *bstrXml;
}
RELEASEOBJECT(bstrXml);
m_oBufferedStream.Seek(nCurPos + length);
}
return pNewElem;
......@@ -829,13 +829,13 @@ namespace BinXlsxRW{
if(length > 0)
{
long nCurPos = m_oBufferedStream.GetPos();
BSTR bstrXml = NULL;
CString* bstrXml = NULL;
HRESULT hRes = m_pOfficeDrawingConverter->GetTxBodyXml(nCurPos, length, &bstrXml);
if (S_OK == hRes && NULL != bstrXml)
{
*pNewElem = bstrXml;
SysFreeString(bstrXml);
*pNewElem = *bstrXml;
}
RELEASEOBJECT(bstrXml);
m_oBufferedStream.Seek(nCurPos + length);
}
return pNewElem;
......@@ -953,15 +953,11 @@ namespace BinXlsxRW{
CString sThemeOverridePath;sThemeOverridePath.Format(_T("%s\\%s"), m_oSaveParams.sThemePath, sThemeOverrideName);
long nCurPos = m_oBufferedStream.GetPos();
BSTR bstrTempTheme = sThemeOverridePath.AllocSysString();
m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, bstrTempTheme);
SysFreeString(bstrTempTheme);
m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, sThemeOverridePath);
m_oBufferedStream.Seek(nCurPos + length);
long rId;
BSTR bstrThemeOverrideRelsPath = sThemeOverrideRelsPath.AllocSysString();
m_pOfficeDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride"), bstrThemeOverrideRelsPath, NULL, &rId);
SysFreeString(bstrThemeOverrideRelsPath);
m_pOfficeDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride")), sThemeOverrideRelsPath, CString(), &rId);
CString sThemePathReverse = m_oSaveParams.sThemePath;sThemePathReverse.MakeReverse();
CString sContentTypesPath;
......@@ -5951,17 +5947,14 @@ namespace BinXlsxRW{
void BinaryChartWriter::GetRecordBinary(int nType, CString& sXml, int nRecordType)
{
int nCurPos = m_oBcw.WriteItemStart(nType);
BSTR bstrXml = sXml.AllocSysString();
HRESULT hRes = m_pOfficeDrawingConverter->GetRecordBinary(nRecordType, bstrXml);
SysFreeString(bstrXml);
HRESULT hRes = m_pOfficeDrawingConverter->GetRecordBinary(nRecordType, sXml);
m_oBcw.WriteItemEnd(nCurPos);
}
void BinaryChartWriter::GetTxBodyBinary(int nType, CString& sXml)
{
int nCurPos = m_oBcw.WriteItemStart(nType);
BSTR bstrXml = (_T("<c:rich xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">") + sXml + _T("</c:rich>")).AllocSysString();
CString bstrXml = _T("<c:rich xmlns:c=\"http://schemas.openxmlformats.org/drawingml/2006/chart\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">") + sXml + _T("</c:rich>");
HRESULT hRes = m_pOfficeDrawingConverter->GetTxBodyBinary(bstrXml);
SysFreeString(bstrXml);
m_oBcw.WriteItemEnd(nCurPos);
}
void BinaryChartWriter::WriteCT_extLst(CT_extLst& oVal)
......@@ -6070,9 +6063,7 @@ namespace BinXlsxRW{
OOX::CThemeOverride* pThemeOverride = static_cast<OOX::CThemeOverride*>(pFile.operator->());
m_oBcw.m_oStream.WriteBYTE(c_oserct_chartspaceTHEMEOVERRIDE);
int nCurPos = m_oBcw.WriteItemWithLengthStart();
BSTR bstrThemePath = pThemeOverride->m_oReadPath.GetPath().AllocSysString();
m_pOfficeDrawingConverter->GetThemeBinary(bstrThemePath);
SysFreeString(bstrThemePath);
m_pOfficeDrawingConverter->GetThemeBinary(pThemeOverride->m_oReadPath.GetPath());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
......
......@@ -1858,9 +1858,7 @@ namespace BinXlsxRW {
CString sFilename = m_pCurDrawing->m_sFilename;
CString sRelsPath;
sRelsPath.Format(_T("%s\\%s.rels"), sRelsDir, sFilename);
BSTR bstrRelsPath = sRelsPath.AllocSysString();
m_pOfficeDrawingConverter->SaveDstContentRels(bstrRelsPath);
SysFreeString(bstrRelsPath);
m_pOfficeDrawingConverter->SaveDstContentRels(sRelsPath);
}
else if(c_oSerWorksheetsTypes::SheetData == type)
{
......@@ -2389,26 +2387,26 @@ namespace BinXlsxRW {
VARIANT var;
var.vt = VT_I4;
var.intVal = m_pCurDrawing->GetGlobalNumberByType(OOX::Spreadsheet::FileTypes::Charts.OverrideType());
m_pOfficeDrawingConverter->SetAdditionalParam(_T("DocumentChartsCount"), var);
m_pOfficeDrawingConverter->SetAdditionalParam(CString(_T("DocumentChartsCount")), var);
}
long nCurPos = m_oBufferedStream.GetPos();
BSTR bstrXml = NULL;
HRESULT hRes = m_pOfficeDrawingConverter->SaveObjectEx(nCurPos, length, NULL, XMLWRITER_DOC_TYPE_XLSX, &bstrXml);
CString* bstrXml = NULL;
HRESULT hRes = m_pOfficeDrawingConverter->SaveObjectEx(nCurPos, length, CString(), XMLWRITER_DOC_TYPE_XLSX, &bstrXml);
m_oBufferedStream.Seek(nCurPos + length);
if(NULL != m_pCurDrawing)
{
VARIANT vt;
m_pOfficeDrawingConverter->GetAdditionalParam(_T("DocumentChartsCount"), &vt);
m_pOfficeDrawingConverter->GetAdditionalParam(CString(_T("DocumentChartsCount")), &vt);
if(VT_I4 == vt.vt)
m_pCurDrawing->SetGlobalNumberByType(OOX::Spreadsheet::FileTypes::Charts.OverrideType(), vt.intVal);
}
if(S_OK == hRes && NULL != bstrXml)
{
pCellAnchor->m_oXml.Init();
pCellAnchor->m_oXml->AppendFormat(_T("%s<xdr:clientData/>"), bstrXml);
SysFreeString(bstrXml);
pCellAnchor->m_oXml->AppendFormat(_T("%s<xdr:clientData/>"), *bstrXml);
}
RELEASEOBJECT(bstrXml);
}
else
res = c_oSerConstants::ReadUnknown;
......@@ -2436,16 +2434,12 @@ namespace BinXlsxRW {
m_pCurDrawing->Add(pChartFile);
CString sRelsPath;sRelsPath.Format(_T("%s\\%s.rels"), sRelsDir, pChartFile->m_sFilename);
BSTR bstrRelsPath = sRelsPath.AllocSysString();
m_pOfficeDrawingConverter->SaveDstContentRels(bstrRelsPath);
SysFreeString(bstrRelsPath);
m_pOfficeDrawingConverter->SaveDstContentRels(sRelsPath);
long rId;
CString sNewImgRel;
sNewImgRel.Format(_T("../charts/%s"), pChartFile->m_sFilename);
BSTR bstrNewImgRel = sNewImgRel.AllocSysString();
m_pOfficeDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"), bstrNewImgRel, NULL, &rId);
SysFreeString(bstrNewImgRel);
m_pOfficeDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart")), sNewImgRel, CString(), &rId);
CString sNewRid;
sNewRid.Format(_T("rId%d"), rId);
......@@ -2558,9 +2552,7 @@ namespace BinXlsxRW {
long rId;
CString sNewImgRel;
sNewImgRel.Format(_T("../media/%s"), sNewImageName);
BSTR bstrNewImgRel = sNewImgRel.AllocSysString();
m_pOfficeDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image"), bstrNewImgRel, NULL, &rId);
SysFreeString(bstrNewImgRel);
m_pOfficeDrawingConverter->WriteRels(CString(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/image")), sNewImgRel, CString(), &rId);
sRId.Format(_T("rId%d"), rId);
pair->second->mapDrawings[m_pCurDrawing] = sRId;
......@@ -2849,9 +2841,7 @@ namespace BinXlsxRW {
{
CString sThemePath;sThemePath.Format(_T("%s\\%s"), m_oSaveParams.sThemePath, OOX::FileTypes::Theme.DefaultFileName());
long nCurPos = m_oBufferedStream.GetPos();
BSTR bstrTempTheme = sThemePath.AllocSysString();
m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, bstrTempTheme);
SysFreeString(bstrTempTheme);
m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, sThemePath);
m_oBufferedStream.Seek(nCurPos + length);
}
else
......@@ -3029,7 +3019,7 @@ namespace BinXlsxRW {
if(NULL != pOfficeDrawingConverter)
{
VARIANT vt;
pOfficeDrawingConverter->GetAdditionalParam(_T("ContentTypes"), &vt);
pOfficeDrawingConverter->GetAdditionalParam(CString(_T("ContentTypes")), &vt);
if(VT_BSTR == vt.vt)
sAdditionalContentTypes.Append(vt.bstrVal);
}
......
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