Commit 143f65ae authored by ElenaSubbotina's avatar ElenaSubbotina

BinaryFormat - refactoring drawing objects, convert embedded objects, ole objects

parent f89d75ae
...@@ -38,72 +38,63 @@ namespace Writers ...@@ -38,72 +38,63 @@ namespace Writers
{ {
class ChartWriter class ChartWriter
{ {
class ChartElem struct _chartElem
{ {
public:
std::wstring content; std::wstring content;
std::wstring filename; std::wstring filename;
int index; int index;
}; };
std::vector<ChartElem*> m_aCharts; std::vector<_chartElem> m_aCharts;
ContentTypesWriter& m_oContentTypesWriter;
int nChartCount; int nChartCount;
public: public:
std::wstring m_sDir; std::wstring m_sDir;
public:
ChartWriter(std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter) ChartWriter(std::wstring sDir) : m_sDir(sDir)
{ {
nChartCount = 0; nChartCount = 0;
} }
~ChartWriter() ~ChartWriter()
{ {
for(size_t i = 0, length = m_aCharts.size(); i < length; ++i)
{
delete m_aCharts[i];
}
} }
bool IsEmpty() bool IsEmpty()
{ {
return 0 == m_aCharts.size(); return 0 == m_aCharts.size();
} }
void Write() bool Write()
{
if(false == IsEmpty())
{ {
if(IsEmpty()) return false;
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts"); OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
NSDirectory::CreateDirectory(pathChartDir.GetPath());
for(size_t i = 0, length = m_aCharts.size(); i < length; ++i) for(size_t i = 0; i < m_aCharts.size(); ++i)
{ {
ChartElem* elem = m_aCharts[i]; _chartElem & elem = m_aCharts[i];
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename; OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem.filename;
NSFile::CFileBinary oFile; NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n"); oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem->content); oFile.WriteStringUTF8(elem.content);
oFile.CloseFile(); oFile.CloseFile();
//Content_Types
std::wstring sRelPath = L"/word/charts/" + elem->filename;
m_oContentTypesWriter.AddOverride(sRelPath, L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
}
} }
return true;
} }
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index) void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index)
{ {
ChartElem* pChartElem = new ChartElem(); _chartElem oChartElem;
pChartElem->content = content;
pChartElem->index = nChartCount + 1; oChartElem.content = content;
oChartElem.index = nChartCount + 1;
nChartCount++; nChartCount++;
pChartElem->filename = L"chart" + std::to_wstring(pChartElem->index) + L".xml";
sRelsName = L"charts/" + pChartElem->filename; oChartElem.filename = L"chart" + std::to_wstring(oChartElem.index) + L".xml";
sFileName = pChartElem->filename;
index = pChartElem->index; sRelsName = L"charts/" + oChartElem.filename;
sFileName = oChartElem.filename;
index = oChartElem.index;
m_aCharts.push_back(pChartElem); m_aCharts.push_back(oChartElem);
} }
int getChartCount() int getChartCount()
{ {
......
...@@ -46,13 +46,12 @@ namespace Writers ...@@ -46,13 +46,12 @@ namespace Writers
class CommentsWriter class CommentsWriter
{ {
std::wstring m_sDir; std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public: public:
std::wstring m_sComment; std::wstring m_sComment;
std::wstring m_sCommentExt; std::wstring m_sCommentExt;
std::wstring m_sPeople; std::wstring m_sPeople;
public:
CommentsWriter(std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter) CommentsWriter(std::wstring sDir) : m_sDir(sDir)
{ {
} }
void setElements(std::wstring& sComment, std::wstring& sCommentExt, std::wstring& sPeople) void setElements(std::wstring& sComment, std::wstring& sCommentExt, std::wstring& sPeople)
...@@ -67,42 +66,30 @@ namespace Writers ...@@ -67,42 +66,30 @@ namespace Writers
{ {
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("comments.xml"); OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("comments.xml");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(g_string_comment_Start); oFile.WriteStringUTF8(g_string_comment_Start);
oFile.WriteStringUTF8(m_sComment); oFile.WriteStringUTF8(m_sComment);
oFile.WriteStringUTF8(g_string_comment_End); oFile.WriteStringUTF8(g_string_comment_End);
oFile.CloseFile(); oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(std::wstring(_T("/word/comments.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml")));
//Rels
//m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments"), _T("comments.xml"));
} }
if(false == m_sCommentExt.empty()) if(false == m_sCommentExt.empty())
{ {
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("commentsExtended.xml")); oFile.CreateFileW(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("commentsExtended.xml"));
oFile.WriteStringUTF8(g_string_commentExt_Start); oFile.WriteStringUTF8(g_string_commentExt_Start);
oFile.WriteStringUTF8(m_sCommentExt); oFile.WriteStringUTF8(m_sCommentExt);
oFile.WriteStringUTF8(g_string_commentExt_End); oFile.WriteStringUTF8(g_string_commentExt_End);
oFile.CloseFile(); oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(std::wstring(_T("/word/commentsExtended.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml")));
} }
if(false == m_sPeople.empty()) if(false == m_sPeople.empty())
{ {
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("people.xml")); oFile.CreateFileW(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("people.xml"));
oFile.WriteStringUTF8(g_string_people_Start); oFile.WriteStringUTF8(g_string_people_Start);
oFile.WriteStringUTF8(m_sPeople); oFile.WriteStringUTF8(m_sPeople);
oFile.WriteStringUTF8(g_string_people_End); oFile.WriteStringUTF8(g_string_people_End);
oFile.CloseFile(); oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(std::wstring(_T("/word/people.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml")));
} }
} }
}; };
......
...@@ -39,15 +39,16 @@ namespace Writers ...@@ -39,15 +39,16 @@ namespace Writers
class DefaultThemeWriter class DefaultThemeWriter
{ {
public: public:
DefaultThemeWriter() std::wstring m_sContent;
DefaultThemeWriter( )
{ {
} }
void Write(std::wstring sThemeFilePath) void Write(std::wstring sThemeFilePath)
{ {
std::wstring s_Common; if (m_sContent.empty())
{
s_Common = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?> \ m_sContent = _T("<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\">\
<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\"> \
<a:themeElements> \ <a:themeElements> \
<a:clrScheme name=\"Office\"> \ <a:clrScheme name=\"Office\"> \
<a:dk1> \ <a:dk1> \
...@@ -87,7 +88,7 @@ namespace Writers ...@@ -87,7 +88,7 @@ namespace Writers
<a:srgbClr val=\"800080\"/> \ <a:srgbClr val=\"800080\"/> \
</a:folHlink> \ </a:folHlink> \
</a:clrScheme> "); </a:clrScheme> ");
s_Common += m_sContent +=
_T("<a:fontScheme name=\"Office\"> \ _T("<a:fontScheme name=\"Office\"> \
<a:majorFont> \ <a:majorFont> \
<a:latin typeface=\"Cambria\"/> \ <a:latin typeface=\"Cambria\"/> \
...@@ -158,7 +159,7 @@ s_Common += ...@@ -158,7 +159,7 @@ s_Common +=
<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/> \ <a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/> \
</a:minorFont> \ </a:minorFont> \
</a:fontScheme>"); </a:fontScheme>");
s_Common += m_sContent +=
_T("<a:fmtScheme name=\"Office\"> \ _T("<a:fmtScheme name=\"Office\"> \
<a:fillStyleLst> \ <a:fillStyleLst> \
<a:solidFill> \ <a:solidFill> \
...@@ -329,13 +330,14 @@ s_Common += ...@@ -329,13 +330,14 @@ s_Common +=
<a:objectDefaults/> \ <a:objectDefaults/> \
<a:extraClrSchemeLst/> \ <a:extraClrSchemeLst/> \
</a:theme>"); </a:theme>");
}
OOX::CPath fileName = sThemeFilePath; OOX::CPath fileName = sThemeFilePath;
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(fileName.GetPath()); oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common); oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
oFile.WriteStringUTF8(m_sContent);
oFile.CloseFile(); oFile.CloseFile();
} }
}; };
......
...@@ -56,8 +56,8 @@ namespace Writers ...@@ -56,8 +56,8 @@ namespace Writers
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels"); OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(fileName.GetPath()); oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common); oFile.WriteStringUTF8(s_Common);
oFile.CloseFile(); oFile.CloseFile();
} }
......
...@@ -51,8 +51,8 @@ namespace Writers ...@@ -51,8 +51,8 @@ namespace Writers
{ {
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") +FILE_SEPARATOR_STR + _T("document.xml"); OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") +FILE_SEPARATOR_STR + _T("document.xml");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"))); oFile.WriteStringUTF8( std::wstring(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>")));
oFile.WriteStringUTF8( std::wstring(_T("<w:document 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\" mc:Ignorable=\"w14 wp14\">"))); oFile.WriteStringUTF8( std::wstring(_T("<w:document 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\" mc:Ignorable=\"w14 wp14\">")));
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
*/ */
#ifndef FILE_WRITER #ifndef FILE_WRITER
#define FILE_WRITER #define FILE_WRITER
#include "../../DesktopEditor/common/Path.h"
#include "NumberingWriter.h" #include "NumberingWriter.h"
#include "fontTableWriter.h" #include "fontTableWriter.h"
...@@ -45,19 +46,21 @@ ...@@ -45,19 +46,21 @@
#include "webSettingsWriter.h" #include "webSettingsWriter.h"
#include "DefaultThemeWriter.h" #include "DefaultThemeWriter.h"
namespace BinDocxRW { namespace BinDocxRW
{
class CComments; class CComments;
} }
namespace NSBinPptxRW
{
class CDrawingConverter;
}
namespace Writers namespace Writers
{ {
class FileWriter class FileWriter
{ {
public: public:
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
std::wstring m_sThemePath;
bool m_bSaveChartAsImg;
ContentTypesWriter m_oContentTypesWriter;
FontTableWriter m_oFontTableWriter; FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter; DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter; MediaWriter m_oMediaWriter;
...@@ -71,35 +74,57 @@ namespace Writers ...@@ -71,35 +74,57 @@ namespace Writers
ChartWriter m_oChartWriter; ChartWriter m_oChartWriter;
DocumentRelsWriter m_oDocumentRelsWriter; DocumentRelsWriter m_oDocumentRelsWriter;
WebSettingsWriter m_oWebSettingsWriter; WebSettingsWriter m_oWebSettingsWriter;
DefaultThemeWriter m_oDefaultTheme; DefaultThemeWriter m_oTheme;
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
bool m_bSaveChartAsImg;
std::wstring m_sThemePath;
int m_nDocPrIndex; int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments; BinDocxRW::CComments* m_pComments;
public:
FileWriter(std::wstring sDirOutput,std::wstring sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath): FileWriter (std::wstring sDirOutput,std::wstring sFontDir, bool bNoFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, std::wstring sThemePath)
m_pDrawingConverter(pDrawingConverter),m_sThemePath(sThemePath),m_bSaveChartAsImg(bSaveChartAsImg), : m_pDrawingConverter(pDrawingConverter), m_sThemePath(sThemePath), m_bSaveChartAsImg(bSaveChartAsImg),
m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir, bNoFontDir), m_oFontTableWriter (sDirOutput, sFontDir, bNoFontDir),
m_oHeaderFooterWriter(sDirOutput, m_oContentTypesWriter), m_oHeaderFooterWriter (sDirOutput),
m_oFootnotesWriter(sDirOutput, m_oContentTypesWriter), m_oFootnotesWriter (sDirOutput),
m_oEndnotesWriter(sDirOutput, m_oContentTypesWriter), m_oEndnotesWriter (sDirOutput),
m_oMediaWriter(sDirOutput), m_oMediaWriter (sDirOutput),
m_oStylesWriter(sDirOutput, nVersion), m_oStylesWriter (sDirOutput, nVersion),
m_oNumberingWriter(sDirOutput, m_oContentTypesWriter), m_oNumberingWriter (sDirOutput),
m_oDocumentWriter(sDirOutput, m_oHeaderFooterWriter), m_oDocumentWriter (sDirOutput, m_oHeaderFooterWriter),
m_oSettingWriter(sDirOutput, m_oHeaderFooterWriter), m_oSettingWriter (sDirOutput, m_oHeaderFooterWriter),
m_oCommentsWriter(sDirOutput, m_oContentTypesWriter), m_oCommentsWriter (sDirOutput),
m_oChartWriter(sDirOutput, m_oContentTypesWriter), m_oChartWriter (sDirOutput),
m_oDocumentRelsWriter(sDirOutput), m_oDocumentRelsWriter (sDirOutput),
m_oWebSettingsWriter(sDirOutput), m_oWebSettingsWriter (sDirOutput),
m_nDocPrIndex(0), m_nDocPrIndex(0),
m_pComments(NULL) m_pComments(NULL)
{ {
} }
public: int getNextDocPr() int getNextDocPr()
{ {
m_nDocPrIndex++; m_nDocPrIndex++;
return m_nDocPrIndex; return m_nDocPrIndex;
} }
void Write()
{
m_oCommentsWriter.Write();
m_oChartWriter.Write();
m_oStylesWriter.Write();
m_oNumberingWriter.Write();
m_oFontTableWriter.Write();
m_oHeaderFooterWriter.Write();
m_oFootnotesWriter.Write();
m_oEndnotesWriter.Write();
//Setting пишем после HeaderFooter, чтобы заполнить evenAndOddHeaders
m_oSettingWriter.Write();
m_oWebSettingsWriter.Write();
//Document пишем после HeaderFooter, чтобы заполнить sectPr
m_oDocumentWriter.Write();
//Rels и ContentTypes пишем в конце
m_oDocumentRelsWriter.Write();
}
}; };
} }
#endif // #ifndef FILE_WRITER #endif // #ifndef FILE_WRITER
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define HEADER_FOOTER_WRITER #define HEADER_FOOTER_WRITER
#include "../../XlsxSerializerCom/Common/Common.h" #include "../../XlsxSerializerCom/Common/Common.h"
#include "../../Common/DocxFormat/Source/Common/SimpleTypes_Word.h"
namespace Writers namespace Writers
{ {
...@@ -74,12 +75,11 @@ namespace Writers ...@@ -74,12 +75,11 @@ namespace Writers
class HeaderFooterWriter class HeaderFooterWriter
{ {
std::wstring m_sDir; std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public: public:
std::vector<HdrFtrItem*> m_aHeaders; std::vector<HdrFtrItem*> m_aHeaders;
std::vector<HdrFtrItem*> m_aFooters; std::vector<HdrFtrItem*> m_aFooters;
public:
HeaderFooterWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter) : m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter) HeaderFooterWriter( std::wstring sDir) : m_sDir(sDir)
{ {
} }
~HeaderFooterWriter() ~HeaderFooterWriter()
...@@ -109,8 +109,8 @@ namespace Writers ...@@ -109,8 +109,8 @@ namespace Writers
{ {
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename; OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
if(bHeader) if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_Start); oFile.WriteStringUTF8(g_string_hdr_Start);
...@@ -122,41 +122,31 @@ namespace Writers ...@@ -122,41 +122,31 @@ namespace Writers
else else
oFile.WriteStringUTF8(g_string_ftr_End); oFile.WriteStringUTF8(g_string_ftr_End);
oFile.CloseFile(); oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(L"/word/" + sFilename, L"application/vnd.openxmlformats-officedocument.wordprocessingml." + sHeader + L"+xml");
//Rels
//return m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/") + sHeader, sFilename);
} }
}; };
class FootnotesWriter class FootnotesWriter
{ {
std::wstring m_sDir; std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public: public:
ContentWriter m_oNotesWriter; ContentWriter m_oNotesWriter;
FootnotesWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
FootnotesWriter( std::wstring sDir ):m_sDir(sDir)
{ {
} }
void Write() void Write()
{ {
if(!IsEmpty()) if(IsEmpty()) return;
{
std::wstring sFilename = getFilename(); std::wstring sFilename = getFilename();
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + sFilename; std::wstring filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + sFilename;
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath); oFile.CreateFileW (filePath);
oFile.WriteStringUTF8(g_string_footnotes_Start); oFile.WriteStringUTF8 (g_string_footnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData()); oFile.WriteStringUTF8 (m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_footnotes_End); oFile.WriteStringUTF8 (g_string_footnotes_End);
oFile.CloseFile(); oFile.CloseFile();
//ContentType
m_oContentTypesWriter.AddOverride(L"/word/" + sFilename, L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml");
}
} }
std::wstring getFilename() std::wstring getFilename()
{ {
...@@ -170,30 +160,26 @@ namespace Writers ...@@ -170,30 +160,26 @@ namespace Writers
class EndnotesWriter class EndnotesWriter
{ {
std::wstring m_sDir; std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public: public:
ContentWriter m_oNotesWriter; ContentWriter m_oNotesWriter;
EndnotesWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
EndnotesWriter( std::wstring sDir ) : m_sDir(sDir)
{ {
} }
void Write() void Write()
{ {
if(!IsEmpty()) if(IsEmpty()) return;
{
std::wstring sFilename = getFilename(); std::wstring sFilename = getFilename();
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename; std::wstring filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath); oFile.CreateFileW(filePath);
oFile.WriteStringUTF8(g_string_endnotes_Start); oFile.WriteStringUTF8(g_string_endnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData()); oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_endnotes_End); oFile.WriteStringUTF8(g_string_endnotes_End);
oFile.CloseFile(); oFile.CloseFile();
//ContentType
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"));
}
} }
std::wstring getFilename() std::wstring getFilename()
{ {
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#ifndef NUMBERING_WRITER #ifndef NUMBERING_WRITER
#define NUMBERING_WRITER #define NUMBERING_WRITER
#include "ContentTypesWriter.h"
#include "DocumentRelsWriter.h" #include "DocumentRelsWriter.h"
namespace Writers namespace Writers
...@@ -44,12 +43,11 @@ namespace Writers ...@@ -44,12 +43,11 @@ namespace Writers
{ {
XmlUtils::CStringWriter m_oWriter; XmlUtils::CStringWriter m_oWriter;
std::wstring m_sDir; std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public: public:
XmlUtils::CStringWriter m_oANum; XmlUtils::CStringWriter m_oANum;
XmlUtils::CStringWriter m_oNumList; XmlUtils::CStringWriter m_oNumList;
public:
NumberingWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter) NumberingWriter( std::wstring sDir) : m_sDir(sDir)
{ {
} }
bool IsEmpty() bool IsEmpty()
...@@ -58,8 +56,8 @@ namespace Writers ...@@ -58,8 +56,8 @@ namespace Writers
} }
void Write() void Write()
{ {
if(false == IsEmpty()) if(IsEmpty()) return;
{
m_oWriter.WriteString(g_string_n_Start); m_oWriter.WriteString(g_string_n_Start);
m_oWriter.Write(m_oANum); m_oWriter.Write(m_oANum);
m_oWriter.Write(m_oNumList); m_oWriter.Write(m_oNumList);
...@@ -67,17 +65,11 @@ namespace Writers ...@@ -67,17 +65,11 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml"); OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData()); oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile(); oFile.CloseFile();
//ContentType
m_oContentTypesWriter.AddOverride( std::wstring(_T("/word/numbering.xml")), std::wstring(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml")));
//Rels
//m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"), _T("numbering.xml"));
}
} }
}; };
} }
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "../../Common/DocxFormat/Source/XML/Utils.h" #include "../../Common/DocxFormat/Source/XML/Utils.h"
#include <boost/algorithm/string.hpp>
namespace BinDocxRW { namespace BinDocxRW {
class SectPr class SectPr
...@@ -1881,6 +1883,11 @@ public: ...@@ -1881,6 +1883,11 @@ public:
class CDrawingProperty class CDrawingProperty
{ {
public: public:
bool bObject;
std::wstring sObjectProgram;
long nObjectId;
BYTE nObjectType;
long DataPos; long DataPos;
long DataLength; long DataLength;
BYTE Type; BYTE Type;
...@@ -1949,6 +1956,10 @@ public: ...@@ -1949,6 +1956,10 @@ public:
CDrawingProperty(int nDocPr) CDrawingProperty(int nDocPr)
{ {
m_nDocPr = nDocPr; m_nDocPr = nDocPr;
bObject = false;
nObjectType = 0;
nObjectId = 0;
bDataPos = false; bDataPos = false;
bDataLength = false; bDataLength = false;
bType = false; bType = false;
......
...@@ -29,52 +29,85 @@ ...@@ -29,52 +29,85 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
* *
*/ */
#ifndef CONTENT_TYPES_WRITER #include "Readers.h"
#define CONTENT_TYPES_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers namespace BinDocxRW {
{
static std::wstring g_string_ct_Start = L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">";
static std::wstring g_string_ct_Ext = L"<Default Extension=\"bin\" ContentType=\"application/vnd.openxmlformats-officedocument.oleObject\"/><Default Extension=\"bmp\" ContentType=\"image/bmp\"/><Default Extension=\"jpg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpeg\" ContentType=\"image/jpeg\"/><Default Extension=\"jpe\" ContentType=\"image/jpeg\"/><Default Extension=\"png\" ContentType=\"image/png\"/><Default Extension=\"gif\" ContentType=\"image/gif\"/><Default Extension=\"emf\" ContentType=\"image/x-emf\"/><Default Extension=\"wmf\" ContentType=\"image/x-wmf\"/><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Default Extension=\"xlsx\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"/>";
static std::wstring g_string_ct_Override = L"<Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/word/settings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\"/><Override PartName=\"/word/webSettings.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\"/><Override PartName=\"/word/fontTable.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\"/><Override PartName=\"/word/theme/theme1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.theme+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/><Override PartName=\"/docProps/app.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.extended-properties+xml\"/>";
static std::wstring g_string_ct_End = L"</Types>";
class ContentTypesWriter Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(NSBinPptxRW::CBinaryFileReader& poBufferedStream, Writers::FileWriter& oFileWriter, CComments* pComments):Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_oHeaderFooterWriter(oFileWriter.m_oHeaderFooterWriter),m_pComments(pComments)
{
}
int Binary_HdrFtrTableReader::Read()
{
return ReadTable(&Binary_HdrFtrTableReader::ReadHdrFtrContent, this);
}
int Binary_HdrFtrTableReader::ReadHdrFtrContent(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerHdrFtrTypes::Header == type || c_oSerHdrFtrTypes::Footer == type )
{ {
XmlUtils::CStringWriter m_oWriter; nCurType = type;
std::wstring m_sDir; res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrFEO, this, poResult);
XmlUtils::CStringWriter m_oAdditional; }
public: else
ContentTypesWriter(std::wstring sDir) : m_sDir(sDir) res = c_oSerConstants::ReadUnknown;
return res;
}
int Binary_HdrFtrTableReader::ReadHdrFtrFEO(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerHdrFtrTypes::HdrFtr_First == type || c_oSerHdrFtrTypes::HdrFtr_Even == type || c_oSerHdrFtrTypes::HdrFtr_Odd == type )
{ {
nCurHeaderType = type;
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItem, this, poResult);
} }
void Write() else
res = c_oSerConstants::ReadUnknown;
return res;
}
int Binary_HdrFtrTableReader::ReadHdrFtrItem(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
if ( c_oSerHdrFtrTypes::HdrFtr_Content == type )
{ {
m_oWriter.WriteString(g_string_ct_Start); Writers::HdrFtrItem* poHdrFtrItem = NULL;
m_oWriter.WriteString(g_string_ct_Ext); switch(nCurHeaderType)
m_oWriter.WriteString(g_string_ct_Override); {
m_oWriter.Write(m_oAdditional); case c_oSerHdrFtrTypes::HdrFtr_First:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrFirst);break;
m_oWriter.WriteString(g_string_ct_End); case c_oSerHdrFtrTypes::HdrFtr_Even:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrEven);break;
case c_oSerHdrFtrTypes::HdrFtr_Odd:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrDefault);break;
OOX::CPath filePath = m_sDir + L"/[Content_Types].xml";
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
} }
void AddOverride(const std::wstring& PartName, const std::wstring& ContentType) if(NULL != poHdrFtrItem)
{ {
std::wstring sOverride = L"<Override PartName=\"" + PartName+ L"\" ContentType=\"" + ContentType + L"\"/>"; if(nCurType == c_oSerHdrFtrTypes::Header)
m_oAdditional.WriteString(sOverride); {
m_oHeaderFooterWriter.m_aHeaders.push_back(poHdrFtrItem);
poHdrFtrItem->m_sFilename = L"header" + std::to_wstring((int)m_oHeaderFooterWriter.m_aHeaders.size()) + L".xml";
} }
void AddOverrideRaw(const std::wstring& sXml) else
{ {
m_oAdditional.WriteString(sXml); m_oHeaderFooterWriter.m_aFooters.push_back(poHdrFtrItem);
poHdrFtrItem->m_sFilename = L"footer" + std::to_wstring((int)m_oHeaderFooterWriter.m_aFooters.size()) + L".xml";
}
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
Binary_DocumentTableReader oBinary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, poHdrFtrItem->Header, m_pComments);
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrItemContent, this, &oBinary_DocumentTableReader);
OOX::CPath fileRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + FILE_SEPARATOR_STR + _T("word") +
FILE_SEPARATOR_STR + _T("_rels")+
FILE_SEPARATOR_STR + poHdrFtrItem->m_sFilename + _T(".rels");
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(fileRelsPath.GetPath());
}
} }
}; else
res = c_oSerConstants::ReadUnknown;
return res;
}
int Binary_HdrFtrTableReader::ReadHdrFtrItemContent(BYTE type, long length, void* poResult)
{
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
}
} }
\ No newline at end of file
#endif // #ifndef CONTENT_TYPES_WRITER
This diff is collapsed.
...@@ -54,8 +54,8 @@ namespace Writers ...@@ -54,8 +54,8 @@ namespace Writers
Prepare(); Prepare();
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"settings.xml"; OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"settings.xml";
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(g_string_set_Start); oFile.WriteStringUTF8(g_string_set_Start);
oFile.WriteStringUTF8(m_oSettingWriter.GetData()); oFile.WriteStringUTF8(m_oSettingWriter.GetData());
oFile.WriteStringUTF8(g_string_set_Default); oFile.WriteStringUTF8(g_string_set_Default);
......
...@@ -58,7 +58,6 @@ namespace Writers ...@@ -58,7 +58,6 @@ namespace Writers
} }
void Write() void Write()
{ {
m_oWriter.WriteString(g_string_st_Start); m_oWriter.WriteString(g_string_st_Start);
m_oWriter.WriteString(std::wstring(_T("<w:docDefaults>"))); m_oWriter.WriteString(std::wstring(_T("<w:docDefaults>")));
m_oWriter.WriteString(std::wstring(_T("<w:rPrDefault>"))); m_oWriter.WriteString(std::wstring(_T("<w:rPrDefault>")));
...@@ -81,8 +80,8 @@ namespace Writers ...@@ -81,8 +80,8 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("styles.xml"); OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("styles.xml");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData()); oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile(); oFile.CloseFile();
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "../../XlsxSerializerCom/Common/Common.h" #include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h" #include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace Writers namespace Writers
{ {
...@@ -48,7 +49,7 @@ namespace Writers ...@@ -48,7 +49,7 @@ namespace Writers
CFontManager* m_pFontManager; CFontManager* m_pFontManager;
public: public:
std::map<std::wstring, int> m_mapFonts; std::map<std::wstring, int> m_mapFonts;
public:
FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir) FontTableWriter(std::wstring sDir, std::wstring sFontDir, bool bNoFontDir):m_sDir(sDir)
{ {
m_pFontManager = NULL; m_pFontManager = NULL;
...@@ -102,8 +103,8 @@ namespace Writers ...@@ -102,8 +103,8 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("fontTable.xml"); OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("fontTable.xml");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(filePath.GetPath()); oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData()); oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile(); oFile.CloseFile();
......
...@@ -54,8 +54,8 @@ namespace Writers ...@@ -54,8 +54,8 @@ namespace Writers
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("webSettings.xml"); OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("webSettings.xml");
CFile oFile; NSFile::CFileBinary oFile;
oFile.CreateFile(fileName.GetPath()); oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common); oFile.WriteStringUTF8(s_Common);
oFile.CloseFile(); oFile.CloseFile();
} }
......
...@@ -33,13 +33,11 @@ ...@@ -33,13 +33,11 @@
#define BINEQUATIONWRITER_H #define BINEQUATIONWRITER_H
#include "BinReaderWriterDefines.h" #include "BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/Common/SimpleTypes_OMath.h"
#include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h" #include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h"
#include <stack> #include <stack>
/*namespace BinDocxRW
{
class BinaryCommonWriter;
}*/
namespace MathEquation namespace MathEquation
{ {
class EquationRun class EquationRun
......
...@@ -997,6 +997,12 @@ extern int g_nCurFormatVersion; ...@@ -997,6 +997,12 @@ extern int g_nCurFormatVersion;
Title = 3, Title = 3,
Descr = 4 Descr = 4
};} };}
namespace c_oSerEmbedded{enum c_oSerEmbedded
{
Type = 0,
Data = 1,
Program = 2
};}
} }
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES #endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
namespace BinDocxRW namespace BinDocxRW
{ {
BinaryHeaderFooterTableWriter::BinaryHeaderFooterTableWriter(ParamsWriter& oParamsWriter, OOX::IFileContainer* oDocumentRels, std::map<int, bool>* mapIgnoreComments): BinaryHeaderFooterTableWriter::BinaryHeaderFooterTableWriter(ParamsWriter& oParamsWriter, OOX::IFileContainer* oDocumentRels, std::map<int, bool>* mapIgnoreComments):
m_oBcw(oParamsWriter), m_oParamsWriter(oParamsWriter), m_poTheme(oParamsWriter.m_poTheme), m_oFontProcessor(*oParamsWriter.m_pFontProcessor), m_oSettings(oParamsWriter.m_oSettings),m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter), m_oDocumentRels(oDocumentRels),m_mapIgnoreComments(mapIgnoreComments) m_oBcw(oParamsWriter), m_oParamsWriter(oParamsWriter), m_poTheme(oParamsWriter.m_poTheme), m_oFontProcessor(*oParamsWriter.m_pFontProcessor), m_oSettings(oParamsWriter.m_oSettings), m_pOfficeDrawingConverter(oParamsWriter.m_pOfficeDrawingConverter), m_oDocumentRels(oDocumentRels),m_mapIgnoreComments(mapIgnoreComments)
{ {
}; }
void BinaryHeaderFooterTableWriter::Write() void BinaryHeaderFooterTableWriter::Write()
{ {
int nStart = m_oBcw.WriteItemWithLengthStart(); int nStart = m_oBcw.WriteItemWithLengthStart();
...@@ -57,7 +57,7 @@ namespace BinDocxRW ...@@ -57,7 +57,7 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
} }
m_oBcw.WriteItemWithLengthEnd(nStart); m_oBcw.WriteItemWithLengthEnd(nStart);
}; }
void BinaryHeaderFooterTableWriter::WriteHdrFtrContent(std::vector<OOX::CHdrFtr*>& aHdrFtrs, std::vector<SimpleTypes::EHdrFtr>& aHdrFtrTypes, std::vector<OOX::Logic::CSectionProperty*>& aHdrSectPrs, bool bHdr) void BinaryHeaderFooterTableWriter::WriteHdrFtrContent(std::vector<OOX::CHdrFtr*>& aHdrFtrs, std::vector<SimpleTypes::EHdrFtr>& aHdrFtrTypes, std::vector<OOX::Logic::CSectionProperty*>& aHdrSectPrs, bool bHdr)
{ {
int nCurPos = 0; int nCurPos = 0;
...@@ -69,15 +69,15 @@ namespace BinDocxRW ...@@ -69,15 +69,15 @@ namespace BinDocxRW
BYTE byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd; BYTE byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;
switch(eType) switch(eType)
{ {
case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First;break; case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First; break;
case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even;break; case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even; break;
default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;break; default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd; break;
} }
nCurPos = m_oBcw.WriteItemStart(byteHdrFtrType); nCurPos = m_oBcw.WriteItemStart(byteHdrFtrType);
WriteHdrFtrItem(pSectPr, pHdrFtr, bHdr); WriteHdrFtrItem(pSectPr, pHdrFtr, bHdr);
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
} }
}; }
void BinaryHeaderFooterTableWriter::WriteHdrFtrItem(OOX::Logic::CSectionProperty* pSectPr, OOX::CHdrFtr* pHdrFtr, bool bHdr) void BinaryHeaderFooterTableWriter::WriteHdrFtrItem(OOX::Logic::CSectionProperty* pSectPr, OOX::CHdrFtr* pHdrFtr, bool bHdr)
{ {
int nCurPos = 0; int nCurPos = 0;
...@@ -90,5 +90,5 @@ namespace BinDocxRW ...@@ -90,5 +90,5 @@ namespace BinDocxRW
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content); nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems); oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos); m_oBcw.WriteItemEnd(nCurPos);
}; }
} }
This diff is collapsed.
...@@ -57,8 +57,10 @@ namespace BinDocxRW ...@@ -57,8 +57,10 @@ namespace BinDocxRW
bool m_bSaveChartAsImg; bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter; ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter; Writers::FileWriter* m_pCurFileWriter;
public:
CDocxSerializer(); CDocxSerializer();
virtual ~CDocxSerializer();
bool ConvertDocxToDoct(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions); bool ConvertDocxToDoct(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions);
bool ConvertDoctToDocx(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions); bool ConvertDoctToDocx(const std::wstring& sSrcFileName, const std::wstring& sDstFileName, const std::wstring& sTmpDir, const std::wstring& sXMLOptions);
......
...@@ -80,7 +80,7 @@ namespace DocWrapper { ...@@ -80,7 +80,7 @@ namespace DocWrapper {
return fontName; return fontName;
} }
std::wstring FontProcessor::getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, OOX::CTheme* pTheme) std::wstring FontProcessor::getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, PPTX::Theme* pTheme)
{ {
CFontSelectFormat oFontSelectFormat; CFontSelectFormat oFontSelectFormat;
std::wstring sFontName; std::wstring sFontName;
...@@ -89,9 +89,9 @@ namespace DocWrapper { ...@@ -89,9 +89,9 @@ namespace DocWrapper {
//берем шрифт из темы //берем шрифт из темы
const SimpleTypes::Spreadsheet::EFontScheme eFontScheme = oScheme->m_oFontScheme->GetValue(); const SimpleTypes::Spreadsheet::EFontScheme eFontScheme = oScheme->m_oFontScheme->GetValue();
if(SimpleTypes::Spreadsheet::fontschemeMajor == eFontScheme) if(SimpleTypes::Spreadsheet::fontschemeMajor == eFontScheme)
sFontName = pTheme->GetMajorFont(); sFontName = pTheme->themeElements.fontScheme.majorFont.latin.typeface;
else if(SimpleTypes::Spreadsheet::fontschemeMinor == eFontScheme) else if(SimpleTypes::Spreadsheet::fontschemeMinor == eFontScheme)
sFontName = pTheme->GetMinorFont(); sFontName = pTheme->themeElements.fontScheme.minorFont.latin.typeface;
} }
if(sFontName.empty() && oRFont.IsInit() && oRFont->m_sVal.IsInit()) if(sFontName.empty() && oRFont.IsInit() && oRFont->m_sVal.IsInit())
sFontName = oRFont->ToString2(); sFontName = oRFont->ToString2();
......
...@@ -30,26 +30,29 @@ ...@@ -30,26 +30,29 @@
* *
*/ */
#pragma once #pragma once
//#include "../stdafx.h"
#include <map> #include <map>
#include "../../DesktopEditor/fontengine/ApplicationFonts.h" #include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{ namespace NSCommon{
template<class Type> class nullable; template<class Type> class nullable;
} }
namespace ComplexTypes{ namespace ComplexTypes
namespace Spreadsheet{ {
namespace Spreadsheet
{
class String; class String;
} }
} }
namespace PPTX
{
class Theme;
}
namespace OOX namespace OOX
{ {
class CFont; class CFont;
class CFontTable; class CFontTable;
class CTheme;
namespace Spreadsheet namespace Spreadsheet
{ {
class CFont; class CFont;
...@@ -61,9 +64,10 @@ namespace OOX ...@@ -61,9 +64,10 @@ namespace OOX
} }
} }
namespace DocWrapper { namespace DocWrapper
{
class FontProcessor { class FontProcessor
{
CFontManager* m_pFontManager; CFontManager* m_pFontManager;
std::map<std::wstring, std::wstring> fontMap; std::map<std::wstring, std::wstring> fontMap;
...@@ -76,7 +80,7 @@ namespace DocWrapper { ...@@ -76,7 +80,7 @@ namespace DocWrapper {
void setFontTable(OOX::CFontTable* fontTable); void setFontTable(OOX::CFontTable* fontTable);
std::wstring getFont(const std::wstring& name); std::wstring getFont(const std::wstring& name);
std::wstring getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, OOX::CTheme* pTheme); std::wstring getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::String>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, PPTX::Theme* pTheme);
private: private:
void addToFontMap(OOX::CFont& font); void addToFontMap(OOX::CFont& font);
}; };
......
...@@ -85,17 +85,17 @@ namespace BinXlsxRW{ ...@@ -85,17 +85,17 @@ namespace BinXlsxRW{
} }
bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir) bool CXlsxSerializer::loadFromFile(const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedDir)
{ {
NSBinPptxRW::CDrawingConverter oOfficeDrawingConverter; NSBinPptxRW::CDrawingConverter oDrawingConverter;
oOfficeDrawingConverter.SetMediaDstPath(sMediaDir);
oOfficeDrawingConverter.SetEmbedDstPath(sEmbedDir); oDrawingConverter.SetMediaDstPath(sMediaDir);
oDrawingConverter.SetEmbedDstPath(sEmbedDir);
//папка с бинарников
std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName); std::wstring strFileInDir = NSSystemPath::GetDirectoryName(sSrcFileName);
oOfficeDrawingConverter.SetSourceFileDir(strFileInDir, 2); oDrawingConverter.SetSourceFileDir(strFileInDir, 2);
BinXlsxRW::BinaryFileReader oBinaryFileReader; BinXlsxRW::BinaryFileReader oBinaryFileReader;
oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oOfficeDrawingConverter, sXMLOptions); oBinaryFileReader.ReadFile(sSrcFileName, sDstPath, &oDrawingConverter, sXMLOptions);
return true; return true;
} }
bool CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions) bool CXlsxSerializer::saveToFile(const std::wstring& sDstFileName, const std::wstring& sSrcPath, const std::wstring& sXMLOptions)
...@@ -139,42 +139,42 @@ namespace BinXlsxRW{ ...@@ -139,42 +139,42 @@ namespace BinXlsxRW{
RELEASEOBJECT(pFontPicker); RELEASEOBJECT(pFontPicker);
return true; return true;
} }
bool CXlsxSerializer::loadChart(const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize) bool CXlsxSerializer::loadChart(const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter* pWriter, long& lDataSize)
{ {
bool bRes = false; if (NULL == pWriter) return false;
//todo передать нормальный oRootPath if (NULL == m_pExternalDrawingConverter) return false;
OOX::CPath oRootPath; OOX::CPath oRootPath;
OOX::Spreadsheet::CChartSpace oChart(oRootPath, sChartPath); OOX::Spreadsheet::CChartSpace oChart(oRootPath, sChartPath);
if(NULL != m_pExternalDrawingConverter)
{ long nStartPos = pWriter->GetPosition();
long nStartPos = oBufferedStream.GetPosition(); BinXlsxRW::BinaryCommonWriter oBcw(*pWriter);
BinXlsxRW::BinaryCommonWriter oBcw(oBufferedStream);
std::wstring sOldRelsPath = m_pExternalDrawingConverter->GetRelsPath(); std::wstring sOldRelsPath = m_pExternalDrawingConverter->GetRelsPath();
m_pExternalDrawingConverter->SetRelsPath(sChartPath); m_pExternalDrawingConverter->SetRelsPath(sChartPath);
BinXlsxRW::BinaryChartWriter oBinaryChartWriter(oBufferedStream, m_pExternalDrawingConverter); BinXlsxRW::BinaryChartWriter oBinaryChartWriter(*pWriter, m_pExternalDrawingConverter);
oBinaryChartWriter.WriteCT_ChartSpace(oChart); oBinaryChartWriter.WriteCT_ChartSpace(oChart);
m_pExternalDrawingConverter->SetRelsPath(sOldRelsPath); m_pExternalDrawingConverter->SetRelsPath(sOldRelsPath);
long nEndPos = oBufferedStream.GetPosition(); long nEndPos = pWriter->GetPosition();
lDataSize = nEndPos - nStartPos; lDataSize = nEndPos - nStartPos;
bRes = true;
} return true;
return bRes;
} }
bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilepath, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber) bool CXlsxSerializer::saveChart(NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilepath, const long& lChartNumber)
{ {
if (NULL == pReader) return false;
if (NULL == m_pExternalDrawingConverter) return false;
bool bRes = false; bool bRes = false;
*sContentTypeElement = NULL;
if(NULL != m_pExternalDrawingConverter)
{
m_pExternalDrawingConverter->SetDstContentRels(); m_pExternalDrawingConverter->SetDstContentRels();
//получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename //получаем sThemePath из bsFilename предполагая что папка theme находится на уровень выше bsFilename
std::wstring sThemePath; std::wstring sThemePath;
std::wstring sEmbedingPath; std::wstring sEmbedingPath;
std::wstring sContentTypePath;
int nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR); int nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR);
nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR, nIndex - 1); nIndex = (int)sFilepath.rfind(FILE_SEPARATOR_CHAR, nIndex - 1);
...@@ -184,19 +184,21 @@ namespace BinXlsxRW{ ...@@ -184,19 +184,21 @@ namespace BinXlsxRW{
sThemePath = sFilepathLeft + L"theme"; sThemePath = sFilepathLeft + L"theme";
sEmbedingPath = sFilepathLeft + L"embeddings"; sEmbedingPath = sFilepathLeft + L"embeddings";
} }
if (pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_DOCX) sContentTypePath = L"/word/charts/";
else if (pReader->m_nDocumentType == XMLWRITER_DOC_TYPE_XLSX) sContentTypePath = L"/xl/charts/";
else sContentTypePath = L"/ppt/charts/";
//todo theme path //todo theme path
BinXlsxRW::SaveParams oSaveParams(sThemePath); BinXlsxRW::SaveParams oSaveParams(sThemePath, m_pExternalDrawingConverter->GetContentTypes());
OOX::Spreadsheet::CChartSpace oChartSpace; OOX::Spreadsheet::CChartSpace oChartSpace;
BinXlsxRW::BinaryChartReader oBinaryChartReader(oBufferedStream, oSaveParams, m_pExternalDrawingConverter); BinXlsxRW::BinaryChartReader oBinaryChartReader(*pReader, oSaveParams, m_pExternalDrawingConverter);
oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace); oBinaryChartReader.ReadCT_ChartSpace(lLength, &oChartSpace.m_oChartSpace);
if(oChartSpace.isValid()) if(oChartSpace.isValid())
{ {
//todo не делать embeddings, если пишем xlsx //save xlsx embedded for chart
//save xlsx if(pReader->m_nDocumentType != XMLWRITER_DOC_TYPE_XLSX && !sEmbedingPath.empty())
if(!sEmbedingPath.empty())
{ {
std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx"; std::wstring sXlsxFilename = L"Microsoft_Excel_Worksheet" + std::to_wstring(lChartNumber) + L".xlsx";
std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename; std::wstring sXlsxPath = sEmbedingPath + FILE_SEPARATOR_STR + sXlsxFilename;
...@@ -204,7 +206,7 @@ namespace BinXlsxRW{ ...@@ -204,7 +206,7 @@ namespace BinXlsxRW{
std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename; std::wstring sChartsWorksheetRelsName = L"../embeddings/" + sXlsxFilename;
long rId; long rId;
std::wstring bstrChartsWorksheetRelType = OOX::Spreadsheet::FileTypes::ChartsWorksheet.RelationType(); std::wstring bstrChartsWorksheetRelType = OOX::FileTypes::MicrosoftOfficeExcelWorksheet.RelationType();
m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId); m_pExternalDrawingConverter->WriteRels(bstrChartsWorksheetRelType, sChartsWorksheetRelsName, std::wstring(), &rId);
oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData(); oChartSpace.m_oChartSpace.m_externalData = new OOX::Spreadsheet::CT_ExternalData();
...@@ -228,17 +230,10 @@ namespace BinXlsxRW{ ...@@ -228,17 +230,10 @@ namespace BinXlsxRW{
OOX::CPath pathRelsFile = pathRelsDir + FILE_SEPARATOR_STR + strFilename + _T(".rels"); OOX::CPath pathRelsFile = pathRelsDir + FILE_SEPARATOR_STR + strFilename + _T(".rels");
m_pExternalDrawingConverter->SaveDstContentRels(pathRelsFile.GetPath()); m_pExternalDrawingConverter->SaveDstContentRels(pathRelsFile.GetPath());
std::wstring sContentType(sContentTypePath); pReader->m_pRels->m_pManager->m_pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml", sContentTypePath, strFilename);
sContentType += strFilename;
std::wstring sContent = L"<Override PartName=\"" + sContentType + L"\" ContentType=\"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\"/>";
sContent += oSaveParams.sAdditionalContentTypes;
(*sContentTypeElement) = new std::wstring(sContent);
bRes = true; bRes = true;
} }
}
return bRes; return bRes;
} }
void CXlsxSerializer::setFontDir(const std::wstring& sFontDir) void CXlsxSerializer::setFontDir(const std::wstring& sFontDir)
...@@ -271,8 +266,8 @@ namespace BinXlsxRW{ ...@@ -271,8 +266,8 @@ namespace BinXlsxRW{
OOX::Spreadsheet::CXlsx oXlsx; OOX::Spreadsheet::CXlsx oXlsx;
helper.toXlsx(oXlsx); helper.toXlsx(oXlsx);
//write //write
std::wstring sAdditionalContentTypes; OOX::CContentTypes oContentTypes;
oXlsx.Write(oPath, sAdditionalContentTypes); oXlsx.Write(oPath, oContentTypes);
//zip //zip
COfficeUtils oOfficeUtils(NULL); COfficeUtils oOfficeUtils(NULL);
oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true); oOfficeUtils.CompressFileOrDirectory(sTempDir, sDstFile, true);
......
...@@ -59,13 +59,13 @@ namespace BinXlsxRW { ...@@ -59,13 +59,13 @@ namespace BinXlsxRW {
CXlsxSerializer(); CXlsxSerializer();
~CXlsxSerializer(); ~CXlsxSerializer();
void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath); static void CreateXlsxFolders (const std::wstring& sXmlOptions, const std::wstring& sDstPath, std::wstring& sMediaPath, std::wstring& sEmbedPath);
bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath); bool loadFromFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions, const std::wstring& sMediaDir, const std::wstring& sEmbedPath);
bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions); bool saveToFile (const std::wstring& sSrcFileName, const std::wstring& sDstPath, const std::wstring& sXMLOptions);
bool loadChart (const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize); bool loadChart (const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter* pWriter, long& lDataSize);
bool saveChart (NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilename, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber); bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber);
void setFontDir (const std::wstring& sFontDir); void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir); void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
......
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
#ifndef SERIALIZER_COMMON #ifndef SERIALIZER_COMMON
#define SERIALIZER_COMMON #define SERIALIZER_COMMON
#include "../../DesktopEditor/common/File.h"
#include "../../Common/DocxFormat/Source/XML/Utils.h" #include "../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include <string> #include <string>
#include <vector> #include <vector>
......
This diff is collapsed.
...@@ -29,19 +29,19 @@ ...@@ -29,19 +29,19 @@
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
* *
*/ */
//Generated code
//#include "stdafx.h"
#include "ChartFromToBinary.h" #include "ChartFromToBinary.h"
#include "../../ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h"
#include "../Common/BinReaderWriterDefines.h"
#include "../Common/BinReaderWriterDefines.h" #include "../Common/BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Theme/ThemeOverride.h" #include "../../ASCOfficePPTXFile/Editor/BinReaderWriterDefines.h"
#include "../../ASCOfficeDocxFile2/BinReader/DefaultThemeWriter.h"
using namespace OOX::Spreadsheet; using namespace OOX::Spreadsheet;
namespace BinXlsxRW namespace BinXlsxRW
{ {
SaveParams::SaveParams(const std::wstring& _sThemePath) SaveParams::SaveParams(const std::wstring& _sThemePath, OOX::CContentTypes* _pContentTypes)
{ {
pContentTypes = _pContentTypes;
sThemePath = _sThemePath; sThemePath = _sThemePath;
nThemeOverrideCount = 1; nThemeOverrideCount = 1;
} }
...@@ -835,7 +835,8 @@ namespace BinXlsxRW ...@@ -835,7 +835,8 @@ namespace BinXlsxRW
BYTE c_oseralternatecontentfallbackSTYLE = 0; BYTE c_oseralternatecontentfallbackSTYLE = 0;
BinaryChartReader::BinaryChartReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, SaveParams& oSaveParams, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter):Binary_CommonReader(oBufferedStream),m_oSaveParams(oSaveParams),m_pOfficeDrawingConverter(pOfficeDrawingConverter) BinaryChartReader::BinaryChartReader(NSBinPptxRW::CBinaryFileReader& oBufferedStream, SaveParams& oSaveParams, NSBinPptxRW::CDrawingConverter* pOfficeDrawingConverter)
: Binary_CommonReader(oBufferedStream), m_oSaveParams(oSaveParams), m_pOfficeDrawingConverter(pOfficeDrawingConverter)
{} {}
int BinaryChartReader::ReadCT_extLst(BYTE type, long length, void* poResult) int BinaryChartReader::ReadCT_extLst(BYTE type, long length, void* poResult)
...@@ -954,9 +955,16 @@ namespace BinXlsxRW ...@@ -954,9 +955,16 @@ namespace BinXlsxRW
OOX::CPath pathThemeOverrideFile = m_oSaveParams.sThemePath + FILE_SEPARATOR_STR + sThemeOverrideName; OOX::CPath pathThemeOverrideFile = m_oSaveParams.sThemePath + FILE_SEPARATOR_STR + sThemeOverrideName;
long nCurPos = m_oBufferedStream.GetPos(); smart_ptr<PPTX::Theme> pTheme = new PPTX::Theme();
m_pOfficeDrawingConverter->SaveThemeXml(nCurPos, length, pathThemeOverrideFile.GetPath()); pTheme->isThemeOverride = true;
m_oBufferedStream.Seek(nCurPos + length);
pTheme->fromPPTY(&m_oBufferedStream);
NSBinPptxRW::CXmlWriter xmlWriter;
pTheme->toXmlWriter(&xmlWriter);
Writers::DefaultThemeWriter oThemeFile;
oThemeFile.m_sContent = xmlWriter.GetXmlString();
oThemeFile.Write(pathThemeOverrideFile.GetPath());
long rId; long rId;
m_pOfficeDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride")), sThemeOverrideRelsPath, std::wstring(), &rId); m_pOfficeDrawingConverter->WriteRels(std::wstring(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride")), sThemeOverrideRelsPath, std::wstring(), &rId);
...@@ -968,11 +976,7 @@ namespace BinXlsxRW ...@@ -968,11 +976,7 @@ namespace BinXlsxRW
std::wstring sContentTypesPath = m_oSaveParams.sThemePath.substr(nIndex + 1); std::wstring sContentTypesPath = m_oSaveParams.sThemePath.substr(nIndex + 1);
XmlUtils::replace_all(sContentTypesPath, L"\\", L"/"); XmlUtils::replace_all(sContentTypesPath, L"\\", L"/");
std::wstring strType = L"<Override PartName=\"/"; m_oSaveParams.pContentTypes->Registration(L"application/vnd.openxmlformats-officedocument.themeOverride+xml", sContentTypesPath, sThemeOverrideName);
strType += sContentTypesPath + L"/" + sThemeOverrideName;
strType += L"\" ContentType=\"application/vnd.openxmlformats-officedocument.themeOverride+xml\"/>";
m_oSaveParams.sAdditionalContentTypes += strType;
} }
} }
else else
...@@ -6161,13 +6165,10 @@ namespace BinXlsxRW ...@@ -6161,13 +6165,10 @@ namespace BinXlsxRW
smart_ptr<OOX::File> pFile = oChartSpace.Find(OOX::FileTypes::ThemeOverride); smart_ptr<OOX::File> pFile = oChartSpace.Find(OOX::FileTypes::ThemeOverride);
if (pFile.IsInit() && OOX::FileTypes::ThemeOverride == pFile->type()) if (pFile.IsInit() && OOX::FileTypes::ThemeOverride == pFile->type())
{ {
OOX::CThemeOverride* pThemeOverride = static_cast<OOX::CThemeOverride*>(pFile.operator->()); PPTX::Theme* pThemeOverride = static_cast<PPTX::Theme*>(pFile.operator->());
BYTE* pThemeData = NULL;
long nThemeDataSize = 0;
m_pOfficeDrawingConverter->GetThemeBinary(&pThemeData, nThemeDataSize, pThemeOverride->m_oReadPath.GetPath());
m_oBcw.m_oStream.WriteBYTE(c_oserct_chartspaceTHEMEOVERRIDE); m_oBcw.m_oStream.WriteBYTE(c_oserct_chartspaceTHEMEOVERRIDE);
m_oBcw.WriteBytesArray(pThemeData, nThemeDataSize); pThemeOverride->toPPTY(&m_oBcw.m_oStream);
RELEASEARRAYOBJECTS(pThemeData);
} }
} }
void BinaryChartWriter::WriteCT_Boolean(CT_Boolean& oVal) void BinaryChartWriter::WriteCT_Boolean(CT_Boolean& oVal)
......
...@@ -38,14 +38,17 @@ ...@@ -38,14 +38,17 @@
#include "../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h" #include "../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h"
using namespace OOX::Spreadsheet; using namespace OOX::Spreadsheet;
namespace BinXlsxRW { namespace BinXlsxRW
{
class SaveParams class SaveParams
{ {
public: public:
SaveParams (const std::wstring& _sThemePath, OOX::CContentTypes *pContentTypes);
smart_ptr<PPTX::Theme> pTheme;
std::wstring sThemePath; std::wstring sThemePath;
std::wstring sAdditionalContentTypes; OOX::CContentTypes* pContentTypes;
int nThemeOverrideCount; int nThemeOverrideCount;
SaveParams(const std::wstring& _sThemePath);
}; };
class BinaryChartReader : public Binary_CommonReader<BinaryChartReader> class BinaryChartReader : public Binary_CommonReader<BinaryChartReader>
......
This diff is collapsed.
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