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

Side by Side Diff: xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.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
« no previous file with comments | « xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h ('k') | xfa/src/fxbarcode/pdf417/BC_PDF417.h » ('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 2010 ZXing authors 8 * Copyright 2010 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 26 matching lines...) Expand all
37 } 37 }
38 CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter() 38 CBC_OnedUPCAWriter::~CBC_OnedUPCAWriter()
39 { 39 {
40 if(m_subWriter != NULL) { 40 if(m_subWriter != NULL) {
41 delete m_subWriter; 41 delete m_subWriter;
42 } 42 }
43 m_subWriter = NULL; 43 m_subWriter = NULL;
44 } 44 }
45 FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity(FX_WSTR contents) 45 FX_BOOL CBC_OnedUPCAWriter::CheckContentValidity(FX_WSTR contents)
46 { 46 {
47 FX_INT32 i = 0; 47 int32_t i = 0;
48 for (i = 0; i < contents.GetLength(); i++) { 48 for (i = 0; i < contents.GetLength(); i++) {
49 if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') { 49 if (contents.GetAt(i) >= '0' && contents.GetAt(i) <= '9') {
50 continue; 50 continue;
51 } else { 51 } else {
52 return FALSE; 52 return FALSE;
53 } 53 }
54 } 54 }
55 return TRUE; 55 return TRUE;
56 } 56 }
57 CFX_WideString CBC_OnedUPCAWriter::FilterContents(FX_WSTR contents) 57 CFX_WideString CBC_OnedUPCAWriter::FilterContents(FX_WSTR contents)
58 { 58 {
59 CFX_WideString filtercontents; 59 CFX_WideString filtercontents;
60 FX_WCHAR ch; 60 FX_WCHAR ch;
61 for (FX_INT32 i = 0; i < contents.GetLength(); i++) { 61 for (int32_t i = 0; i < contents.GetLength(); i++) {
62 ch = contents.GetAt(i); 62 ch = contents.GetAt(i);
63 if(ch > 175) { 63 if(ch > 175) {
64 i++; 64 i++;
65 continue; 65 continue;
66 } 66 }
67 if (ch >= '0' && ch <= '9') { 67 if (ch >= '0' && ch <= '9') {
68 filtercontents += ch; 68 filtercontents += ch;
69 } 69 }
70 } 70 }
71 return filtercontents; 71 return filtercontents;
72 } 72 }
73 FX_INT32 CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString &contents) 73 int32_t CBC_OnedUPCAWriter::CalcChecksum(const CFX_ByteString &contents)
74 { 74 {
75 FX_INT32 odd = 0; 75 int32_t odd = 0;
76 FX_INT32 even = 0; 76 int32_t even = 0;
77 FX_INT32 j = 1; 77 int32_t j = 1;
78 for(FX_INT32 i = contents.GetLength() - 1; i >= 0; i--) { 78 for(int32_t i = contents.GetLength() - 1; i >= 0; i--) {
79 if(j % 2) { 79 if(j % 2) {
80 odd += FXSYS_atoi(contents.Mid(i, 1)); 80 odd += FXSYS_atoi(contents.Mid(i, 1));
81 } else { 81 } else {
82 even += FXSYS_atoi(contents.Mid(i, 1)); 82 even += FXSYS_atoi(contents.Mid(i, 1));
83 } 83 }
84 j++; 84 j++;
85 } 85 }
86 FX_INT32 checksum = (odd * 3 + even) % 10; 86 int32_t checksum = (odd * 3 + even) % 10;
87 checksum = (10 - checksum) % 10; 87 checksum = (10 - checksum) % 10;
88 return (checksum); 88 return (checksum);
89 } 89 }
90 FX_BYTE *CBC_OnedUPCAWriter::Encode(const CFX_ByteString &contents, BCFORMAT for mat, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 &e) 90 uint8_t *CBC_OnedUPCAWriter::Encode(const CFX_ByteString &contents, BCFORMAT for mat, int32_t &outWidth, int32_t &outHeight, int32_t &e)
91 { 91 {
92 FX_BYTE *ret = Encode(contents, format, outWidth, outHeight, 0, e); 92 uint8_t *ret = Encode(contents, format, outWidth, outHeight, 0, e);
93 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 93 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
94 return ret; 94 return ret;
95 } 95 }
96 FX_BYTE *CBC_OnedUPCAWriter::Encode(const CFX_ByteString &contents, BCFORMAT for mat, FX_INT32 &outWidth, FX_INT32 &outHeight, FX_INT32 hints, FX_INT32 &e) 96 uint8_t *CBC_OnedUPCAWriter::Encode(const CFX_ByteString &contents, BCFORMAT for mat, int32_t &outWidth, int32_t &outHeight, int32_t hints, int32_t &e)
97 { 97 {
98 if (format != BCFORMAT_UPC_A) { 98 if (format != BCFORMAT_UPC_A) {
99 e = BCExceptionOnlyEncodeUPC_A; 99 e = BCExceptionOnlyEncodeUPC_A;
100 return NULL; 100 return NULL;
101 } 101 }
102 CFX_ByteString toEAN13String = '0' + contents; 102 CFX_ByteString toEAN13String = '0' + contents;
103 m_iDataLenth = 13; 103 m_iDataLenth = 13;
104 FX_BYTE *ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, outHeight, hints, e); 104 uint8_t *ret = m_subWriter->Encode(toEAN13String, BCFORMAT_EAN_13, outWidth, outHeight, hints, e);
105 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 105 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
106 return ret; 106 return ret;
107 } 107 }
108 void CBC_OnedUPCAWriter::ShowChars(FX_WSTR contents, CFX_DIBitmap *pOutBitmap, C FX_RenderDevice* device, const CFX_Matrix* matrix, FX_INT32 barWidth, FX_INT32 m ultiple, FX_INT32 &e) 108 void CBC_OnedUPCAWriter::ShowChars(FX_WSTR contents, CFX_DIBitmap *pOutBitmap, C FX_RenderDevice* device, const CFX_Matrix* matrix, int32_t barWidth, int32_t mul tiple, int32_t &e)
109 { 109 {
110 if (device == NULL && pOutBitmap == NULL) { 110 if (device == NULL && pOutBitmap == NULL) {
111 e = BCExceptionIllegalArgument; 111 e = BCExceptionIllegalArgument;
112 return; 112 return;
113 } 113 }
114 FX_INT32 leftPadding = 7 * multiple; 114 int32_t leftPadding = 7 * multiple;
115 FX_INT32 leftPosition = 10 * multiple + leftPadding; 115 int32_t leftPosition = 10 * multiple + leftPadding;
116 CFX_ByteString str = FX_UTF8Encode(contents); 116 CFX_ByteString str = FX_UTF8Encode(contents);
117 FX_INT32 iLen = str.GetLength(); 117 int32_t iLen = str.GetLength();
118 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen); 118 FXTEXT_CHARPOS* pCharPos = FX_Alloc(FXTEXT_CHARPOS, iLen);
119 if (!pCharPos) { 119 if (!pCharPos) {
120 return; 120 return;
121 } 121 }
122 FXSYS_memset32(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen); 122 FXSYS_memset32(pCharPos, 0, sizeof(FXTEXT_CHARPOS) * iLen);
123 CFX_ByteString tempStr = str.Mid(1, 5); 123 CFX_ByteString tempStr = str.Mid(1, 5);
124 FX_FLOAT strWidth = (FX_FLOAT)35 * multiple; 124 FX_FLOAT strWidth = (FX_FLOAT)35 * multiple;
125 FX_FLOAT blank = 0.0; 125 FX_FLOAT blank = 0.0;
126 CFX_FxgeDevice geBitmap; 126 CFX_FxgeDevice geBitmap;
127 if (pOutBitmap != NULL) { 127 if (pOutBitmap != NULL) {
128 geBitmap.Attach(pOutBitmap); 128 geBitmap.Attach(pOutBitmap);
129 } 129 }
130 FX_FLOAT charsWidth = 0; 130 FX_FLOAT charsWidth = 0;
131 iLen = tempStr.GetLength(); 131 iLen = tempStr.GetLength();
132 FX_INT32 iFontSize = (FX_INT32)fabs(m_fFontSize); 132 int32_t iFontSize = (int32_t)fabs(m_fFontSize);
133 FX_INT32 iTextHeight = iFontSize + 1; 133 int32_t iTextHeight = iFontSize + 1;
134 if (pOutBitmap == NULL) { 134 if (pOutBitmap == NULL) {
135 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); 135 CFX_Matrix matr(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
136 CFX_FloatRect rect((FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHe ight), (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height); 136 CFX_FloatRect rect((FX_FLOAT)leftPosition, (FX_FLOAT)(m_Height - iTextHe ight), (FX_FLOAT)(leftPosition + strWidth - 0.5), (FX_FLOAT)m_Height);
137 matr.Concat(*matrix); 137 matr.Concat(*matrix);
138 matr.TransformRect(rect); 138 matr.TransformRect(rect);
139 FX_RECT re = rect.GetOutterRect(); 139 FX_RECT re = rect.GetOutterRect();
140 device->FillRect(&re, m_backgroundColor); 140 device->FillRect(&re, m_backgroundColor);
141 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0); 141 CFX_Matrix matr1(m_outputHScale, 0.0, 0.0, 1.0, 0.0, 0.0);
142 CFX_FloatRect rect1((FX_FLOAT)(leftPosition + 40 * multiple), (FX_FLOAT) (m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), (FX_FLOAT)m_Height); 142 CFX_FloatRect rect1((FX_FLOAT)(leftPosition + 40 * multiple), (FX_FLOAT) (m_Height - iTextHeight), (FX_FLOAT)((leftPosition + 40 * multiple) + strWidth - 0.5), (FX_FLOAT)m_Height);
143 matr1.Concat(*matrix); 143 matr1.Concat(*matrix);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 device->DrawNormalText(iLen, 271 device->DrawNormalText(iLen,
272 pCharPos + 11, 272 pCharPos + 11,
273 m_pFont, 273 m_pFont,
274 CFX_GEModule::Get()->GetFontCache(), 274 CFX_GEModule::Get()->GetFontCache(),
275 (FX_FLOAT)iFontSize , 275 (FX_FLOAT)iFontSize ,
276 (CFX_AffineMatrix *) &affine_matrix1, 276 (CFX_AffineMatrix *) &affine_matrix1,
277 m_fontColor, FXTEXT_CLEARTYPE); 277 m_fontColor, FXTEXT_CLEARTYPE);
278 } 278 }
279 FX_Free(pCharPos); 279 FX_Free(pCharPos);
280 } 280 }
281 void CBC_OnedUPCAWriter::RenderResult(FX_WSTR contents, FX_BYTE* code, FX_INT32 codeLength, FX_BOOL isDevice, FX_INT32 &e) 281 void CBC_OnedUPCAWriter::RenderResult(FX_WSTR contents, uint8_t* code, int32_t c odeLength, FX_BOOL isDevice, int32_t &e)
282 { 282 {
283 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e); 283 CBC_OneDimWriter::RenderResult(contents, code, codeLength, isDevice, e);
284 } 284 }
285 285
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/oned/BC_OnedUPCAWriter.h ('k') | xfa/src/fxbarcode/pdf417/BC_PDF417.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698