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

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

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

Powered by Google App Engine
This is Rietveld 408576698