Commit 97a87307 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander Trofimov

(2.0.0.166): ASCOfficeDocxFile2

themecolor на открытие

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@55794 954022d7-b5bf-4e40-9824-e11837661b57
parent 34273b14
......@@ -111,6 +111,84 @@ public:
return sR + sG + sB;
}
};
class CThemeColor{
public:
bool Auto;
byte Color;
byte Tint;
byte Shade;
bool bShade;
bool bTint;
bool bColor;
CThemeColor(){
Reset();
}
void Reset()
{
bShade = false;
bTint = false;
bColor = false;
Auto = false;
}
bool IsNoEmpty()
{
return bShade || bTint || bColor || Auto;
}
CString ToStringColor()
{
CString sRes;
if(bColor)
{
switch(Color)
{
case 0: sRes = _T("accent1");break;
case 1: sRes = _T("accent2");break;
case 2: sRes = _T("accent3");break;
case 3: sRes = _T("accent4");break;
case 4: sRes = _T("accent5");break;
case 5: sRes = _T("accent6");break;
case 6: sRes = _T("background1");break;
case 7: sRes = _T("background2");break;
case 8: sRes = _T("dark1");break;
case 9: sRes = _T("dark2");break;
case 10: sRes = _T("followedHyperlink");break;
case 11: sRes = _T("hyperlink");break;
case 12: sRes = _T("light1");break;
case 13: sRes = _T("light2");break;
case 14: sRes = _T("none");break;
case 15: sRes = _T("text1");break;
case 16: sRes = _T("text2");break;
default : sRes = _T("none");break;
}
}
return sRes;
}
CString ToStringTint()
{
CString sRes;
if(bTint)
{
if(Tint > 0xF)
sRes.AppendFormat(_T("%X"), Tint);
else
sRes.AppendFormat(_T("0%X"), Tint);
}
return sRes;
}
CString ToStringShade()
{
CString sRes;
if(bShade)
{
if(Shade > 0xF)
sRes.AppendFormat(_T("%X"), Shade);
else
sRes.AppendFormat(_T("0%X"), Shade);
}
return sRes;
}
};
class Spacing
{
public:
......@@ -142,13 +220,38 @@ class Shd
public:
BYTE Value;
docRGB Color;
CThemeColor ThemeColor;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bColor = false;
bThemeColor = false;
}
CString ToString()
{
return Color.ToString();
CString sShd;
if(bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
{
sShd.Append(_T("<w:shd w:val=\"clear\" w:color=\"auto\""));
if(bColor)
sShd.AppendFormat(_T(" w:fill=\"%s\""), Color.ToString());
if(bThemeColor && ThemeColor.IsNoEmpty())
{
if(ThemeColor.Auto && !bColor)
sShd.Append(_T(" w:fill=\"auto\""));
if(ThemeColor.bColor)
sShd.AppendFormat(_T(" w:themeFill=\"%s\""), ThemeColor.ToStringColor());
if(ThemeColor.bTint)
sShd.AppendFormat(_T(" w:themeFillTint=\"%s\""), ThemeColor.ToStringTint());
if(ThemeColor.bShade)
sShd.AppendFormat(_T(" w:themeFillShade=\"%s\""), ThemeColor.ToStringShade());
}
sShd.Append(_T("/>"));
}
return sShd;
}
};
class Tab
......@@ -199,6 +302,7 @@ public:
CString Lang;
CString LangBidi;
CString LangEA;
CThemeColor ThemeColor;
bool bBold;
bool bItalic;
......@@ -227,6 +331,7 @@ public:
bool bLang;
bool bLangBidi;
bool bLangEA;
bool bThemeColor;
bool bDoNotWriteNullProp;
public:
......@@ -273,11 +378,13 @@ public:
bLang = false;
bLangBidi = false;
bLangEA = false;
bThemeColor = false;
ThemeColor.Reset();
}
bool IsNoEmpty()
{
return bBold || bItalic || bUnderline || bStrikeout || bFontAscii || bFontHAnsi || bFontAE || bFontCS || bFontSize || bColor || bVertAlign || bHighLight ||
bRStyle || bSpacing || bDStrikeout || bCaps || bSmallCaps || bPosition || bFontHint || bBoldCs || bItalicCs || bFontSizeCs || bCs || bRtl || bLang || bLangBidi || bLangEA;
bRStyle || bSpacing || bDStrikeout || bCaps || bSmallCaps || bPosition || bFontHint || bBoldCs || bItalicCs || bFontSizeCs || bCs || bRtl || bLang || bLangBidi || bLangEA || bThemeColor;
}
void Write(XmlUtils::CStringWriter* pCStringWriter)
{
......@@ -375,9 +482,23 @@ public:
else if(false == bDoNotWriteNullProp)
pCStringWriter->WriteString(CString(_T("<w:dstrike w:val=\"false\"/>")));
}
if(bColor)
if(bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
{
CString sColor;sColor.Format(_T("<w:color w:val=\"%s\" />"), Color.ToString());
CString sColor(_T("<w:color"));
if(bColor)
sColor.AppendFormat(_T(" w:val=\"%s\""), Color.ToString());
if(bThemeColor && ThemeColor.IsNoEmpty())
{
if(ThemeColor.Auto && !bColor)
sColor.Append(_T(" w:val=\"auto\""));
if(ThemeColor.bColor)
sColor.AppendFormat(_T(" w:themeColor=\"%s\""), ThemeColor.ToStringColor());
if(ThemeColor.bTint)
sColor.AppendFormat(_T(" w:themeTint=\"%s\""), ThemeColor.ToStringTint());
if(ThemeColor.bShade)
sColor.AppendFormat(_T(" w:themeShade=\"%s\""), ThemeColor.ToStringShade());
}
sColor.Append(_T("/>"));
pCStringWriter->WriteString(sColor);
}
if(bSpacing)
......@@ -818,17 +939,20 @@ public:
double Space;
double Size;
BYTE Value;
CThemeColor ThemeColor;
bool bColor;
bool bSpace;
bool bSize;
bool bValue;
bool bThemeColor;
docBorder()
{
bColor = false;
bSpace = false;
bSize = false;
bValue = false;
bThemeColor = false;
}
void Write(CString sName, XmlUtils::CStringWriter* pCStringWriter, bool bCell)
{
......@@ -854,6 +978,29 @@ public:
CString sSpace;sSpace.Format(_T(" w:space=\"%d\""), nSpace);
pCStringWriter->WriteString(sSpace);
}
if(bThemeColor && ThemeColor.IsNoEmpty())
{
if(ThemeColor.Auto && !bColor)
{
CString sAuto(_T(" w:color=\"auto\""));
pCStringWriter->WriteString(sAuto);
}
if(ThemeColor.bColor)
{
CString sThemeColor;sThemeColor.Format(_T(" w:themeColor=\"%s\""), ThemeColor.ToStringColor());
pCStringWriter->WriteString(sThemeColor);
}
if(ThemeColor.bTint)
{
CString sThemeTint;sThemeTint.Format(_T(" w:themeTint=\"%s\""), ThemeColor.ToStringTint());
pCStringWriter->WriteString(sThemeTint);
}
if(ThemeColor.bShade)
{
CString sThemeShade;sThemeShade.Format(_T(" w:themeShade=\"%s\""), ThemeColor.ToStringShade());
pCStringWriter->WriteString(sThemeShade);
}
}
pCStringWriter->WriteString(CString(_T("/>")));
}
else
......
......@@ -121,6 +121,37 @@ public:
oRGB.B = m_oBufferedStream.ReadByte();
return oRGB;
}
void ReadThemeColor(int length, CThemeColor& oCThemeColor)
{
Read2(length, &Binary_CommonReader2::_ReadThemeColor, this, &oCThemeColor);
}
int _ReadThemeColor(BYTE type, long length, void* poResult)
{
int res = c_oSerConstants::ReadOk;
CThemeColor* pCThemeColor = static_cast<CThemeColor*>(poResult);
switch(type)
{
case c_oSer_ColorThemeType::Auto:
pCThemeColor->Auto = true;
break;
case c_oSer_ColorThemeType::Color:
pCThemeColor->bColor = true;
pCThemeColor->Color = m_oBufferedStream.ReadByte();
break;
case c_oSer_ColorThemeType::Tint:
pCThemeColor->bTint = true;
pCThemeColor->Tint = m_oBufferedStream.ReadByte();
break;
case c_oSer_ColorThemeType::Shade:
pCThemeColor->bShade = true;
pCThemeColor->Shade = m_oBufferedStream.ReadByte();
break;
default:
res = c_oSerConstants::ReadUnknown;
break;
}
return res;
}
int ReadShdOut(long length, Shd* shd)
{
return Read2(length, &Binary_CommonReader2::ReadShd, this, shd);
......@@ -133,7 +164,14 @@ private:
switch(type)
{
case c_oSerShdType::Value: pShd->Value = m_oBufferedStream.ReadByte();break;
case c_oSerShdType::Color: pShd->Color = ReadColor();break;
case c_oSerShdType::Color:
pShd->bColor = true;
pShd->Color = ReadColor();
break;
case c_oSerShdType::ColorTheme:
pShd->bThemeColor = true;
ReadThemeColor(length, pShd->ThemeColor);
break;
default:
res = c_oSerConstants::ReadUnknown;
break;
......@@ -372,6 +410,12 @@ public:
orPr->LangEA = m_oBufferedStream.ReadString2(length);
}
break;
case c_oSerProp_rPrType::ColorTheme:
{
orPr->bThemeColor = true;
oBinary_CommonReader2.ReadThemeColor(length, orPr->ThemeColor);
}
break;
default:
res = c_oSerConstants::ReadUnknown;
break;
......@@ -544,9 +588,7 @@ public:
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
CString sShd;
sShd.Format(_T("<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"%s\"/>"), oShd.ToString());
pCStringWriter->WriteString(sShd);
pCStringWriter->WriteString(oShd.ToString());
}
else
{
......@@ -849,6 +891,11 @@ public:
odocBorder->bValue = true;
odocBorder->Value = m_oBufferedStream.ReadByte();
}
else if( c_oSerBorderType::ColorTheme == type )
{
odocBorder->bThemeColor = true;
oBinary_CommonReader2.ReadThemeColor(length, odocBorder->ThemeColor);
}
else
res = c_oSerConstants::ReadUnknown;
return res;
......@@ -1178,7 +1225,7 @@ public:
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pWiterTblPr->Shd.Format(_T("<w:shd w:fill=\"%s\" w:val=\"clear\" w:color=\"auto\" />"), oShd.ToString());
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
}
......@@ -1590,9 +1637,7 @@ public:
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
CString sShd;
sShd.Format(_T("<w:shd w:fill=\"%s\" w:val=\"clear\" w:color=\"auto\" />"), oShd.ToString());
pCStringWriter->WriteString(sShd);
pCStringWriter->WriteString(oShd.ToString());
}
}
else if( c_oSerProp_cellPrType::TableCellBorders == type )
......
......@@ -326,7 +326,8 @@ const int g_nFormatVersion = 5;
Rtl = 24,
Lang = 25,
LangBidi = 26,
LangEA = 27
LangEA = 27,
ColorTheme = 28
};}
namespace c_oSerProp_rowPrType{enum c_oSerProp_rowPrType
{
......@@ -521,12 +522,14 @@ const int g_nFormatVersion = 5;
Color = 0,
Space = 1,
Size = 2,
Value = 3
Value = 3,
ColorTheme = 4
};}
namespace c_oSerShdType{enum c_oSerShdType
{
Value = 0,
Color = 1
Color = 1,
ColorTheme = 2
};}
namespace c_oSerPaddingType{enum c_oSerPaddingType
{
......@@ -786,4 +789,11 @@ const int g_nFormatVersion = 5;
DocLocation = 5,
TgtFrame = 6
};}
namespace c_oSer_ColorThemeType{ enum c_oSer_ColorThemeType
{
Auto = 0,
Color = 1,
Tint = 2,
Shade = 3
};}
}
......@@ -61,6 +61,7 @@ namespace BinDocxRW
{
if(border.m_oColor.IsInit())
WriteColor(c_oSerBorderType::Color, border.m_oColor.get());
WriteThemeColor(c_oSerBorderType::ColorTheme, border.m_oColor, border.m_oThemeColor, border.m_oThemeTint, border.m_oThemeShade);
if(border.m_oSpace.IsInit())
{
m_oStream.WriteByte(c_oSerBorderType::Space);
......@@ -227,18 +228,42 @@ namespace BinDocxRW
m_oStream.WriteByte(color.Get_G());
m_oStream.WriteByte(color.Get_B());
}
else if(SimpleTypes::hexcolorAuto == color.GetValue())
};
void WriteThemeColor(BYTE type, const nullable<SimpleTypes::CHexColor<>>& oHexColor, const nullable<SimpleTypes::CThemeColor<>>& oThemeColor,
const nullable<SimpleTypes::CUcharHexNumber<>>& oThemeTint, const nullable<SimpleTypes::CUcharHexNumber<>>& oThemeShade)
{
if(oHexColor.IsInit() && SimpleTypes::hexcolorAuto == oHexColor->GetValue() || oThemeColor.IsInit() || oThemeTint.IsInit() || oThemeShade.IsInit())
{
m_oStream.WriteByte(type);
m_oStream.WriteByte(c_oSerPropLenType::Three);
m_oStream.WriteByte(0);
m_oStream.WriteByte(0);
m_oStream.WriteByte(0);
m_oStream.WriteByte(c_oSerPropLenType::Variable);
int nCurPos = WriteItemWithLengthStart();
if(oHexColor.IsInit() && SimpleTypes::hexcolorAuto == oHexColor->GetValue())
{
m_oStream.WriteByte(c_oSer_ColorThemeType::Auto);
m_oStream.WriteByte(c_oSerPropLenType::Null);
}
if(oThemeColor.IsInit())
{
m_oStream.WriteByte(c_oSer_ColorThemeType::Color);
m_oStream.WriteByte(c_oSerPropLenType::Byte);
m_oStream.WriteByte(oThemeColor->GetValue());
}
if(oThemeTint.IsInit())
{
m_oStream.WriteByte(c_oSer_ColorThemeType::Tint);
m_oStream.WriteByte(c_oSerPropLenType::Byte);
m_oStream.WriteByte(oThemeTint->GetValue());
}
if(oThemeShade.IsInit())
{
m_oStream.WriteByte(c_oSer_ColorThemeType::Shade);
m_oStream.WriteByte(c_oSerPropLenType::Byte);
m_oStream.WriteByte(oThemeShade->GetValue());
}
WriteItemWithLengthEnd(nCurPos);
}
};
void WriteShd(const ComplexTypes::Word::CShading& Shd)
{
if(Shd.m_oFill.IsInit() && SimpleTypes::hexcolorRGB == Shd.m_oFill->GetValue())
{
//Type
if(false != Shd.m_oVal.IsInit())
......@@ -253,11 +278,8 @@ namespace BinDocxRW
}
//Value
if(false != Shd.m_oFill.IsInit())
{
//Todo themeColor
WriteColor(c_oSerShdType::Color, Shd.m_oFill.get());
}
}
WriteThemeColor(c_oSerShdType::ColorTheme, Shd.m_oFill, Shd.m_oThemeFill, Shd.m_oThemeFillTint, Shd.m_oThemeFillShade);
};
void WriteDistance(const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistL,
const NSCommon::nullable<SimpleTypes::CWrapDistance<>>& m_oDistT,
......@@ -530,6 +552,8 @@ namespace BinDocxRW
if(false != rPr.m_oColor.IsInit())
{
m_oBcw.WriteColor(c_oSerProp_rPrType::Color, rPr.m_oColor.get().m_oVal.get());
m_oBcw.WriteThemeColor(c_oSerProp_rPrType::ColorTheme, rPr.m_oColor->m_oVal, rPr.m_oColor->m_oThemeColor, rPr.m_oColor->m_oThemeTint, rPr.m_oColor->m_oThemeShade);
}
//VertAlign
if(false != rPr.m_oVertAlign.IsInit())
......
......@@ -2,6 +2,6 @@
//2
//0
//0
//165
#define INTVER 2,0,0,165
#define STRVER "2,0,0,165\0"
//166
#define INTVER 2,0,0,166
#define STRVER "2,0,0,166\0"
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