Commit 424c20bf authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

открытие/сохранение свойств колонок.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@67530 954022d7-b5bf-4e40-9824-e11837661b57
parent 5c4eb82a
......@@ -23,6 +23,7 @@ public:
BYTE SectionType;
int PageNumStart;
CString sectPrChange;
CString cols;
bool bHeader;
bool bFooter;
......@@ -42,6 +43,7 @@ public:
Header = 12.5;
Footer = 12.5;
sHeaderFooterReference = _T("");
cols = _T("<w:cols w:space=\"708\"/>");
bHeader = false;
bFooter = false;
......@@ -89,7 +91,9 @@ public:
sRes.Append(_T("/>"));
if(bPageNumStart)
sRes.AppendFormat(_T("<w:pgNumType w:start=\"%d\"/>"), PageNumStart);
sRes.Append(_T("<w:cols w:space=\"708\"/><w:docGrid w:linePitch=\"360\"/>"));
if(!cols.IsEmpty())
sRes.Append(cols);
sRes.Append(_T("<w:docGrid w:linePitch=\"360\"/>"));
if(bTitlePg && TitlePg)
sRes.Append(_T("<w:titlePg/>"));
if(!sectPrChange.IsEmpty())
......
......@@ -6,6 +6,7 @@
#include "ReaderClasses.h"
#include "../../XlsxSerializerCom/Writer/BinaryReader.h"
#include "../../DesktopEditor/common/ASCVariant.h"
#include "../../Common/DocxFormat/Source/DocxFormat/Docx.h"
namespace BinDocxRW {
......@@ -1163,6 +1164,12 @@ public:
res = Read1(length, &Binary_pPrReader::ReadSectPrChange, this, &sectPrChange);
pSectPr->sectPrChange = sectPrChange.ToString(_T("w:sectPrChange"));
}
else if( c_oSerProp_secPrType::cols == type )
{
OOX::Logic::CColumns oCols;
res = Read1(length, &Binary_pPrReader::ReadCols, this, &oCols);
pSectPr->cols = oCols.toXML();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......@@ -1321,6 +1328,58 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadCols(BYTE type, long length, void* poResult)
{
OOX::Logic::CColumns* pCols = static_cast<OOX::Logic::CColumns*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerProp_Columns::EqualWidth == type )
{
pCols->m_oEqualWidth.Init();
pCols->m_oEqualWidth->FromBool(m_oBufferedStream.GetBool());
}
else if( c_oSerProp_Columns::Num == type )
{
pCols->m_oNum.Init();
pCols->m_oNum->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerProp_Columns::Sep == type )
{
pCols->m_oSep.Init();
pCols->m_oSep->FromBool(m_oBufferedStream.GetBool());
}
else if( c_oSerProp_Columns::Space == type )
{
pCols->m_oSpace.Init();
pCols->m_oSpace->FromTwips(m_oBufferedStream.GetLong());
}
else if( c_oSerProp_Columns::Column == type )
{
ComplexTypes::Word::CColumn* pCol = new ComplexTypes::Word::CColumn();
res = Read1(length, &Binary_pPrReader::ReadCol, this, pCol);
pCols->m_arrColumns.push_back(pCol);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadCol(BYTE type, long length, void* poResult)
{
ComplexTypes::Word::CColumn* pCol = static_cast<ComplexTypes::Word::CColumn*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerProp_Columns::ColumnSpace == type )
{
pCol->m_oSpace.Init();
pCol->m_oSpace->FromTwips(m_oBufferedStream.GetLong());
}
else if( c_oSerProp_Columns::ColumnW == type )
{
pCol->m_oW.Init();
pCol->m_oW->FromTwips(m_oBufferedStream.GetLong());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
class Binary_tblPrReader : public Binary_CommonReader<Binary_tblPrReader>
{
......
......@@ -385,7 +385,8 @@ extern int g_nCurFormatVersion;
footers = 4,
hdrftrelem = 5,
pageNumType = 6,
sectPrChange = 7
sectPrChange = 7,
cols = 8
};}
namespace c_oSerProp_secPrSettingsType{enum c_oSerProp_secPrSettingsType
{
......@@ -853,6 +854,16 @@ extern int g_nCurFormatVersion;
trPrChange = 13,
ContentRun = 14
};}
namespace c_oSerProp_Columns{enum c_oSerProp_Columns
{
EqualWidth = 0,
Num = 1,
Sep = 2,
Space = 3,
Column = 4,
ColumnSpace = 5,
ColumnW = 6
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
......@@ -1318,6 +1318,12 @@ namespace BinDocxRW
WriteSectPrChange(pSectPr->m_oSectPrChange.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(pSectPr->m_oCols.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_secPrType::cols);
WriteColumns(pSectPr->m_oCols.get());
m_oBcw.WriteItemEnd(nCurPos);
}
};
void WritePageSettings(OOX::Logic::CSectionProperty* pSectPr)
{
......@@ -1486,6 +1492,58 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteColumns(const OOX::Logic::CColumns& columns)
{
int nCurPos = 0;
if(columns.m_oEqualWidth.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::EqualWidth);
m_oBcw.m_oStream.WriteBOOL(columns.m_oEqualWidth->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(columns.m_oNum.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::Num);
m_oBcw.m_oStream.WriteLONG(columns.m_oNum->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(columns.m_oSep.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::Sep);
m_oBcw.m_oStream.WriteBOOL(columns.m_oSep->ToBool());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(columns.m_oSpace.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::Space);
m_oBcw.m_oStream.WriteLONG(columns.m_oSpace->ToTwips());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
for(int i = 0; i < columns.m_arrColumns.size(); ++i)
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::Column);
WriteColumn(*columns.m_arrColumns[i]);
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WriteColumn(const ComplexTypes::Word::CColumn& column)
{
int nCurPos = 0;
if(column.m_oSpace.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::ColumnSpace);
m_oBcw.m_oStream.WriteLONG(column.m_oSpace->ToTwips());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(column.m_oW.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_Columns::ColumnW);
m_oBcw.m_oStream.WriteLONG(column.m_oW->ToTwips());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
};
class Binary_tblPrWriter
{
......
......@@ -44,17 +44,17 @@ namespace ComplexTypes
{
CString sResult;
if ( m_oSpace.IsInit() )
if ( m_oW.IsInit() )
{
sResult += "w:space=\"";
sResult += m_oSpace->ToString();
sResult += "w:w=\"";
sResult.AppendFormat(_T("%d"), m_oW->ToTwips());
sResult += "\" ";
}
if ( m_oW.IsInit() )
if ( m_oSpace.IsInit() )
{
sResult += "w:w=\"";
sResult += m_oW->ToString();
sResult += "w:space=\"";
sResult.AppendFormat(_T("%d"), m_oSpace->ToTwips());
sResult += "\" ";
}
......@@ -1217,13 +1217,6 @@ namespace OOX
{
CString sResult = _T("<w:cols ");
if ( m_oEqualWidth.IsInit() )
{
sResult += "w:equalWidth=\"";
sResult += m_oEqualWidth->ToString();
sResult += "\" ";
}
if ( m_oNum.IsInit() )
{
sResult += "w:num=\"";
......@@ -1234,14 +1227,21 @@ namespace OOX
if ( m_oSep.IsInit() )
{
sResult += "w:sep=\"";
sResult += m_oSep->ToString();
sResult += m_oSep->ToString2(SimpleTypes::onofftostring1);
sResult += "\" ";
}
if ( m_oSpace.IsInit() )
{
sResult += "w:space=\"";
sResult += m_oSpace->ToString();
sResult.AppendFormat(_T("%d"), m_oSpace->ToTwips());
sResult += "\" ";
}
if ( m_oEqualWidth.IsInit() )
{
sResult += "w:equalWidth=\"";
sResult += m_oEqualWidth->ToString2(SimpleTypes::onofftostring1);
sResult += "\" ";
}
......@@ -2130,4 +2130,4 @@ namespace OOX
} // namespace Logic
}// namespace OOX
#endif // OOX_LOGIC_SECTOR_PROPERTY_INCLUDE_H_
\ No newline at end of file
#endif // OOX_LOGIC_SECTOR_PROPERTY_INCLUDE_H_
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