Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: xfa/fxfa/app/xfa_ffapp.cpp

Issue 2558373002: Remove last usage of CFX_ObjectArray. (Closed)
Patch Set: disallow copy and assign Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcrt/fx_basic.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fxfa/xfa_ffapp.h" 7 #include "xfa/fxfa/xfa_ffapp.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "third_party/base/stl_util.h"
14 #include "xfa/fgas/font/cfgas_fontmgr.h" 15 #include "xfa/fgas/font/cfgas_fontmgr.h"
15 #include "xfa/fwl/cfwl_notedriver.h" 16 #include "xfa/fwl/cfwl_notedriver.h"
16 #include "xfa/fwl/cfwl_widgetmgr.h" 17 #include "xfa/fwl/cfwl_widgetmgr.h"
17 #include "xfa/fxfa/app/xfa_fwladapter.h" 18 #include "xfa/fxfa/app/xfa_fwladapter.h"
18 #include "xfa/fxfa/app/xfa_fwltheme.h" 19 #include "xfa/fxfa/app/xfa_fwltheme.h"
19 #include "xfa/fxfa/xfa_ffdoc.h" 20 #include "xfa/fxfa/xfa_ffdoc.h"
20 #include "xfa/fxfa/xfa_ffdochandler.h" 21 #include "xfa/fxfa/xfa_ffdochandler.h"
21 #include "xfa/fxfa/xfa_ffwidgethandler.h" 22 #include "xfa/fxfa/xfa_ffwidgethandler.h"
22 #include "xfa/fxfa/xfa_fontmgr.h" 23 #include "xfa/fxfa/xfa_fontmgr.h"
23 24
24 namespace { 25 namespace {
25 26
26 class CXFA_FileRead : public IFX_SeekableReadStream { 27 class CXFA_FileRead : public IFX_SeekableReadStream {
27 public: 28 public:
28 explicit CXFA_FileRead(const std::vector<CPDF_Stream*>& streams); 29 explicit CXFA_FileRead(const std::vector<CPDF_Stream*>& streams);
29 ~CXFA_FileRead() override; 30 ~CXFA_FileRead() override;
30 31
31 // IFX_SeekableReadStream 32 // IFX_SeekableReadStream
32 FX_FILESIZE GetSize() override; 33 FX_FILESIZE GetSize() override;
33 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override; 34 bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
34 35
35 private: 36 private:
36 CFX_ObjectArray<CPDF_StreamAcc> m_Data; 37 std::vector<std::unique_ptr<CPDF_StreamAcc>> m_Data;
37 }; 38 };
38 39
39 CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) { 40 CXFA_FileRead::CXFA_FileRead(const std::vector<CPDF_Stream*>& streams) {
40 for (CPDF_Stream* pStream : streams) { 41 for (CPDF_Stream* pStream : streams) {
41 CPDF_StreamAcc& acc = m_Data.Add(); 42 m_Data.push_back(pdfium::MakeUnique<CPDF_StreamAcc>());
42 acc.LoadAllData(pStream); 43 m_Data.back()->LoadAllData(pStream);
43 } 44 }
44 } 45 }
45 46
46 CXFA_FileRead::~CXFA_FileRead() {} 47 CXFA_FileRead::~CXFA_FileRead() {}
47 48
48 FX_FILESIZE CXFA_FileRead::GetSize() { 49 FX_FILESIZE CXFA_FileRead::GetSize() {
49 uint32_t dwSize = 0; 50 uint32_t dwSize = 0;
50 int32_t iCount = m_Data.GetSize(); 51 for (const auto& acc : m_Data)
51 for (int32_t i = 0; i < iCount; i++) { 52 dwSize += acc->GetSize();
52 CPDF_StreamAcc& acc = m_Data[i];
53 dwSize += acc.GetSize();
54 }
55 return dwSize; 53 return dwSize;
56 } 54 }
57 55
58 bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { 56 bool CXFA_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
59 int32_t iCount = m_Data.GetSize(); 57 int32_t iCount = pdfium::CollectionSize<int32_t>(m_Data);
60 int32_t index = 0; 58 int32_t index = 0;
61 while (index < iCount) { 59 while (index < iCount) {
62 CPDF_StreamAcc& acc = m_Data[index]; 60 const auto& acc = m_Data[index];
63 FX_FILESIZE dwSize = acc.GetSize(); 61 FX_FILESIZE dwSize = acc->GetSize();
64 if (offset < dwSize) { 62 if (offset < dwSize)
65 break; 63 break;
66 } 64
67 offset -= dwSize; 65 offset -= dwSize;
68 index++; 66 index++;
69 } 67 }
70 while (index < iCount) { 68 while (index < iCount) {
71 CPDF_StreamAcc& acc = m_Data[index]; 69 const auto& acc = m_Data[index];
72 uint32_t dwSize = acc.GetSize(); 70 uint32_t dwSize = acc->GetSize();
73 size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset)); 71 size_t dwRead = std::min(size, static_cast<size_t>(dwSize - offset));
74 FXSYS_memcpy(buffer, acc.GetData() + offset, dwRead); 72 FXSYS_memcpy(buffer, acc->GetData() + offset, dwRead);
75 size -= dwRead; 73 size -= dwRead;
76 if (size == 0) { 74 if (size == 0)
77 return true; 75 return true;
78 } 76
79 buffer = (uint8_t*)buffer + dwRead; 77 buffer = (uint8_t*)buffer + dwRead;
80 offset = 0; 78 offset = 0;
81 index++; 79 index++;
82 } 80 }
83 return false; 81 return false;
84 } 82 }
85 83
86 } // namespace 84 } // namespace
87 85
88 CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream( 86 CFX_RetainPtr<IFX_SeekableReadStream> MakeSeekableReadStream(
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return m_pAdapterWidgetMgr.get(); 156 return m_pAdapterWidgetMgr.get();
159 } 157 }
160 158
161 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const { 159 IFWL_AdapterTimerMgr* CXFA_FFApp::GetTimerMgr() const {
162 return m_pProvider->GetTimerMgr(); 160 return m_pProvider->GetTimerMgr();
163 } 161 }
164 162
165 void CXFA_FFApp::ClearEventTargets() { 163 void CXFA_FFApp::ClearEventTargets() {
166 m_pFWLApp->GetNoteDriver()->ClearEventTargets(false); 164 m_pFWLApp->GetNoteDriver()->ClearEventTargets(false);
167 } 165 }
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698