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

Side by Side Diff: core/fpdfapi/fpdf_page/cpdf_textobject.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 | « core/fpdfapi/fpdf_font/fpdf_font_cid.cpp ('k') | core/fpdfapi/fpdf_parser/cfdf_document.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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 6
7 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" 7 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h"
8 8
9 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h" 9 #include "core/fpdfapi/fpdf_font/cpdf_cidfont.h"
10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 10 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 int nsegs) { 135 int nsegs) {
136 if (m_nChars > 1) { 136 if (m_nChars > 1) {
137 FX_Free(m_pCharCodes); 137 FX_Free(m_pCharCodes);
138 m_pCharCodes = nullptr; 138 m_pCharCodes = nullptr;
139 } 139 }
140 FX_Free(m_pCharPos); 140 FX_Free(m_pCharPos);
141 m_pCharPos = nullptr; 141 m_pCharPos = nullptr;
142 CPDF_Font* pFont = m_TextState.GetFont(); 142 CPDF_Font* pFont = m_TextState.GetFont();
143 m_nChars = 0; 143 m_nChars = 0;
144 for (int i = 0; i < nsegs; ++i) { 144 for (int i = 0; i < nsegs; ++i) {
145 m_nChars += pFont->CountChar(pStrs[i], pStrs[i].GetLength()); 145 m_nChars += pFont->CountChar(pStrs[i].c_str(), pStrs[i].GetLength());
146 } 146 }
147 m_nChars += nsegs - 1; 147 m_nChars += nsegs - 1;
148 if (m_nChars > 1) { 148 if (m_nChars > 1) {
149 m_pCharCodes = FX_Alloc(uint32_t, m_nChars); 149 m_pCharCodes = FX_Alloc(uint32_t, m_nChars);
150 m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1); 150 m_pCharPos = FX_Alloc(FX_FLOAT, m_nChars - 1);
151 int index = 0; 151 int index = 0;
152 for (int i = 0; i < nsegs; ++i) { 152 for (int i = 0; i < nsegs; ++i) {
153 const FX_CHAR* segment = pStrs[i]; 153 const FX_CHAR* segment = pStrs[i].c_str();
154 int offset = 0, len = pStrs[i].GetLength(); 154 int len = pStrs[i].GetLength();
155 int offset = 0;
155 while (offset < len) { 156 while (offset < len) {
156 m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset); 157 m_pCharCodes[index++] = pFont->GetNextChar(segment, len, offset);
157 } 158 }
158 if (i != nsegs - 1) { 159 if (i != nsegs - 1) {
159 m_pCharPos[index - 1] = pKerning[i]; 160 m_pCharPos[index - 1] = pKerning[i];
160 m_pCharCodes[index++] = CPDF_Font::kInvalidCharCode; 161 m_pCharCodes[index++] = CPDF_Font::kInvalidCharCode;
161 } 162 }
162 } 163 }
163 } else { 164 } else {
164 int offset = 0; 165 int offset = 0;
165 m_pCharCodes = (uint32_t*)(uintptr_t)pFont->GetNextChar( 166 m_pCharCodes = (uint32_t*)(uintptr_t)pFont->GetNextChar(
166 pStrs[0], pStrs[0].GetLength(), offset); 167 pStrs[0].c_str(), pStrs[0].GetLength(), offset);
167 } 168 }
168 } 169 }
169 170
170 void CPDF_TextObject::SetText(const CFX_ByteString& str) { 171 void CPDF_TextObject::SetText(const CFX_ByteString& str) {
171 SetSegments(&str, nullptr, 1); 172 SetSegments(&str, nullptr, 1);
172 RecalcPositionData(); 173 RecalcPositionData();
173 } 174 }
174 175
175 FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const { 176 FX_FLOAT CPDF_TextObject::GetCharWidth(uint32_t charcode) const {
176 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000; 177 FX_FLOAT fontsize = m_TextState.GetFontSize() / 1000;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) { 341 void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) {
341 FX_FLOAT dx = x - m_PosX; 342 FX_FLOAT dx = x - m_PosX;
342 FX_FLOAT dy = y - m_PosY; 343 FX_FLOAT dy = y - m_PosY;
343 m_PosX = x; 344 m_PosX = x;
344 m_PosY = y; 345 m_PosY = y;
345 m_Left += dx; 346 m_Left += dx;
346 m_Right += dx; 347 m_Right += dx;
347 m_Top += dy; 348 m_Top += dy;
348 m_Bottom += dy; 349 m_Bottom += dy;
349 } 350 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_font/fpdf_font_cid.cpp ('k') | core/fpdfapi/fpdf_parser/cfdf_document.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698