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

Side by Side Diff: fpdfsdk/src/fpdf_dataavail.cpp

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 months 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
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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fpdf_dataavail.h" 8 #include "../include/fpdf_dataavail.h"
9 9
10 extern void ProcessParseError(FX_DWORD err_code); 10 extern void ProcessParseError(FX_DWORD err_code);
11 class CFPDF_FileAvailWrap : public IFX_FileAvail 11 class CFPDF_FileAvailWrap : public IFX_FileAvail {
12 { 12 public:
13 public: 13 CFPDF_FileAvailWrap() { m_pfileAvail = NULL; }
14 » CFPDF_FileAvailWrap()
15 » {
16 » » m_pfileAvail = NULL;
17 » }
18 14
19 » void Set(FX_FILEAVAIL* pfileAvail) 15 void Set(FX_FILEAVAIL* pfileAvail) { m_pfileAvail = pfileAvail; }
20 » {
21 » » m_pfileAvail = pfileAvail;
22 » }
23 16
24 » virtual FX_BOOL»» » IsDataAvail( FX_FILESIZE offset, FX_DWOR D size) 17 virtual FX_BOOL IsDataAvail(FX_FILESIZE offset, FX_DWORD size) {
25 » { 18 return m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size);
26 » » return m_pfileAvail->IsDataAvail(m_pfileAvail, offset, size); 19 }
27 » }
28 20
29 private: 21 private:
30 » FX_FILEAVAIL* m_pfileAvail; 22 FX_FILEAVAIL* m_pfileAvail;
31 };
32
33 class CFPDF_FileAccessWrap : public IFX_FileRead
34 {
35 public:
36 » CFPDF_FileAccessWrap()
37 » {
38 » » m_pFileAccess = NULL;
39 » }
40
41 » void Set(FPDF_FILEACCESS* pFile)
42 » {
43 » » m_pFileAccess = pFile;
44 » }
45
46 » virtual FX_FILESIZE» » GetSize()
47 » {
48 » » return m_pFileAccess->m_FileLen;
49 » }
50
51 » virtual FX_BOOL»» » ReadBlock(void* buffer, FX_FILESIZE offs et, size_t size)
52 » {
53 » » return m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset, (FX_LPBYTE)buffer, size);
54 » }
55
56 » virtual void» » » Release()
57 » {
58 » }
59
60 private:
61 » FPDF_FILEACCESS*» » m_pFileAccess;
62 }; 23 };
63 24
64 class CFPDF_DownloadHintsWrap : public IFX_DownloadHints 25 class CFPDF_FileAccessWrap : public IFX_FileRead {
65 { 26 public:
66 public: 27 CFPDF_FileAccessWrap() { m_pFileAccess = NULL; }
67 » CFPDF_DownloadHintsWrap(FX_DOWNLOADHINTS* pDownloadHints) 28
68 » { 29 void Set(FPDF_FILEACCESS* pFile) { m_pFileAccess = pFile; }
69 » » m_pDownloadHints = pDownloadHints; 30
70 » } 31 virtual FX_FILESIZE GetSize() { return m_pFileAccess->m_FileLen; }
71 public: 32
72 » virtual void» » » AddSegment(FX_FILESIZE offset, FX_DWORD size) 33 virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) {
73 » { 34 return m_pFileAccess->m_GetBlock(
74 » » m_pDownloadHints->AddSegment(m_pDownloadHints, offset, size); 35 m_pFileAccess->m_Param, offset, (FX_LPBYTE)buffer, size);
75 » }» 36 }
76 private: 37
77 » FX_DOWNLOADHINTS* m_pDownloadHints; 38 virtual void Release() {}
39
40 private:
41 FPDF_FILEACCESS* m_pFileAccess;
78 }; 42 };
79 43
80 class CFPDF_DataAvail : public CFX_Object 44 class CFPDF_DownloadHintsWrap : public IFX_DownloadHints {
81 { 45 public:
82 public: 46 CFPDF_DownloadHintsWrap(FX_DOWNLOADHINTS* pDownloadHints) {
83 » CFPDF_DataAvail() 47 m_pDownloadHints = pDownloadHints;
84 » { 48 }
85 » » m_pDataAvail = NULL;
86 » }
87 49
88 » ~CFPDF_DataAvail() 50 public:
89 » { 51 virtual void AddSegment(FX_FILESIZE offset, FX_DWORD size) {
90 » » if (m_pDataAvail) delete m_pDataAvail; 52 m_pDownloadHints->AddSegment(m_pDownloadHints, offset, size);
91 » } 53 }
92 54
93 » CPDF_DataAvail*»» » m_pDataAvail; 55 private:
94 » CFPDF_FileAvailWrap» » m_FileAvail; 56 FX_DOWNLOADHINTS* m_pDownloadHints;
95 » CFPDF_FileAccessWrap» m_FileRead;
96 }; 57 };
97 58
98 DLLEXPORT FPDF_AVAIL STDCALL FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FIL EACCESS* file) 59 class CFPDF_DataAvail : public CFX_Object {
99 { 60 public:
100 » CFPDF_DataAvail* pAvail = FX_NEW CFPDF_DataAvail; 61 CFPDF_DataAvail() { m_pDataAvail = NULL; }
101 » pAvail->m_FileAvail.Set(file_avail); 62
102 » pAvail->m_FileRead.Set(file); 63 ~CFPDF_DataAvail() {
103 » pAvail->m_pDataAvail = FX_NEW CPDF_DataAvail(&pAvail->m_FileAvail, &pAva il->m_FileRead); 64 if (m_pDataAvail)
104 » return pAvail; 65 delete m_pDataAvail;
66 }
67
68 CPDF_DataAvail* m_pDataAvail;
69 CFPDF_FileAvailWrap m_FileAvail;
70 CFPDF_FileAccessWrap m_FileRead;
71 };
72
73 DLLEXPORT FPDF_AVAIL STDCALL
74 FPDFAvail_Create(FX_FILEAVAIL* file_avail, FPDF_FILEACCESS* file) {
75 CFPDF_DataAvail* pAvail = FX_NEW CFPDF_DataAvail;
76 pAvail->m_FileAvail.Set(file_avail);
77 pAvail->m_FileRead.Set(file);
78 pAvail->m_pDataAvail =
79 FX_NEW CPDF_DataAvail(&pAvail->m_FileAvail, &pAvail->m_FileRead);
80 return pAvail;
105 } 81 }
106 82
107 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) 83 DLLEXPORT void STDCALL FPDFAvail_Destroy(FPDF_AVAIL avail) {
108 { 84 if (avail == NULL)
109 » if (avail == NULL) return; 85 return;
110 » delete (CFPDF_DataAvail*)avail; 86 delete (CFPDF_DataAvail*)avail;
111 } 87 }
112 88
113 DLLEXPORT int STDCALL FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* h ints) 89 DLLEXPORT int STDCALL
114 { 90 FPDFAvail_IsDocAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) {
115 » if (avail == NULL || hints == NULL) return 0; 91 if (avail == NULL || hints == NULL)
116 » CFPDF_DownloadHintsWrap hints_wrap(hints); 92 return 0;
117 » return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap); 93 CFPDF_DownloadHintsWrap hints_wrap(hints);
94 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsDocAvail(&hints_wrap);
118 } 95 }
119 96
120 extern void CheckUnSupportError(CPDF_Document * pDoc, FX_DWORD err_code); 97 extern void CheckUnSupportError(CPDF_Document* pDoc, FX_DWORD err_code);
121 98
122 DLLEXPORT FPDF_DOCUMENT STDCALL FPDFAvail_GetDocument(FPDF_AVAIL avail,»FPDF_BYT ESTRING password) 99 DLLEXPORT FPDF_DOCUMENT STDCALL
123 { 100 FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) {
124 » if (avail == NULL) return NULL; 101 if (avail == NULL)
125 » CPDF_Parser* pParser = FX_NEW CPDF_Parser; 102 return NULL;
126 » pParser->SetPassword(password); 103 CPDF_Parser* pParser = FX_NEW CPDF_Parser;
104 pParser->SetPassword(password);
127 105
128 » FX_DWORD err_code = pParser->StartAsynParse(((CFPDF_DataAvail*)avail)->m _pDataAvail->GetFileRead()); 106 FX_DWORD err_code = pParser->StartAsynParse(
129 » if (err_code) { 107 ((CFPDF_DataAvail*)avail)->m_pDataAvail->GetFileRead());
130 » » delete pParser; 108 if (err_code) {
131 » » ProcessParseError(err_code); 109 delete pParser;
132 » » return NULL; 110 ProcessParseError(err_code);
133 » } 111 return NULL;
134 » ((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocumen t()); 112 }
135 » CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS); 113 ((CFPDF_DataAvail*)avail)->m_pDataAvail->SetDocument(pParser->GetDocument());
136 » return pParser->GetDocument(); 114 CheckUnSupportError(pParser->GetDocument(), FPDF_ERR_SUCCESS);
115 return pParser->GetDocument();
137 } 116 }
138 117
139 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) 118 DLLEXPORT int STDCALL FPDFAvail_GetFirstPageNum(FPDF_DOCUMENT doc) {
140 { 119 if (doc == NULL)
141 » if (doc == NULL) return 0; 120 return 0;
142 » CPDF_Document* pDoc = (CPDF_Document*)doc; 121 CPDF_Document* pDoc = (CPDF_Document*)doc;
143 » return ((CPDF_Parser*)pDoc->GetParser())->GetFirstPageNo(); 122 return ((CPDF_Parser*)pDoc->GetParser())->GetFirstPageNo();
144 } 123 }
145 124
146 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail, int page_index, FX _DOWNLOADHINTS* hints) 125 DLLEXPORT int STDCALL FPDFAvail_IsPageAvail(FPDF_AVAIL avail,
147 { 126 int page_index,
148 » if (avail == NULL || hints == NULL) return 0; 127 FX_DOWNLOADHINTS* hints) {
149 » CFPDF_DownloadHintsWrap hints_wrap(hints); 128 if (avail == NULL || hints == NULL)
150 » return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsPageAvail(page_index, &hints_wrap); 129 return 0;
130 CFPDF_DownloadHintsWrap hints_wrap(hints);
131 return ((CFPDF_DataAvail*)avail)
132 ->m_pDataAvail->IsPageAvail(page_index, &hints_wrap);
151 } 133 }
152 134
153 DLLEXPORT int STDCALL FPDFAvail_IsFormAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) 135 DLLEXPORT int STDCALL
154 { 136 FPDFAvail_IsFormAvail(FPDF_AVAIL avail, FX_DOWNLOADHINTS* hints) {
155 » if (avail == NULL || hints == NULL) return -1; 137 if (avail == NULL || hints == NULL)
156 » CFPDF_DownloadHintsWrap hints_wrap(hints); 138 return -1;
157 » return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap) ; 139 CFPDF_DownloadHintsWrap hints_wrap(hints);
140 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsFormAvail(&hints_wrap);
158 } 141 }
159 142
160 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) 143 DLLEXPORT FPDF_BOOL STDCALL FPDFAvail_IsLinearized(FPDF_AVAIL avail) {
161 { 144 if (avail == NULL)
162 » » if (avail == NULL) return -1; 145 return -1;
163 » return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF(); 146 return ((CFPDF_DataAvail*)avail)->m_pDataAvail->IsLinearizedPDF();
164
165 } 147 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698