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

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

Issue 1961333002: Remove CPVT_Size and CPVT_FloatRange. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: More point to size Created 4 years, 7 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/csection.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"
8
7 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
8 #include "core/fpdfdoc/cpvt_wordinfo.h" 10 #include "core/fpdfdoc/cpvt_wordinfo.h"
9 #include "core/fpdfdoc/csection.h" 11 #include "core/fpdfdoc/csection.h"
10 #include "core/fpdfdoc/include/cpdf_variabletext.h"
11 #include "core/fpdfdoc/include/cpvt_section.h" 12 #include "core/fpdfdoc/include/cpvt_section.h"
12 #include "core/fpdfdoc/include/cpvt_word.h" 13 #include "core/fpdfdoc/include/cpvt_word.h"
13 #include "core/fpdfdoc/include/ipvt_fontmap.h" 14 #include "core/fpdfdoc/include/ipvt_fontmap.h"
14 15
15 namespace { 16 namespace {
16 17
17 const float kDefaultFontSize = 18.0f; 18 const float kDefaultFontSize = 18.0f;
18 const float kFontScale = 0.001f; 19 const float kFontScale = 0.001f;
19 const uint8_t kReturnLength = 1; 20 const uint8_t kReturnLength = 1;
20 const float kScalePercent = 0.01f; 21 const float kScalePercent = 0.01f;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 return 0; 64 return 0;
64 } 65 }
65 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) { 66 if (CPDF_Font* pSysFont = m_pFontMap->GetPDFFont(1)) {
66 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode) 67 if (pSysFont->CharCodeFromUnicode(word) != CPDF_Font::kInvalidCharCode)
67 return 1; 68 return 1;
68 } 69 }
69 return -1; 70 return -1;
70 } 71 }
71 72
72 FX_BOOL CPDF_VariableText::Provider::IsLatinWord(uint16_t word) { 73 FX_BOOL CPDF_VariableText::Provider::IsLatinWord(uint16_t word) {
73 if ((word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) || 74 return (word >= 0x61 && word <= 0x7A) || (word >= 0x41 && word <= 0x5A) ||
74 word == 0x2D || word == 0x27) { 75 word == 0x2D || word == 0x27;
75 return TRUE;
76 }
77 return FALSE;
78 } 76 }
79 77
80 int32_t CPDF_VariableText::Provider::GetDefaultFontIndex() { 78 int32_t CPDF_VariableText::Provider::GetDefaultFontIndex() {
81 return 0; 79 return 0;
82 } 80 }
83 81
84 CPDF_VariableText::Iterator::Iterator(CPDF_VariableText* pVT) 82 CPDF_VariableText::Iterator::Iterator(CPDF_VariableText* pVT)
85 : m_CurPos(-1, -1, -1), m_pVT(pVT) {} 83 : m_CurPos(-1, -1, -1), m_pVT(pVT) {}
86 84
87 CPDF_VariableText::Iterator::~Iterator() {} 85 CPDF_VariableText::Iterator::~Iterator() {}
(...skipping 958 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 continue; 1044 continue;
1047 } else { 1045 } else {
1048 nLeft = nMid + 1; 1046 nLeft = nMid + 1;
1049 nMid = (nLeft + nRight) / 2; 1047 nMid = (nLeft + nRight) / 2;
1050 continue; 1048 continue;
1051 } 1049 }
1052 } 1050 }
1053 return (FX_FLOAT)gFontSizeSteps[nMid]; 1051 return (FX_FLOAT)gFontSizeSteps[nMid];
1054 } 1052 }
1055 1053
1056 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) { 1054 bool CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) const {
1057 FX_BOOL bBigger = FALSE; 1055 CFX_SizeF szTotal;
1058 CPVT_Size szTotal;
1059 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1056 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1060 if (CSection* pSection = m_SectionArray.GetAt(s)) { 1057 if (CSection* pSection = m_SectionArray.GetAt(s)) {
1061 CPVT_Size size = pSection->GetSectionSize(fFontSize); 1058 CFX_SizeF size = pSection->GetSectionSize(fFontSize);
1062 szTotal.x = std::max(size.x, szTotal.x); 1059 szTotal.x = std::max(size.x, szTotal.x);
1063 szTotal.y += size.y; 1060 szTotal.y += size.y;
1064 if (IsFloatBigger(szTotal.x, GetPlateWidth()) || 1061 if (IsFloatBigger(szTotal.x, GetPlateWidth()) ||
1065 IsFloatBigger(szTotal.y, GetPlateHeight())) { 1062 IsFloatBigger(szTotal.y, GetPlateHeight())) {
1066 bBigger = TRUE; 1063 return true;
1067 break;
1068 } 1064 }
1069 } 1065 }
1070 } 1066 }
1071 return bBigger; 1067 return false;
1072 } 1068 }
1073 1069
1074 CPVT_FloatRect CPDF_VariableText::RearrangeSections( 1070 CPVT_FloatRect CPDF_VariableText::RearrangeSections(
1075 const CPVT_WordRange& PlaceRange) { 1071 const CPVT_WordRange& PlaceRange) {
1076 CPVT_WordPlace place; 1072 CPVT_WordPlace place;
1077 FX_FLOAT fPosY = 0; 1073 FX_FLOAT fPosY = 0;
1078 FX_FLOAT fOldHeight; 1074 FX_FLOAT fOldHeight;
1079 int32_t nSSecIndex = PlaceRange.BeginPos.nSecIndex; 1075 int32_t nSSecIndex = PlaceRange.BeginPos.nSecIndex;
1080 int32_t nESecIndex = PlaceRange.EndPos.nSecIndex; 1076 int32_t nESecIndex = PlaceRange.EndPos.nSecIndex;
1081 CPVT_FloatRect rcRet; 1077 CPVT_FloatRect rcRet;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 m_pVTIterator = new CPDF_VariableText::Iterator(this); 1148 m_pVTIterator = new CPDF_VariableText::Iterator(this);
1153 return m_pVTIterator; 1149 return m_pVTIterator;
1154 } 1150 }
1155 1151
1156 CPDF_VariableText::Provider* CPDF_VariableText::SetProvider( 1152 CPDF_VariableText::Provider* CPDF_VariableText::SetProvider(
1157 CPDF_VariableText::Provider* pProvider) { 1153 CPDF_VariableText::Provider* pProvider) {
1158 CPDF_VariableText::Provider* pOld = m_pVTProvider; 1154 CPDF_VariableText::Provider* pOld = m_pVTProvider;
1159 m_pVTProvider = pProvider; 1155 m_pVTProvider = pProvider;
1160 return pOld; 1156 return pOld;
1161 } 1157 }
OLDNEW
« no previous file with comments | « no previous file | core/fpdfdoc/csection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698