Compare commits

...

2 Commits

4 changed files with 42 additions and 35 deletions

View File

@ -318,20 +318,29 @@ public:
docRGB Color;
CThemeColor ThemeColor;
bool bValue;
bool bColor;
bool bThemeColor;
Shd()
{
Value = shd_Nil;
bValue = false;
bColor = false;
bThemeColor = false;
}
std::wstring ToString()
{
std::wstring sShd;
if(bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
if(bValue || bColor || (bThemeColor && ThemeColor.IsNoEmpty()))
{
sShd += L"<w:shd w:val=\"clear\" w:color=\"auto\"";
sShd += L"<w:shd";
if(bValue)
{
if(shd_Nil == Value)
sShd += L" w:val=\"nil\"";
else
sShd += L" w:val=\"clear\"";
}
sShd += L" w:color=\"auto\"";
if(bColor)
sShd += L" w:fill=\"" + Color.ToString() + L"\"";
if(bThemeColor && ThemeColor.IsNoEmpty())

View File

@ -266,7 +266,10 @@ private:
Shd* pShd = static_cast<Shd*>(poResult);
switch(type)
{
case c_oSerShdType::Value: pShd->Value = m_oBufferedStream.GetUChar();break;
case c_oSerShdType::Value:
pShd->bValue = true;
pShd->Value = m_oBufferedStream.GetUChar();
break;
case c_oSerShdType::Color:
pShd->bColor = true;
pShd->Color = ReadColor();
@ -451,11 +454,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
orPr->bShd = true;
orPr->Shd = oShd.ToString();
}
orPr->bShd = true;
orPr->Shd = oShd.ToString();
break;
}
case c_oSerProp_rPrType::RStyle:
@ -801,15 +801,7 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
else
{
std::wstring sShd(L"<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"auto\"/>");
pCStringWriter->WriteString(sShd);
}
pCStringWriter->WriteString(oShd.ToString());
break;
}
case c_oSerProp_pPrType::WidowControl:
@ -1782,11 +1774,8 @@ public:
{
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
pWiterTblPr->Shd = oShd.ToString();
m_sCurTableShd = pWiterTblPr->Shd;
}
else if( c_oSerProp_tblPrType::tblpPr == type )
{
@ -2244,10 +2233,7 @@ public:
bCellShd = true;
Shd oShd;
oBinary_CommonReader2.ReadShdOut(length, &oShd);
if(shd_Nil != oShd.Value)
{
pCStringWriter->WriteString(oShd.ToString());
}
pCStringWriter->WriteString(oShd.ToString());
}
else if( c_oSerProp_cellPrType::TableCellBorders == type )
{

View File

@ -3368,19 +3368,31 @@ namespace BinXlsxRW
if(oComment.m_sGfxdata.IsInit())
{
const std::wstring& sGfxData = oComment.m_sGfxdata.get2();
std::wstring sSignatureBase64(_T("WExTV"));
if(sSignatureBase64 == sGfxData.substr(0, sSignatureBase64.length()))
std::wstring sSignatureBase64Old(_T("WExTV"));//XLST
std::wstring sSignatureBase64(_T("WExTM"));//XLS2
//compatibility with fact that previously used long that can be 4 or 8 byte
bool bCompatibility = sSignatureBase64Old == sGfxData.substr(0, sSignatureBase64Old.length());
bool isComment = (sSignatureBase64 == sGfxData.substr(0, sSignatureBase64.length())) || bCompatibility;
if(isComment)
{
std::string sSignature("XLST");
std::string sSignature("XLS2");
int nSignatureSize = (int)sSignature.length();
int nDataLengthSize = sizeof(long);
int nDataLengthSize = bCompatibility ? sizeof(long) : sizeof(_INT32);
int nJunkSize = 2;
std::string sGfxDataA = std::string(sGfxData.begin(), sGfxData.end());
int nDataSize = (int)sGfxDataA.length();
BYTE* pBuffer = new BYTE[nDataSize];
if(false != Base64::Base64Decode((const char*)sGfxDataA.c_str(), (int)sGfxDataA.length(), pBuffer, &nDataSize))
{
int nLength = *((long*)(pBuffer + nSignatureSize));
int nLength;
if (bCompatibility)
{
nLength = *((long*)(pBuffer + nSignatureSize));
}
else
{
nLength = *((_INT32*)(pBuffer + nSignatureSize));
}
NSBinPptxRW::CBinaryFileReader oBufferedStream;
oBufferedStream.Init((BYTE*)pBuffer, nSignatureSize + nDataLengthSize, nLength);

View File

@ -2236,16 +2236,16 @@ namespace BinXlsxRW
BYTE* pSourceBuffer = m_oBufferedStream.GetPointer(length);
m_oBufferedStream.Seek(nStartPos);
std::string sSignature("XLST");
std::string sSignature("XLS2");
int nSignatureSize = (int)sSignature.length();
int nDataLengthSize = sizeof(long);
int nDataLengthSize = sizeof(_INT32);
int nJunkSize = 2;
int nWriteBufferLength = nSignatureSize + nDataLengthSize + length + nJunkSize;
BYTE* pWriteBuffer = new BYTE[nWriteBufferLength];
memcpy(pWriteBuffer, sSignature.c_str(), nSignatureSize);
memcpy(pWriteBuffer + nSignatureSize, &length, nDataLengthSize);
*((_INT32*)(pWriteBuffer + nSignatureSize)) = (_INT32)length;
memcpy(pWriteBuffer + nSignatureSize + nDataLengthSize, pSourceBuffer, length);
//пишем в конце 0, потому что при редактировании Excel меняет посление байты.
memset(pWriteBuffer + nSignatureSize + nDataLengthSize + length, 0, nJunkSize);