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

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

Issue 1545183002: Merge to XFA: Switch from nonstd::unique_ptr to std::unique_ptr. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: xfa Created 4 years, 12 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
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");
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 "BC_OneDimWriter.h" 23 #include "BC_OneDimWriter.h"
24 24
25 #include <memory>
26
25 #include "../BC_Writer.h" 27 #include "../BC_Writer.h"
26 #include "../barcode.h" 28 #include "../barcode.h"
27 #include "../common/BC_CommonBitMatrix.h" 29 #include "../common/BC_CommonBitMatrix.h"
28 #include "third_party/base/nonstd_unique_ptr.h"
29 30
30 CBC_OneDimWriter::CBC_OneDimWriter() { 31 CBC_OneDimWriter::CBC_OneDimWriter() {
31 m_locTextLoc = BC_TEXT_LOC_BELOWEMBED; 32 m_locTextLoc = BC_TEXT_LOC_BELOWEMBED;
32 m_bPrintChecksum = TRUE; 33 m_bPrintChecksum = TRUE;
33 m_iDataLenth = 0; 34 m_iDataLenth = 0;
34 m_bCalcChecksum = FALSE; 35 m_bCalcChecksum = FALSE;
35 m_pFont = NULL; 36 m_pFont = NULL;
36 m_fFontSize = 10; 37 m_fFontSize = 10;
37 ; 38 ;
38 m_iFontStyle = 0; 39 m_iFontStyle = 0;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 color ^= 1; 126 color ^= 1;
126 } 127 }
127 return numAdded; 128 return numAdded;
128 } 129 }
129 void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text, 130 void CBC_OneDimWriter::CalcTextInfo(const CFX_ByteString& text,
130 FXTEXT_CHARPOS* charPos, 131 FXTEXT_CHARPOS* charPos,
131 CFX_Font* cFont, 132 CFX_Font* cFont,
132 FX_FLOAT geWidth, 133 FX_FLOAT geWidth,
133 int32_t fontSize, 134 int32_t fontSize,
134 FX_FLOAT& charsLen) { 135 FX_FLOAT& charsLen) {
135 nonstd::unique_ptr<CFX_UnicodeEncodingEx> encoding( 136 std::unique_ptr<CFX_UnicodeEncodingEx> encoding(
136 FX_CreateFontEncodingEx(cFont)); 137 FX_CreateFontEncodingEx(cFont));
137 138
138 int32_t length = text.GetLength(); 139 int32_t length = text.GetLength();
139 FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength()); 140 FX_DWORD* pCharCode = FX_Alloc(FX_DWORD, text.GetLength());
140 FX_FLOAT charWidth = 0; 141 FX_FLOAT charWidth = 0;
141 for (int32_t j = 0; j < text.GetLength(); j++) { 142 for (int32_t j = 0; j < text.GetLength(); j++) {
142 pCharCode[j] = encoding->CharCodeFromUnicode(text[j]); 143 pCharCode[j] = encoding->CharCodeFromUnicode(text[j]);
143 int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]); 144 int32_t glyp_code = encoding->GlyphFromCharCode(pCharCode[j]);
144 int32_t glyp_value = cFont->GetGlyphWidth(glyp_code); 145 int32_t glyp_value = cFont->GetGlyphWidth(glyp_code);
145 FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0); 146 FX_FLOAT temp = (FX_FLOAT)((glyp_value)*fontSize / 1000.0);
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) { 431 if (outputX + m_multiple > outputWidth && outputWidth - outputX > 0) {
431 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e); 432 m_output->SetRegion(outputX, 0, outputWidth - outputX, outputHeight, e);
432 break; 433 break;
433 } 434 }
434 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e); 435 m_output->SetRegion(outputX, 0, m_multiple, outputHeight, e);
435 BC_EXCEPTION_CHECK_ReturnVoid(e); 436 BC_EXCEPTION_CHECK_ReturnVoid(e);
436 } 437 }
437 outputX += m_multiple; 438 outputX += m_multiple;
438 } 439 }
439 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698