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

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

Issue 2221023003: Use smart pointers for class owned pointers in xfa/fxbarcode (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: address comments Created 4 years, 4 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_OneDimWriter.h ('k') | xfa/fxbarcode/oned/BC_OnedUPCAWriter.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 2011 ZXing authors 8 * Copyright 2011 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 24 matching lines...) Expand all
35 m_bPrintChecksum = TRUE; 35 m_bPrintChecksum = TRUE;
36 m_iDataLenth = 0; 36 m_iDataLenth = 0;
37 m_bCalcChecksum = FALSE; 37 m_bCalcChecksum = FALSE;
38 m_pFont = nullptr; 38 m_pFont = nullptr;
39 m_fFontSize = 10; 39 m_fFontSize = 10;
40 m_iFontStyle = 0; 40 m_iFontStyle = 0;
41 m_fontColor = 0xff000000; 41 m_fontColor = 0xff000000;
42 m_iContentLen = 0; 42 m_iContentLen = 0;
43 m_bLeftPadding = FALSE; 43 m_bLeftPadding = FALSE;
44 m_bRightPadding = FALSE; 44 m_bRightPadding = FALSE;
45 m_output = nullptr;
46 } 45 }
47 CBC_OneDimWriter::~CBC_OneDimWriter() { 46
48 delete m_output; 47 CBC_OneDimWriter::~CBC_OneDimWriter() {}
49 } 48
50 void CBC_OneDimWriter::SetPrintChecksum(FX_BOOL checksum) { 49 void CBC_OneDimWriter::SetPrintChecksum(FX_BOOL checksum) {
51 m_bPrintChecksum = checksum; 50 m_bPrintChecksum = checksum;
52 } 51 }
52
53 void CBC_OneDimWriter::SetDataLength(int32_t length) { 53 void CBC_OneDimWriter::SetDataLength(int32_t length) {
54 m_iDataLenth = length; 54 m_iDataLenth = length;
55 } 55 }
56
56 void CBC_OneDimWriter::SetCalcChecksum(int32_t state) { 57 void CBC_OneDimWriter::SetCalcChecksum(int32_t state) {
57 m_bCalcChecksum = state; 58 m_bCalcChecksum = state;
58 } 59 }
60
59 FX_BOOL CBC_OneDimWriter::SetFont(CFX_Font* cFont) { 61 FX_BOOL CBC_OneDimWriter::SetFont(CFX_Font* cFont) {
60 if (!cFont) 62 if (!cFont)
61 return FALSE; 63 return FALSE;
62 64
63 m_pFont = cFont; 65 m_pFont = cFont;
64 return TRUE; 66 return TRUE;
65 } 67 }
68
66 void CBC_OneDimWriter::SetFontSize(FX_FLOAT size) { 69 void CBC_OneDimWriter::SetFontSize(FX_FLOAT size) {
67 m_fFontSize = size; 70 m_fFontSize = size;
68 } 71 }
72
69 void CBC_OneDimWriter::SetFontStyle(int32_t style) { 73 void CBC_OneDimWriter::SetFontStyle(int32_t style) {
70 m_iFontStyle = style; 74 m_iFontStyle = style;
71 } 75 }
76
72 void CBC_OneDimWriter::SetFontColor(FX_ARGB color) { 77 void CBC_OneDimWriter::SetFontColor(FX_ARGB color) {
73 m_fontColor = color; 78 m_fontColor = color;
74 } 79 }
80
75 FX_WCHAR CBC_OneDimWriter::Upper(FX_WCHAR ch) { 81 FX_WCHAR CBC_OneDimWriter::Upper(FX_WCHAR ch) {
76 if (ch >= 'a' && ch <= 'z') { 82 if (ch >= 'a' && ch <= 'z') {
77 ch = ch - ('a' - 'A'); 83 ch = ch - ('a' - 'A');
78 } 84 }
79 return ch; 85 return ch;
80 } 86 }
87
81 uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, 88 uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents,
82 BCFORMAT format, 89 BCFORMAT format,
83 int32_t& outWidth, 90 int32_t& outWidth,
84 int32_t& outHeight, 91 int32_t& outHeight,
85 int32_t hints, 92 int32_t hints,
86 int32_t& e) { 93 int32_t& e) {
87 uint8_t* ret = nullptr; 94 uint8_t* ret = nullptr;
88 outHeight = 1; 95 outHeight = 1;
89 if (m_Width >= 20) { 96 if (m_Width >= 20) {
90 ret = Encode(contents, outWidth, e); 97 ret = Encode(contents, outWidth, e);
91 } else { 98 } else {
92 ret = Encode(contents, outWidth, e); 99 ret = Encode(contents, outWidth, e);
93 } 100 }
94 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 101 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
95 return ret; 102 return ret;
96 } 103 }
104
97 uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents, 105 uint8_t* CBC_OneDimWriter::Encode(const CFX_ByteString& contents,
98 BCFORMAT format, 106 BCFORMAT format,
99 int32_t& outWidth, 107 int32_t& outWidth,
100 int32_t& outHeight, 108 int32_t& outHeight,
101 int32_t& e) { 109 int32_t& e) {
102 uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e); 110 uint8_t* ret = Encode(contents, format, outWidth, outHeight, 0, e);
103 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 111 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
104 return ret; 112 return ret;
105 } 113 }
106 114
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]); 184 charPos[i].m_GlyphIndex = encoding->GlyphFromCharCode(pCharCode[i]);
177 charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex); 185 charPos[i].m_FontCharWidth = cFont->GetGlyphWidth(charPos[i].m_GlyphIndex);
178 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 186 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
179 charPos[i].m_ExtGID = charPos[i].m_GlyphIndex; 187 charPos[i].m_ExtGID = charPos[i].m_GlyphIndex;
180 #endif 188 #endif
181 penX += 189 penX +=
182 (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f; 190 (FX_FLOAT)(charPos[i].m_FontCharWidth) * (FX_FLOAT)fontSize / 1000.0f;
183 } 191 }
184 FX_Free(pCharCode); 192 FX_Free(pCharCode);
185 } 193 }
194
186 void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device, 195 void CBC_OneDimWriter::ShowDeviceChars(CFX_RenderDevice* device,
187 const CFX_Matrix* matrix, 196 const CFX_Matrix* matrix,
188 const CFX_ByteString str, 197 const CFX_ByteString str,
189 FX_FLOAT geWidth, 198 FX_FLOAT geWidth,
190 FXTEXT_CHARPOS* pCharPos, 199 FXTEXT_CHARPOS* pCharPos,
191 FX_FLOAT locX, 200 FX_FLOAT locX,
192 FX_FLOAT locY, 201 FX_FLOAT locY,
193 int32_t barWidth) { 202 int32_t barWidth) {
194 int32_t iFontSize = (int32_t)fabs(m_fFontSize); 203 int32_t iFontSize = (int32_t)fabs(m_fFontSize);
195 int32_t iTextHeight = iFontSize + 1; 204 int32_t iTextHeight = iFontSize + 1;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 } 431 }
423 } 432 }
424 int32_t outputWidth = codeLength; 433 int32_t outputWidth = codeLength;
425 if (!isDevice) { 434 if (!isDevice) {
426 outputWidth = (int32_t)(codeLength * m_multiple / dataLengthScale); 435 outputWidth = (int32_t)(codeLength * m_multiple / dataLengthScale);
427 } 436 }
428 m_barWidth = m_Width; 437 m_barWidth = m_Width;
429 if (!isDevice) { 438 if (!isDevice) {
430 m_barWidth = codeLength * m_multiple; 439 m_barWidth = codeLength * m_multiple;
431 } 440 }
432 m_output = new CBC_CommonBitMatrix; 441 m_output.reset(new CBC_CommonBitMatrix);
433 m_output->Init(outputWidth, outputHeight); 442 m_output->Init(outputWidth, outputHeight);
434 int32_t outputX = leftPadding * m_multiple; 443 int32_t outputX = leftPadding * m_multiple;
435 for (int32_t inputX = 0; inputX < codeOldLength; inputX++) { 444 for (int32_t inputX = 0; inputX < codeOldLength; inputX++) {
436 if (code[inputX] == 1) { 445 if (code[inputX] == 1) {
437 if (outputX >= outputWidth) { 446 if (outputX >= outputWidth) {
438 break; 447 break;
439 } 448 }
440 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) { 449 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) {
441 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); 450 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e);
442 break; 451 break;
(...skipping 12 matching lines...) Expand all
455 464
456 CFX_WideString CBC_OneDimWriter::FilterContents( 465 CFX_WideString CBC_OneDimWriter::FilterContents(
457 const CFX_WideStringC& contents) { 466 const CFX_WideStringC& contents) {
458 return CFX_WideString(); 467 return CFX_WideString();
459 } 468 }
460 469
461 CFX_WideString CBC_OneDimWriter::RenderTextContents( 470 CFX_WideString CBC_OneDimWriter::RenderTextContents(
462 const CFX_WideStringC& contents) { 471 const CFX_WideStringC& contents) {
463 return CFX_WideString(); 472 return CFX_WideString();
464 } 473 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/oned/BC_OneDimWriter.h ('k') | xfa/fxbarcode/oned/BC_OnedUPCAWriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698