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
{
class ChartWriter
{
class ChartElem
struct _chartElem
{
public:
std::wstring content;
std::wstring filename;
int index;
std::wstring content;
std::wstring filename;
int index;
};
std::vector<ChartElem*> m_aCharts;
ContentTypesWriter& m_oContentTypesWriter;
int nChartCount;
std::vector<_chartElem> m_aCharts;
int nChartCount;
public:
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;
}
~ChartWriter()
{
for(size_t i = 0, length = m_aCharts.size(); i < length; ++i)
{
delete m_aCharts[i];
}
}
bool IsEmpty()
{
return 0 == m_aCharts.size();
}
void Write()
bool Write()
{
if(false == IsEmpty())
{
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)
{
ChartElem* elem = m_aCharts[i];
if(IsEmpty()) return false;
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename;
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
for(size_t i = 0; i < m_aCharts.size(); ++i)
{
_chartElem & elem = m_aCharts[i];
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem.filename;
//Content_Types
std::wstring sRelPath = L"/word/charts/" + elem->filename;
m_oContentTypesWriter.AddOverride(sRelPath, L"application/vnd.openxmlformats-officedocument.drawingml.chart+xml");
}
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n");
oFile.WriteStringUTF8(elem.content);
oFile.CloseFile();
}
return true;
}
void AddChart(std::wstring& content, std::wstring& sRelsName, std::wstring& sFileName, int& index)
{
ChartElem* pChartElem = new ChartElem();
pChartElem->content = content;
pChartElem->index = nChartCount + 1;
_chartElem oChartElem;
oChartElem.content = content;
oChartElem.index = nChartCount + 1;
nChartCount++;
pChartElem->filename = L"chart" + std::to_wstring(pChartElem->index) + L".xml";
oChartElem.filename = L"chart" + std::to_wstring(oChartElem.index) + L".xml";
sRelsName = L"charts/" + pChartElem->filename;
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()
{
......
......@@ -46,20 +46,19 @@ namespace Writers
class CommentsWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
std::wstring m_sComment;
std::wstring m_sCommentExt;
std::wstring m_sPeople;
public:
CommentsWriter(std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
std::wstring m_sComment;
std::wstring m_sCommentExt;
std::wstring m_sPeople;
CommentsWriter(std::wstring sDir) : m_sDir(sDir)
{
}
void setElements(std::wstring& sComment, std::wstring& sCommentExt, std::wstring& sPeople)
{
m_sComment = sComment;
m_sCommentExt = sCommentExt;
m_sPeople = sPeople;
m_sComment = sComment;
m_sCommentExt = sCommentExt;
m_sPeople = sPeople;
}
void Write()
{
......@@ -67,42 +66,30 @@ namespace Writers
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("comments.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(g_string_comment_Start);
oFile.WriteStringUTF8(m_sComment);
oFile.WriteStringUTF8(g_string_comment_End);
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())
{
CFile oFile;
oFile.CreateFile(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("commentsExtended.xml"));
NSFile::CFileBinary oFile;
oFile.CreateFileW(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("commentsExtended.xml"));
oFile.WriteStringUTF8(g_string_commentExt_Start);
oFile.WriteStringUTF8(m_sCommentExt);
oFile.WriteStringUTF8(g_string_commentExt_End);
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())
{
CFile oFile;
oFile.CreateFile(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("people.xml"));
NSFile::CFileBinary oFile;
oFile.CreateFileW(m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("people.xml"));
oFile.WriteStringUTF8(g_string_people_Start);
oFile.WriteStringUTF8(m_sPeople);
oFile.WriteStringUTF8(g_string_people_End);
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
class DefaultThemeWriter
{
public:
DefaultThemeWriter()
std::wstring m_sContent;
DefaultThemeWriter( )
{
}
void Write(std::wstring sThemeFilePath)
{
std::wstring s_Common;
s_Common = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?> \
<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\"> \
if (m_sContent.empty())
{
m_sContent = _T("<a:theme xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" name=\"Office Theme\">\
<a:themeElements> \
<a:clrScheme name=\"Office\"> \
<a:dk1> \
......@@ -87,7 +88,7 @@ namespace Writers
<a:srgbClr val=\"800080\"/> \
</a:folHlink> \
</a:clrScheme> ");
s_Common +=
m_sContent +=
_T("<a:fontScheme name=\"Office\"> \
<a:majorFont> \
<a:latin typeface=\"Cambria\"/> \
......@@ -158,7 +159,7 @@ s_Common +=
<a:font script=\"Uigh\" typeface=\"Microsoft Uighur\"/> \
</a:minorFont> \
</a:fontScheme>");
s_Common +=
m_sContent +=
_T("<a:fmtScheme name=\"Office\"> \
<a:fillStyleLst> \
<a:solidFill> \
......@@ -329,13 +330,14 @@ s_Common +=
<a:objectDefaults/> \
<a:extraClrSchemeLst/> \
</a:theme>");
}
OOX::CPath fileName = sThemeFilePath;
CFile oFile;
oFile.CreateFile(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
NSFile::CFileBinary oFile;
oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(L"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
oFile.WriteStringUTF8(m_sContent);
oFile.CloseFile();
}
};
......
......@@ -56,8 +56,8 @@ namespace Writers
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels");
CFile oFile;
oFile.CreateFile(fileName.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
oFile.CloseFile();
}
......
......@@ -51,8 +51,8 @@ namespace Writers
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") +FILE_SEPARATOR_STR + _T("document.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
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\">")));
......
......@@ -31,6 +31,7 @@
*/
#ifndef FILE_WRITER
#define FILE_WRITER
#include "../../DesktopEditor/common/Path.h"
#include "NumberingWriter.h"
#include "fontTableWriter.h"
......@@ -45,19 +46,21 @@
#include "webSettingsWriter.h"
#include "DefaultThemeWriter.h"
namespace BinDocxRW {
namespace BinDocxRW
{
class CComments;
}
namespace NSBinPptxRW
{
class CDrawingConverter;
}
namespace Writers
{
class FileWriter
{
public:
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
std::wstring m_sThemePath;
bool m_bSaveChartAsImg;
ContentTypesWriter m_oContentTypesWriter;
public:
FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter;
......@@ -71,35 +74,57 @@ namespace Writers
ChartWriter m_oChartWriter;
DocumentRelsWriter m_oDocumentRelsWriter;
WebSettingsWriter m_oWebSettingsWriter;
DefaultThemeWriter m_oDefaultTheme;
int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments;
public:
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_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir, bNoFontDir),
m_oHeaderFooterWriter(sDirOutput, m_oContentTypesWriter),
m_oFootnotesWriter(sDirOutput, m_oContentTypesWriter),
m_oEndnotesWriter(sDirOutput, m_oContentTypesWriter),
m_oMediaWriter(sDirOutput),
m_oStylesWriter(sDirOutput, nVersion),
m_oNumberingWriter(sDirOutput, m_oContentTypesWriter),
m_oDocumentWriter(sDirOutput, m_oHeaderFooterWriter),
m_oSettingWriter(sDirOutput, m_oHeaderFooterWriter),
m_oCommentsWriter(sDirOutput, m_oContentTypesWriter),
m_oChartWriter(sDirOutput, m_oContentTypesWriter),
m_oDocumentRelsWriter(sDirOutput),
m_oWebSettingsWriter(sDirOutput),
DefaultThemeWriter m_oTheme;
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
bool m_bSaveChartAsImg;
std::wstring m_sThemePath;
int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments;
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_oFontTableWriter (sDirOutput, sFontDir, bNoFontDir),
m_oHeaderFooterWriter (sDirOutput),
m_oFootnotesWriter (sDirOutput),
m_oEndnotesWriter (sDirOutput),
m_oMediaWriter (sDirOutput),
m_oStylesWriter (sDirOutput, nVersion),
m_oNumberingWriter (sDirOutput),
m_oDocumentWriter (sDirOutput, m_oHeaderFooterWriter),
m_oSettingWriter (sDirOutput, m_oHeaderFooterWriter),
m_oCommentsWriter (sDirOutput),
m_oChartWriter (sDirOutput),
m_oDocumentRelsWriter (sDirOutput),
m_oWebSettingsWriter (sDirOutput),
m_nDocPrIndex(0),
m_pComments(NULL)
{
}
public: int getNextDocPr()
{
m_nDocPrIndex++;
return m_nDocPrIndex;
}
int getNextDocPr()
{
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
......@@ -33,6 +33,7 @@
#define HEADER_FOOTER_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../Common/DocxFormat/Source/Common/SimpleTypes_Word.h"
namespace Writers
{
......@@ -54,10 +55,10 @@ namespace Writers
{
return m_sFilename.empty();
}
std::wstring m_sFilename;
ContentWriter Header;
std::wstring rId;
SimpleTypes::EHdrFtr eType;
std::wstring m_sFilename;
ContentWriter Header;
std::wstring rId;
SimpleTypes::EHdrFtr eType;
};
static std::wstring g_string_hdr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:hdr 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\">");
static std::wstring g_string_hdr_End = _T("</w:hdr>");
......@@ -74,12 +75,11 @@ namespace Writers
class HeaderFooterWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
std::vector<HdrFtrItem*> m_aHeaders;
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()
......@@ -109,8 +109,8 @@ namespace Writers
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_Start);
......@@ -122,43 +122,33 @@ namespace Writers
else
oFile.WriteStringUTF8(g_string_ftr_End);
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
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
ContentWriter m_oNotesWriter;
FootnotesWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
FootnotesWriter( std::wstring sDir ):m_sDir(sDir)
{
}
void Write()
{
if(!IsEmpty())
{
std::wstring sFilename = getFilename();
if(IsEmpty()) return;
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + sFilename;
std::wstring sFilename = getFilename();
CFile oFile;
oFile.CreateFile(filePath);
oFile.WriteStringUTF8(g_string_footnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_footnotes_End);
oFile.CloseFile();
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + sFilename;
//ContentType
m_oContentTypesWriter.AddOverride(L"/word/" + sFilename, L"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml");
}
NSFile::CFileBinary oFile;
oFile.CreateFileW (filePath);
oFile.WriteStringUTF8 (g_string_footnotes_Start);
oFile.WriteStringUTF8 (m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8 (g_string_footnotes_End);
oFile.CloseFile();
}
std::wstring getFilename()
std::wstring getFilename()
{
return _T("footnotes.xml");
}
......@@ -169,33 +159,29 @@ namespace Writers
};
class EndnotesWriter
{
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
std::wstring m_sDir;
public:
ContentWriter m_oNotesWriter;
EndnotesWriter( std::wstring sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
EndnotesWriter( std::wstring sDir ) : m_sDir(sDir)
{
}
void Write()
{
if(!IsEmpty())
{
std::wstring sFilename = getFilename();
if(IsEmpty()) return;
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
std::wstring sFilename = getFilename();
CFile oFile;
oFile.CreateFile(filePath);
oFile.WriteStringUTF8(g_string_endnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_endnotes_End);
oFile.CloseFile();
std::wstring filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
//ContentType
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml"));
}
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath);
oFile.WriteStringUTF8(g_string_endnotes_Start);
oFile.WriteStringUTF8(m_oNotesWriter.m_oContent.GetData());
oFile.WriteStringUTF8(g_string_endnotes_End);
oFile.CloseFile();
}
std::wstring getFilename()
std::wstring getFilename()
{
return _T("endnotes.xml");
}
......
......@@ -32,7 +32,6 @@
#ifndef NUMBERING_WRITER
#define NUMBERING_WRITER
#include "ContentTypesWriter.h"
#include "DocumentRelsWriter.h"
namespace Writers
......@@ -43,13 +42,12 @@ namespace Writers
class NumberingWriter
{
XmlUtils::CStringWriter m_oWriter;
std::wstring m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
std::wstring m_sDir;
public:
XmlUtils::CStringWriter m_oANum;
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()
......@@ -58,26 +56,20 @@ namespace Writers
}
void Write()
{
if(false == IsEmpty())
{
m_oWriter.WriteString(g_string_n_Start);
m_oWriter.Write(m_oANum);
m_oWriter.Write(m_oNumList);
m_oWriter.WriteString(g_string_n_End);
if(IsEmpty()) return;
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml");
m_oWriter.WriteString(g_string_n_Start);
m_oWriter.Write(m_oANum);
m_oWriter.Write(m_oNumList);
m_oWriter.WriteString(g_string_n_End);
CFile oFile;
oFile.CreateFile(filePath.GetPath());
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml");
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
//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"));
}
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
};
}
......
......@@ -34,6 +34,8 @@
#include "../../Common/DocxFormat/Source/XML/Utils.h"
#include <boost/algorithm/string.hpp>
namespace BinDocxRW {
class SectPr
......@@ -1881,7 +1883,12 @@ public:
class CDrawingProperty
{
public:
long DataPos;
bool bObject;
std::wstring sObjectProgram;
long nObjectId;
BYTE nObjectType;
long DataPos;
long DataLength;
BYTE Type;
bool BehindDoc;
......@@ -1914,8 +1921,8 @@ public:
int m_nDocPr;
std::wstring sGraphicFramePr;
std::wstring sDocPr;
CDrawingPropertyWrap DrawingPropertyWrap;
CDrawingPropertyWrap DrawingPropertyWrap;
bool bDataPos;
bool bDataLength;
......@@ -1949,6 +1956,10 @@ public:
CDrawingProperty(int nDocPr)
{
m_nDocPr = nDocPr;
bObject = false;
nObjectType = 0;
nObjectId = 0;
bDataPos = false;
bDataLength = false;
bType = false;
......
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#ifndef CONTENT_TYPES_WRITER
#define CONTENT_TYPES_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
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
{
XmlUtils::CStringWriter m_oWriter;
std::wstring m_sDir;
XmlUtils::CStringWriter m_oAdditional;
public:
ContentTypesWriter(std::wstring sDir) : m_sDir(sDir)
{
}
void Write()
{
m_oWriter.WriteString(g_string_ct_Start);
m_oWriter.WriteString(g_string_ct_Ext);
m_oWriter.WriteString(g_string_ct_Override);
m_oWriter.Write(m_oAdditional);
m_oWriter.WriteString(g_string_ct_End);
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)
{
std::wstring sOverride = L"<Override PartName=\"" + PartName+ L"\" ContentType=\"" + ContentType + L"\"/>";
m_oAdditional.WriteString(sOverride);
}
void AddOverrideRaw(const std::wstring& sXml)
{
m_oAdditional.WriteString(sXml);
}
};
}
#endif // #ifndef CONTENT_TYPES_WRITER
/*
* (c) Copyright Ascensio System SIA 2010-2017
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
#include "Readers.h"
namespace BinDocxRW {
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 )
{
nCurType = type;
res = Read1(length, &Binary_HdrFtrTableReader::ReadHdrFtrFEO, this, poResult);
}
else
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);
}
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 )
{
Writers::HdrFtrItem* poHdrFtrItem = NULL;
switch(nCurHeaderType)
{
case c_oSerHdrFtrTypes::HdrFtr_First:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrFirst);break;
case c_oSerHdrFtrTypes::HdrFtr_Even:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrEven);break;
case c_oSerHdrFtrTypes::HdrFtr_Odd:poHdrFtrItem = new Writers::HdrFtrItem(SimpleTypes::hdrftrDefault);break;
}
if(NULL != poHdrFtrItem)
{
if(nCurType == c_oSerHdrFtrTypes::Header)
{
m_oHeaderFooterWriter.m_aHeaders.push_back(poHdrFtrItem);
poHdrFtrItem->m_sFilename = L"header" + std::to_wstring((int)m_oHeaderFooterWriter.m_aHeaders.size()) + L".xml";
}
else
{
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
This diff is collapsed.
......@@ -42,9 +42,9 @@ namespace Writers
class SettingWriter
{
std::wstring m_sDir;
XmlUtils::CStringWriter m_oSettingWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
std::wstring m_sDir;
XmlUtils::CStringWriter m_oSettingWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
SettingWriter(std::wstring sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir),m_oHeaderFooterWriter(oHeaderFooterWriter)
{
......@@ -54,8 +54,8 @@ namespace Writers
Prepare();
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + L"word" + FILE_SEPARATOR_STR + L"settings.xml";
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(g_string_set_Start);
oFile.WriteStringUTF8(m_oSettingWriter.GetData());
oFile.WriteStringUTF8(g_string_set_Default);
......
......@@ -58,7 +58,6 @@ namespace Writers
}
void Write()
{
m_oWriter.WriteString(g_string_st_Start);
m_oWriter.WriteString(std::wstring(_T("<w:docDefaults>")));
m_oWriter.WriteString(std::wstring(_T("<w:rPrDefault>")));
......@@ -81,8 +80,8 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("styles.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
......
......@@ -34,6 +34,7 @@
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
namespace Writers
{
......@@ -48,8 +49,8 @@ namespace Writers
CFontManager* m_pFontManager;
public:
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;
if(!bNoFontDir)
......@@ -102,8 +103,8 @@ namespace Writers
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("fontTable.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
......
......@@ -54,8 +54,8 @@ namespace Writers
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("webSettings.xml");
CFile oFile;
oFile.CreateFile(fileName.GetPath());
NSFile::CFileBinary oFile;
oFile.CreateFileW(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
oFile.CloseFile();
}
......
......@@ -33,13 +33,11 @@
#define BINEQUATIONWRITER_H
#include "BinReaderWriterDefines.h"
#include "../../Common/DocxFormat/Source/Common/SimpleTypes_OMath.h"
#include "../../Common/DocxFormat/Source/MathEquation/OutputDev.h"
#include <stack>
/*namespace BinDocxRW
{
class BinaryCommonWriter;
}*/
namespace MathEquation
{
class EquationRun
......
......@@ -997,6 +997,12 @@ extern int g_nCurFormatVersion;
Title = 3,
Descr = 4
};}
namespace c_oSerEmbedded{enum c_oSerEmbedded
{
Type = 0,
Data = 1,
Program = 2
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
......@@ -35,9 +35,9 @@
namespace BinDocxRW
{
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()
{
int nStart = m_oBcw.WriteItemWithLengthStart();
......@@ -57,7 +57,7 @@ namespace BinDocxRW
m_oBcw.WriteItemEnd(nCurPos);
}
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)
{
int nCurPos = 0;
......@@ -69,26 +69,26 @@ namespace BinDocxRW
BYTE byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;
switch(eType)
{
case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First;break;
case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even;break;
default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd;break;
case SimpleTypes::hdrftrFirst: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_First; break;
case SimpleTypes::hdrftrEven: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Even; break;
default: byteHdrFtrType = c_oSerHdrFtrTypes::HdrFtr_Odd; break;
}
nCurPos = m_oBcw.WriteItemStart(byteHdrFtrType);
WriteHdrFtrItem(pSectPr, pHdrFtr, bHdr);
m_oBcw.WriteItemEnd(nCurPos);
}
};
}
void BinaryHeaderFooterTableWriter::WriteHdrFtrItem(OOX::Logic::CSectionProperty* pSectPr, OOX::CHdrFtr* pHdrFtr, bool bHdr)
{
int nCurPos = 0;
//Content
ParamsDocumentWriter oParamsDocumentWriter(pHdrFtr, pHdrFtr->m_oReadPath.GetPath());
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath;
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_sDocumentPath, pHdrFtr->m_arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
};
{
int nCurPos = 0;
//Content
ParamsDocumentWriter oParamsDocumentWriter(pHdrFtr, pHdrFtr->m_oReadPath.GetPath());
m_oParamsWriter.m_pCurRels = oParamsDocumentWriter.m_pRels;
m_oParamsWriter.m_sCurDocumentPath = oParamsDocumentWriter.m_sDocumentPath;
BinaryDocumentTableWriter oBinaryDocumentTableWriter(m_oParamsWriter, oParamsDocumentWriter, m_mapIgnoreComments, NULL);
oBinaryDocumentTableWriter.prepareOfficeDrawingConverter(m_pOfficeDrawingConverter, oParamsDocumentWriter.m_sDocumentPath, pHdrFtr->m_arrShapeTypes);
nCurPos = m_oBcw.WriteItemStart(c_oSerHdrFtrTypes::HdrFtr_Content);
oBinaryDocumentTableWriter.WriteDocumentContent(pHdrFtr->m_arrItems);
m_oBcw.WriteItemEnd(nCurPos);
}
}
This diff is collapsed.
......@@ -51,14 +51,16 @@ namespace BinDocxRW
class CDocxSerializer
{
public:
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter;
public:
std::wstring m_sFontDir;
std::wstring m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bSaveChartAsImg;
ParamsWriter* m_pParamsWriter;
Writers::FileWriter* m_pCurFileWriter;
CDocxSerializer();
virtual ~CDocxSerializer();
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);
......
......@@ -80,24 +80,24 @@ namespace DocWrapper {
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;
std::wstring sFontName;
if(NULL != pTheme && oScheme.IsInit() && oScheme->m_oFontScheme.IsInit())
{
//берем шрифт из темы
//берем шрифт из темы
const SimpleTypes::Spreadsheet::EFontScheme eFontScheme = oScheme->m_oFontScheme->GetValue();
if(SimpleTypes::Spreadsheet::fontschemeMajor == eFontScheme)
sFontName = pTheme->GetMajorFont();
sFontName = pTheme->themeElements.fontScheme.majorFont.latin.typeface;
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())
sFontName = oRFont->ToString2();
if(sFontName.empty())
sFontName = std::wstring(gc_sNoNameFont);
//подбор перенесен в js
//подбор перенесен в js
return sFontName;
oFontSelectFormat.wsName = new std::wstring(sFontName);
......
......@@ -30,26 +30,29 @@
*
*/
#pragma once
//#include "../stdafx.h"
#include <map>
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;
}
namespace ComplexTypes{
namespace Spreadsheet{
namespace ComplexTypes
{
namespace Spreadsheet
{
class String;
}
}
namespace PPTX
{
class Theme;
}
namespace OOX
{
class CFont;
class CFontTable;
class CTheme;
namespace Spreadsheet
{
class CFont;
......@@ -61,9 +64,10 @@ namespace OOX
}
}
namespace DocWrapper {
class FontProcessor {
namespace DocWrapper
{
class FontProcessor
{
CFontManager* m_pFontManager;
std::map<std::wstring, std::wstring> fontMap;
......@@ -76,7 +80,7 @@ namespace DocWrapper {
void setFontTable(OOX::CFontTable* fontTable);
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:
void addToFontMap(OOX::CFont& font);
};
......
......@@ -59,13 +59,13 @@ namespace BinXlsxRW {
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 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 saveChart (NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, const std::wstring& sFilename, const std::wstring& sContentTypePath, std::wstring** sContentTypeElement, const long& lChartNumber);
bool loadChart (const std::wstring& sChartPath, NSBinPptxRW::CBinaryFileWriter* pWriter, long& lDataSize);
bool saveChart (NSBinPptxRW::CBinaryFileReader* pReader, long lLength, const std::wstring& sFilename, const long& lChartNumber);
void setFontDir (const std::wstring& sFontDir);
void setEmbeddedFontsDir(const std::wstring& sEmbeddedFontsDir);
......
......@@ -32,8 +32,8 @@
#ifndef SERIALIZER_COMMON
#define SERIALIZER_COMMON
#include "../../DesktopEditor/common/File.h"
#include "../../Common/DocxFormat/Source/XML/Utils.h"
#include "../../Common/DocxFormat/Source/SystemUtility/SystemUtility.h"
#include <string>
#include <vector>
......
This diff is collapsed.
......@@ -38,14 +38,17 @@
#include "../../ASCOfficePPTXFile/ASCOfficeDrawingConverter.h"
using namespace OOX::Spreadsheet;
namespace BinXlsxRW {
namespace BinXlsxRW
{
class SaveParams
{
public:
std::wstring sThemePath;
std::wstring sAdditionalContentTypes;
int nThemeOverrideCount;
SaveParams(const std::wstring& _sThemePath);
SaveParams (const std::wstring& _sThemePath, OOX::CContentTypes *pContentTypes);
smart_ptr<PPTX::Theme> pTheme;
std::wstring sThemePath;
OOX::CContentTypes* pContentTypes;
int nThemeOverrideCount;
};
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