summaryrefslogtreecommitdiff
path: root/xfa/src/fxfa
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-10-23 15:16:01 -0700
committerLei Zhang <thestig@chromium.org>2015-10-23 15:16:01 -0700
commite5457b7376e4f2b69c691363368af6cf4df3e0d8 (patch)
treeff8888240e5c08ab7596b22aeb4c282174425f6d /xfa/src/fxfa
parent924b7e968e3aa19e9e916f8437acbf85d92df40e (diff)
downloadpdfium-e5457b7376e4f2b69c691363368af6cf4df3e0d8.tar.xz
Merge to XFA: Cleanup: Remove unused CPDF_Stream::Clone().
Cloning a CPDF_Stream actually happens via CPDF_Object::Clone(). Transitively, remove: - GetStreamFilter() -- all the filters. Also remove CXFA_FileRead. R=jam@chromium.org Review URL: https://codereview.chromium.org/1288543002 . (cherry picked from commit c9a05f1c90860a97dbe4b8014bc4584bfa3a4580) Review URL: https://codereview.chromium.org/1297463002 .
Diffstat (limited to 'xfa/src/fxfa')
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffapp.cpp86
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffapp.h15
-rw-r--r--xfa/src/fxfa/src/app/xfa_ffdoc.cpp2
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();