Commit 841dfe40 authored by konovalovsergey's avatar konovalovsergey Committed by Alexander Trofimov

open/save page border

parent a0bebab5
......@@ -24,6 +24,7 @@ public:
int PageNumStart;
CString sectPrChange;
CString cols;
CString pgBorders;
bool bHeader;
bool bFooter;
......@@ -89,6 +90,8 @@ public:
if(bFooter)
sRes.AppendFormat(_T(" w:footer=\"%d\""), nMFooter);
sRes.Append(_T("/>"));
if(!pgBorders.IsEmpty())
sRes.Append(pgBorders);
if(bPageNumStart)
sRes.AppendFormat(_T("<w:pgNumType w:start=\"%d\"/>"), PageNumStart);
if(!cols.IsEmpty())
......
......@@ -1171,6 +1171,12 @@ public:
res = Read1(length, &Binary_pPrReader::ReadCols, this, &oCols);
pSectPr->cols = oCols.toXML();
}
else if( c_oSerProp_secPrType::pgBorders == type )
{
OOX::Logic::CPageBorders pgBorders;
res = Read1(length, &Binary_pPrReader::ReadPageBorders, this, &pgBorders);
pSectPr->pgBorders = pgBorders.toXML();
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......@@ -1381,6 +1387,117 @@ public:
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadPageBorders(BYTE type, long length, void* poResult)
{
OOX::Logic::CPageBorders* pPageBorders = static_cast<OOX::Logic::CPageBorders*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerPageBorders::Display == type )
{
pPageBorders->m_oDisplay.Init();
pPageBorders->m_oDisplay->SetValue((SimpleTypes::EPageBorderDisplay)m_oBufferedStream.GetChar());
}
else if( c_oSerPageBorders::OffsetFrom == type )
{
pPageBorders->m_oOffsetFrom.Init();
pPageBorders->m_oOffsetFrom->SetValue((SimpleTypes::EPageBorderOffset)m_oBufferedStream.GetChar());
}
else if( c_oSerPageBorders::ZOrder == type )
{
pPageBorders->m_oZOrder.Init();
pPageBorders->m_oZOrder->SetValue((SimpleTypes::EPageBorderZOrder)m_oBufferedStream.GetChar());
}
else if( c_oSerPageBorders::Bottom == type )
{
pPageBorders->m_oBottom.Init();
res = Read2(length, &Binary_pPrReader::ReadPageBorder, this, pPageBorders->m_oBottom.GetPointer());
}
else if( c_oSerPageBorders::Left == type )
{
pPageBorders->m_oLeft.Init();
res = Read2(length, &Binary_pPrReader::ReadPageBorder, this, pPageBorders->m_oLeft.GetPointer());
}
else if( c_oSerPageBorders::Right == type )
{
pPageBorders->m_oRight.Init();
res = Read2(length, &Binary_pPrReader::ReadPageBorder, this, pPageBorders->m_oRight.GetPointer());
}
else if( c_oSerPageBorders::Top == type )
{
pPageBorders->m_oTop.Init();
res = Read2(length, &Binary_pPrReader::ReadPageBorder, this, pPageBorders->m_oTop.GetPointer());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
int ReadPageBorder(BYTE type, long length, void* poResult)
{
ComplexTypes::Word::CPageBorder* pPageBorder = static_cast<ComplexTypes::Word::CPageBorder*>(poResult);
int res = c_oSerConstants::ReadOk;
if( c_oSerPageBorders::Color == type )
{
docRGB color = oBinary_CommonReader2.ReadColor();
pPageBorder->m_oColor.Init();
pPageBorder->m_oColor->SetValue(SimpleTypes::hexcolorRGB);
pPageBorder->m_oColor->Set_R(color.R);
pPageBorder->m_oColor->Set_G(color.G);
pPageBorder->m_oColor->Set_B(color.B);
}
else if( c_oSerPageBorders::ColorTheme == type )
{
CThemeColor themeColor;
oBinary_CommonReader2.ReadThemeColor(length, themeColor);
if(themeColor.Auto)
{
pPageBorder->m_oColor.Init();
pPageBorder->m_oColor->SetValue(SimpleTypes::hexcolorAuto);
}
if(themeColor.bColor)
{
pPageBorder->m_oThemeColor.Init();
pPageBorder->m_oThemeColor->SetValue((SimpleTypes::EThemeColor)themeColor.Color);
}
if(themeColor.bShade)
{
pPageBorder->m_oThemeShade.Init();
pPageBorder->m_oThemeShade->SetValue(themeColor.Shade);
}
if(themeColor.bTint)
{
pPageBorder->m_oThemeTint.Init();
pPageBorder->m_oThemeTint->SetValue(themeColor.Tint);
}
}
else if( c_oSerPageBorders::Space == type )
{
pPageBorder->m_oSpace.Init();
pPageBorder->m_oSpace->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerPageBorders::Sz == type )
{
pPageBorder->m_oSz.Init();
pPageBorder->m_oSz->SetValue(m_oBufferedStream.GetLong());
}
else if( c_oSerPageBorders::Val == type )
{
pPageBorder->m_oVal.Init();
pPageBorder->m_oVal->SetValue((SimpleTypes::EBorder)m_oBufferedStream.GetLong());
}
else if( c_oSerPageBorders::Frame == type )
{
pPageBorder->m_oFrame.Init();
pPageBorder->m_oFrame->FromBool(m_oBufferedStream.GetBool());
}
else if( c_oSerPageBorders::Shadow == type )
{
pPageBorder->m_oShadow.Init();
pPageBorder->m_oShadow->FromBool(m_oBufferedStream.GetBool());
}
else
res = c_oSerConstants::ReadUnknown;
return res;
}
};
class Binary_tblPrReader : public Binary_CommonReader<Binary_tblPrReader>
{
......
......@@ -390,7 +390,8 @@ extern int g_nCurFormatVersion;
hdrftrelem = 5,
pageNumType = 6,
sectPrChange = 7,
cols = 8
cols = 8,
pgBorders = 9
};}
namespace c_oSerProp_secPrSettingsType{enum c_oSerProp_secPrSettingsType
{
......@@ -882,6 +883,24 @@ extern int g_nCurFormatVersion;
ColumnSpace = 5,
ColumnW = 6
};}
namespace c_oSerPageBorders{enum c_oSerPageBorders
{
Display = 0,
OffsetFrom = 1,
ZOrder = 2,
Bottom = 3,
Left = 4,
Right = 5,
Top = 6,
Color = 7,
Frame = 8,
Id = 9,
Shadow = 10,
Space = 11,
Sz = 12,
ColorTheme = 13,
Val = 16
};}
}
#endif // #ifndef DOCX_BIN_READER_WRITER_DEFINES
......@@ -1297,6 +1297,12 @@ namespace BinDocxRW
WriteColumns(pSectPr->m_oCols.get());
m_oBcw.WriteItemEnd(nCurPos);
}
if(pSectPr->m_oPgBorders.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerProp_secPrType::pgBorders);
WritePageBorders(pSectPr->m_oPgBorders.get());
m_oBcw.WriteItemEnd(nCurPos);
}
};
void WritePageSettings(OOX::Logic::CSectionProperty* pSectPr)
{
......@@ -1517,6 +1523,92 @@ namespace BinDocxRW
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
}
void WritePageBorders(const OOX::Logic::CPageBorders& PageBorders)
{
int nCurPos = 0;
if(PageBorders.m_oDisplay.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::Display);
m_oBcw.m_oStream.WriteBYTE(PageBorders.m_oDisplay->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(PageBorders.m_oOffsetFrom.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::OffsetFrom);
m_oBcw.m_oStream.WriteBYTE(PageBorders.m_oOffsetFrom->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(PageBorders.m_oZOrder.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::ZOrder);
m_oBcw.m_oStream.WriteBYTE(PageBorders.m_oZOrder->GetValue());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(PageBorders.m_oBottom.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::Bottom);
WritePageBorder(PageBorders.m_oBottom.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(PageBorders.m_oLeft.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::Left);
WritePageBorder(PageBorders.m_oLeft.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(PageBorders.m_oRight.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::Right);
WritePageBorder(PageBorders.m_oRight.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
if(PageBorders.m_oTop.IsInit())
{
nCurPos = m_oBcw.WriteItemStart(c_oSerPageBorders::Top);
WritePageBorder(PageBorders.m_oTop.get());
m_oBcw.WriteItemWithLengthEnd(nCurPos);
}
};
void WritePageBorder(const ComplexTypes::Word::CPageBorder& pageBorder)
{
int nCurPos = 0;
if(pageBorder.m_oColor.IsInit())
{
m_oBcw.WriteColor(c_oSerPageBorders::Color, pageBorder.m_oColor.get());
}
m_oBcw.WriteThemeColor(c_oSerPageBorders::ColorTheme, pageBorder.m_oColor, pageBorder.m_oThemeColor, pageBorder.m_oThemeTint, pageBorder.m_oThemeShade);
if(pageBorder.m_oSpace.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPageBorders::Space);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pageBorder.m_oSpace->GetValue());
}
if(pageBorder.m_oSz.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPageBorders::Sz);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pageBorder.m_oSz->GetValue());
}
if(pageBorder.m_oVal.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPageBorders::Val);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Long);
m_oBcw.m_oStream.WriteLONG(pageBorder.m_oVal.get().GetValue());
}
if(pageBorder.m_oFrame.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPageBorders::Frame);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(pageBorder.m_oFrame->ToBool());
}
if(pageBorder.m_oShadow.IsInit())
{
m_oBcw.m_oStream.WriteBYTE(c_oSerPageBorders::Shadow);
m_oBcw.m_oStream.WriteBYTE(c_oSerPropLenType::Byte);
m_oBcw.m_oStream.WriteBOOL(pageBorder.m_oShadow->ToBool());
}
//todo id
};
};
class Binary_tblPrWriter
{
......
......@@ -1860,7 +1860,7 @@ namespace SimpleTypes
//--------------------------------------------------------------------------------
template<int nDefValue = 0>
class CEighthPointMeasure : CSimpleType<int, nDefValue>
class CEighthPointMeasure : public CSimpleType<int, nDefValue>
{
public:
CEighthPointMeasure() {}
......@@ -2634,6 +2634,31 @@ namespace SimpleTypes
default : return _T("auto");
}
}
virtual CString ToStringNoAlpha () const
{
switch(this->m_eValue)
{
case hexcolorAuto : return _T("auto");
case hexcolorRGB :
{
CString sResult =_T("");//alfa
if(m_unR > 0x0f)
sResult.AppendFormat(_T("%X"), m_unR);
else
sResult.AppendFormat(_T("0%X"), m_unR);
if(m_unG > 0x0f)
sResult.AppendFormat(_T("%X"), m_unG);
else
sResult.AppendFormat(_T("0%X"), m_unG);
if(m_unB > 0x0f)
sResult.AppendFormat(_T("%X"), m_unB);
else
sResult.AppendFormat(_T("0%X"), m_unB);
return sResult;
}
default : return _T("auto");
}
}
SimpleType_FromString (EHexColor)
SimpleType_Operator_Equal (CHexColor)
......
......@@ -404,14 +404,14 @@ namespace ComplexTypes
if ( m_oColor.IsInit() )
{
sResult += _T("w:color=\"");
sResult += m_oColor->ToString();
sResult += m_oColor->ToStringNoAlpha();
sResult += _T("\" ");
}
if ( m_oFrame.IsInit() )
{
sResult += _T("w:frame=\"");
sResult += m_oFrame->ToString();
sResult += m_oFrame->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
if ( m_oId.IsInit() )
......@@ -424,7 +424,7 @@ namespace ComplexTypes
if ( m_oShadow.IsInit() )
{
sResult += _T("w:shadow=\"");
sResult += m_oShadow->ToString();
sResult += m_oShadow->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
......@@ -561,14 +561,14 @@ namespace ComplexTypes
if ( m_oColor.IsInit() )
{
sResult += _T("w:color=\"");
sResult += m_oColor->ToString();
sResult += m_oColor->ToStringNoAlpha();
sResult += _T("\" ");
}
if ( m_oFrame.IsInit() )
{
sResult += _T("w:frame=\"");
sResult += m_oFrame->ToString();
sResult += m_oFrame->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
if ( m_oId.IsInit() )
......@@ -581,7 +581,7 @@ namespace ComplexTypes
if ( m_oShadow.IsInit() )
{
sResult += _T("w:shadow=\"");
sResult += m_oShadow->ToString();
sResult += m_oShadow->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
......@@ -700,14 +700,14 @@ namespace ComplexTypes
if ( m_oColor.IsInit() )
{
sResult += _T("w:color=\"");
sResult += m_oColor->ToString();
sResult += m_oColor->ToStringNoAlpha();
sResult += _T("\" ");
}
if ( m_oFrame.IsInit() )
{
sResult += _T("w:frame=\"");
sResult += m_oFrame->ToString();
sResult += m_oFrame->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
if ( m_oId.IsInit() )
......@@ -720,7 +720,7 @@ namespace ComplexTypes
if ( m_oShadow.IsInit() )
{
sResult += _T("w:shadow=\"");
sResult += m_oShadow->ToString();
sResult += m_oShadow->ToString2(SimpleTypes::onofftostring1);
sResult += _T("\" ");
}
......
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