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

Side by Side Diff: xfa/src/fwl/src/basewidget/fxmath_barcodeimp.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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 "../../../foxitlib.h" 7 #include "../../../foxitlib.h"
8 #include "include/fxmath_barcodeimp.h" 8 #include "include/fxmath_barcodeimp.h"
9 static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type) 9 static CBC_CodeBase* FX_Barcode_CreateBarCodeEngineObject(BC_TYPE type)
10 { 10 {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 delete this; 56 delete this;
57 } 57 }
58 BC_TYPE CFX_Barcode::GetType() 58 BC_TYPE CFX_Barcode::GetType()
59 { 59 {
60 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; 60 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN;
61 } 61 }
62 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) 62 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding)
63 { 63 {
64 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE; 64 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE;
65 } 65 }
66 FX_BOOL CFX_Barcode::SetModuleHeight(FX_INT32 moduleHeight) 66 FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight)
67 { 67 {
68 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE; 68 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE;
69 } 69 }
70 FX_BOOL CFX_Barcode::SetModuleWidth(FX_INT32 moduleWidth) 70 FX_BOOL CFX_Barcode::SetModuleWidth(int32_t moduleWidth)
71 { 71 {
72 return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE; 72 return m_pBCEngine ? m_pBCEngine->SetModuleWidth(moduleWidth) : FALSE;
73 } 73 }
74 FX_BOOL CFX_Barcode::SetHeight(FX_INT32 height) 74 FX_BOOL CFX_Barcode::SetHeight(int32_t height)
75 { 75 {
76 return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE; 76 return m_pBCEngine ? m_pBCEngine->SetHeight(height) : FALSE;
77 } 77 }
78 FX_BOOL CFX_Barcode::SetWidth(FX_INT32 width) 78 FX_BOOL CFX_Barcode::SetWidth(int32_t width)
79 { 79 {
80 return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE; 80 return m_pBCEngine ? m_pBCEngine->SetWidth(width) : FALSE;
81 } 81 }
82 FX_BOOL CFX_Barcode::CheckContentValidity(FX_WSTR contents) 82 FX_BOOL CFX_Barcode::CheckContentValidity(FX_WSTR contents)
83 { 83 {
84 switch(GetType()) { 84 switch(GetType()) {
85 case BC_CODE39: 85 case BC_CODE39:
86 case BC_CODABAR: 86 case BC_CODABAR:
87 case BC_CODE128: 87 case BC_CODE128:
88 case BC_CODE128_B: 88 case BC_CODE128_B:
(...skipping 17 matching lines...) Expand all
106 case BC_CODE128_C: 106 case BC_CODE128_C:
107 case BC_EAN8: 107 case BC_EAN8:
108 case BC_EAN13: 108 case BC_EAN13:
109 case BC_UPCA: 109 case BC_UPCA:
110 return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetPrintChecksum( checksum), TRUE) 110 return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetPrintChecksum( checksum), TRUE)
111 : FALSE; 111 : FALSE;
112 default: 112 default:
113 return FALSE; 113 return FALSE;
114 } 114 }
115 } 115 }
116 FX_BOOL»CFX_Barcode::SetDataLength(FX_INT32 length) 116 FX_BOOL»CFX_Barcode::SetDataLength(int32_t length)
117 { 117 {
118 switch(GetType()) { 118 switch(GetType()) {
119 case BC_CODE39: 119 case BC_CODE39:
120 case BC_CODABAR: 120 case BC_CODABAR:
121 case BC_CODE128: 121 case BC_CODE128:
122 case BC_CODE128_B: 122 case BC_CODE128_B:
123 case BC_CODE128_C: 123 case BC_CODE128_C:
124 case BC_EAN8: 124 case BC_EAN8:
125 case BC_EAN13: 125 case BC_EAN13:
126 case BC_UPCA: 126 case BC_UPCA:
127 return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetDataLength(len gth), TRUE) 127 return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetDataLength(len gth), TRUE)
128 : FALSE; 128 : FALSE;
129 default: 129 default:
130 return FALSE; 130 return FALSE;
131 } 131 }
132 } 132 }
133 FX_BOOL»CFX_Barcode::SetCalChecksum(FX_INT32 state) 133 FX_BOOL»CFX_Barcode::SetCalChecksum(int32_t state)
134 { 134 {
135 switch(GetType()) { 135 switch(GetType()) {
136 case BC_CODE39: 136 case BC_CODE39:
137 case BC_CODABAR: 137 case BC_CODABAR:
138 case BC_CODE128: 138 case BC_CODE128:
139 case BC_CODE128_B: 139 case BC_CODE128_B:
140 case BC_CODE128_C: 140 case BC_CODE128_C:
141 case BC_EAN8: 141 case BC_EAN8:
142 case BC_EAN13: 142 case BC_EAN13:
143 case BC_UPCA: 143 case BC_UPCA:
(...skipping 30 matching lines...) Expand all
174 case BC_CODE128_C: 174 case BC_CODE128_C:
175 case BC_EAN8: 175 case BC_EAN8:
176 case BC_EAN13: 176 case BC_EAN13:
177 case BC_UPCA: 177 case BC_UPCA:
178 return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetFontSize(size) , TRUE) 178 return m_pBCEngine ? (((CBC_OneCode*)m_pBCEngine)->SetFontSize(size) , TRUE)
179 : FALSE; 179 : FALSE;
180 default: 180 default:
181 return FALSE; 181 return FALSE;
182 } 182 }
183 } 183 }
184 FX_BOOL»CFX_Barcode::SetFontStyle(FX_INT32 style) 184 FX_BOOL»CFX_Barcode::SetFontStyle(int32_t style)
185 { 185 {
186 switch(GetType()) { 186 switch(GetType()) {
187 case BC_CODE39: 187 case BC_CODE39:
188 case BC_CODABAR: 188 case BC_CODABAR:
189 case BC_CODE128: 189 case BC_CODE128:
190 case BC_CODE128_B: 190 case BC_CODE128_B:
191 case BC_CODE128_C: 191 case BC_CODE128_C:
192 case BC_EAN8: 192 case BC_EAN8:
193 case BC_EAN13: 193 case BC_EAN13:
194 case BC_UPCA: 194 case BC_UPCA:
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 case BC_CODE128_B: 230 case BC_CODE128_B:
231 case BC_CODE128_C: 231 case BC_CODE128_C:
232 memptr = (memptrtype)&CBC_Code128::SetTextLocation; 232 memptr = (memptrtype)&CBC_Code128::SetTextLocation;
233 break; 233 break;
234 default: 234 default:
235 break; 235 break;
236 } 236 }
237 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) 237 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location)
238 : FALSE; 238 : FALSE;
239 } 239 }
240 FX_BOOL»CFX_Barcode::SetWideNarrowRatio(FX_INT32 ratio) 240 FX_BOOL»CFX_Barcode::SetWideNarrowRatio(int32_t ratio)
241 { 241 {
242 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_INT32); 242 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
243 memptrtype memptr = NULL; 243 memptrtype memptr = NULL;
244 switch(GetType()) { 244 switch(GetType()) {
245 case BC_CODE39: 245 case BC_CODE39:
246 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; 246 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio;
247 break; 247 break;
248 case BC_CODABAR: 248 case BC_CODABAR:
249 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; 249 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio;
250 break; 250 break;
251 default: 251 default:
252 break; 252 break;
(...skipping 22 matching lines...) Expand all
275 switch(GetType()) { 275 switch(GetType()) {
276 case BC_CODABAR: 276 case BC_CODABAR:
277 memptr = (memptrtype)&CBC_Codabar::SetEndChar; 277 memptr = (memptrtype)&CBC_Codabar::SetEndChar;
278 break; 278 break;
279 default: 279 default:
280 break; 280 break;
281 } 281 }
282 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) 282 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end)
283 : FALSE; 283 : FALSE;
284 } 284 }
285 FX_BOOL»CFX_Barcode::SetVersion(FX_INT32 version) 285 FX_BOOL»CFX_Barcode::SetVersion(int32_t version)
286 { 286 {
287 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_INT32); 287 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
288 memptrtype memptr = NULL; 288 memptrtype memptr = NULL;
289 switch(GetType()) { 289 switch(GetType()) {
290 case BC_QR_CODE: 290 case BC_QR_CODE:
291 memptr = (memptrtype)&CBC_QRCode::SetVersion; 291 memptr = (memptrtype)&CBC_QRCode::SetVersion;
292 break; 292 break;
293 default: 293 default:
294 break; 294 break;
295 } 295 }
296 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) 296 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version)
297 : FALSE; 297 : FALSE;
298 } 298 }
299 FX_BOOL»CFX_Barcode::SetErrorCorrectionLevel(FX_INT32 level) 299 FX_BOOL»CFX_Barcode::SetErrorCorrectionLevel(int32_t level)
300 { 300 {
301 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_INT32); 301 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t);
302 memptrtype memptr = NULL; 302 memptrtype memptr = NULL;
303 switch(GetType()) { 303 switch(GetType()) {
304 case BC_QR_CODE: 304 case BC_QR_CODE:
305 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; 305 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel;
306 break; 306 break;
307 case BC_PDF417: 307 case BC_PDF417:
308 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; 308 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel;
309 break; 309 break;
310 default: 310 default:
311 return FALSE; 311 return FALSE;
(...skipping 17 matching lines...) Expand all
329 } 329 }
330 #ifndef BCExceptionNO 330 #ifndef BCExceptionNO
331 #define BCExceptionNO 0 331 #define BCExceptionNO 0
332 #endif 332 #endif
333 #ifndef BCExceptionFormatException 333 #ifndef BCExceptionFormatException
334 #define BCExceptionFormatException 8 334 #define BCExceptionFormatException 8
335 #endif 335 #endif
336 #ifndef BCExceptionUnSupportedBarcode 336 #ifndef BCExceptionUnSupportedBarcode
337 #define BCExceptionUnSupportedBarcode 18 337 #define BCExceptionUnSupportedBarcode 18
338 #endif 338 #endif
339 FX_BOOL CFX_Barcode::Encode(FX_WSTR contents, FX_BOOL isDevice, FX_INT32 &e) 339 FX_BOOL CFX_Barcode::Encode(FX_WSTR contents, FX_BOOL isDevice, int32_t &e)
340 { 340 {
341 if(!m_pBCEngine) { 341 if(!m_pBCEngine) {
342 return FALSE; 342 return FALSE;
343 } 343 }
344 return m_pBCEngine->Encode(contents, isDevice, e); 344 return m_pBCEngine->Encode(contents, isDevice, e);
345 } 345 }
346 FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* ma tirx, FX_INT32 &e) 346 FX_BOOL CFX_Barcode::RenderDevice(CFX_RenderDevice* device, const CFX_Matrix* ma tirx, int32_t &e)
347 { 347 {
348 if (!m_pBCEngine) { 348 if (!m_pBCEngine) {
349 return FALSE; 349 return FALSE;
350 } 350 }
351 return m_pBCEngine->RenderDevice(device, matirx, e); 351 return m_pBCEngine->RenderDevice(device, matirx, e);
352 } 352 }
353 FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap *&pOutBitmap, FX_INT32 &e) 353 FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap *&pOutBitmap, int32_t &e)
354 { 354 {
355 if (!m_pBCEngine) { 355 if (!m_pBCEngine) {
356 return FALSE; 356 return FALSE;
357 } 357 }
358 return m_pBCEngine->RenderBitmap(pOutBitmap, e); 358 return m_pBCEngine->RenderBitmap(pOutBitmap, e);
359 } 359 }
360 #define BC_TYPE_MIN BC_CODE39 360 #define BC_TYPE_MIN BC_CODE39
361 #define BC_TYPE_MAX BC_DATAMATRIX 361 #define BC_TYPE_MAX BC_DATAMATRIX
362 CFX_WideString» CFX_Barcode::Decode(FX_BYTE* buf, FX_INT32 width, FX_INT32 heigh t, FX_INT32 &errorCode) 362 CFX_WideString» CFX_Barcode::Decode(uint8_t* buf, int32_t width, int32_t height, int32_t &errorCode)
363 { 363 {
364 for(BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; t = (BC_TYPE)((FX_INT32)t + 1 )) { 364 for(BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; t = (BC_TYPE)((int32_t)t + 1) ) {
365 CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); 365 CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
366 if(!pTmpEngine) { 366 if(!pTmpEngine) {
367 continue; 367 continue;
368 } 368 }
369 CFX_WideString ret = pTmpEngine->Decode(buf, width, height, errorCode); 369 CFX_WideString ret = pTmpEngine->Decode(buf, width, height, errorCode);
370 if(errorCode == BCExceptionNO) { 370 if(errorCode == BCExceptionNO) {
371 return ret; 371 return ret;
372 } 372 }
373 } 373 }
374 errorCode = BCExceptionUnSupportedBarcode; 374 errorCode = BCExceptionUnSupportedBarcode;
375 return CFX_WideString(); 375 return CFX_WideString();
376 } 376 }
377 CFX_WideString» CFX_Barcode::Decode(CFX_DIBitmap *pBitmap, FX_INT32 &errorCode) 377 CFX_WideString» CFX_Barcode::Decode(CFX_DIBitmap *pBitmap, int32_t &errorCode)
378 { 378 {
379 for(BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; t = (BC_TYPE)((FX_INT32)t + 1 )) { 379 for(BC_TYPE t = BC_TYPE_MIN; t <= BC_TYPE_MAX; t = (BC_TYPE)((int32_t)t + 1) ) {
380 CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t); 380 CBC_CodeBase* pTmpEngine = FX_Barcode_CreateBarCodeEngineObject(t);
381 if(!pTmpEngine) { 381 if(!pTmpEngine) {
382 continue; 382 continue;
383 } 383 }
384 CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode); 384 CFX_WideString ret = pTmpEngine->Decode(pBitmap, errorCode);
385 if(errorCode == BCExceptionNO) { 385 if(errorCode == BCExceptionNO) {
386 return ret; 386 return ret;
387 } 387 }
388 } 388 }
389 errorCode = BCExceptionUnSupportedBarcode; 389 errorCode = BCExceptionUnSupportedBarcode;
390 return CFX_WideString(); 390 return CFX_WideString();
391 } 391 }
392 IFX_Barcode* FX_Barcode_Create(BC_TYPE type) 392 IFX_Barcode* FX_Barcode_Create(BC_TYPE type)
393 { 393 {
394 CFX_Barcode* pBarcode = FX_NEW CFX_Barcode; 394 CFX_Barcode* pBarcode = FX_NEW CFX_Barcode;
395 if (pBarcode->Crreate(type)) { 395 if (pBarcode->Crreate(type)) {
396 return pBarcode; 396 return pBarcode;
397 } 397 }
398 pBarcode->Release(); 398 pBarcode->Release();
399 return NULL; 399 return NULL;
400 } 400 }
OLDNEW
« no previous file with comments | « xfa/src/fwl/src/basewidget/fwl_tooltipctrlimp.cpp ('k') | xfa/src/fwl/src/basewidget/include/fwl_caretimp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698