diff options
Diffstat (limited to 'xfa/src/fxfa')
-rw-r--r-- | xfa/src/fxfa/src/app/xfa_ffapp.cpp | 86 | ||||
-rw-r--r-- | xfa/src/fxfa/src/app/xfa_ffapp.h | 15 | ||||
-rw-r--r-- | xfa/src/fxfa/src/app/xfa_ffdoc.cpp | 2 |
3 files changed, 8 insertions, 95 deletions
diff --git a/xfa/src/fxfa/src/app/xfa_ffapp.cpp b/xfa/src/fxfa/src/app/xfa_ffapp.cpp index 5cdbb3661b..bca0e182e8 100644 --- a/xfa/src/fxfa/src/app/xfa_ffapp.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffapp.cpp @@ -13,89 +13,15 @@ #include "xfa_fwltheme.h"
#include "xfa_fontmgr.h"
#include "xfa_ffwidgethandler.h"
-CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams)
- : m_dwSize(0) {
- m_Streams.Copy(streams);
-}
-CXFA_FileRead::~CXFA_FileRead() {
- m_Streams.RemoveAll();
- m_StreamSize.RemoveAll();
-}
-FX_FILESIZE CXFA_FileRead::GetSize() {
- if (m_StreamSize.GetSize() > 0) {
- return m_dwSize;
- }
- int32_t iCount = m_Streams.GetSize();
- FX_DWORD iBufferSize = 4096;
- uint8_t* pBuf = FX_Alloc(uint8_t, iBufferSize);
- for (int32_t i = 0; i < iCount; i++) {
- CPDF_StreamFilter* pStreamFilter = m_Streams[i]->GetStreamFilter(FALSE);
- FX_DWORD dwCurSize = 0;
- while (TRUE) {
- FX_DWORD dwRead = pStreamFilter->ReadBlock(pBuf, iBufferSize);
- dwCurSize += dwRead;
- if (dwRead < iBufferSize) {
- break;
- }
- }
- m_dwSize += dwCurSize;
- m_StreamSize.Add(dwCurSize);
- delete pStreamFilter;
- }
- FX_Free(pBuf);
- return m_dwSize;
-}
-FX_BOOL CXFA_FileRead::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- FX_FILESIZE dwLen = 0;
- int32_t iCount = m_Streams.GetSize();
- int32_t i = 0;
- for (; i < iCount; i++) {
- dwLen += m_StreamSize[i];
- if (dwLen > offset) {
- dwLen -= m_StreamSize[i];
- break;
- }
- }
- if (i >= iCount) {
- return FALSE;
- }
- CPDF_StreamFilter* pStreamFilter = m_Streams[i]->GetStreamFilter(FALSE);
- if ((offset -= dwLen) > 0) {
- uint8_t* pBuf = FX_Alloc(uint8_t, offset);
- FX_DWORD dwRead = pStreamFilter->ReadBlock(pBuf, offset);
- FX_Free(pBuf);
- }
- FX_DWORD dwHadRead = pStreamFilter->ReadBlock((uint8_t*)buffer, size);
- delete pStreamFilter;
- size -= dwHadRead;
- if (size <= 0) {
- return TRUE;
- }
- FX_DWORD dwReadSize = dwHadRead;
- for (int32_t iStart = i + 1; iStart < iCount; iStart++) {
- CPDF_StreamFilter* pStreamFilter =
- m_Streams[iStart]->GetStreamFilter(FALSE);
- FX_DWORD dwHadRead =
- pStreamFilter->ReadBlock(((uint8_t*)buffer) + dwReadSize, size);
- delete pStreamFilter;
- size -= dwHadRead;
- if (size <= 0) {
- return TRUE;
- }
- dwReadSize += dwHadRead;
- }
- return FALSE;
-}
-CXFA_FileRead2::CXFA_FileRead2(const CFX_ArrayTemplate<CPDF_Stream*>& streams) {
+
+CXFA_FileRead::CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams) {
int32_t iCount = streams.GetSize();
for (int32_t i = 0; i < iCount; i++) {
CPDF_StreamAcc& acc = m_Data.Add();
acc.LoadAllData(streams[i]);
}
}
-FX_FILESIZE CXFA_FileRead2::GetSize() {
+FX_FILESIZE CXFA_FileRead::GetSize() {
FX_DWORD dwSize = 0;
int32_t iCount = m_Data.GetSize();
for (int32_t i = 0; i < iCount; i++) {
@@ -104,9 +30,9 @@ FX_FILESIZE CXFA_FileRead2::GetSize() { }
return dwSize;
}
-FX_BOOL CXFA_FileRead2::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+FX_BOOL CXFA_FileRead::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
int32_t iCount = m_Data.GetSize();
int32_t index = 0;
while (index < iCount) {
diff --git a/xfa/src/fxfa/src/app/xfa_ffapp.h b/xfa/src/fxfa/src/app/xfa_ffapp.h index 3137b0d965..838d2d6fce 100644 --- a/xfa/src/fxfa/src/app/xfa_ffapp.h +++ b/xfa/src/fxfa/src/app/xfa_ffapp.h @@ -9,20 +9,7 @@ class CXFA_FileRead : public IFX_FileRead {
public:
- CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams);
- ~CXFA_FileRead();
- virtual FX_FILESIZE GetSize();
- virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
- virtual void Release() { delete this; }
-
- protected:
- CFX_ArrayTemplate<CPDF_Stream*> m_Streams;
- CFX_DWordArray m_StreamSize;
- FX_DWORD m_dwSize;
-};
-class CXFA_FileRead2 : public IFX_FileRead {
- public:
- CXFA_FileRead2(const CFX_ArrayTemplate<CPDF_Stream*>& streams);
+ explicit CXFA_FileRead(const CFX_ArrayTemplate<CPDF_Stream*>& streams);
virtual FX_FILESIZE GetSize();
virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size);
diff --git a/xfa/src/fxfa/src/app/xfa_ffdoc.cpp b/xfa/src/fxfa/src/app/xfa_ffdoc.cpp index 84beae9b8b..69907a5f6b 100644 --- a/xfa/src/fxfa/src/app/xfa_ffdoc.cpp +++ b/xfa/src/fxfa/src/app/xfa_ffdoc.cpp @@ -252,7 +252,7 @@ FX_BOOL CXFA_FFDoc::OpenDoc(CPDF_Document* pPDFDoc) { if (xfaStreams.GetSize() < 1) {
return FALSE;
}
- IFX_FileRead* pFileRead = new CXFA_FileRead2(xfaStreams);
+ IFX_FileRead* pFileRead = new CXFA_FileRead(xfaStreams);
m_pPDFDoc = pPDFDoc;
if (m_pStream) {
m_pStream->Release();
|