Commit 64190e0e authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

(2.0.0.164): ASCOfficeDocxFile2

Открытие/сохранение sectPr

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55353 954022d7-b5bf-4e40-9824-e11837661b57
parent 8dc067b2
......@@ -3,6 +3,7 @@
#define BINREADER_COMMON
#include "FileDownloader.h"
#include "../../Common/Base64.h"
bool IsUnicodeSymbol( WCHAR symbol )
{
......
#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())
{
WriteItem(_T("header"), m_oHeaderFirst.m_sFilename, m_oHeaderFirst.Header, true);
//m_oHeaderFirst.RelsWriter.Write(sFilename + _T(".rels"));
}
if(false == m_oHeaderEven.IsEmpty())
{
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())
for(int i = 0, length = m_aHeaders.GetCount(); i < length; ++i)
{
WriteItem(_T("footer"), m_oFooterEven.m_sFilename, m_oFooterEven.Header, false);
//m_oFooterEven.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_oFooterOdd.IsEmpty())
for(int i = 0, length = m_aFooters.GetCount(); i < length; ++i)
{
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())
......
This diff is collapsed.
......@@ -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/>"));
}
}
};
}
\ No newline at end of file
#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
{
......
This diff is collapsed.
......@@ -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"),
......
#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;
......
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