| OLD | NEW |
| 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/fwl/basewidget/cfx_barcode.h" | 7 #include "xfa/fwl/basewidget/cfx_barcode.h" |
| 8 | 8 |
| 9 #include "xfa/fxbarcode/cbc_codabar.h" | 9 #include "xfa/fxbarcode/cbc_codabar.h" |
| 10 #include "xfa/fxbarcode/cbc_code128.h" | 10 #include "xfa/fxbarcode/cbc_code128.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 case BC_EAN13: | 39 case BC_EAN13: |
| 40 return new CBC_EAN13(); | 40 return new CBC_EAN13(); |
| 41 case BC_QR_CODE: | 41 case BC_QR_CODE: |
| 42 return new CBC_QRCode(); | 42 return new CBC_QRCode(); |
| 43 case BC_PDF417: | 43 case BC_PDF417: |
| 44 return new CBC_PDF417I(); | 44 return new CBC_PDF417I(); |
| 45 case BC_DATAMATRIX: | 45 case BC_DATAMATRIX: |
| 46 return new CBC_DataMatrix(); | 46 return new CBC_DataMatrix(); |
| 47 case BC_UNKNOWN: | 47 case BC_UNKNOWN: |
| 48 default: | 48 default: |
| 49 return NULL; | 49 return nullptr; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| 53 } // namespace | 53 } // namespace |
| 54 | 54 |
| 55 CFX_Barcode::CFX_Barcode() {} | 55 CFX_Barcode::CFX_Barcode() {} |
| 56 | 56 |
| 57 CFX_Barcode::~CFX_Barcode() { | 57 CFX_Barcode::~CFX_Barcode() { |
| 58 delete m_pBCEngine; | 58 delete m_pBCEngine; |
| 59 } | 59 } |
| 60 | 60 |
| 61 FX_BOOL CFX_Barcode::Create(BC_TYPE type) { | 61 FX_BOOL CFX_Barcode::Create(BC_TYPE type) { |
| 62 m_pBCEngine = CreateBarCodeEngineObject(type); | 62 m_pBCEngine = CreateBarCodeEngineObject(type); |
| 63 return m_pBCEngine != NULL; | 63 return !!m_pBCEngine; |
| 64 } | 64 } |
| 65 BC_TYPE CFX_Barcode::GetType() { | 65 BC_TYPE CFX_Barcode::GetType() { |
| 66 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; | 66 return m_pBCEngine ? m_pBCEngine->GetType() : BC_UNKNOWN; |
| 67 } | 67 } |
| 68 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { | 68 FX_BOOL CFX_Barcode::SetCharEncoding(BC_CHAR_ENCODING encoding) { |
| 69 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE; | 69 return m_pBCEngine ? m_pBCEngine->SetCharEncoding(encoding) : FALSE; |
| 70 } | 70 } |
| 71 FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) { | 71 FX_BOOL CFX_Barcode::SetModuleHeight(int32_t moduleHeight) { |
| 72 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE; | 72 return m_pBCEngine ? m_pBCEngine->SetModuleHeight(moduleHeight) : FALSE; |
| 73 } | 73 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 return m_pBCEngine | 218 return m_pBCEngine |
| 219 ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color), | 219 ? (static_cast<CBC_OneCode*>(m_pBCEngine)->SetFontColor(color), |
| 220 TRUE) | 220 TRUE) |
| 221 : FALSE; | 221 : FALSE; |
| 222 default: | 222 default: |
| 223 return FALSE; | 223 return FALSE; |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) { | 226 FX_BOOL CFX_Barcode::SetTextLocation(BC_TEXT_LOC location) { |
| 227 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC); | 227 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(BC_TEXT_LOC); |
| 228 memptrtype memptr = NULL; | 228 memptrtype memptr = nullptr; |
| 229 switch (GetType()) { | 229 switch (GetType()) { |
| 230 case BC_CODE39: | 230 case BC_CODE39: |
| 231 memptr = (memptrtype)&CBC_Code39::SetTextLocation; | 231 memptr = (memptrtype)&CBC_Code39::SetTextLocation; |
| 232 break; | 232 break; |
| 233 case BC_CODABAR: | 233 case BC_CODABAR: |
| 234 memptr = (memptrtype)&CBC_Codabar::SetTextLocation; | 234 memptr = (memptrtype)&CBC_Codabar::SetTextLocation; |
| 235 break; | 235 break; |
| 236 case BC_CODE128: | 236 case BC_CODE128: |
| 237 case BC_CODE128_B: | 237 case BC_CODE128_B: |
| 238 case BC_CODE128_C: | 238 case BC_CODE128_C: |
| 239 memptr = (memptrtype)&CBC_Code128::SetTextLocation; | 239 memptr = (memptrtype)&CBC_Code128::SetTextLocation; |
| 240 break; | 240 break; |
| 241 default: | 241 default: |
| 242 break; | 242 break; |
| 243 } | 243 } |
| 244 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE; | 244 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(location) : FALSE; |
| 245 } | 245 } |
| 246 FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) { | 246 FX_BOOL CFX_Barcode::SetWideNarrowRatio(int32_t ratio) { |
| 247 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); | 247 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); |
| 248 memptrtype memptr = NULL; | 248 memptrtype memptr = nullptr; |
| 249 switch (GetType()) { | 249 switch (GetType()) { |
| 250 case BC_CODE39: | 250 case BC_CODE39: |
| 251 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; | 251 memptr = (memptrtype)&CBC_Code39::SetWideNarrowRatio; |
| 252 break; | 252 break; |
| 253 case BC_CODABAR: | 253 case BC_CODABAR: |
| 254 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; | 254 memptr = (memptrtype)&CBC_Codabar::SetWideNarrowRatio; |
| 255 break; | 255 break; |
| 256 default: | 256 default: |
| 257 break; | 257 break; |
| 258 } | 258 } |
| 259 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE; | 259 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(ratio) : FALSE; |
| 260 } | 260 } |
| 261 FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) { | 261 FX_BOOL CFX_Barcode::SetStartChar(FX_CHAR start) { |
| 262 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); | 262 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); |
| 263 memptrtype memptr = NULL; | 263 memptrtype memptr = nullptr; |
| 264 switch (GetType()) { | 264 switch (GetType()) { |
| 265 case BC_CODABAR: | 265 case BC_CODABAR: |
| 266 memptr = (memptrtype)&CBC_Codabar::SetStartChar; | 266 memptr = (memptrtype)&CBC_Codabar::SetStartChar; |
| 267 break; | 267 break; |
| 268 default: | 268 default: |
| 269 break; | 269 break; |
| 270 } | 270 } |
| 271 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE; | 271 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(start) : FALSE; |
| 272 } | 272 } |
| 273 FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) { | 273 FX_BOOL CFX_Barcode::SetEndChar(FX_CHAR end) { |
| 274 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); | 274 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(FX_CHAR); |
| 275 memptrtype memptr = NULL; | 275 memptrtype memptr = nullptr; |
| 276 switch (GetType()) { | 276 switch (GetType()) { |
| 277 case BC_CODABAR: | 277 case BC_CODABAR: |
| 278 memptr = (memptrtype)&CBC_Codabar::SetEndChar; | 278 memptr = (memptrtype)&CBC_Codabar::SetEndChar; |
| 279 break; | 279 break; |
| 280 default: | 280 default: |
| 281 break; | 281 break; |
| 282 } | 282 } |
| 283 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE; | 283 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(end) : FALSE; |
| 284 } | 284 } |
| 285 FX_BOOL CFX_Barcode::SetVersion(int32_t version) { | 285 FX_BOOL CFX_Barcode::SetVersion(int32_t version) { |
| 286 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); | 286 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); |
| 287 memptrtype memptr = NULL; | 287 memptrtype memptr = nullptr; |
| 288 switch (GetType()) { | 288 switch (GetType()) { |
| 289 case BC_QR_CODE: | 289 case BC_QR_CODE: |
| 290 memptr = (memptrtype)&CBC_QRCode::SetVersion; | 290 memptr = (memptrtype)&CBC_QRCode::SetVersion; |
| 291 break; | 291 break; |
| 292 default: | 292 default: |
| 293 break; | 293 break; |
| 294 } | 294 } |
| 295 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE; | 295 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(version) : FALSE; |
| 296 } | 296 } |
| 297 FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) { | 297 FX_BOOL CFX_Barcode::SetErrorCorrectionLevel(int32_t level) { |
| 298 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); | 298 typedef FX_BOOL (CBC_CodeBase::*memptrtype)(int32_t); |
| 299 memptrtype memptr = NULL; | 299 memptrtype memptr = nullptr; |
| 300 switch (GetType()) { | 300 switch (GetType()) { |
| 301 case BC_QR_CODE: | 301 case BC_QR_CODE: |
| 302 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; | 302 memptr = (memptrtype)&CBC_QRCode::SetErrorCorrectionLevel; |
| 303 break; | 303 break; |
| 304 case BC_PDF417: | 304 case BC_PDF417: |
| 305 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; | 305 memptr = (memptrtype)&CBC_PDF417I::SetErrorCorrectionLevel; |
| 306 break; | 306 break; |
| 307 default: | 307 default: |
| 308 return FALSE; | 308 return FALSE; |
| 309 } | 309 } |
| 310 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE; | 310 return m_pBCEngine && memptr ? (m_pBCEngine->*memptr)(level) : FALSE; |
| 311 } | 311 } |
| 312 FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) { | 312 FX_BOOL CFX_Barcode::SetTruncated(FX_BOOL truncated) { |
| 313 typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL); | 313 typedef void (CBC_CodeBase::*memptrtype)(FX_BOOL); |
| 314 memptrtype memptr = NULL; | 314 memptrtype memptr = nullptr; |
| 315 switch (GetType()) { | 315 switch (GetType()) { |
| 316 case BC_PDF417: | 316 case BC_PDF417: |
| 317 memptr = (memptrtype)&CBC_PDF417I::SetTruncated; | 317 memptr = (memptrtype)&CBC_PDF417I::SetTruncated; |
| 318 break; | 318 break; |
| 319 default: | 319 default: |
| 320 break; | 320 break; |
| 321 } | 321 } |
| 322 return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE) | 322 return m_pBCEngine && memptr ? ((m_pBCEngine->*memptr)(truncated), TRUE) |
| 323 : FALSE; | 323 : FALSE; |
| 324 } | 324 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 338 return FALSE; | 338 return FALSE; |
| 339 } | 339 } |
| 340 return m_pBCEngine->RenderDevice(device, matrix, e); | 340 return m_pBCEngine->RenderDevice(device, matrix, e); |
| 341 } | 341 } |
| 342 FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { | 342 FX_BOOL CFX_Barcode::RenderBitmap(CFX_DIBitmap*& pOutBitmap, int32_t& e) { |
| 343 if (!m_pBCEngine) { | 343 if (!m_pBCEngine) { |
| 344 return FALSE; | 344 return FALSE; |
| 345 } | 345 } |
| 346 return m_pBCEngine->RenderBitmap(pOutBitmap, e); | 346 return m_pBCEngine->RenderBitmap(pOutBitmap, e); |
| 347 } | 347 } |
| OLD | NEW |