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

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

Issue 2146993002: Remove default params in CPDF_VariableText. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@ifx_cleanup_3
Patch Set: Fix calls to GetFont{Ascent|Descent} 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 | « no previous file | core/fpdfdoc/ctypeset.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/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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 pNewSection->AddWord(NewPlace, *pWord); 328 pNewSection->AddWord(NewPlace, *pWord);
329 } 329 }
330 } 330 }
331 } 331 }
332 ClearSectionRightWords(wordplace); 332 ClearSectionRightWords(wordplace);
333 } 333 }
334 return newplace; 334 return newplace;
335 } 335 }
336 336
337 CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place, 337 CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace& place,
338 const FX_WCHAR* text, 338 const FX_WCHAR* text) {
339 int32_t charset,
340 const CPVT_SecProps* pSecProps,
341 const CPVT_WordProps* pProps) {
342 CFX_WideString swText = text; 339 CFX_WideString swText = text;
343 CPVT_WordPlace wp = place; 340 CPVT_WordPlace wp = place;
344 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { 341 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
345 CPVT_WordPlace oldwp = wp; 342 CPVT_WordPlace oldwp = wp;
346 uint16_t word = swText.GetAt(i); 343 uint16_t word = swText.GetAt(i);
347 switch (word) { 344 switch (word) {
348 case 0x0D: 345 case 0x0D:
349 if (m_bMultiLine) { 346 if (m_bMultiLine) {
350 if (swText.GetAt(i + 1) == 0x0A) 347 if (swText.GetAt(i + 1) == 0x0A)
351 i += 1; 348 i += 1;
352 349
353 wp = InsertSection(wp, pSecProps, pProps); 350 wp = InsertSection(wp, nullptr, nullptr);
354 } 351 }
355 break; 352 break;
356 case 0x0A: 353 case 0x0A:
357 if (m_bMultiLine) { 354 if (m_bMultiLine) {
358 if (swText.GetAt(i + 1) == 0x0D) 355 if (swText.GetAt(i + 1) == 0x0D)
359 i += 1; 356 i += 1;
360 357
361 wp = InsertSection(wp, pSecProps, pProps); 358 wp = InsertSection(wp, nullptr, nullptr);
362 } 359 }
363 break; 360 break;
364 case 0x09: 361 case 0x09:
365 word = 0x20; 362 word = 0x20;
366 default: 363 default:
367 wp = InsertWord(wp, word, charset, pProps); 364 wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr);
368 break; 365 break;
369 } 366 }
370 if (wp == oldwp) 367 if (wp == oldwp)
371 break; 368 break;
372 } 369 }
373 return wp; 370 return wp;
374 } 371 }
375 372
376 CPVT_WordPlace CPDF_VariableText::DeleteWords( 373 CPVT_WordPlace CPDF_VariableText::DeleteWords(
377 const CPVT_WordRange& PlaceRange) { 374 const CPVT_WordRange& PlaceRange) {
(...skipping 11 matching lines...) Expand all
389 } 386 }
390 387
391 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) { 388 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace& place) {
392 return ClearRightWord(AdjustLineHeader(place, TRUE)); 389 return ClearRightWord(AdjustLineHeader(place, TRUE));
393 } 390 }
394 391
395 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) { 392 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace& place) {
396 return ClearLeftWord(AdjustLineHeader(place, TRUE)); 393 return ClearLeftWord(AdjustLineHeader(place, TRUE));
397 } 394 }
398 395
399 void CPDF_VariableText::SetText(const FX_WCHAR* text, 396 void CPDF_VariableText::SetText(const FX_WCHAR* text) {
400 int32_t charset,
401 const CPVT_SecProps* pSecProps,
402 const CPVT_WordProps* pWordProps) {
403 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); 397 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
404 CFX_WideString swText = text; 398 CFX_WideString swText = text;
405 CPVT_WordPlace wp(0, 0, -1); 399 CPVT_WordPlace wp(0, 0, -1);
406 CPVT_SectionInfo secinfo; 400 CPVT_SectionInfo secinfo;
407 if (CSection* pSection = m_SectionArray.GetAt(0)) 401 if (CSection* pSection = m_SectionArray.GetAt(0))
408 pSection->m_SecInfo = secinfo; 402 pSection->m_SecInfo = secinfo;
409 403
410 int32_t nCharCount = 0; 404 int32_t nCharCount = 0;
411 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) { 405 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
412 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) 406 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar)
(...skipping 21 matching lines...) Expand all
434 428
435 wp.nSecIndex++; 429 wp.nSecIndex++;
436 wp.nLineIndex = 0; 430 wp.nLineIndex = 0;
437 wp.nWordIndex = -1; 431 wp.nWordIndex = -1;
438 AddSection(wp, secinfo); 432 AddSection(wp, secinfo);
439 } 433 }
440 break; 434 break;
441 case 0x09: 435 case 0x09:
442 word = 0x20; 436 word = 0x20;
443 default: 437 default:
444 wp = InsertWord(wp, word, charset, pWordProps); 438 wp = InsertWord(wp, word, FXFONT_DEFAULT_CHARSET, nullptr);
445 break; 439 break;
446 } 440 }
447 nCharCount++; 441 nCharCount++;
448 } 442 }
449 } 443 }
450 444
451 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const { 445 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace& place) const {
452 if (place.nSecIndex < 0) 446 if (place.nSecIndex < 0)
453 place = GetBeginWordPlace(); 447 place = GetBeginWordPlace();
454 if (place.nSecIndex >= m_SectionArray.GetSize()) 448 if (place.nSecIndex >= m_SectionArray.GetSize())
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 } 760 }
767 761
768 CFX_FloatRect CPDF_VariableText::GetContentRect() const { 762 CFX_FloatRect CPDF_VariableText::GetContentRect() const {
769 return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect())); 763 return InToOut(CPVT_FloatRect(CPDF_EditContainer::GetContentRect()));
770 } 764 }
771 765
772 const CFX_FloatRect& CPDF_VariableText::GetPlateRect() const { 766 const CFX_FloatRect& CPDF_VariableText::GetPlateRect() const {
773 return CPDF_EditContainer::GetPlateRect(); 767 return CPDF_EditContainer::GetPlateRect();
774 } 768 }
775 769
776 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo, 770 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo& WordInfo) {
777 FX_BOOL bFactFontSize) {
778 return GetFontSize(); 771 return GetFontSize();
779 } 772 }
780 773
781 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) { 774 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo& WordInfo) {
782 return WordInfo.nFontIndex; 775 return WordInfo.nFontIndex;
783 } 776 }
784 777
785 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, 778 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex,
786 uint16_t Word, 779 uint16_t Word,
787 uint16_t SubWord, 780 uint16_t SubWord,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo, 819 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo,
827 FX_FLOAT fFontSize) { 820 FX_FLOAT fFontSize) {
828 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize); 821 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize);
829 } 822 }
830 823
831 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo, 824 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo,
832 FX_FLOAT fFontSize) { 825 FX_FLOAT fFontSize) {
833 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize); 826 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize);
834 } 827 }
835 828
836 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo, 829 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo& WordInfo) {
837 FX_BOOL bFactFontSize) { 830 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo));
838 return GetFontAscent(GetWordFontIndex(WordInfo),
839 GetWordFontSize(WordInfo, bFactFontSize));
840 } 831 }
841 832
842 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo, 833 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo& WordInfo) {
843 FX_BOOL bFactFontSize) { 834 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo));
844 return GetFontDescent(GetWordFontIndex(WordInfo),
845 GetWordFontSize(WordInfo, bFactFontSize));
846 } 835 }
847 836
848 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo& SecInfo) { 837 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo& SecInfo) {
849 return m_fLineLeading; 838 return m_fLineLeading;
850 } 839 }
851 840
852 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo& SecInfo) { 841 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo& SecInfo) {
853 return 0.0f; 842 return 0.0f;
854 } 843 }
855 844
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 1096
1108 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() { 1097 CPDF_VariableText::Iterator* CPDF_VariableText::GetIterator() {
1109 if (!m_pVTIterator) 1098 if (!m_pVTIterator)
1110 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this)); 1099 m_pVTIterator.reset(new CPDF_VariableText::Iterator(this));
1111 return m_pVTIterator.get(); 1100 return m_pVTIterator.get();
1112 } 1101 }
1113 1102
1114 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) { 1103 void CPDF_VariableText::SetProvider(CPDF_VariableText::Provider* pProvider) {
1115 m_pVTProvider = pProvider; 1104 m_pVTProvider = pProvider;
1116 } 1105 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfdoc/ctypeset.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698