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 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part | 8 * Copyright 2006 Jeremias Maerki in part, and ZXing Authors in part |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
11 * you may not use this file except in compliance with the License. | 11 * you may not use this file except in compliance with the License. |
12 * You may obtain a copy of the License at | 12 * You may obtain a copy of the License at |
13 * | 13 * |
14 * http://www.apache.org/licenses/LICENSE-2.0 | 14 * http://www.apache.org/licenses/LICENSE-2.0 |
15 * | 15 * |
16 * Unless required by applicable law or agreed to in writing, software | 16 * Unless required by applicable law or agreed to in writing, software |
17 * distributed under the License is distributed on an "AS IS" BASIS, | 17 * distributed under the License is distributed on an "AS IS" BASIS, |
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 * See the License for the specific language governing permissions and | 19 * See the License for the specific language governing permissions and |
20 * limitations under the License. | 20 * limitations under the License. |
21 */ | 21 */ |
22 | 22 |
23 #include "xfa/fxbarcode/pdf417/BC_PDF417.h" | 23 #include "xfa/fxbarcode/pdf417/BC_PDF417.h" |
| 24 |
| 25 #include "third_party/base/ptr_util.h" |
24 #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" | 26 #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeMatrix.h" |
25 #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" | 27 #include "xfa/fxbarcode/pdf417/BC_PDF417BarcodeRow.h" |
26 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" | 28 #include "xfa/fxbarcode/pdf417/BC_PDF417Compaction.h" |
27 #include "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h" | 29 #include "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h" |
28 #include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" | 30 #include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h" |
29 #include "xfa/fxbarcode/utils.h" | 31 #include "xfa/fxbarcode/utils.h" |
30 | 32 |
31 const int32_t CBC_PDF417::CODEWORD_TABLE[][929] = { | 33 const int32_t CBC_PDF417::CODEWORD_TABLE[][929] = { |
32 {0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470, | 34 {0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470, |
33 0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0, | 35 0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0, |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 sb += (FX_WCHAR)n; | 427 sb += (FX_WCHAR)n; |
426 sb += highLevel; | 428 sb += highLevel; |
427 for (int32_t i = 0; i < pad; i++) { | 429 for (int32_t i = 0; i < pad; i++) { |
428 sb += (FX_WCHAR)900; | 430 sb += (FX_WCHAR)900; |
429 } | 431 } |
430 CFX_WideString dataCodewords(sb); | 432 CFX_WideString dataCodewords(sb); |
431 CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection( | 433 CFX_WideString ec = CBC_PDF417ErrorCorrection::generateErrorCorrection( |
432 dataCodewords, errorCorrectionLevel, e); | 434 dataCodewords, errorCorrectionLevel, e); |
433 BC_EXCEPTION_CHECK_ReturnVoid(e); | 435 BC_EXCEPTION_CHECK_ReturnVoid(e); |
434 CFX_WideString fullCodewords = dataCodewords + ec; | 436 CFX_WideString fullCodewords = dataCodewords + ec; |
435 m_barcodeMatrix.reset(new CBC_BarcodeMatrix(rows, cols)); | 437 m_barcodeMatrix = pdfium::MakeUnique<CBC_BarcodeMatrix>(rows, cols); |
436 encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel, | 438 encodeLowLevel(fullCodewords, cols, rows, errorCorrectionLevel, |
437 m_barcodeMatrix.get()); | 439 m_barcodeMatrix.get()); |
438 } | 440 } |
439 | 441 |
440 void CBC_PDF417::setDimensions(int32_t maxCols, | 442 void CBC_PDF417::setDimensions(int32_t maxCols, |
441 int32_t minCols, | 443 int32_t minCols, |
442 int32_t maxRows, | 444 int32_t maxRows, |
443 int32_t minRows) { | 445 int32_t minRows) { |
444 m_maxCols = maxCols; | 446 m_maxCols = maxCols; |
445 m_minCols = minCols; | 447 m_minCols = minCols; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 dimension->Add(m_minCols); | 571 dimension->Add(m_minCols); |
570 dimension->Add(rows); | 572 dimension->Add(rows); |
571 } | 573 } |
572 } | 574 } |
573 if (!dimension) { | 575 if (!dimension) { |
574 e = BCExceptionUnableToFitMessageInColumns; | 576 e = BCExceptionUnableToFitMessageInColumns; |
575 return nullptr; | 577 return nullptr; |
576 } | 578 } |
577 return dimension; | 579 return dimension; |
578 } | 580 } |
OLD | NEW |