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

(2.0.0.167): ASCOfficeDocxFile2

Синхронизация chart, создание папки theme/_rels

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55885 954022d7-b5bf-4e40-9824-e11837661b57
parent d1115d72
...@@ -13,9 +13,10 @@ namespace Writers ...@@ -13,9 +13,10 @@ namespace Writers
int index; int index;
}; };
CSimpleArray<ChartElem*> m_aCharts; CSimpleArray<ChartElem*> m_aCharts;
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter; ContentTypesWriter& m_oContentTypesWriter;
int nChartCount; int nChartCount;
public:
CString m_sDir;
public: public:
ChartWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter) ChartWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{ {
...@@ -54,7 +55,7 @@ namespace Writers ...@@ -54,7 +55,7 @@ namespace Writers
} }
} }
} }
void AddChart(CString& content, CString& sRelsName, int& index) void AddChart(CString& content, CString& sRelsName, CString& sFileName, int& index)
{ {
ChartElem* pChartElem = new ChartElem(); ChartElem* pChartElem = new ChartElem();
pChartElem->content = content; pChartElem->content = content;
...@@ -62,6 +63,7 @@ namespace Writers ...@@ -62,6 +63,7 @@ namespace Writers
nChartCount++; nChartCount++;
pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index); pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index);
sRelsName = _T("charts/") + pChartElem->filename; sRelsName = _T("charts/") + pChartElem->filename;
sFileName = pChartElem->filename;
index = pChartElem->index; index = pChartElem->index;
m_aCharts.Add(pChartElem); m_aCharts.Add(pChartElem);
......
...@@ -5548,28 +5548,45 @@ public: ...@@ -5548,28 +5548,45 @@ public:
{ {
if(false == m_oFileWriter.m_bSaveChartAsImg) if(false == m_oFileWriter.m_bSaveChartAsImg)
{ {
BinXlsxRW::BinaryChartReader oBinaryChartReader(m_oBufferedStream, m_oFileWriter.m_pArray, m_oFileWriter.m_pDrawingConverter); // rels
CString sRelsDir;
sRelsDir.Format(_T("%s\\word\\charts\\_rels"), m_oFileWriter.m_oChartWriter.m_sDir);
DWORD dwFileAttr = ::GetFileAttributes( sRelsDir );
if( dwFileAttr == INVALID_FILE_ATTRIBUTES )
OOX::CSystemUtility::CreateDirectories(sRelsDir);
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
CString sThemeDir;
int nIndex = m_oFileWriter.m_sThemePath.ReverseFind('\\');
if(-1 != nIndex)
sThemeDir = m_oFileWriter.m_sThemePath.Left(nIndex);
BinXlsxRW::SaveParams oSaveParams(sThemeDir);
BinXlsxRW::BinaryChartReader oBinaryChartReader(m_oBufferedStream, oSaveParams, m_oFileWriter.m_pArray, m_oFileWriter.m_pDrawingConverter);
OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace(); OOX::Spreadsheet::CChartSpace* pChartSpace = new OOX::Spreadsheet::CChartSpace();
oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace); oBinaryChartReader.ReadCT_ChartSpace(length, &pChartSpace->m_oChartSpace);
XmlUtils::CStringWriter sw; XmlUtils::CStringWriter sw;
pChartSpace->toXML(sw); pChartSpace->toXML(sw);
CString sChartContent = sw.GetData(); CString sChartContent = sw.GetData();
if(false == sChartContent.IsEmpty()) CString sFilename;
{ CString sRelsName;
CString sRelsName; int nChartIndex;
int nIndex; m_oFileWriter.m_oChartWriter.AddChart(sChartContent, sRelsName, sFilename, nChartIndex);
m_oFileWriter.m_oChartWriter.AddChart(sChartContent, sRelsName, nIndex); m_oFileWriter.m_oContentTypesWriter.AddOverrideRaw(oSaveParams.sAdditionalContentTypes);
long rId; CString sRelsPath;sRelsPath.Format(_T("%s\\%s.rels"), sRelsDir, sFilename);
BSTR bstrChartRelType = OOX::Spreadsheet::FileTypes::Charts.RelationType().AllocSysString(); BSTR bstrRelsPath = sRelsPath.AllocSysString();
BSTR bstrNewImgRel = sRelsName.AllocSysString(); m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(bstrRelsPath);
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, bstrNewImgRel, NULL, &rId); SysFreeString(bstrRelsPath);
SysFreeString(bstrChartRelType);
SysFreeString(bstrNewImgRel);
pDrawingProperty->sChartRels.Format(_T("rId%d"), rId); long rId;
} BSTR bstrChartRelType = OOX::Spreadsheet::FileTypes::Charts.RelationType().AllocSysString();
BSTR bstrNewImgRel = sRelsName.AllocSysString();
m_oFileWriter.m_pDrawingConverter->WriteRels(bstrChartRelType, bstrNewImgRel, NULL, &rId);
SysFreeString(bstrChartRelType);
SysFreeString(bstrNewImgRel);
pDrawingProperty->sChartRels.Format(_T("rId%d"), rId);
} }
else else
res = c_oSerConstants::ReadUnknown; res = c_oSerConstants::ReadUnknown;
......
...@@ -4704,7 +4704,7 @@ namespace BinDocxRW ...@@ -4704,7 +4704,7 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemWithLengthStart(); int nCurPos = m_oBcw.WriteItemWithLengthStart();
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(m_oBcw.m_oStream, m_pOfficeDrawingConverter); BinXlsxRW::BinaryChartWriter oBinaryChartWriter(m_oBcw.m_oStream, m_pOfficeDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(pChart->m_oChartSpace); oBinaryChartWriter.WriteCT_ChartSpace(*pChart);
m_oBcw.WriteItemWithLengthEnd(nCurPos); m_oBcw.WriteItemWithLengthEnd(nCurPos);
} }
} }
...@@ -4875,7 +4875,7 @@ namespace BinDocxRW ...@@ -4875,7 +4875,7 @@ namespace BinDocxRW
int nCurPos = m_oBcw.WriteItemWithLengthStart(); int nCurPos = m_oBcw.WriteItemWithLengthStart();
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(m_oBcw.m_oStream, m_pOfficeDrawingConverter); BinXlsxRW::BinaryChartWriter oBinaryChartWriter(m_oBcw.m_oStream, m_pOfficeDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(pChart->m_oChartSpace); oBinaryChartWriter.WriteCT_ChartSpace(*pChart);
m_oBcw.WriteItemWithLengthEnd(nCurPos); m_oBcw.WriteItemWithLengthEnd(nCurPos);
} }
} }
......
...@@ -440,6 +440,8 @@ private: ...@@ -440,6 +440,8 @@ private:
// theme // theme
CString strTheme = strWord + _T("\\theme"); CString strTheme = strWord + _T("\\theme");
CreateDirectory(strTheme, NULL); CreateDirectory(strTheme, NULL);
CString strThemeRels = strTheme + _T("\\_rels");
CreateDirectory(strThemeRels, NULL);
sThemePath = strTheme + _T("\\theme1.xml"); sThemePath = strTheme + _T("\\theme1.xml");
LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_THEME), _T("DOCXWR"), sThemePath); LoadResourceFile(hInst, MAKEINTRESOURCE(IDB_DEFAULT_DOC_THEME), _T("DOCXWR"), sThemePath);
......
...@@ -2,6 +2,6 @@ ...@@ -2,6 +2,6 @@
//2 //2
//0 //0
//0 //0
//166 //167
#define INTVER 2,0,0,166 #define INTVER 2,0,0,167
#define STRVER "2,0,0,166\0" #define STRVER "2,0,0,167\0"
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