mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-19 23:02:34 +08:00
bug: bug on save onlyoffice extention for comments in xlsx
This commit is contained in:
@ -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);
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user