mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix copy memory
This commit is contained in:
@ -902,7 +902,7 @@
|
|||||||
// optional bBase64 - true/false base64 result
|
// optional bBase64 - true/false base64 result
|
||||||
// optional nWidget ...
|
// optional nWidget ...
|
||||||
// optional sIconView - icon - I/RI/IX
|
// optional sIconView - icon - I/RI/IX
|
||||||
CFile.prototype["getButtonIcons"] = function(pageIndex, width, height, backgroundColor, nWidget, bBase64, sIconView)
|
CFile.prototype["getButtonIcons"] = function(pageIndex, width, height, backgroundColor, bBase64, nWidget, sIconView)
|
||||||
{
|
{
|
||||||
let nView = -1;
|
let nView = -1;
|
||||||
if (sIconView)
|
if (sIconView)
|
||||||
@ -916,7 +916,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let res = {};
|
let res = {};
|
||||||
let ext = Module["_GetButtonIcons"](this.nativeFile, width, height, backgroundColor === undefined ? 0xFFFFFF : backgroundColor, pageIndex, nWidget === undefined ? -1 : nWidget, bBase64 === undefined ? false : bBase64, nView);
|
let ext = Module["_GetButtonIcons"](this.nativeFile, width, height, backgroundColor === undefined ? 0xFFFFFF : backgroundColor, pageIndex, bBase64 ? 1 : 0, nWidget === undefined ? -1 : nWidget, nView);
|
||||||
if (ext == 0)
|
if (ext == 0)
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
|
|||||||
@ -174,7 +174,7 @@ WASM_EXPORT BYTE* GetInteractiveFormsAP(CGraphicsFileDrawing* pGraphics, int nRa
|
|||||||
|
|
||||||
return pGraphics->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sButtonView);
|
return pGraphics->GetAPWidget(nRasterW, nRasterH, nBackgroundColor, nPageIndex, nWidget, sView, sButtonView);
|
||||||
}
|
}
|
||||||
WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, bool bBase64, int nButtonWidget, int nIconView)
|
WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nRasterW, int nRasterH, int nBackgroundColor, int nPageIndex, int bBase64, int nButtonWidget, int nIconView)
|
||||||
{
|
{
|
||||||
const char* sIconView = NULL;
|
const char* sIconView = NULL;
|
||||||
if (nIconView == 0)
|
if (nIconView == 0)
|
||||||
@ -184,7 +184,7 @@ WASM_EXPORT BYTE* GetButtonIcons(CGraphicsFileDrawing* pGraphics, int nRasterW,
|
|||||||
else if (nIconView == 2)
|
else if (nIconView == 2)
|
||||||
sIconView = "IX";
|
sIconView = "IX";
|
||||||
|
|
||||||
return pGraphics->GetButtonIcon(nRasterW, nRasterH, nBackgroundColor, nPageIndex, bBase64, nButtonWidget, sIconView);
|
return pGraphics->GetButtonIcon(nRasterW, nRasterH, nBackgroundColor, nPageIndex, bBase64 ? true : false, nButtonWidget, sIconView);
|
||||||
}
|
}
|
||||||
WASM_EXPORT BYTE* GetAnnotationsInfo(CGraphicsFileDrawing* pGraphics, int nPageIndex)
|
WASM_EXPORT BYTE* GetAnnotationsInfo(CGraphicsFileDrawing* pGraphics, int nPageIndex)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -915,7 +915,7 @@ int main(int argc, char* argv[])
|
|||||||
if (pWidgetsAP)
|
if (pWidgetsAP)
|
||||||
free(pWidgetsAP);
|
free(pWidgetsAP);
|
||||||
|
|
||||||
bool bBase64 = true;
|
int bBase64 = 1;
|
||||||
BYTE* pWidgetsMK = GetButtonIcons(pGrFile, nWidth, nHeight, 0xFFFFFF, nTestPage, bBase64, -1, -1);
|
BYTE* pWidgetsMK = GetButtonIcons(pGrFile, nWidth, nHeight, 0xFFFFFF, nTestPage, bBase64, -1, -1);
|
||||||
nLength = READ_INT(pWidgetsMK);
|
nLength = READ_INT(pWidgetsMK);
|
||||||
i = 4;
|
i = 4;
|
||||||
|
|||||||
@ -1025,23 +1025,39 @@ BYTE* CPdfReader::GetButtonIcon(int nRasterW, int nRasterH, int nBackgroundColor
|
|||||||
if (oImDict->lookup("Length", &oLength)->isInt())
|
if (oImDict->lookup("Length", &oLength)->isInt())
|
||||||
nLength = oLength.getInt();
|
nLength = oLength.getInt();
|
||||||
oLength.free();
|
oLength.free();
|
||||||
|
if (oImDict->lookup("DL", &oLength)->isInt())
|
||||||
|
nLength = oLength.getInt();
|
||||||
|
oLength.free();
|
||||||
|
|
||||||
// TODO используется размер закодированного потока, а необходим размер после декодирования, и DecodeLength есть не всегда
|
bool bNew = false;
|
||||||
BYTE* pBuffer = new BYTE[nLength];
|
BYTE* pBuffer = NULL;
|
||||||
BYTE* pBufferPtr = pBuffer;
|
|
||||||
|
|
||||||
Stream* pImage = oIm.getStream()->getUndecodedStream();
|
Stream* pImage = oIm.getStream()->getUndecodedStream();
|
||||||
for (int nI = 0; nI < nLength; ++nI)
|
MemStream* pMemory = dynamic_cast<MemStream*>(pImage);
|
||||||
*pBufferPtr++ = (BYTE)pImage->getChar();
|
if (pImage->getKind() == strWeird && pMemory)
|
||||||
|
{
|
||||||
|
if (pMemory->getBufPtr() + nLength == pMemory->getBufEnd())
|
||||||
|
pBuffer = (BYTE*)pMemory->getBufPtr();
|
||||||
|
else
|
||||||
|
nLength = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bNew = true;
|
||||||
|
pBuffer = new BYTE[nLength];
|
||||||
|
BYTE* pBufferPtr = pBuffer;
|
||||||
|
for (int nI = 0; nI < nLength; ++nI)
|
||||||
|
*pBufferPtr++ = (BYTE)pImage->getChar();
|
||||||
|
}
|
||||||
|
|
||||||
char* cData64 = NULL;
|
char* cData64 = NULL;
|
||||||
int nData64Dst = 0;
|
int nData64Dst = 0;
|
||||||
NSFile::CBase64Converter::Encode(pBuffer, nLength, cData64, nData64Dst);
|
NSFile::CBase64Converter::Encode(pBuffer, nLength, cData64, nData64Dst, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||||
|
|
||||||
oRes.WriteString((BYTE*)cData64, nData64Dst);
|
oRes.WriteString((BYTE*)cData64, nData64Dst);
|
||||||
|
|
||||||
nMKLength++;
|
nMKLength++;
|
||||||
RELEASEARRAYOBJECTS(pBuffer);
|
if (bNew)
|
||||||
|
RELEASEARRAYOBJECTS(pBuffer);
|
||||||
RELEASEARRAYOBJECTS(cData64);
|
RELEASEARRAYOBJECTS(cData64);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1276,7 +1292,7 @@ BYTE* CPdfReader::GetButtonIcon(int nRasterW, int nRasterH, int nBackgroundColor
|
|||||||
|
|
||||||
char* cData64 = NULL;
|
char* cData64 = NULL;
|
||||||
int nData64Dst = 0;
|
int nData64Dst = 0;
|
||||||
NSFile::CBase64Converter::Encode(pPngBuffer, nPngSize, cData64, nData64Dst);
|
NSFile::CBase64Converter::Encode(pPngBuffer, nPngSize, cData64, nData64Dst, NSBase64::B64_BASE64_FLAG_NOCRLF);
|
||||||
|
|
||||||
oRes.WriteString((BYTE*)cData64, nData64Dst);
|
oRes.WriteString((BYTE*)cData64, nData64Dst);
|
||||||
|
|
||||||
|
|||||||
@ -365,6 +365,9 @@ public:
|
|||||||
virtual GFileOffset getStart() { return start; }
|
virtual GFileOffset getStart() { return start; }
|
||||||
virtual void moveStart(int delta);
|
virtual void moveStart(int delta);
|
||||||
|
|
||||||
|
char* getBufPtr() { return bufPtr; }
|
||||||
|
char* getBufEnd() { return bufEnd; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|||||||
Reference in New Issue
Block a user