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

Side by Side Diff: core/fpdfdoc/cpdf_variabletext.cpp

Issue 2136683002: Use smart pointers for class owned member variables (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 5 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_render/render_int.h ('k') | core/fpdfdoc/cpvt_sectioninfo.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 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/fpdfdoc/include/cpdf_variabletext.h" 7 #include "core/fpdfdoc/include/cpdf_variabletext.h"
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfdoc/cpvt_wordinfo.h" 10 #include "core/fpdfdoc/cpvt_wordinfo.h"
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 m_pVTProvider(nullptr) {} 257 m_pVTProvider(nullptr) {}
258 258
259 CPDF_VariableText::~CPDF_VariableText() { 259 CPDF_VariableText::~CPDF_VariableText() {
260 ResetAll(); 260 ResetAll();
261 } 261 }
262 262
263 void CPDF_VariableText::Initialize() { 263 void CPDF_VariableText::Initialize() {
264 if (!m_bInitial) { 264 if (!m_bInitial) {
265 CPVT_SectionInfo secinfo; 265 CPVT_SectionInfo secinfo;
266 if (m_bRichText) { 266 if (m_bRichText) {
267 secinfo.pSecProps = new CPVT_SecProps(0.0f, 0.0f, 0); 267 secinfo.pSecProps.reset(new CPVT_SecProps(0.0f, 0.0f, 0));
268 secinfo.pWordProps = new CPVT_WordProps( 268 secinfo.pWordProps.reset(new CPVT_WordProps(
269 GetDefaultFontIndex(), kDefaultFontSize, 0, ScriptType::Normal, 0); 269 GetDefaultFontIndex(), kDefaultFontSize, 0, ScriptType::Normal, 0));
270 } 270 }
271 CPVT_WordPlace place; 271 CPVT_WordPlace place;
272 place.nSecIndex = 0; 272 place.nSecIndex = 0;
273 AddSection(place, secinfo); 273 AddSection(place, secinfo);
274 CPVT_LineInfo lineinfo; 274 CPVT_LineInfo lineinfo;
275 lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize()); 275 lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize());
276 lineinfo.fLineDescent = 276 lineinfo.fLineDescent =
277 GetFontDescent(GetDefaultFontIndex(), GetFontSize()); 277 GetFontDescent(GetDefaultFontIndex(), GetFontSize());
278 AddLine(place, lineinfo); 278 AddLine(place, lineinfo);
279 if (CSection* pSection = m_SectionArray.GetAt(0)) 279 if (CSection* pSection = m_SectionArray.GetAt(0))
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 return place; 326 return place;
327 327
328 CPVT_WordPlace wordplace = place; 328 CPVT_WordPlace wordplace = place;
329 UpdateWordPlace(wordplace); 329 UpdateWordPlace(wordplace);
330 CPVT_WordPlace newplace = place; 330 CPVT_WordPlace newplace = place;
331 if (CSection* pSection = m_SectionArray.GetAt(wordplace.nSecIndex)) { 331 if (CSection* pSection = m_SectionArray.GetAt(wordplace.nSecIndex)) {
332 CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1); 332 CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1);
333 CPVT_SectionInfo secinfo; 333 CPVT_SectionInfo secinfo;
334 if (m_bRichText) { 334 if (m_bRichText) {
335 if (pSecProps) 335 if (pSecProps)
336 secinfo.pSecProps = new CPVT_SecProps(*pSecProps); 336 secinfo.pSecProps.reset(new CPVT_SecProps(*pSecProps));
337 if (pWordProps) 337 if (pWordProps)
338 secinfo.pWordProps = new CPVT_WordProps(*pWordProps); 338 secinfo.pWordProps.reset(new CPVT_WordProps(*pWordProps));
339 } 339 }
340 AddSection(NewPlace, secinfo); 340 AddSection(NewPlace, secinfo);
341 newplace = NewPlace; 341 newplace = NewPlace;
342 if (CSection* pNewSection = m_SectionArray.GetAt(NewPlace.nSecIndex)) { 342 if (CSection* pNewSection = m_SectionArray.GetAt(NewPlace.nSecIndex)) {
343 for (int32_t w = wordplace.nWordIndex + 1, 343 for (int32_t w = wordplace.nWordIndex + 1,
344 sz = pSection->m_WordArray.GetSize(); 344 sz = pSection->m_WordArray.GetSize();
345 w < sz; w++) { 345 w < sz; w++) {
346 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(w)) { 346 if (CPVT_WordInfo* pWord = pSection->m_WordArray.GetAt(w)) {
347 NewPlace.nWordIndex++; 347 NewPlace.nWordIndex++;
348 pNewSection->AddWord(NewPlace, *pWord); 348 pNewSection->AddWord(NewPlace, *pWord);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 void CPDF_VariableText::SetText(const FX_WCHAR* text, 419 void CPDF_VariableText::SetText(const FX_WCHAR* text,
420 int32_t charset, 420 int32_t charset,
421 const CPVT_SecProps* pSecProps, 421 const CPVT_SecProps* pSecProps,
422 const CPVT_WordProps* pWordProps) { 422 const CPVT_WordProps* pWordProps) {
423 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); 423 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
424 CFX_WideString swText = text; 424 CFX_WideString swText = text;
425 CPVT_WordPlace wp(0, 0, -1); 425 CPVT_WordPlace wp(0, 0, -1);
426 CPVT_SectionInfo secinfo; 426 CPVT_SectionInfo secinfo;
427 if (m_bRichText) { 427 if (m_bRichText) {
428 if (pSecProps) 428 if (pSecProps)
429 secinfo.pSecProps = new CPVT_SecProps(*pSecProps); 429 secinfo.pSecProps.reset(new CPVT_SecProps(*pSecProps));
430 if (pWordProps) 430 if (pWordProps)
431 secinfo.pWordProps = new CPVT_WordProps(*pWordProps); 431 secinfo.pWordProps.reset(new CPVT_WordProps(*pWordProps));
432 } 432 }
433 if (CSection* pSection = m_SectionArray.GetAt(0)) 433 if (CSection* pSection = m_SectionArray.GetAt(0))
434 pSection->m_SecInfo = secinfo; 434 pSection->m_SecInfo = secinfo;
435 435
436 int32_t nCharCount = 0; 436 int32_t nCharCount = 0;
437 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { 437 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
438 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) 438 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar)
439 break; 439 break;
440 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) 440 if (m_nCharArray > 0 && nCharCount >= m_nCharArray)
441 break; 441 break;
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 1150
1151 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { 1151 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() {
1152 if (!m_pVTIterator) 1152 if (!m_pVTIterator)
1153 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); 1153 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this));
1154 return m_pVTIterator.get(); 1154 return m_pVTIterator.get();
1155 } 1155 }
1156 1156
1157 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { 1157 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) {
1158 m_pVTProvider = pProvider; 1158 m_pVTProvider = pProvider;
1159 } 1159 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/render_int.h ('k') | core/fpdfdoc/cpvt_sectioninfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698