Commit 0eedfe82 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

git-svn-id:...

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61917 954022d7-b5bf-4e40-9824-e11837661b57
parent 809065e7
......@@ -194,6 +194,17 @@ ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/TestFile.docx svn_mime_002dtype=app
ASCOfficeDocFile/Tests/DocFileTest/bin/Debug/test.doc svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocFile/pole svnc_tsvn_003alogminsize=5
ASCOfficeDocFile/pole/linux svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/BinReader/DefaultThemeWriterWin.h svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocxFile2/Mac svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/project.xcworkspace svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/project.xcworkspace/xcuserdata svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/project.xcworkspace/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/project.xcworkspace/xcuserdata/alexey.musinov.xcuserdatad/UserInterfaceState.xcuserstate svn_mime_002dtype=application%2Foctet-stream
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/xcuserdata svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad svnc_tsvn_003alogminsize=5
ASCOfficeDocxFile2/Mac/ASCOfficeDocxFile2Lib.xcodeproj/xcuserdata/alexey.musinov.xcuserdatad/xcschemes svnc_tsvn_003alogminsize=5
ASCOfficeEWSEditor/ASCOfficeEWSEditor/Editor/Charts svnc_bugtraq_003anumber=true
ASCOfficeFB2File/ASCOfficeFB2File/Resource/DocxTemplate.docx svn_mime_002dtype=application%2Foctet-stream
ASCOfficeFB2File/ASCOfficeFB2FileTest/ASCOfficeFB2FileTest/bin/Release/AVSOfficeFB2FileTest.exe svn_mime_002dtype=application%2Foctet-stream
......
......@@ -49,6 +49,27 @@ ASCImageStudio3/AVSImageRaw3/trunk/workingcopy/doxygen
ASCImageStudio3/AVSImageRaw3/trunk/workingcopy/lcmslib/bin
ASCImageStudio3/AVSImageRaw3/trunk/workingcopy/lcmslib/debug
ASCImageStudio3/AVSImageRaw3/trunk/workingcopy/lcmslib/release
ASCOfficeDocxFile2/AVSOfficeDocxFile2.ncb
ASCOfficeDocxFile2/AVSOfficeDocxFile2.suo
ASCOfficeDocxFile2/AVSOfficeDocxFile2.vcproj.AVSMEDIA.Dmitry.Davydov.user
ASCOfficeDocxFile2/BinReader/DefaultThemeWriter.h
ASCOfficeDocxFile2/Debug
ASCOfficeDocxFile2/DocWrapper/Debug
ASCOfficeDocxFile2/DocWrapper/Release
ASCOfficeDocxFile2/Release
ASCOfficeDocxFile2/ReleaseAVSOfficeDocxFile2.pdb
ASCOfficeDocxFile2/_AVSOfficeDocxFile2.h
ASCOfficeDocxFile2/_AVSOfficeDocxFile2.idl
ASCOfficeDocxFile2/_AVSOfficeDocxFile2.tlb
ASCOfficeDocxFile2/_AVSOfficeDocxFile2_i.c
ASCOfficeDocxFile2/_AVSOfficeDocxFile2_p.c
ASCOfficeDocxFile2/avsgraphics.tlh
ASCOfficeDocxFile2/avsimagestudio3.tlh
ASCOfficeDocxFile2/avsmediacore3.tlh
ASCOfficeDocxFile2/debug
ASCOfficeDocxFile2/msxml3.tlh
ASCOfficeDocxFile2/msxml3.tli
ASCOfficeDocxFile2/release
ASCOfficeOdpFile/*
ASCOfficeOdpFile/ODPFormat/Debug
ASCOfficeOdpFile/ODPFormat/ODPFormat.vcproj.AVSMEDIA.Viktor.Logunov.user
......
// AVSOfficeDocxFile2.cpp : Implementation of DLL Exports.
#include "stdafx.h"
#include "resource.h"
#include "DocxFile2.h"
#include "XlsxFile2.h"
#include "PptxFile.h"
// The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you
[ module(dll, uuid = "{A1EEE61A-FAA7-47af-B078-4E955623B9CA}",
name = "ASCOfficeDocxFile2",
helpstring = "ASCOfficeDocxFile2 1.0 Type Library",
resource_name = "IDR_ASCOFFICEDOCXFILE2") ];
\ No newline at end of file
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define COMPONENT_NAME "OfficeDocxFile2"
#include "../Common/FileInfo.h"
#include "version.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "winres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// Russian resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS)
#ifdef _WIN32
LANGUAGE LANG_RUSSIAN, SUBLANG_DEFAULT
#pragma code_page(1251)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // Russian resources
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""winres.h""\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION INTVER
PRODUCTVERSION INTVER
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", COMPANY_NAME
VALUE "FileDescription", FILE_DESCRIPTION_ACTIVEX
VALUE "FileVersion", STRVER
VALUE "InternalName", COMPONENT_FILE_NAME_DLL
VALUE "LegalCopyright", LEGAL_COPYRIGHT
VALUE "OriginalFilename", COMPONENT_FILE_NAME_DLL
VALUE "ProductName", FILE_DESCRIPTION_ACTIVEX
VALUE "ProductVersion", STRVER
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
/////////////////////////////////////////////////////////////////////////////
//
// REGISTRY
//
IDR_ASCOFFICEDOCXFILE2 REGISTRY "ASCOfficeDocxFile2.rgs"
/////////////////////////////////////////////////////////////////////////////
//
// String Table
//
STRINGTABLE
BEGIN
IDS_PROJNAME "ASCOfficeDocxFile2"
END
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ASCOfficeDocxFile2'
'ASCOfficeDocxFile2.DLL'
{
val AppID = s '%APPID%'
}
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef CHART_WRITER
#define CHART_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
class ChartWriter
{
class ChartElem
{
public:
CString content;
CString filename;
int index;
};
std::vector<ChartElem*> m_aCharts;
ContentTypesWriter& m_oContentTypesWriter;
int nChartCount;
public:
CString m_sDir;
public:
ChartWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
nChartCount = 0;
}
~ChartWriter()
{
for(int i = 0, length = m_aCharts.size(); i < length; ++i)
{
delete m_aCharts[i];
}
}
bool IsEmpty()
{
return 0 == m_aCharts.size();
}
void Write()
{
if(false == IsEmpty())
{
OOX::CPath pathChartDir = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("charts");
FileSystem::Directory::CreateDirectory(string2std_string(pathChartDir.GetPath()));
for(int i = 0, length = m_aCharts.size(); i < length; ++i)
{
ChartElem* elem = m_aCharts[i];
OOX::CPath filePath = pathChartDir + FILE_SEPARATOR_STR + elem->filename;
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\r\n")));
oFile.WriteStringUTF8(elem->content);
oFile.CloseFile();
//Content_Types
CString sRelPath = _T("/word/charts/") + elem->filename;
m_oContentTypesWriter.AddOverride(sRelPath, CString(_T("application/vnd.openxmlformats-officedocument.drawingml.chart+xml")));
}
}
}
void AddChart(CString& content, CString& sRelsName, CString& sFileName, int& index)
{
ChartElem* pChartElem = new ChartElem();
pChartElem->content = content;
pChartElem->index = nChartCount + 1;
nChartCount++;
pChartElem->filename.Format(_T("chart%d.xml"), pChartElem->index);
sRelsName = _T("charts/") + pChartElem->filename;
sFileName = pChartElem->filename;
index = pChartElem->index;
m_aCharts.push_back(pChartElem);
}
int getChartCount()
{
return nChartCount;
}
void setChartCount(int val)
{
nChartCount = val;
}
};
}
#endif // #ifndef CHART_WRITER
#ifndef COMMENTS_WRITER
#define COMMENTS_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
static CString g_string_comment_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:comments 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:w15=\"http://schemas.microsoft.com/office/word/2012/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 w15 wp14\">");
static CString g_string_comment_End = _T("</w:comments>");
static CString g_string_commentExt_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w15:commentsEx 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:w15=\"http://schemas.microsoft.com/office/word/2012/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 w15 wp14\">");
static CString g_string_commentExt_End = _T("</w15:commentsEx>");
static CString g_string_people_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w15:people 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:w15=\"http://schemas.microsoft.com/office/word/2012/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 w15 wp14\">");
static CString g_string_people_End = _T("</w15:people>");
class CommentsWriter
{
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
CString m_sComment;
CString m_sCommentExt;
CString m_sPeople;
public:
CommentsWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
void setElements(CString& sComment, CString& sCommentExt, CString& sPeople)
{
m_sComment = sComment;
m_sCommentExt = sCommentExt;
m_sPeople = sPeople;
}
void Write()
{
if(false == m_sComment.IsEmpty())
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("comments.xml");
CFile oFile;
oFile.CreateFile(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(CString(_T("/word/comments.xml")), CString(_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.IsEmpty())
{
CFile oFile;
oFile.CreateFile(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(CString(_T("/word/commentsExtended.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml")));
}
if(false == m_sPeople.IsEmpty())
{
CFile oFile;
oFile.CreateFile(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(CString(_T("/word/people.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml")));
}
}
};
}
#endif // #ifndef COMMENTS_WRITER
#ifndef CONTENT_TYPES_WRITER
#define CONTENT_TYPES_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
static CString g_string_ct_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\">");
static CString g_string_ct_Ext = _T("<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\"/>");
static CString g_string_ct_Override = _T("<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 CString g_string_ct_End = _T("</Types>");
class ContentTypesWriter
{
XmlUtils::CStringWriter m_oWriter;
CString m_sDir;
XmlUtils::CStringWriter m_oAdditional;
public:
ContentTypesWriter(CString 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 + _T("/[Content_Types].xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
void AddOverride(const CString& PartName, const CString& ContentType)
{
CString sOverride;sOverride.Format(_T("<Override PartName=\"%ls\" ContentType=\"%ls\"/>"),PartName , ContentType);
m_oAdditional.WriteString(sOverride);
}
void AddOverrideRaw(const CString& sXml)
{
m_oAdditional.WriteString(sXml);
}
};
}
#endif // #ifndef CONTENT_TYPES_WRITER
This diff is collapsed.
#ifndef DOCUMENT_RELS_WRITER
#define DOCUMENT_RELS_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
class DocumentRelsWriter
{
CString m_sDir;
public:
DocumentRelsWriter(CString sDir):m_sDir(sDir)
{
}
void Write()
{
CString s_Common;
s_Common = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?> \
<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"> \
<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"word/document.xml\"/> \
<Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/> \
<Relationship Id=\"rId3\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\" Target=\"docProps/app.xml\"/> \
</Relationships>");
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR + _T("_rels") + FILE_SEPARATOR_STR + _T(".rels");
CFile oFile;
oFile.CreateFile(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
oFile.CloseFile();
}
};
}
#endif // #ifndef DOCUMENT_RELS_WRITER
#ifndef DOCUMENT_WRITER
#define DOCUMENT_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../BinWriter/BinReaderWriterDefines.h";
namespace Writers
{
class DocumentWriter : public ContentWriter
{
XmlUtils::CStringWriter m_oWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
CString m_sDir;
public:
DocumentWriter(CString sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir), m_oHeaderFooterWriter(oHeaderFooterWriter)
{
}
void Write()
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") +FILE_SEPARATOR_STR + _T("document.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(CString(_T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><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\"><w:body>")));
oFile.WriteStringUTF8(m_oContent.GetData());
oFile.WriteStringUTF8(CString(_T("<w:sectPr >")));
oFile.WriteStringUTF8(WriteSectPrHdrFtr());
oFile.WriteStringUTF8(m_oSecPr.GetData());
oFile.WriteStringUTF8(CString(_T("</w:sectPr>")));
oFile.WriteStringUTF8(CString(_T("</w:body></w:document>")));
oFile.CloseFile();
}
CString WriteSectPrHdrFtr()
{
CString sResult;
if(BinDocxRW::g_nCurFormatVersion < 5)
{
bool bTitlePage = false;
for(int i = 0, length = m_oHeaderFooterWriter.m_aHeaders.size(); i < length; ++i)
{
HdrFtrItem* pHeader = m_oHeaderFooterWriter.m_aHeaders[i];
if(false == pHeader->rId.IsEmpty())
{
if(SimpleTypes::hdrftrFirst == pHeader->eType)
{
sResult += _T("<w:headerReference w:type=\"first\" r:id=\"") + pHeader->rId + _T("\"/>");
bTitlePage = true;
}
else if(SimpleTypes::hdrftrEven == pHeader->eType)
{
sResult += _T("<w:headerReference w:type=\"even\" r:id=\"") + pHeader->rId + _T("\"/>");
}
else
{
sResult += _T("<w:headerReference w:type=\"default\" r:id=\"") + pHeader->rId + _T("\"/>");
}
}
}
for(int i = 0, length = m_oHeaderFooterWriter.m_aFooters.size(); i < length; ++i)
{
HdrFtrItem* pFooter = m_oHeaderFooterWriter.m_aFooters[i];
if(false == pFooter->rId.IsEmpty())
{
if(SimpleTypes::hdrftrFirst == pFooter->eType)
{
sResult += _T("<w:footerReference w:type=\"first\" r:id=\"") + pFooter->rId + _T("\"/>");
bTitlePage = true;
}
else if(SimpleTypes::hdrftrEven == pFooter->eType)
{
sResult += _T("<w:footerReference w:type=\"even\" r:id=\"") + pFooter->rId + _T("\"/>");
}
else
{
sResult += _T("<w:footerReference w:type=\"default\" r:id=\"") + pFooter->rId + _T("\"/>");
}
}
}
if(true == bTitlePage)
sResult += _T("<w:titlePg/>");
}
return sResult;
}
};
}
#endif // #ifndef DOCUMENT_WRITER
#ifndef FILE_WRITER
#define FILE_WRITER
#include "NumberingWriter.h"
#include "fontTableWriter.h"
#include "HeaderFooterWriter.h"
#include "DocumentWriter.h"
#include "MediaWriter.h"
#include "StylesWriter.h"
#include "SettingWriter.h"
#include "CommentsWriter.h"
#include "ChartWriter.h"
#include "DocumentRelsWriter.h"
#include "webSettingsWriter.h"
#if defined(_WIN32) || defined (_WIN64)
#include "DefaultThemeWriterWin.h"
#else
#include "DefaultThemeWriterLinux.h"
#endif
namespace BinDocxRW {
class CComments;
}
namespace Writers
{
class FileWriter
{
public:
NSBinPptxRW::CDrawingConverter* m_pDrawingConverter;
CString m_sThemePath;
bool m_bSaveChartAsImg;
ContentTypesWriter m_oContentTypesWriter;
FontTableWriter m_oFontTableWriter;
DocumentWriter m_oDocumentWriter;
MediaWriter m_oMediaWriter;
StylesWriter m_oStylesWriter;
NumberingWriter m_oNumberingWriter;
HeaderFooterWriter m_oHeaderFooterWriter;
SettingWriter m_oSettingWriter;
CommentsWriter m_oCommentsWriter;
ChartWriter m_oChartWriter;
DocumentRelsWriter m_oDocumentRelsWriter;
WebSettingsWriter m_oWebSettingsWriter;
DefaultThemeWriter m_oDefaultTheme;
int m_nDocPrIndex;
BinDocxRW::CComments* m_pComments;
public:
FileWriter(CString sDirOutput,CString sFontDir, int nVersion, bool bSaveChartAsImg, NSBinPptxRW::CDrawingConverter* pDrawingConverter, CString sThemePath):
m_pDrawingConverter(pDrawingConverter),m_sThemePath(sThemePath),m_bSaveChartAsImg(bSaveChartAsImg),
m_oContentTypesWriter(sDirOutput), m_oFontTableWriter(sDirOutput, sFontDir),
m_oHeaderFooterWriter(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),
m_nDocPrIndex(0),
m_pComments(NULL)
{
}
public: int getNextDocPr()
{
m_nDocPrIndex++;
return m_nDocPrIndex;
}
};
}
#endif // #ifndef FILE_WRITER
#ifndef HEADER_FOOTER_WRITER
#define HEADER_FOOTER_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
class ContentWriter
{
public:
XmlUtils::CStringWriter m_oContent;
XmlUtils::CStringWriter m_oSecPr;
};
class HdrFtrItem
{
public:
HdrFtrItem(SimpleTypes::EHdrFtr _eType)
{
eType = _eType;
}
bool IsEmpty()
{
return m_sFilename.IsEmpty();
}
CString m_sFilename;
ContentWriter Header;
CString rId;
SimpleTypes::EHdrFtr eType;
};
static CString 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 CString g_string_hdr_End = _T("</w:hdr>");
static CString g_string_ftr_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:ftr 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 CString g_string_ftr_End = _T("</w:ftr>");
class HeaderFooterWriter
{
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
std::vector<HdrFtrItem*> m_aHeaders;
std::vector<HdrFtrItem*> m_aFooters;
public:
HeaderFooterWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
~HeaderFooterWriter()
{
for(int i = 0, length = m_aHeaders.size(); i < length; ++i)
delete m_aHeaders[i];
m_aHeaders.clear();
for(int i = 0, length = m_aFooters.size(); i < length; ++i)
delete m_aFooters[i];
m_aFooters.clear();
}
void Write()
{
for(int i = 0, length = m_aHeaders.size(); i < length; ++i)
{
HdrFtrItem* pHeader = m_aHeaders[i];
WriteItem(_T("header"), pHeader->m_sFilename, pHeader->Header, true);
}
for(int i = 0, length = m_aFooters.size(); i < length; ++i)
{
HdrFtrItem* pFooter = m_aFooters[i];
WriteItem(_T("footer"), pFooter->m_sFilename, pFooter->Header, false);
}
}
void WriteItem(CString sHeader, CString& sFilename, ContentWriter& m_oWriter, bool bHeader)
{
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + sFilename;
CFile oFile;
oFile.CreateFile(filePath.GetPath());
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_Start);
else
oFile.WriteStringUTF8(g_string_ftr_Start);
oFile.WriteStringUTF8(m_oWriter.m_oContent.GetData());
if(bHeader)
oFile.WriteStringUTF8(g_string_hdr_End);
else
oFile.WriteStringUTF8(g_string_ftr_End);
oFile.CloseFile();
//Content_Types
m_oContentTypesWriter.AddOverride(_T("/word/") + sFilename, _T("application/vnd.openxmlformats-officedocument.wordprocessingml.")+sHeader+_T("+xml"));
//Rels
//return m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/") + sHeader, sFilename);
}
};
}
#endif // #ifndef HEADER_FOOTER_WRITER
#ifndef MEDIA_WRITER
#define MEDIA_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
class MediaWriter
{
XmlUtils::CStringWriter m_oWriter;
CString m_sDir;
CString m_sMediaDir;
public:
std::vector<CString> m_aImageNames;
long nImageCount;
public:
MediaWriter(CString sDir):m_sDir(sDir)
{
nImageCount = 0;
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR + _T("word") + FILE_SEPARATOR_STR + _T("media");
m_sMediaDir = filePath.GetPath();
}
CString AddImageGetNewPath()
{
OOX::CSystemUtility::CreateDirectories(m_sMediaDir);
CString sNewImgName;sNewImgName.Format(_T("image%d.jpg"), (nImageCount + 1));
CString sNewImg = m_sMediaDir + FILE_SEPARATOR_STR + sNewImgName;
nImageCount++;
return sNewImg;
}
void AddImage2(FILE* pFile)
{
long size = ftell(pFile);
if(size > 0)
{
rewind(pFile);
BYTE* pData = new BYTE[size];
DWORD dwSizeRead = (DWORD)fread((void*)pData, 1, size, pFile);
if(dwSizeRead > 0)
{
CString sNewImagePath = AddImageGetNewPath();
NSFile::CFileBinary oFile;
oFile.CreateFileW(string2std_string(sNewImagePath));
oFile.WriteFile(pData, dwSizeRead);
oFile.CloseFile();
CString sFilename = NSSystemPath::GetFileName(string2std_string(sNewImagePath)).c_str();
m_aImageNames.push_back(sFilename);
}
RELEASEARRAYOBJECTS(pData);
}
}
void AddImage(const CString& sImg)
{
OOX::CPath pathNewImg = AddImageGetNewPath();
NSFile::CFileBinary::Copy(string2std_string(sImg), string2std_string(pathNewImg.GetPath()));
CString sFilename = NSSystemPath::GetFileName(string2std_string(pathNewImg.GetPath())).c_str();
m_aImageNames.push_back(sFilename);
}
};
}
#endif // #ifndef MEDIA_WRITER
#ifndef NUMBERING_WRITER
#define NUMBERING_WRITER
#include "ContentTypesWriter.h"
#include "DocumentRelsWriter.h"
namespace Writers
{
static CString g_string_n_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:numbering 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 CString g_string_n_End = _T("</w:numbering>");
class NumberingWriter
{
XmlUtils::CStringWriter m_oWriter;
CString m_sDir;
ContentTypesWriter& m_oContentTypesWriter;
public:
XmlUtils::CStringWriter m_oANum;
XmlUtils::CStringWriter m_oNumList;
public:
NumberingWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
{
}
bool IsEmpty()
{
return 0 == m_oANum.GetCurSize();
}
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);
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("numbering.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
//ContentType
m_oContentTypesWriter.AddOverride(CString(_T("/word/numbering.xml")), CString(_T("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml")));
//Rels
//m_oDocumentRelsWriter.AddRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"), _T("numbering.xml"));
}
}
};
}
#endif // #ifndef NUMBERING_WRITER
This diff is collapsed.
This diff is collapsed.
#ifndef SETTING_WRITER
#define SETTING_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
static CString g_string_set_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><w:settings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">");
static CString g_string_set_Default = _T("<w:zoom w:percent=\"100\"/><w:characterSpacingControl w:val=\"doNotCompress\"/><w:compat><w:compatSetting w:name=\"compatibilityMode\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"14\"/><w:compatSetting w:name=\"overrideTableStyleFontSizeAndJustification\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"enableOpenTypeFeatures\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/><w:compatSetting w:name=\"doNotFlipMirrorIndents\" w:uri=\"http://schemas.microsoft.com/office/word\" w:val=\"1\"/></w:compat><w:themeFontLang w:val=\"en-US\" w:eastAsia=\"zh-CN\"/><w:shapeDefaults><o:shapedefaults v:ext=\"edit\" spidmax=\"1026\"/><o:shapelayout v:ext=\"edit\"><o:idmap v:ext=\"edit\" data=\"1\"/></o:shapelayout></w:shapeDefaults><w:decimalSymbol w:val=\".\"/><w:listSeparator w:val=\",\"/>");
static CString g_string_set_End = _T("</w:settings>");
class SettingWriter
{
CString m_sDir;
XmlUtils::CStringWriter m_oSettingWriter;
HeaderFooterWriter& m_oHeaderFooterWriter;
public:
SettingWriter(CString sDir, HeaderFooterWriter& oHeaderFooterWriter):m_sDir(sDir),m_oHeaderFooterWriter(oHeaderFooterWriter)
{
}
void Write()
{
Prepare();
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("settings.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(g_string_set_Start);
oFile.WriteStringUTF8(m_oSettingWriter.GetData());
oFile.WriteStringUTF8(g_string_set_Default);
oFile.WriteStringUTF8(g_string_set_End);
oFile.CloseFile();
}
void AddSetting(CString sSetting)
{
m_oSettingWriter.WriteString(sSetting);
}
void Prepare()
{
if(BinDocxRW::g_nCurFormatVersion < 5)
{
bool bevenAndOddHeaders = false;
for(int i = 0, length = m_oHeaderFooterWriter.m_aHeaders.size(); i < length; ++i)
{
HdrFtrItem* pHeader = m_oHeaderFooterWriter.m_aHeaders[i];
if(SimpleTypes::hdrftrEven == pHeader->eType)
bevenAndOddHeaders = true;
}
for(int i = 0, length = m_oHeaderFooterWriter.m_aFooters.size(); i < length; ++i)
{
HdrFtrItem* pFooter = m_oHeaderFooterWriter.m_aFooters[i];
if(SimpleTypes::hdrftrEven == pFooter->eType)
bevenAndOddHeaders = true;
}
if(bevenAndOddHeaders)
AddSetting(_T("<w:evenAndOddHeaders/>"));
}
}
};
}
#endif // #ifndef SETTING_WRITER
This diff is collapsed.
#ifndef FONT_TABLE_WRITER
#define FONT_TABLE_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
namespace Writers
{
static CString g_string_ft_Start = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><w:fonts xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:w14=\"http://schemas.microsoft.com/office/word/2010/wordml\" mc:Ignorable=\"w14\">");
static CString g_string_ft_End = _T("</w:fonts>");
class FontTableWriter
{
XmlUtils::CStringWriter m_oWriter;
CString m_sDir;
CApplicationFonts m_oApplicationFonts;
CFontManager* m_pFontManager;
public:
std::map<CString, int> m_mapFonts;
public:
FontTableWriter(CString sDir, CString sFontDir):m_sDir(sDir)
{
if(sFontDir.IsEmpty())
m_oApplicationFonts.Initialize();
else
m_oApplicationFonts.InitializeFromFolder(string2std_string(sFontDir));
CFontList* pFontList = m_oApplicationFonts.GetList();
if(NULL != pFontList)
{
std::wstring sDefaultFont(_T("Arial"));
pFontList->SetDefaultFont(sDefaultFont);
}
m_pFontManager = m_oApplicationFonts.GenerateFontManager();
}
~FontTableWriter()
{
RELEASEOBJECT(m_pFontManager);
}
void Write()
{
m_oWriter.WriteString(g_string_ft_Start);
// FontTable
bool bCalibri = false;
bool bTimes = false;
bool bCambria = false;
for (std::map<CString, int>::const_iterator it = m_mapFonts.begin(); it != m_mapFonts.end(); ++it)
{
const CString& sFontName = it->first;
if(_T("Calibri") == sFontName)
bCalibri = true;
else if(_T("Times New Roman") == sFontName)
bTimes = true;
else if(_T("Cambria") == sFontName)
bCambria = true;
WriteFont(sFontName);
}
if(false == bCalibri)
WriteFont(_T("Calibri"));
if(false == bTimes)
WriteFont(_T("Times New Roman"));
if(false == bCambria)
WriteFont(_T("Cambria"));
m_oWriter.WriteString(g_string_ft_End);
OOX::CPath filePath = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("fontTable.xml");
CFile oFile;
oFile.CreateFile(filePath.GetPath());
oFile.WriteStringUTF8(m_oWriter.GetData());
oFile.CloseFile();
}
void WriteFont(CString sFontName)
{
CString sPanose;
bool bUsePanose = false;
if(NULL != m_pFontManager)
{
CFontSelectFormat oFontSelectFormat;
oFontSelectFormat.wsName = new std::wstring;
*oFontSelectFormat.wsName = std::wstring(sFontName.GetString());
CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelectFormat);
if(NULL != pFontInfo)
{
for(int i = 0; i < 10; ++i)
{
BYTE cElem = pFontInfo->m_aPanose[i];
if(0 != cElem)
bUsePanose = true;
if(cElem > 0xF)
sPanose.AppendFormat(_T("%X"), cElem);
else
sPanose.AppendFormat(_T("0%X"), cElem);
}
}
}
sFontName = XmlUtils::EncodeXmlString(sFontName);
m_oWriter.WriteString(_T("<w:font w:name=\"") + sFontName + _T("\">"));
if(bUsePanose && !sPanose.IsEmpty())
m_oWriter.WriteString(_T("<w:panose1 w:val=\"")+sPanose+_T("\"/>"));
m_oWriter.WriteString(CString(_T("</w:font>")));
}
};
}
#endif // #ifndef FONT_TABLE_WRITER
#ifndef WEB_SETTINGS_WRITER
#define WEB_SETTINGS_WRITER
#include "../../XlsxSerializerCom/Common/Common.h"
namespace Writers
{
class WebSettingsWriter
{
CString m_sDir;
public:
WebSettingsWriter(CString sDir):m_sDir(sDir)
{
}
void Write()
{
CString s_Common;
s_Common = _T("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?> \
<w:webSettings xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\"> \
<w:optimizeForBrowser/> \
</w:webSettings>");
OOX::CPath fileName = m_sDir + FILE_SEPARATOR_STR +_T("word") + FILE_SEPARATOR_STR + _T("webSettings.xml");
CFile oFile;
oFile.CreateFile(fileName.GetPath());
oFile.WriteStringUTF8(s_Common);
oFile.CloseFile();
}
};
}
#endif // #ifndef WEB_SETTINGS_WRITER
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef DOCX_SERIALIZER
#define DOCX_SERIALIZER
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
namespace Writers
{
class FileWriter;
}
namespace NSBinPptxRW
{
class CBinaryFileReader;
class CBinaryFileWriter;
}
namespace BinDocxRW
{
class BinaryFileWriter;
class CDocxSerializer
{
private:
CString m_sFontDir;
CString m_sEmbeddedFontsDir;
bool m_bIsNoBase64Save;
bool m_bSaveChartAsImg;
BinaryFileWriter* m_oBinaryFileWriter;
Writers::FileWriter* m_pCurFileWriter;
public:
CDocxSerializer();
bool ConvertDocxToDoct(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions);
bool ConvertDoctToDocx(const CString& sSrcFileName, const CString& sDstFileName, const CString& sTmpDir, const CString& sXMLOptions);
bool loadFromFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions, const CString& sThemePath, const CString& sMediaPath);
bool saveToFile(const CString& sSrcFileName, const CString& sDstPath, const CString& sXMLOptions);
void CreateDocxFolders(CString strDirectory, CString& sThemePath, CString& sMediaPath);
bool getXmlContent(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sOutputXml);
bool getBinaryContent(const CString& bsTxContent, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
void setFontDir(const CString& sFontDir);
void setEmbeddedFontsDir(const CString& sEmbeddedFontsDir);
void setIsNoBase64Save(bool bIsNoBase64Save);
void setSaveChartAsImg(bool bSaveChartAsImg);
};
}
#endif // #ifndef DOCX_SERIALIZER
This diff is collapsed.
#pragma once
//#include "../stdafx.h"
#include <map>
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
#include "../../DesktopEditor/fontengine/ApplicationFonts.h"
//#include "DocWrapper/Base.h"
namespace NSCommon{
template<class Type> class nullable;
}
namespace ComplexTypes{
namespace Spreadsheet{
class CString_;
}
}
namespace OOX
{
class CFont;
class CFontTable;
class CTheme;
namespace Spreadsheet
{
class CFont;
class CFontTable;
class CFontScheme;
class CString_;
class CCharset;
class CFontFamily;
}
}
namespace DocWrapper {
class FontProcessor {
CFontManager* m_pFontManager;
std::map<CString, CString> fontMap;
public:
FontProcessor();
~FontProcessor();
void setFontManager(CFontManager* pFontManager);
CFontManager* getFontManager();
void setFontTable(OOX::CFontTable* fontTable);
CString getFont(const CString& name);
CString getFont(const NSCommon::nullable<OOX::Spreadsheet::CFontScheme>& oScheme, const NSCommon::nullable<ComplexTypes::Spreadsheet::CString_>& oRFont, const NSCommon::nullable<OOX::Spreadsheet::CCharset>& oCharset, const NSCommon::nullable<OOX::Spreadsheet::CFontFamily >& oFamily, OOX::CTheme* pTheme);
private:
void addToFontMap(OOX::CFont& font);
};
}
This diff is collapsed.
#ifndef XLSX_SERIALIZER
#define XLSX_SERIALIZER
#if defined(_WIN32) || defined (_WIN64)
#include <atlbase.h>
#include <atlstr.h>
#else
#include "../../Common/DocxFormat/Source/Base/ASCString.h"
#endif
namespace NSBinPptxRW{
class CDrawingConverter;
}
namespace NSBinPptxRW{
class CBinaryFileReader;
class CBinaryFileWriter;
}
namespace BinXlsxRW {
class CXlsxSerializer{
private:
CString m_sFontDir;
CString m_sEmbeddedFontsDir;
NSBinPptxRW::CDrawingConverter* m_pExternalDrawingConverter;
public:
CXlsxSerializer();
~CXlsxSerializer();
void CreateXlsxFolders(CString& sXmlOptions, CString sDstPath, CString& sMediaPath);
bool loadFromFile(CString& sSrcFileName, CString& sDstPath, CString& sXMLOptions, CString& sMediaDir);
bool saveToFile(CString& sSrcFileName, CString& sDstPath, CString& sXMLOptions);
bool loadChart(CString& sChartPath, NSBinPptxRW::CBinaryFileWriter& oBufferedStream, long& lDataSize);
bool saveChart(NSBinPptxRW::CBinaryFileReader& oBufferedStream, long lLength, CString& sFilename, CString& sContentTypePath, CString** sContentTypeElement);
void setFontDir(CString& sFontDir);
void setEmbeddedFontsDir(CString& sEmbeddedFontsDir);
void setDrawingConverter(NSBinPptxRW::CDrawingConverter* pDrawingConverter);
};
}
#endif // #ifndef XLSX_SERIALIZER
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:ASCOfficeDocxFile2Lib.xcodeproj">
</FileRef>
</Workspace>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
// stdafx.cpp : source file that includes just the standard includes
// AVSOfficeDocxFile2.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
This diff is collapsed.
This diff is collapsed.
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