mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
(2.0.0.164): ASCOfficeDocxFile2
Открытие/сохранение sectPr git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55353 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
committed by
Alexander Trofimov
parent
ca84c4d117
commit
00e7c7f994
@ -3,6 +3,7 @@
|
||||
#define BINREADER_COMMON
|
||||
|
||||
#include "FileDownloader.h"
|
||||
#include "../../Common/Base64.h"
|
||||
|
||||
bool IsUnicodeSymbol( WCHAR symbol )
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "Common.h"
|
||||
|
||||
#include "../BinWriter/BinReaderWriterDefines.h";
|
||||
namespace Writers
|
||||
{
|
||||
class DocumentWriter : public ContentWriter
|
||||
@ -29,27 +29,52 @@ namespace Writers
|
||||
CString WriteSectPrHdrFtr()
|
||||
{
|
||||
CString sResult;
|
||||
bool bTitlePage = false;
|
||||
if(!m_oHeaderFooterWriter.m_oHeaderFirst.rId.IsEmpty())
|
||||
if(g_nCurFormatVersion < 5)
|
||||
{
|
||||
sResult += _T("<w:headerReference w:type=\"first\" r:id=\"") + m_oHeaderFooterWriter.m_oHeaderFirst.rId + _T("\"/>");
|
||||
bTitlePage = true;
|
||||
bool bTitlePage = false;
|
||||
for(int i = 0, length = m_oHeaderFooterWriter.m_aHeaders.GetCount(); 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.GetCount(); 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/>");
|
||||
}
|
||||
if(!m_oHeaderFooterWriter.m_oHeaderEven.rId.IsEmpty())
|
||||
sResult += _T("<w:headerReference w:type=\"even\" r:id=\"") + m_oHeaderFooterWriter.m_oHeaderEven.rId + _T("\"/>");
|
||||
if(!m_oHeaderFooterWriter.m_oHeaderOdd.rId.IsEmpty())
|
||||
sResult += _T("<w:headerReference w:type=\"default\" r:id=\"") + m_oHeaderFooterWriter.m_oHeaderOdd.rId + _T("\"/>");
|
||||
if(!m_oHeaderFooterWriter.m_oFooterFirst.rId.IsEmpty())
|
||||
{
|
||||
sResult += _T("<w:footerReference w:type=\"first\" r:id=\"") + m_oHeaderFooterWriter.m_oFooterFirst.rId + _T("\"/>");
|
||||
bTitlePage = true;
|
||||
}
|
||||
if(!m_oHeaderFooterWriter.m_oFooterEven.rId.IsEmpty())
|
||||
sResult += _T("<w:footerReference w:type=\"even\" r:id=\"") + m_oHeaderFooterWriter.m_oFooterEven.rId + _T("\"/>");
|
||||
if(!m_oHeaderFooterWriter.m_oFooterOdd.rId.IsEmpty())
|
||||
sResult += _T("<w:footerReference w:type=\"default\" r:id=\"") + m_oHeaderFooterWriter.m_oFooterOdd.rId + _T("\"/>");
|
||||
if(true == bTitlePage)
|
||||
sResult += _T("<w:titlePg/>");
|
||||
return sResult;
|
||||
}
|
||||
};
|
||||
|
||||
@ -12,8 +12,9 @@ namespace Writers
|
||||
class HdrFtrItem
|
||||
{
|
||||
public:
|
||||
HdrFtrItem(CString sDir)
|
||||
HdrFtrItem(SimpleTypes::EHdrFtr _eType)
|
||||
{
|
||||
eType = _eType;
|
||||
}
|
||||
bool IsEmpty()
|
||||
{
|
||||
@ -22,6 +23,7 @@ namespace Writers
|
||||
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>");
|
||||
@ -34,50 +36,38 @@ namespace Writers
|
||||
CString m_sDir;
|
||||
ContentTypesWriter& m_oContentTypesWriter;
|
||||
public:
|
||||
HdrFtrItem m_oHeaderFirst;
|
||||
HdrFtrItem m_oHeaderEven;
|
||||
HdrFtrItem m_oHeaderOdd;
|
||||
|
||||
HdrFtrItem m_oFooterFirst;
|
||||
HdrFtrItem m_oFooterEven;
|
||||
HdrFtrItem m_oFooterOdd;
|
||||
CAtlArray<HdrFtrItem*> m_aHeaders;
|
||||
CAtlArray<HdrFtrItem*> m_aFooters;
|
||||
public:
|
||||
HeaderFooterWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter),
|
||||
m_oHeaderFirst(sDir),m_oHeaderEven(sDir),m_oHeaderOdd(sDir),m_oFooterFirst(sDir),m_oFooterEven(sDir),m_oFooterOdd(sDir)
|
||||
HeaderFooterWriter(CString sDir, ContentTypesWriter& oContentTypesWriter):m_sDir(sDir),m_oContentTypesWriter(oContentTypesWriter)
|
||||
{
|
||||
}
|
||||
~HeaderFooterWriter()
|
||||
{
|
||||
for(int i = 0, length = m_aHeaders.GetCount(); i < length; ++i)
|
||||
delete m_aHeaders[i];
|
||||
m_aHeaders.RemoveAll();
|
||||
for(int i = 0, length = m_aFooters.GetCount(); i < length; ++i)
|
||||
delete m_aFooters[i];
|
||||
m_aFooters.RemoveAll();
|
||||
}
|
||||
void Write()
|
||||
{
|
||||
if(false == m_oHeaderFirst.IsEmpty())
|
||||
for(int i = 0, length = m_aHeaders.GetCount(); i < length; ++i)
|
||||
{
|
||||
WriteItem(_T("header"), m_oHeaderFirst.m_sFilename, m_oHeaderFirst.Header, true);
|
||||
//m_oHeaderFirst.RelsWriter.Write(sFilename + _T(".rels"));
|
||||
HdrFtrItem* pHeader = m_aHeaders[i];
|
||||
if(false == pHeader->IsEmpty())
|
||||
{
|
||||
WriteItem(_T("header"), pHeader->m_sFilename, pHeader->Header, true);
|
||||
}
|
||||
}
|
||||
if(false == m_oHeaderEven.IsEmpty())
|
||||
for(int i = 0, length = m_aFooters.GetCount(); i < length; ++i)
|
||||
{
|
||||
WriteItem(_T("header"), m_oHeaderEven.m_sFilename, m_oHeaderEven.Header, true);
|
||||
//m_oHeaderEven.RelsWriter.Write(sFilename + _T(".rels"));
|
||||
}
|
||||
if(false == m_oHeaderOdd.IsEmpty())
|
||||
{
|
||||
WriteItem(_T("header"), m_oHeaderOdd.m_sFilename, m_oHeaderOdd.Header, true);
|
||||
//m_oHeaderOdd.RelsWriter.Write(sFilename + _T(".rels"));
|
||||
}
|
||||
|
||||
if(false == m_oFooterFirst.IsEmpty())
|
||||
{
|
||||
WriteItem(_T("footer"), m_oFooterFirst.m_sFilename, m_oFooterFirst.Header, false);
|
||||
//m_oFooterFirst.RelsWriter.Write(sFilename + _T(".rels"));
|
||||
}
|
||||
if(false == m_oFooterEven.IsEmpty())
|
||||
{
|
||||
WriteItem(_T("footer"), m_oFooterEven.m_sFilename, m_oFooterEven.Header, false);
|
||||
//m_oFooterEven.RelsWriter.Write(sFilename + _T(".rels"));
|
||||
}
|
||||
if(false == m_oFooterOdd.IsEmpty())
|
||||
{
|
||||
WriteItem(_T("footer"), m_oFooterOdd.m_sFilename, m_oFooterOdd.Header, false);
|
||||
//m_oFooterOdd.RelsWriter.Write(sFilename + _T(".rels"));
|
||||
HdrFtrItem* pFooter = m_aFooters[i];
|
||||
if(false == pFooter->IsEmpty())
|
||||
{
|
||||
WriteItem(_T("footer"), pFooter->m_sFilename, pFooter->Header, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
void WriteItem(CString sHeader, CString& sFilename, ContentWriter& m_oWriter, bool bHeader)
|
||||
|
||||
@ -5,6 +5,7 @@ namespace BinDocxRW {
|
||||
class SectPr
|
||||
{
|
||||
public:
|
||||
CString sHeaderFooterReference;
|
||||
double W;
|
||||
double H;
|
||||
BYTE cOrientation;
|
||||
@ -14,9 +15,13 @@ public:
|
||||
double Bottom;
|
||||
double Header;
|
||||
double Footer;
|
||||
bool TitlePg;
|
||||
bool EvenAndOddHeaders;
|
||||
|
||||
bool bHeader;
|
||||
bool bFooter;
|
||||
bool bTitlePg;
|
||||
bool bEvenAndOddHeaders;
|
||||
SectPr()
|
||||
{
|
||||
W = Page_Width;
|
||||
@ -28,9 +33,40 @@ public:
|
||||
Bottom = 20;
|
||||
Header = 12.5;
|
||||
Footer = 12.5;
|
||||
sHeaderFooterReference = _T("");
|
||||
|
||||
bHeader = false;
|
||||
bFooter = false;
|
||||
bTitlePg = false;
|
||||
bEvenAndOddHeaders = false;
|
||||
}
|
||||
CString Write()
|
||||
{
|
||||
CString sRes = _T("");
|
||||
long nWidth = Round(W * g_dKoef_mm_to_twips);
|
||||
long nHeight = Round(H * g_dKoef_mm_to_twips);
|
||||
long nMLeft = Round(Left * g_dKoef_mm_to_twips);
|
||||
long nMTop = Round(Top * g_dKoef_mm_to_twips);
|
||||
long nMRight = Round(Right * g_dKoef_mm_to_twips);
|
||||
long nMBottom = Round(Bottom * g_dKoef_mm_to_twips);
|
||||
long nMHeader = Round(Header * g_dKoef_mm_to_twips);
|
||||
long nMFooter = Round(Footer * g_dKoef_mm_to_twips);
|
||||
if(!sHeaderFooterReference.IsEmpty())
|
||||
sRes.Append(sHeaderFooterReference);
|
||||
if(orientation_Portrait == cOrientation)
|
||||
sRes.AppendFormat(_T("<w:pgSz w:w=\"%d\" w:h=\"%d\"/>"), nWidth, nHeight);
|
||||
else
|
||||
sRes.AppendFormat(_T("<w:pgSz w:w=\"%d\" w:h=\"%d\" w:orient=\"landscape\"/>"), nWidth, nHeight);
|
||||
sRes.AppendFormat(_T("<w:pgMar w:top=\"%d\" w:right=\"%d\" w:bottom=\"%d\" w:left=\"%d\" w:gutter=\"0\""), nMTop, nMRight, nMBottom, nMLeft);
|
||||
if(bHeader)
|
||||
sRes.AppendFormat(_T(" w:header=\"%d\""), nMHeader);
|
||||
if(bFooter)
|
||||
sRes.AppendFormat(_T(" w:footer=\"%d\""), nMFooter);
|
||||
sRes.Append(_T("/>"));
|
||||
sRes.Append(_T("<w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/>"));
|
||||
if(bTitlePg && TitlePg)
|
||||
sRes.Append(_T("<w:titlePg/>"));
|
||||
return sRes;
|
||||
}
|
||||
};
|
||||
class docRGB
|
||||
@ -1946,7 +1982,7 @@ public:
|
||||
{
|
||||
if(false == Layout.IsEmpty())
|
||||
sRes.Append(Layout);
|
||||
else if(g_nFormatVersion < 4)
|
||||
else if(g_nCurFormatVersion < 4)
|
||||
sRes.Append(_T("<w:tblLayout w:type=\"fixed\"/>"));
|
||||
}
|
||||
if(false == TableCellMar.IsEmpty())
|
||||
|
||||
@ -141,6 +141,21 @@ private:
|
||||
return res;
|
||||
};
|
||||
};
|
||||
class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableReader>
|
||||
{
|
||||
Writers::FileWriter& m_oFileWriter;
|
||||
int nCurType;
|
||||
int nCurHeaderType;
|
||||
public:
|
||||
Writers::HeaderFooterWriter& m_oHeaderFooterWriter;
|
||||
public:
|
||||
Binary_HdrFtrTableReader(Streams::CBufferedStream& poBufferedStream, Writers::FileWriter& oFileWriter);
|
||||
int Read();
|
||||
int ReadHdrFtrContent(BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrFEO(BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrItem(BYTE type, long length, void* poResult);
|
||||
int ReadHdrFtrItemContent(BYTE type, long length, void* poResult);
|
||||
};
|
||||
class Binary_rPrReader : public Binary_CommonReader<Binary_rPrReader>
|
||||
{
|
||||
protected:
|
||||
@ -371,11 +386,14 @@ private:
|
||||
public:
|
||||
Binary_CommonReader2 oBinary_CommonReader2;
|
||||
Binary_rPrReader oBinary_rPrReader;
|
||||
Binary_HdrFtrTableReader oBinary_HdrFtrTableReader;
|
||||
Writers::FileWriter& m_oFileWriter;
|
||||
bool bDoNotWriteNullProp;
|
||||
long m_nCurNumId;
|
||||
long m_nCurLvl;
|
||||
|
||||
Binary_pPrReader(Streams::CBufferedStream& poBufferedStream, Writers::FileWriter& oFileWriter):m_oFontTableWriter(oFileWriter.m_oFontTableWriter),Binary_CommonReader(poBufferedStream),oBinary_CommonReader2(poBufferedStream),oBinary_rPrReader(poBufferedStream)
|
||||
Binary_pPrReader(Streams::CBufferedStream& poBufferedStream, Writers::FileWriter& oFileWriter):
|
||||
m_oFontTableWriter(oFileWriter.m_oFontTableWriter),Binary_CommonReader(poBufferedStream),oBinary_CommonReader2(poBufferedStream),oBinary_rPrReader(poBufferedStream),oBinary_HdrFtrTableReader(poBufferedStream,oFileWriter),m_oFileWriter(oFileWriter)
|
||||
{
|
||||
bDoNotWriteNullProp = false;
|
||||
m_nCurNumId = -1;
|
||||
@ -619,6 +637,15 @@ public:
|
||||
oFramePr.Write(*pCStringWriter);
|
||||
break;
|
||||
}
|
||||
case c_oSerProp_pPrType::SectPr:
|
||||
{
|
||||
SectPr oSectPr;
|
||||
res = Read1(length, &Binary_pPrReader::Read_SecPr, this, &oSectPr);
|
||||
pCStringWriter->WriteString(CString(_T("<w:sectPr>")));
|
||||
pCStringWriter->WriteString(oSectPr.Write());
|
||||
pCStringWriter->WriteString(CString(_T("</w:sectPr>")));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
break;
|
||||
@ -904,6 +931,156 @@ public:
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int Read_SecPr(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSerProp_secPrType::pgSz == type )
|
||||
{
|
||||
res = Read2(length, &Binary_pPrReader::Read_pgSz, this, poResult);
|
||||
}
|
||||
else if( c_oSerProp_secPrType::pgMar == type )
|
||||
{
|
||||
res = Read2(length, &Binary_pPrReader::Read_pgMar, this, poResult);
|
||||
}
|
||||
else if( c_oSerProp_secPrType::setting == type )
|
||||
{
|
||||
res = Read2(length, &Binary_pPrReader::Read_pgSetting, this, poResult);
|
||||
}
|
||||
else if( c_oSerProp_secPrType::headers == type )
|
||||
{
|
||||
res = Read1(length, &Binary_pPrReader::Read_pgHeader, this, poResult);
|
||||
}
|
||||
else if( c_oSerProp_secPrType::footers == type )
|
||||
{
|
||||
res = Read1(length, &Binary_pPrReader::Read_pgFooter, this, poResult);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgSz(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSer_pgSzType::Orientation == type )
|
||||
{
|
||||
pSectPr->cOrientation = m_oBufferedStream.ReadByte();
|
||||
}
|
||||
else if( c_oSer_pgSzType::W == type )
|
||||
{
|
||||
pSectPr->W = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgSzType::H == type )
|
||||
{
|
||||
pSectPr->H = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgMar(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSer_pgMarType::Left == type )
|
||||
{
|
||||
pSectPr->Left = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Top == type )
|
||||
{
|
||||
pSectPr->Top = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Right == type )
|
||||
{
|
||||
pSectPr->Right = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Bottom == type )
|
||||
{
|
||||
pSectPr->Bottom = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Header == type )
|
||||
{
|
||||
pSectPr->bHeader = true;
|
||||
pSectPr->Header = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Footer == type )
|
||||
{
|
||||
pSectPr->bFooter = true;
|
||||
pSectPr->Footer = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgSetting(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSerProp_secPrSettingsType::titlePg == type )
|
||||
{
|
||||
pSectPr->bTitlePg = true;
|
||||
pSectPr->TitlePg = m_oBufferedStream.ReadBool();
|
||||
}
|
||||
else if( c_oSerProp_secPrSettingsType::EvenAndOddHeaders == type )
|
||||
{
|
||||
pSectPr->bEvenAndOddHeaders = true;
|
||||
pSectPr->EvenAndOddHeaders = m_oBufferedStream.ReadBool();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgHeader(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSerProp_secPrType::hdrftrelem == type )
|
||||
{
|
||||
int nHdrFtrIndex = m_oBufferedStream.ReadLong();
|
||||
if(nHdrFtrIndex >= 0 && nHdrFtrIndex <= m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders.GetCount())
|
||||
{
|
||||
Writers::HdrFtrItem* pHdrFtrItem = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[nHdrFtrIndex];
|
||||
pHdrFtrItem->m_sFilename;
|
||||
CString sType;
|
||||
if(SimpleTypes::hdrftrFirst == pHdrFtrItem->eType)
|
||||
sType = _T("first");
|
||||
else if(SimpleTypes::hdrftrEven == pHdrFtrItem->eType)
|
||||
sType = _T("even");
|
||||
else
|
||||
sType = _T("default");
|
||||
pSectPr->sHeaderFooterReference += _T("<w:headerReference w:type=\"") + sType +_T("\" r:id=\"") + pHdrFtrItem->rId + _T("\"/>");
|
||||
}
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgFooter(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSerProp_secPrType::hdrftrelem == type )
|
||||
{
|
||||
int nHdrFtrIndex = m_oBufferedStream.ReadLong();
|
||||
if(nHdrFtrIndex >= 0 && nHdrFtrIndex <= oBinary_HdrFtrTableReader.m_oHeaderFooterWriter.m_aFooters.GetCount())
|
||||
{
|
||||
Writers::HdrFtrItem* pHdrFtrItem = oBinary_HdrFtrTableReader.m_oHeaderFooterWriter.m_aFooters[nHdrFtrIndex];
|
||||
pHdrFtrItem->m_sFilename;
|
||||
CString sType;
|
||||
if(SimpleTypes::hdrftrFirst == pHdrFtrItem->eType)
|
||||
sType = _T("first");
|
||||
else if(SimpleTypes::hdrftrEven == pHdrFtrItem->eType)
|
||||
sType = _T("even");
|
||||
else
|
||||
sType = _T("default");
|
||||
pSectPr->sHeaderFooterReference += _T("<w:footerReference w:type=\"") + sType +_T("\" r:id=\"") + pHdrFtrItem->rId + _T("\"/>");
|
||||
}
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
class Binary_tblPrReader : public Binary_CommonReader<Binary_tblPrReader>
|
||||
{
|
||||
@ -2662,35 +2839,9 @@ public:
|
||||
{
|
||||
SectPr oSectPr;
|
||||
res = Read1(length, &Binary_DocumentTableReader::Read_SecPr, this, &oSectPr);
|
||||
long nWidth = Round(oSectPr.W * g_dKoef_mm_to_twips);
|
||||
long nHeight = Round(oSectPr.H * g_dKoef_mm_to_twips);
|
||||
long nMLeft = Round(oSectPr.Left * g_dKoef_mm_to_twips);
|
||||
long nMTop = Round(oSectPr.Top * g_dKoef_mm_to_twips);
|
||||
long nMRight = Round(oSectPr.Right * g_dKoef_mm_to_twips);
|
||||
long nMBottom = Round(oSectPr.Bottom * g_dKoef_mm_to_twips);
|
||||
long nMHeader = Round(oSectPr.Header * g_dKoef_mm_to_twips);
|
||||
long nMFooter = Round(oSectPr.Footer * g_dKoef_mm_to_twips);
|
||||
|
||||
CString pgSz;
|
||||
if(orientation_Portrait == oSectPr.cOrientation)
|
||||
pgSz.Format(_T("<w:pgSz w:w=\"%d\" w:h=\"%d\"/>"), nWidth, nHeight);
|
||||
else
|
||||
pgSz.Format(_T("<w:pgSz w:w=\"%d\" w:h=\"%d\" w:orient=\"landscape\"/>"), nWidth, nHeight);
|
||||
CString pgMar;pgMar.Format(_T("<w:pgMar w:top=\"%d\" w:right=\"%d\" w:bottom=\"%d\" w:left=\"%d\" w:gutter=\"0\""), nMTop, nMRight, nMBottom, nMLeft);
|
||||
if(oSectPr.bHeader)
|
||||
{
|
||||
CString sHeader;sHeader.Format(_T(" w:header=\"%d\""), nMHeader);
|
||||
pgMar+= sHeader;
|
||||
}
|
||||
if(oSectPr.bFooter)
|
||||
{
|
||||
CString sFooter;sFooter.Format(_T(" w:footer=\"%d\""), nMFooter);
|
||||
pgMar+= sFooter;
|
||||
}
|
||||
pgMar+= _T("/>");
|
||||
m_oDocumentWriter.m_oSecPr.WriteString(pgSz);
|
||||
m_oDocumentWriter.m_oSecPr.WriteString(pgMar);
|
||||
m_oDocumentWriter.m_oSecPr.WriteString(CString(_T("<w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/>")));
|
||||
m_oDocumentWriter.m_oSecPr.WriteString(oSectPr.Write());
|
||||
if(oSectPr.bEvenAndOddHeaders && oSectPr.EvenAndOddHeaders)
|
||||
m_oFileWriter.m_oSettingWriter.AddSetting(_T("<w:evenAndOddHeaders/>"));
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
@ -5265,75 +5416,6 @@ public:
|
||||
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
|
||||
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
|
||||
}
|
||||
int Read_SecPr(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSerProp_secPrType::pgSz == type )
|
||||
{
|
||||
res = Read2(length, &Binary_DocumentTableReader::Read_pgSz, this, poResult);
|
||||
}
|
||||
else if( c_oSerProp_secPrType::pgMar == type )
|
||||
{
|
||||
res = Read2(length, &Binary_DocumentTableReader::Read_pgMar, this, poResult);
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgSz(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSer_pgSzType::Orientation == type )
|
||||
{
|
||||
pSectPr->cOrientation = m_oBufferedStream.ReadByte();
|
||||
}
|
||||
else if( c_oSer_pgSzType::W == type )
|
||||
{
|
||||
pSectPr->W = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgSzType::H == type )
|
||||
{
|
||||
pSectPr->H = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int Read_pgMar(BYTE type, long length, void* poResult)
|
||||
{
|
||||
SectPr* pSectPr = static_cast<SectPr*>(poResult);
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if( c_oSer_pgMarType::Left == type )
|
||||
{
|
||||
pSectPr->Left = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Top == type )
|
||||
{
|
||||
pSectPr->Top = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Right == type )
|
||||
{
|
||||
pSectPr->Right = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Bottom == type )
|
||||
{
|
||||
pSectPr->Bottom = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Header == type )
|
||||
{
|
||||
pSectPr->bHeader = true;
|
||||
pSectPr->Header = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else if( c_oSer_pgMarType::Footer == type )
|
||||
{
|
||||
pSectPr->bFooter = true;
|
||||
pSectPr->Footer = m_oBufferedStream.ReadDouble2();
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
int ReadImage(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
@ -5715,76 +5797,65 @@ public:
|
||||
int res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
}
|
||||
};
|
||||
class Binary_HdrFtrTableReader : public Binary_CommonReader<Binary_HdrFtrTableReader>
|
||||
{
|
||||
Writers::FileWriter& m_oFileWriter;
|
||||
Writers::HeaderFooterWriter& m_oHeaderFooterWriter;
|
||||
int nCurType;
|
||||
int nCurHeaderType;
|
||||
int nHeaderCount;
|
||||
int nFooterCount;
|
||||
public:
|
||||
Binary_HdrFtrTableReader(Streams::CBufferedStream& poBufferedStream, Writers::FileWriter& oFileWriter):Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_oHeaderFooterWriter(oFileWriter.m_oHeaderFooterWriter)
|
||||
int Read_SecPr(BYTE type, long length, void* poResult)
|
||||
{
|
||||
nHeaderCount = 0;
|
||||
nFooterCount = 0;
|
||||
return oBinary_pPrReader.Read_SecPr(type, length, poResult);
|
||||
}
|
||||
int Read()
|
||||
{
|
||||
return ReadTable(&Binary_HdrFtrTableReader::ReadHdrFtrContent, this);
|
||||
};
|
||||
int 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 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 ReadHdrFtrItem(BYTE type, long length, void* poResult)
|
||||
{
|
||||
int res = c_oSerConstants::ReadOk;
|
||||
if ( c_oSerHdrFtrTypes::HdrFtr_Content == type )
|
||||
{
|
||||
Writers::HdrFtrItem* poHdrFtrItem = NULL;
|
||||
};
|
||||
Binary_HdrFtrTableReader::Binary_HdrFtrTableReader(Streams::CBufferedStream& poBufferedStream, Writers::FileWriter& oFileWriter):Binary_CommonReader(poBufferedStream),m_oFileWriter(oFileWriter),m_oHeaderFooterWriter(oFileWriter.m_oHeaderFooterWriter)
|
||||
{
|
||||
}
|
||||
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)
|
||||
{
|
||||
switch(nCurHeaderType)
|
||||
{
|
||||
case c_oSerHdrFtrTypes::HdrFtr_First:poHdrFtrItem = &m_oHeaderFooterWriter.m_oHeaderFirst;break;
|
||||
case c_oSerHdrFtrTypes::HdrFtr_Even:poHdrFtrItem = &m_oHeaderFooterWriter.m_oHeaderEven;break;
|
||||
case c_oSerHdrFtrTypes::HdrFtr_Odd:poHdrFtrItem = &m_oHeaderFooterWriter.m_oHeaderOdd;break;
|
||||
}
|
||||
nHeaderCount++;
|
||||
poHdrFtrItem->m_sFilename.Format(_T("header%d.xml"), nHeaderCount);
|
||||
m_oHeaderFooterWriter.m_aHeaders.Add(poHdrFtrItem);
|
||||
poHdrFtrItem->m_sFilename.Format(_T("header%d.xml"), m_oHeaderFooterWriter.m_aHeaders.GetCount());
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(nCurHeaderType)
|
||||
{
|
||||
case c_oSerHdrFtrTypes::HdrFtr_First:poHdrFtrItem = &m_oHeaderFooterWriter.m_oFooterFirst;break;
|
||||
case c_oSerHdrFtrTypes::HdrFtr_Even:poHdrFtrItem = &m_oHeaderFooterWriter.m_oFooterEven;break;
|
||||
case c_oSerHdrFtrTypes::HdrFtr_Odd:poHdrFtrItem = &m_oHeaderFooterWriter.m_oFooterOdd;break;
|
||||
}
|
||||
nFooterCount++;
|
||||
poHdrFtrItem->m_sFilename.Format(_T("footer%d.xml"), nFooterCount);
|
||||
m_oHeaderFooterWriter.m_aFooters.Add(poHdrFtrItem);
|
||||
poHdrFtrItem->m_sFilename.Format(_T("footer%d.xml"), m_oHeaderFooterWriter.m_aFooters.GetCount());
|
||||
}
|
||||
m_oFileWriter.m_pDrawingConverter->SetDstContentRels();
|
||||
Binary_DocumentTableReader oBinary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, poHdrFtrItem->Header, NULL);
|
||||
@ -5797,17 +5868,16 @@ public:
|
||||
m_oFileWriter.m_pDrawingConverter->SaveDstContentRels(bstrRelsPath);
|
||||
SysFreeString(bstrRelsPath);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
res = c_oSerConstants::ReadUnknown;
|
||||
return res;
|
||||
};
|
||||
int ReadHdrFtrItemContent(BYTE type, long length, void* poResult)
|
||||
{
|
||||
Binary_DocumentTableReader* pBinary_DocumentTableReader = static_cast<Binary_DocumentTableReader*>(poResult);
|
||||
return pBinary_DocumentTableReader->ReadDocumentContent(type, length, NULL);
|
||||
};
|
||||
}
|
||||
}
|
||||
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);
|
||||
};
|
||||
class BinaryFileReader
|
||||
{
|
||||
@ -5953,53 +6023,29 @@ public: BinaryFileReader(CString& sFileInDir, Streams::CBufferedStream& oBuffere
|
||||
long rId;
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"), _T("numbering.xml"), NULL, &rId);
|
||||
}
|
||||
if(false == m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderFirst.IsEmpty())
|
||||
for(int i = 0, length = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders.GetCount(); i < length; ++i)
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderFirst.m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderFirst.rId.Format(_T("rId%d"), rId);
|
||||
Writers::HdrFtrItem* pHeader = m_oFileWriter.m_oHeaderFooterWriter.m_aHeaders[i];
|
||||
if(false == pHeader->IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = pHeader->m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
pHeader->rId.Format(_T("rId%d"), rId);
|
||||
}
|
||||
}
|
||||
if(false == m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderEven.IsEmpty())
|
||||
for(int i = 0, length = m_oFileWriter.m_oHeaderFooterWriter.m_aFooters.GetCount(); i < length; ++i)
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderEven.m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderEven.rId.Format(_T("rId%d"), rId);
|
||||
}
|
||||
if(false == m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderOdd.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderOdd.m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/header"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
m_oFileWriter.m_oHeaderFooterWriter.m_oHeaderOdd.rId.Format(_T("rId%d"), rId);
|
||||
}
|
||||
if(false == m_oFileWriter.m_oHeaderFooterWriter.m_oFooterFirst.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = m_oFileWriter.m_oHeaderFooterWriter.m_oFooterFirst.m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
m_oFileWriter.m_oHeaderFooterWriter.m_oFooterFirst.rId.Format(_T("rId%d"), rId);
|
||||
}
|
||||
if(false == m_oFileWriter.m_oHeaderFooterWriter.m_oFooterEven.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = m_oFileWriter.m_oHeaderFooterWriter.m_oFooterEven.m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
m_oFileWriter.m_oHeaderFooterWriter.m_oFooterEven.rId.Format(_T("rId%d"), rId);
|
||||
}
|
||||
if(false == m_oFileWriter.m_oHeaderFooterWriter.m_oFooterOdd.IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = m_oFileWriter.m_oHeaderFooterWriter.m_oFooterOdd.m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
m_oFileWriter.m_oHeaderFooterWriter.m_oFooterOdd.rId.Format(_T("rId%d"), rId);
|
||||
Writers::HdrFtrItem* pFooter = m_oFileWriter.m_oHeaderFooterWriter.m_aFooters[i];
|
||||
if(false == pFooter->IsEmpty())
|
||||
{
|
||||
long rId;
|
||||
BSTR bstrFilename = pFooter->m_sFilename.AllocSysString();
|
||||
m_oFileWriter.m_pDrawingConverter->WriteRels(_T("http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer"), bstrFilename, NULL, &rId);
|
||||
SysFreeString(bstrFilename);
|
||||
pFooter->rId.Format(_T("rId%d"), rId);
|
||||
}
|
||||
}
|
||||
res = Binary_DocumentTableReader(m_oBufferedStream, m_oFileWriter, m_oFileWriter.m_oDocumentWriter, &oBinary_CommentsTableReader.m_oComments).Read();
|
||||
CString sRelsPath = m_oFileWriter.m_oDocumentWriter.m_sDir + _T("\\word\\_rels\\document.xml.rels");
|
||||
|
||||
@ -34,13 +34,24 @@ namespace Writers
|
||||
}
|
||||
void Prepare()
|
||||
{
|
||||
bool bevenAndOddHeaders = false;
|
||||
if(!m_oHeaderFooterWriter.m_oHeaderEven.rId.IsEmpty())
|
||||
bevenAndOddHeaders = true;
|
||||
if(!m_oHeaderFooterWriter.m_oFooterEven.rId.IsEmpty())
|
||||
bevenAndOddHeaders = true;
|
||||
if(bevenAndOddHeaders)
|
||||
AddSetting(_T("<w:evenAndOddHeaders/>"));
|
||||
if(g_nCurFormatVersion < 5)
|
||||
{
|
||||
bool bevenAndOddHeaders = false;
|
||||
for(int i = 0, length = m_oHeaderFooterWriter.m_aHeaders.GetCount(); 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.GetCount(); i < length; ++i)
|
||||
{
|
||||
HdrFtrItem* pFooter = m_oHeaderFooterWriter.m_aFooters[i];
|
||||
if(SimpleTypes::hdrftrEven == pFooter->eType)
|
||||
bevenAndOddHeaders = true;
|
||||
}
|
||||
if(bevenAndOddHeaders)
|
||||
AddSetting(_T("<w:evenAndOddHeaders/>"));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
extern int g_nCurFormatVersion;
|
||||
namespace BinDocxRW
|
||||
{
|
||||
const double eps = 0.001;
|
||||
@ -93,7 +94,7 @@ const double g_dKoef_mm_to_eightpoint = 8 * g_dKoef_mm_to_pt;
|
||||
const double g_dKoef_mm_to_hps = 2 * g_dKoef_mm_to_pt;
|
||||
|
||||
const static TCHAR* g_sFormatSignature = _T("DOCY");
|
||||
const int g_nFormatVersion = 4;
|
||||
const int g_nFormatVersion = 5;
|
||||
namespace c_oAscWrapStyle{enum c_oSerFormat
|
||||
{
|
||||
Inline = 0,
|
||||
@ -293,7 +294,8 @@ const int g_nFormatVersion = 4;
|
||||
pBdr = 27,
|
||||
Spacing_BeforeAuto = 28,
|
||||
Spacing_AfterAuto = 29,
|
||||
FramePr = 30
|
||||
FramePr = 30,
|
||||
SectPr = 31
|
||||
};}
|
||||
namespace c_oSerProp_rPrType{enum c_oSerProp_rPrType
|
||||
{
|
||||
@ -358,7 +360,10 @@ const int g_nFormatVersion = 4;
|
||||
{
|
||||
pgSz = 0,
|
||||
pgMar = 1,
|
||||
setting = 2
|
||||
setting = 2,
|
||||
headers = 3,
|
||||
footers = 4,
|
||||
hdrftrelem = 5
|
||||
};}
|
||||
namespace c_oSerProp_secPrSettingsType{enum c_oSerProp_secPrSettingsType
|
||||
{
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,8 @@
|
||||
#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
|
||||
#endif
|
||||
|
||||
int g_nCurFormatVersion = 0;
|
||||
|
||||
#define BUFFER_GROW_SIZE 1 * 1024 * 1024
|
||||
|
||||
// IAVSOfficeDocxFile2
|
||||
@ -226,7 +228,7 @@ public:
|
||||
|
||||
BinDocxRW::BinaryCommonWriter oBinaryCommonWriter(oBufferedStream, m_oBinaryFileWriter->m_oEmbeddedFontsManager);
|
||||
int nCurPos = oBinaryCommonWriter.WriteItemWithLengthStart();
|
||||
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(oBufferedStream, m_oBinaryFileWriter->m_oEmbeddedFontsManager, m_oBinaryFileWriter->m_pTheme, m_oBinaryFileWriter->m_pSettings, m_oBinaryFileWriter->m_oFontProcessor, m_oBinaryFileWriter->m_pCurRels, m_oBinaryFileWriter->m_pOfficeDrawingConverter, NULL);
|
||||
BinDocxRW::BinaryDocumentTableWriter oBinaryDocumentTableWriter(oBufferedStream, m_oBinaryFileWriter->m_oEmbeddedFontsManager, m_oBinaryFileWriter->m_pTheme, m_oBinaryFileWriter->m_pSettings, m_oBinaryFileWriter->m_oFontProcessor, m_oBinaryFileWriter->m_pCurRels, m_oBinaryFileWriter->m_pOfficeDrawingConverter, NULL, NULL);
|
||||
oBinaryDocumentTableWriter.WriteDocumentContent(oSdtContent.m_arrItems);
|
||||
oBinaryCommonWriter.WriteItemWithLengthEnd(nCurPos);
|
||||
|
||||
@ -321,7 +323,9 @@ public:
|
||||
version = version.Right(version.GetLength() - 1);
|
||||
int nTempVersion = atoi(version);
|
||||
if(0 != nTempVersion)
|
||||
nVersion = nTempVersion;
|
||||
{
|
||||
g_nCurFormatVersion = nVersion = nTempVersion;
|
||||
}
|
||||
}
|
||||
PPTXFile::IAVSOfficeDrawingConverter* pDrawingConverter = NULL;
|
||||
CoCreateInstance(__uuidof(PPTXFile::CAVSOfficeDrawingConverter), NULL, CLSCTX_ALL, __uuidof(PPTXFile::IAVSOfficeDrawingConverter), (void**) &pDrawingConverter);
|
||||
|
||||
@ -2,6 +2,6 @@
|
||||
//2
|
||||
//0
|
||||
//0
|
||||
//163
|
||||
#define INTVER 2,0,0,163
|
||||
#define STRVER "2,0,0,163\0"
|
||||
//164
|
||||
#define INTVER 2,0,0,164
|
||||
#define STRVER "2,0,0,164\0"
|
||||
|
||||
@ -198,7 +198,7 @@ namespace NSCommon
|
||||
|
||||
return IsInit();
|
||||
}
|
||||
Type* GetPointer()
|
||||
Type* GetPointer() const
|
||||
{
|
||||
return m_pPointer;
|
||||
}
|
||||
|
||||
@ -4,6 +4,9 @@
|
||||
#include "Reader/BinaryWriter.h"
|
||||
#include "Reader/FontProcessor.h"
|
||||
#include "Writer/BinaryReader.h"
|
||||
|
||||
int g_nCurFormatVersion = 0;
|
||||
|
||||
[
|
||||
object,
|
||||
uuid("87476A4D-6A42-44e9-A947-42B8E8613070"),
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
extern int g_nCurFormatVersion;
|
||||
|
||||
namespace BinXlsxRW
|
||||
{
|
||||
const double g_dKoef_mm_to_pt = 72 / (2.54 * 10);
|
||||
|
||||
@ -2586,7 +2586,7 @@ namespace BinXlsxRW {
|
||||
{
|
||||
pRow->m_oHt.Init();
|
||||
pRow->m_oHt->SetValue(m_oBufferedStream.ReadDouble());
|
||||
if(g_nFormatVersion < 2)
|
||||
if(g_nCurFormatVersion < 2)
|
||||
{
|
||||
pRow->m_oCustomHeight.Init();
|
||||
pRow->m_oCustomHeight->SetValue(SimpleTypes::onoffTrue);
|
||||
@ -2990,7 +2990,9 @@ namespace BinXlsxRW {
|
||||
version = version.Right(version.GetLength() - 1);
|
||||
int nTempVersion = atoi(version);
|
||||
if(0 != nTempVersion)
|
||||
nVersion = nTempVersion;
|
||||
{
|
||||
g_nCurFormatVersion = nVersion = nTempVersion;
|
||||
}
|
||||
}
|
||||
OOX::Spreadsheet::CXlsx oXlsx;
|
||||
CSimpleArray<CString> aDeleteFiles;
|
||||
|
||||
Reference in New Issue
Block a user