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

Side by Side Diff: xfa/fxbarcode/oned/BC_OnedEAN8Writer.cpp

Issue 1885973002: Remove implicit cast from CFX_ByteString to (const char*). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Typo Created 4 years, 8 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
« no previous file with comments | « xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp ('k') | xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2009 ZXing authors 8 * Copyright 2009 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 } 69 }
70 } 70 }
71 return filtercontents; 71 return filtercontents;
72 } 72 }
73 int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) { 73 int32_t CBC_OnedEAN8Writer::CalcChecksum(const CFX_ByteString& contents) {
74 int32_t odd = 0; 74 int32_t odd = 0;
75 int32_t even = 0; 75 int32_t even = 0;
76 int32_t j = 1; 76 int32_t j = 1;
77 for (int32_t i = contents.GetLength() - 1; i >= 0; i--) { 77 for (int32_t i = contents.GetLength() - 1; i >= 0; i--) {
78 if (j % 2) { 78 if (j % 2) {
79 odd += FXSYS_atoi(contents.Mid(i, 1)); 79 odd += FXSYS_atoi(contents.Mid(i, 1).c_str());
80 } else { 80 } else {
81 even += FXSYS_atoi(contents.Mid(i, 1)); 81 even += FXSYS_atoi(contents.Mid(i, 1).c_str());
82 } 82 }
83 j++; 83 j++;
84 } 84 }
85 int32_t checksum = (odd * 3 + even) % 10; 85 int32_t checksum = (odd * 3 + even) % 10;
86 checksum = (10 - checksum) % 10; 86 checksum = (10 - checksum) % 10;
87 return (checksum); 87 return (checksum);
88 } 88 }
89 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents, 89 uint8_t* CBC_OnedEAN8Writer::Encode(const CFX_ByteString& contents,
90 BCFORMAT format, 90 BCFORMAT format,
91 int32_t& outWidth, 91 int32_t& outWidth,
(...skipping 29 matching lines...) Expand all
121 uint8_t* result = FX_Alloc(uint8_t, m_codeWidth); 121 uint8_t* result = FX_Alloc(uint8_t, m_codeWidth);
122 int32_t pos = 0; 122 int32_t pos = 0;
123 pos += 123 pos +=
124 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); 124 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e);
125 if (e != BCExceptionNO) { 125 if (e != BCExceptionNO) {
126 FX_Free(result); 126 FX_Free(result);
127 return NULL; 127 return NULL;
128 } 128 }
129 int32_t i = 0; 129 int32_t i = 0;
130 for (i = 0; i <= 3; i++) { 130 for (i = 0; i <= 3; i++) {
131 int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); 131 int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str());
132 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0, 132 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 0,
133 e); 133 e);
134 if (e != BCExceptionNO) { 134 if (e != BCExceptionNO) {
135 FX_Free(result); 135 FX_Free(result);
136 return NULL; 136 return NULL;
137 } 137 }
138 } 138 }
139 pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e); 139 pos += AppendPattern(result, pos, CBC_OneDimReader::MIDDLE_PATTERN, 5, 0, e);
140 if (e != BCExceptionNO) { 140 if (e != BCExceptionNO) {
141 FX_Free(result); 141 FX_Free(result);
142 return NULL; 142 return NULL;
143 } 143 }
144 for (i = 4; i <= 7; i++) { 144 for (i = 4; i <= 7; i++) {
145 int32_t digit = FXSYS_atoi(contents.Mid(i, 1)); 145 int32_t digit = FXSYS_atoi(contents.Mid(i, 1).c_str());
146 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1, 146 pos += AppendPattern(result, pos, CBC_OneDimReader::L_PATTERNS[digit], 4, 1,
147 e); 147 e);
148 if (e != BCExceptionNO) { 148 if (e != BCExceptionNO) {
149 FX_Free(result); 149 FX_Free(result);
150 return NULL; 150 return NULL;
151 } 151 }
152 } 152 }
153 pos += 153 pos +=
154 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e); 154 AppendPattern(result, pos, CBC_OneDimReader::START_END_PATTERN, 3, 1, e);
155 if (e != BCExceptionNO) { 155 if (e != BCExceptionNO) {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 } 259 }
260 FX_Free(pCharPos); 260 FX_Free(pCharPos);
261 } 261 }
262 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents, 262 void CBC_OnedEAN8Writer::RenderResult(const CFX_WideStringC& contents,
263 uint8_t* code, 263 uint8_t* code,
264 int32_t codeLength, 264 int32_t codeLength,
265 FX_BOOL isDevice, 265 FX_BOOL isDevice,
266 int32_t& e) { 266 int32_t& e) {
267 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); 267 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e);
268 } 268 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OnedEAN13Writer.cpp ('k') | xfa/fxbarcode/oned/BC_OnedUPCAWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698