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

Side by Side Diff: core/src/fpdfdoc/doc_vt.cpp

Issue 1177483002: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 6 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/src/fpdfdoc/doc_viewerPreferences.cpp ('k') | core/src/fpdfdoc/pdf_vt.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 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 6
7 #include "../../include/fpdfdoc/fpdf_doc.h" 7 #include "../../include/fpdfdoc/fpdf_doc.h"
8 #include "../../include/fpdfdoc/fpdf_vt.h" 8 #include "../../include/fpdfdoc/fpdf_vt.h"
9 #include "pdf_vt.h" 9 #include "pdf_vt.h"
10 const FX_BYTE gFontSizeSteps[] = {» 4, 6, 8, 9, 10,»12, 14, 18, 20, 25,» 30, 35, 40, 45, 50,» 55, 60, 70, 80, 90,» 100, 110, 120, 130, 144}; 10 const uint8_t gFontSizeSteps[] = {» 4, 6, 8, 9, 10,»12, 14, 18, 20, 25,» 30, 35, 40, 45, 50,» 55, 60, 70, 80, 90,» 100, 110, 120, 130, 144};
11 #define PVT_RETURN_LENGTH 1 11 #define PVT_RETURN_LENGTH 1
12 #define PVT_DEFAULT_FONTSIZE 18.0f 12 #define PVT_DEFAULT_FONTSIZE 18.0f
13 #define PVTWORD_SCRIPT_NORMAL 0 13 #define PVTWORD_SCRIPT_NORMAL 0
14 #define PVTWORD_SCRIPT_SUPER 1 14 #define PVTWORD_SCRIPT_SUPER 1
15 #define PVTWORD_SCRIPT_SUB 2 15 #define PVTWORD_SCRIPT_SUB 2
16 #define PVT_FONTSCALE 0.001f 16 #define PVT_FONTSCALE 0.001f
17 #define PVT_PERCENT 0.01f 17 #define PVT_PERCENT 0.01f
18 #define PVT_HALF 0.5f 18 #define PVT_HALF 0.5f
19 CLine::CLine() 19 CLine::CLine()
20 { 20 {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 { 55 {
56 ResetWordArray(); 56 ResetWordArray();
57 ResetLineArray(); 57 ResetLineArray();
58 } 58 }
59 void CSection::ResetLineArray() 59 void CSection::ResetLineArray()
60 { 60 {
61 m_LineArray.RemoveAll(); 61 m_LineArray.RemoveAll();
62 } 62 }
63 void CSection::ResetWordArray() 63 void CSection::ResetWordArray()
64 { 64 {
65 for (FX_INT32 i = 0, sz = m_WordArray.GetSize(); i < sz; i++) { 65 for (int32_t i = 0, sz = m_WordArray.GetSize(); i < sz; i++) {
66 delete m_WordArray.GetAt(i); 66 delete m_WordArray.GetAt(i);
67 } 67 }
68 m_WordArray.RemoveAll(); 68 m_WordArray.RemoveAll();
69 } 69 }
70 void CSection::ResetLinePlace() 70 void CSection::ResetLinePlace()
71 { 71 {
72 for (FX_INT32 i = 0, sz = m_LineArray.GetSize(); i < sz; i++) { 72 for (int32_t i = 0, sz = m_LineArray.GetSize(); i < sz; i++) {
73 if (CLine * pLine = m_LineArray.GetAt(i)) { 73 if (CLine * pLine = m_LineArray.GetAt(i)) {
74 pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1); 74 pLine->LinePlace = CPVT_WordPlace(SecPlace.nSecIndex, i, -1);
75 } 75 }
76 } 76 }
77 } 77 }
78 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace & place, const CPVT_WordIn fo & wordinfo) 78 CPVT_WordPlace CSection::AddWord(const CPVT_WordPlace & place, const CPVT_WordIn fo & wordinfo)
79 { 79 {
80 CPVT_WordInfo * pWord = new CPVT_WordInfo(wordinfo); 80 CPVT_WordInfo * pWord = new CPVT_WordInfo(wordinfo);
81 FX_INT32 nWordIndex = FPDF_MAX(FPDF_MIN(place.nWordIndex, this->m_WordArray. GetSize()), 0); 81 int32_t nWordIndex = FPDF_MAX(FPDF_MIN(place.nWordIndex, this->m_WordArray.G etSize()), 0);
82 if (nWordIndex == m_WordArray.GetSize()) { 82 if (nWordIndex == m_WordArray.GetSize()) {
83 m_WordArray.Add(pWord); 83 m_WordArray.Add(pWord);
84 } else { 84 } else {
85 m_WordArray.InsertAt(nWordIndex, pWord); 85 m_WordArray.InsertAt(nWordIndex, pWord);
86 } 86 }
87 return place; 87 return place;
88 } 88 }
89 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo & lineinfo) 89 CPVT_WordPlace CSection::AddLine(const CPVT_LineInfo & lineinfo)
90 { 90 {
91 return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1); 91 return CPVT_WordPlace(SecPlace.nSecIndex, m_LineArray.Add(lineinfo), -1);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 return pNextLine->GetBeginWordPlace(); 154 return pNextLine->GetBeginWordPlace();
155 } 155 }
156 } else { 156 } else {
157 return pLine->GetNextWordPlace(place); 157 return pLine->GetNextWordPlace(place);
158 } 158 }
159 } 159 }
160 return place; 160 return place;
161 } 161 }
162 void CSection::UpdateWordPlace(CPVT_WordPlace & place) const 162 void CSection::UpdateWordPlace(CPVT_WordPlace & place) const
163 { 163 {
164 FX_INT32 nLeft = 0; 164 int32_t nLeft = 0;
165 FX_INT32 nRight = m_LineArray.GetSize() - 1; 165 int32_t nRight = m_LineArray.GetSize() - 1;
166 FX_INT32 nMid = (nLeft + nRight) / 2; 166 int32_t nMid = (nLeft + nRight) / 2;
167 while (nLeft <= nRight) { 167 while (nLeft <= nRight) {
168 if (CLine * pLine = m_LineArray.GetAt(nMid)) { 168 if (CLine * pLine = m_LineArray.GetAt(nMid)) {
169 if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) { 169 if (place.nWordIndex < pLine->m_LineInfo.nBeginWordIndex) {
170 nRight = nMid - 1; 170 nRight = nMid - 1;
171 nMid = (nLeft + nRight) / 2; 171 nMid = (nLeft + nRight) / 2;
172 } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) { 172 } else if (place.nWordIndex > pLine->m_LineInfo.nEndWordIndex) {
173 nLeft = nMid + 1; 173 nLeft = nMid + 1;
174 nMid = (nLeft + nRight) / 2; 174 nMid = (nLeft + nRight) / 2;
175 } else { 175 } else {
176 place.nLineIndex = nMid; 176 place.nLineIndex = nMid;
177 return; 177 return;
178 } 178 }
179 } else { 179 } else {
180 break; 180 break;
181 } 181 }
182 } 182 }
183 } 183 }
184 CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point & point) const 184 CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point & point) const
185 { 185 {
186 ASSERT(m_pVT != NULL); 186 ASSERT(m_pVT != NULL);
187 CPVT_WordPlace place = GetBeginWordPlace(); 187 CPVT_WordPlace place = GetBeginWordPlace();
188 FX_BOOL bUp = TRUE; 188 FX_BOOL bUp = TRUE;
189 FX_BOOL bDown = TRUE; 189 FX_BOOL bDown = TRUE;
190 FX_INT32 nLeft = 0; 190 int32_t nLeft = 0;
191 FX_INT32 nRight = m_LineArray.GetSize() - 1; 191 int32_t nRight = m_LineArray.GetSize() - 1;
192 FX_INT32 nMid = m_LineArray.GetSize() / 2; 192 int32_t nMid = m_LineArray.GetSize() / 2;
193 FX_FLOAT fTop = 0; 193 FX_FLOAT fTop = 0;
194 FX_FLOAT fBottom = 0; 194 FX_FLOAT fBottom = 0;
195 while (nLeft <= nRight) { 195 while (nLeft <= nRight) {
196 if (CLine * pLine = m_LineArray.GetAt(nMid)) { 196 if (CLine * pLine = m_LineArray.GetAt(nMid)) {
197 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_ pVT->GetLineLeading(m_SecInfo); 197 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_ pVT->GetLineLeading(m_SecInfo);
198 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent; 198 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
199 if (IsFloatBigger(point.y, fTop)) { 199 if (IsFloatBigger(point.y, fTop)) {
200 bUp = FALSE; 200 bUp = FALSE;
201 } 201 }
202 if (IsFloatSmaller(point.y, fBottom)) { 202 if (IsFloatSmaller(point.y, fBottom)) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 } 235 }
236 return GetBeginWordPlace(); 236 return GetBeginWordPlace();
237 } 237 }
238 CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx, const CPVT_WordRange & ran ge) const 238 CPVT_WordPlace CSection::SearchWordPlace(FX_FLOAT fx, const CPVT_WordRange & ran ge) const
239 { 239 {
240 CPVT_WordPlace wordplace = range.BeginPos; 240 CPVT_WordPlace wordplace = range.BeginPos;
241 wordplace.nWordIndex = -1; 241 wordplace.nWordIndex = -1;
242 if (!m_pVT) { 242 if (!m_pVT) {
243 return wordplace; 243 return wordplace;
244 } 244 }
245 FX_INT32 nLeft = range.BeginPos.nWordIndex; 245 int32_t nLeft = range.BeginPos.nWordIndex;
246 FX_INT32 nRight = range.EndPos.nWordIndex + 1; 246 int32_t nRight = range.EndPos.nWordIndex + 1;
247 FX_INT32 nMid = (nLeft + nRight) / 2; 247 int32_t nMid = (nLeft + nRight) / 2;
248 while (nLeft < nRight) { 248 while (nLeft < nRight) {
249 if (nMid == nLeft) { 249 if (nMid == nLeft) {
250 break; 250 break;
251 } 251 }
252 if (nMid == nRight) { 252 if (nMid == nRight) {
253 nMid--; 253 nMid--;
254 break; 254 break;
255 } 255 }
256 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) { 256 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) {
257 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) { 257 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) {
258 nLeft = nMid; 258 nLeft = nMid;
259 nMid = (nLeft + nRight) / 2; 259 nMid = (nLeft + nRight) / 2;
260 continue; 260 continue;
261 } else { 261 } else {
262 nRight = nMid; 262 nRight = nMid;
263 nMid = (nLeft + nRight) / 2; 263 nMid = (nLeft + nRight) / 2;
264 continue; 264 continue;
265 } 265 }
266 } else { 266 } else {
267 break; 267 break;
268 } 268 }
269 } 269 }
270 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) { 270 if (CPVT_WordInfo * pWord = m_WordArray.GetAt(nMid)) {
271 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) { 271 if (fx > pWord->fWordX + m_pVT->GetWordWidth(*pWord) * PVT_HALF) {
272 wordplace.nWordIndex = nMid; 272 wordplace.nWordIndex = nMid;
273 } 273 }
274 } 274 }
275 return wordplace; 275 return wordplace;
276 } 276 }
277 void CSection::ClearLeftWords(FX_INT32 nWordIndex) 277 void CSection::ClearLeftWords(int32_t nWordIndex)
278 { 278 {
279 for (FX_INT32 i = nWordIndex; i >= 0; i--) { 279 for (int32_t i = nWordIndex; i >= 0; i--) {
280 delete m_WordArray.GetAt(i); 280 delete m_WordArray.GetAt(i);
281 m_WordArray.RemoveAt(i); 281 m_WordArray.RemoveAt(i);
282 } 282 }
283 } 283 }
284 void CSection::ClearRightWords(FX_INT32 nWordIndex) 284 void CSection::ClearRightWords(int32_t nWordIndex)
285 { 285 {
286 for (FX_INT32 i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) { 286 for (int32_t i = m_WordArray.GetSize() - 1; i > nWordIndex; i--) {
287 delete m_WordArray.GetAt(i); 287 delete m_WordArray.GetAt(i);
288 m_WordArray.RemoveAt(i); 288 m_WordArray.RemoveAt(i);
289 } 289 }
290 } 290 }
291 void CSection::ClearMidWords(FX_INT32 nBeginIndex, FX_INT32 nEndIndex) 291 void CSection::ClearMidWords(int32_t nBeginIndex, int32_t nEndIndex)
292 { 292 {
293 for (FX_INT32 i = nEndIndex; i > nBeginIndex; i--) { 293 for (int32_t i = nEndIndex; i > nBeginIndex; i--) {
294 delete m_WordArray.GetAt(i); 294 delete m_WordArray.GetAt(i);
295 m_WordArray.RemoveAt(i); 295 m_WordArray.RemoveAt(i);
296 } 296 }
297 } 297 }
298 void CSection::ClearWords(const CPVT_WordRange & PlaceRange) 298 void CSection::ClearWords(const CPVT_WordRange & PlaceRange)
299 { 299 {
300 CPVT_WordPlace SecBeginPos = GetBeginWordPlace(); 300 CPVT_WordPlace SecBeginPos = GetBeginWordPlace();
301 CPVT_WordPlace SecEndPos = GetEndWordPlace(); 301 CPVT_WordPlace SecEndPos = GetEndWordPlace();
302 if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) { 302 if (PlaceRange.BeginPos.WordCmp(SecBeginPos) >= 0) {
303 if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) { 303 if (PlaceRange.EndPos.WordCmp(SecEndPos) <= 0) {
(...skipping 20 matching lines...) Expand all
324 } 324 }
325 CPVT_FloatRect CTypeset::CharArray() 325 CPVT_FloatRect CTypeset::CharArray()
326 { 326 {
327 ASSERT(m_pSection != NULL); 327 ASSERT(m_pSection != NULL);
328 ASSERT(m_pVT != NULL); 328 ASSERT(m_pVT != NULL);
329 FX_FLOAT fLineAscent = m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_ pVT->GetFontSize()); 329 FX_FLOAT fLineAscent = m_pVT->GetFontAscent(m_pVT->GetDefaultFontIndex(), m_ pVT->GetFontSize());
330 FX_FLOAT fLineDescent = m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize()); 330 FX_FLOAT fLineDescent = m_pVT->GetFontDescent(m_pVT->GetDefaultFontIndex(), m_pVT->GetFontSize());
331 m_rcRet.Default(); 331 m_rcRet.Default();
332 FX_FLOAT x = 0.0f, y = 0.0f; 332 FX_FLOAT x = 0.0f, y = 0.0f;
333 FX_FLOAT fNextWidth; 333 FX_FLOAT fNextWidth;
334 FX_INT32 nStart = 0; 334 int32_t nStart = 0;
335 FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() / (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray); 335 FX_FLOAT fNodeWidth = m_pVT->GetPlateWidth() / (m_pVT->m_nCharArray <= 0 ? 1 : m_pVT->m_nCharArray);
336 if (CLine * pLine = m_pSection->m_LineArray.GetAt(0)) { 336 if (CLine * pLine = m_pSection->m_LineArray.GetAt(0)) {
337 x = 0.0f; 337 x = 0.0f;
338 y += m_pVT->GetLineLeading(m_pSection->m_SecInfo); 338 y += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
339 y += fLineAscent; 339 y += fLineAscent;
340 nStart = 0; 340 nStart = 0;
341 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { 341 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
342 case 0: 342 case 0:
343 pLine->m_LineInfo.fLineX = fNodeWidth * PVT_HALF; 343 pLine->m_LineInfo.fLineX = fNodeWidth * PVT_HALF;
344 break; 344 break;
345 case 1: 345 case 1:
346 nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize( )) / 2; 346 nStart = (m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize( )) / 2;
347 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF; 347 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF;
348 break; 348 break;
349 case 2: 349 case 2:
350 nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize() ; 350 nStart = m_pVT->m_nCharArray - m_pSection->m_WordArray.GetSize() ;
351 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF; 351 pLine->m_LineInfo.fLineX = fNodeWidth * nStart - fNodeWidth * PV T_HALF;
352 break; 352 break;
353 } 353 }
354 for (FX_INT32 w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++ ) { 354 for (int32_t w = 0, sz = m_pSection->m_WordArray.GetSize(); w < sz; w++) {
355 if (w >= m_pVT->m_nCharArray) { 355 if (w >= m_pVT->m_nCharArray) {
356 break; 356 break;
357 } 357 }
358 fNextWidth = 0; 358 fNextWidth = 0;
359 if (CPVT_WordInfo * pNextWord = (CPVT_WordInfo *)m_pSection->m_WordA rray.GetAt(w + 1)) { 359 if (CPVT_WordInfo * pNextWord = (CPVT_WordInfo *)m_pSection->m_WordA rray.GetAt(w + 1)) {
360 pNextWord->fWordTail = 0; 360 pNextWord->fWordTail = 0;
361 fNextWidth = m_pVT->GetWordWidth(*pNextWord); 361 fNextWidth = m_pVT->GetWordWidth(*pNextWord);
362 } 362 }
363 if (CPVT_WordInfo * pWord = (CPVT_WordInfo *)m_pSection->m_WordArray .GetAt(w)) { 363 if (CPVT_WordInfo * pWord = (CPVT_WordInfo *)m_pSection->m_WordArray .GetAt(w)) {
364 pWord->fWordTail = 0; 364 pWord->fWordTail = 0;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 return TRUE; 583 return TRUE;
584 } else if (IsCJK(prevWord)) { 584 } else if (IsCJK(prevWord)) {
585 return TRUE; 585 return TRUE;
586 } 586 }
587 return FALSE; 587 return FALSE;
588 } 588 }
589 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) 589 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize)
590 { 590 {
591 ASSERT(m_pVT != NULL); 591 ASSERT(m_pVT != NULL);
592 ASSERT(m_pSection != NULL); 592 ASSERT(m_pSection != NULL);
593 FX_INT32 nLineHead = 0; 593 int32_t nLineHead = 0;
594 FX_INT32 nLineTail = 0; 594 int32_t nLineTail = 0;
595 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; 595 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f;
596 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f; 596 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f;
597 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f; 597 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f;
598 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f; 598 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f;
599 FX_INT32 nWordStartPos = 0; 599 int32_t nWordStartPos = 0;
600 FX_BOOL bFullWord = FALSE; 600 FX_BOOL bFullWord = FALSE;
601 FX_INT32 nLineFullWordIndex = 0; 601 int32_t nLineFullWordIndex = 0;
602 FX_INT32 nCharIndex = 0; 602 int32_t nCharIndex = 0;
603 CPVT_LineInfo line; 603 CPVT_LineInfo line;
604 FX_FLOAT fWordWidth = 0; 604 FX_FLOAT fWordWidth = 0;
605 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - m_pVT->GetLineInd ent(m_pSection->m_SecInfo), 0.0f); 605 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - m_pVT->GetLineInd ent(m_pSection->m_SecInfo), 0.0f);
606 FX_INT32 nTotalWords = m_pSection->m_WordArray.GetSize(); 606 int32_t nTotalWords = m_pSection->m_WordArray.GetSize();
607 FX_BOOL bOpened = FALSE; 607 FX_BOOL bOpened = FALSE;
608 if (nTotalWords > 0) { 608 if (nTotalWords > 0) {
609 FX_INT32 i = 0; 609 int32_t i = 0;
610 while (i < nTotalWords) { 610 while (i < nTotalWords) {
611 CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(i); 611 CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(i);
612 CPVT_WordInfo* pOldWord = pWord; 612 CPVT_WordInfo* pOldWord = pWord;
613 if (i > 0) { 613 if (i > 0) {
614 pOldWord = m_pSection->m_WordArray.GetAt(i - 1); 614 pOldWord = m_pSection->m_WordArray.GetAt(i - 1);
615 } 615 }
616 if (pWord) { 616 if (pWord) {
617 if (bTypeset) { 617 if (bTypeset) {
618 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, TRUE)); 618 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, TRUE));
619 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, TRUE)); 619 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, TRUE));
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 case 1: 745 case 1:
746 fMinX = (fTypesetWidth - m_rcRet.Width()) * PVT_HALF; 746 fMinX = (fTypesetWidth - m_rcRet.Width()) * PVT_HALF;
747 break; 747 break;
748 case 2: 748 case 2:
749 fMinX = fTypesetWidth - m_rcRet.Width(); 749 fMinX = fTypesetWidth - m_rcRet.Width();
750 break; 750 break;
751 } 751 }
752 fMaxX = fMinX + m_rcRet.Width(); 752 fMaxX = fMinX + m_rcRet.Width();
753 fMinY = 0.0f; 753 fMinY = 0.0f;
754 fMaxY = m_rcRet.Height(); 754 fMaxY = m_rcRet.Height();
755 FX_INT32 nTotalLines = m_pSection->m_LineArray.GetSize(); 755 int32_t nTotalLines = m_pSection->m_LineArray.GetSize();
756 if (nTotalLines > 0) { 756 if (nTotalLines > 0) {
757 m_pSection->m_SecInfo.nTotalLine = nTotalLines; 757 m_pSection->m_SecInfo.nTotalLine = nTotalLines;
758 for (FX_INT32 l = 0; l < nTotalLines; l++) { 758 for (int32_t l = 0; l < nTotalLines; l++) {
759 if (CLine * pLine = m_pSection->m_LineArray.GetAt(l)) { 759 if (CLine * pLine = m_pSection->m_LineArray.GetAt(l)) {
760 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) { 760 switch (m_pVT->GetAlignment(m_pSection->m_SecInfo)) {
761 default: 761 default:
762 case 0: 762 case 0:
763 fPosX = 0; 763 fPosX = 0;
764 break; 764 break;
765 case 1: 765 case 1:
766 fPosX = (fTypesetWidth - pLine->m_LineInfo.fLineWidth) * PVT_HALF; 766 fPosX = (fTypesetWidth - pLine->m_LineInfo.fLineWidth) * PVT_HALF;
767 break; 767 break;
768 case 2: 768 case 2:
769 fPosX = fTypesetWidth - pLine->m_LineInfo.fLineWidth; 769 fPosX = fTypesetWidth - pLine->m_LineInfo.fLineWidth;
770 break; 770 break;
771 } 771 }
772 fPosX += fLineIndent; 772 fPosX += fLineIndent;
773 fPosY += m_pVT->GetLineLeading(m_pSection->m_SecInfo); 773 fPosY += m_pVT->GetLineLeading(m_pSection->m_SecInfo);
774 fPosY += pLine->m_LineInfo.fLineAscent; 774 fPosY += pLine->m_LineInfo.fLineAscent;
775 pLine->m_LineInfo.fLineX = fPosX - fMinX; 775 pLine->m_LineInfo.fLineX = fPosX - fMinX;
776 pLine->m_LineInfo.fLineY = fPosY - fMinY; 776 pLine->m_LineInfo.fLineY = fPosY - fMinY;
777 for (FX_INT32 w = pLine->m_LineInfo.nBeginWordIndex; w <= pLine- >m_LineInfo.nEndWordIndex; w++) { 777 for (int32_t w = pLine->m_LineInfo.nBeginWordIndex; w <= pLine-> m_LineInfo.nEndWordIndex; w++) {
778 if (CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(w) ) { 778 if (CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(w) ) {
779 pWord->fWordX = fPosX - fMinX; 779 pWord->fWordX = fPosX - fMinX;
780 if (pWord->pWordProps) { 780 if (pWord->pWordProps) {
781 switch (pWord->pWordProps->nScriptType) { 781 switch (pWord->pWordProps->nScriptType) {
782 default: 782 default:
783 case PVTWORD_SCRIPT_NORMAL: 783 case PVTWORD_SCRIPT_NORMAL:
784 pWord->fWordY = fPosY - fMinY; 784 pWord->fWordY = fPosY - fMinY;
785 break; 785 break;
786 case PVTWORD_SCRIPT_SUPER: 786 case PVTWORD_SCRIPT_SUPER:
787 pWord->fWordY = fPosY - m_pVT->GetWordAscent (*pWord) - fMinY; 787 pWord->fWordY = fPosY - m_pVT->GetWordAscent (*pWord) - fMinY;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 pSection->ResetLinePlace(); 847 pSection->ResetLinePlace();
848 } 848 }
849 m_bInitial = TRUE; 849 m_bInitial = TRUE;
850 } 850 }
851 } 851 }
852 void CPDF_VariableText::ResetAll() 852 void CPDF_VariableText::ResetAll()
853 { 853 {
854 m_bInitial = FALSE; 854 m_bInitial = FALSE;
855 ResetSectionArray(); 855 ResetSectionArray();
856 } 856 }
857 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO RD word, FX_INT32 charset, 857 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO RD word, int32_t charset,
858 const CPVT_WordProps * pWordProps) 858 const CPVT_WordProps * pWordProps)
859 { 859 {
860 FX_INT32 nTotlaWords = this->GetTotalWords(); 860 int32_t nTotlaWords = this->GetTotalWords();
861 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { 861 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) {
862 return place; 862 return place;
863 } 863 }
864 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { 864 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) {
865 return place; 865 return place;
866 } 866 }
867 CPVT_WordPlace newplace = place; 867 CPVT_WordPlace newplace = place;
868 newplace.nWordIndex ++; 868 newplace.nWordIndex ++;
869 if (m_bRichText) { 869 if (m_bRichText) {
870 CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps ) : new CPVT_WordProps(); 870 CPVT_WordProps * pNewProps = pWordProps ? new CPVT_WordProps(*pWordProps ) : new CPVT_WordProps();
871 pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFon tIndex); 871 pNewProps->nFontIndex = GetWordFontIndex(word, charset, pWordProps->nFon tIndex);
872 return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps)); 872 return AddWord(newplace, CPVT_WordInfo(word, charset, -1, pNewProps));
873 } else { 873 } else {
874 FX_INT32 nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWord FontIndex(word, charset, GetDefaultFontIndex()); 874 int32_t nFontIndex = GetSubWord() > 0 ? GetDefaultFontIndex() : GetWordF ontIndex(word, charset, GetDefaultFontIndex());
875 return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)) ; 875 return AddWord(newplace, CPVT_WordInfo(word, charset, nFontIndex, NULL)) ;
876 } 876 }
877 return place; 877 return place;
878 } 878 }
879 CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, co nst CPVT_SecProps * pSecProps, 879 CPVT_WordPlace CPDF_VariableText::InsertSection(const CPVT_WordPlace & place, co nst CPVT_SecProps * pSecProps,
880 const CPVT_WordProps * pWordProps) 880 const CPVT_WordProps * pWordProps)
881 { 881 {
882 FX_INT32 nTotlaWords = this->GetTotalWords(); 882 int32_t nTotlaWords = this->GetTotalWords();
883 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { 883 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) {
884 return place; 884 return place;
885 } 885 }
886 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { 886 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) {
887 return place; 887 return place;
888 } 888 }
889 if (!m_bMultiLine) { 889 if (!m_bMultiLine) {
890 return place; 890 return place;
891 } 891 }
892 CPVT_WordPlace wordplace = place; 892 CPVT_WordPlace wordplace = place;
893 UpdateWordPlace(wordplace); 893 UpdateWordPlace(wordplace);
894 CPVT_WordPlace newplace = place; 894 CPVT_WordPlace newplace = place;
895 if (CSection * pSection = m_SectionArray.GetAt(wordplace.nSecIndex)) { 895 if (CSection * pSection = m_SectionArray.GetAt(wordplace.nSecIndex)) {
896 CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1); 896 CPVT_WordPlace NewPlace(wordplace.nSecIndex + 1, 0, -1);
897 CPVT_SectionInfo secinfo; 897 CPVT_SectionInfo secinfo;
898 if (m_bRichText) { 898 if (m_bRichText) {
899 if (pSecProps) { 899 if (pSecProps) {
900 secinfo.pSecProps = new CPVT_SecProps(*pSecProps); 900 secinfo.pSecProps = new CPVT_SecProps(*pSecProps);
901 } 901 }
902 if (pWordProps) { 902 if (pWordProps) {
903 secinfo.pWordProps = new CPVT_WordProps(*pWordProps); 903 secinfo.pWordProps = new CPVT_WordProps(*pWordProps);
904 } 904 }
905 } 905 }
906 AddSection(NewPlace, secinfo); 906 AddSection(NewPlace, secinfo);
907 newplace = NewPlace; 907 newplace = NewPlace;
908 if (CSection * pNewSection = m_SectionArray.GetAt(NewPlace.nSecIndex)) { 908 if (CSection * pNewSection = m_SectionArray.GetAt(NewPlace.nSecIndex)) {
909 for (FX_INT32 w = wordplace.nWordIndex + 1, sz = pSection->m_WordArr ay.GetSize(); w < sz; w++) { 909 for (int32_t w = wordplace.nWordIndex + 1, sz = pSection->m_WordArra y.GetSize(); w < sz; w++) {
910 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(w)) { 910 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(w)) {
911 NewPlace.nWordIndex++; 911 NewPlace.nWordIndex++;
912 pNewSection->AddWord(NewPlace, *pWord); 912 pNewSection->AddWord(NewPlace, *pWord);
913 } 913 }
914 } 914 }
915 } 915 }
916 ClearSectionRightWords(wordplace); 916 ClearSectionRightWords(wordplace);
917 } 917 }
918 return newplace; 918 return newplace;
919 } 919 }
920 CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace & place, FX_LP CWSTR text, FX_INT32 charset, 920 CPVT_WordPlace CPDF_VariableText::InsertText(const CPVT_WordPlace & place, FX_LP CWSTR text, int32_t charset,
921 const CPVT_SecProps * pSecProps, const CPVT_WordProps * pProps) 921 const CPVT_SecProps * pSecProps, const CPVT_WordProps * pProps)
922 { 922 {
923 CFX_WideString swText = text; 923 CFX_WideString swText = text;
924 CPVT_WordPlace wp = place; 924 CPVT_WordPlace wp = place;
925 for (FX_INT32 i = 0, sz = swText.GetLength(); i < sz; i++) { 925 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
926 CPVT_WordPlace oldwp = wp; 926 CPVT_WordPlace oldwp = wp;
927 FX_WORD word = swText.GetAt(i); 927 FX_WORD word = swText.GetAt(i);
928 switch (word) { 928 switch (word) {
929 case 0x0D: 929 case 0x0D:
930 if (m_bMultiLine) { 930 if (m_bMultiLine) {
931 if (swText.GetAt(i + 1) == 0x0A) { 931 if (swText.GetAt(i + 1) == 0x0A) {
932 i += 1; 932 i += 1;
933 } 933 }
934 wp = InsertSection(wp, pSecProps, pProps); 934 wp = InsertSection(wp, pSecProps, pProps);
935 } 935 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 return PlaceRange.BeginPos; 970 return PlaceRange.BeginPos;
971 } 971 }
972 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace & place) 972 CPVT_WordPlace CPDF_VariableText::DeleteWord(const CPVT_WordPlace & place)
973 { 973 {
974 return ClearRightWord(AjustLineHeader(place, TRUE)); 974 return ClearRightWord(AjustLineHeader(place, TRUE));
975 } 975 }
976 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace & place) 976 CPVT_WordPlace CPDF_VariableText::BackSpaceWord(const CPVT_WordPlace & place)
977 { 977 {
978 return ClearLeftWord(AjustLineHeader(place, TRUE)); 978 return ClearLeftWord(AjustLineHeader(place, TRUE));
979 } 979 }
980 void CPDF_VariableText::SetText(FX_LPCWSTR text, FX_INT32 charset, const CPVT_Se cProps * pSecProps, 980 void CPDF_VariableText::SetText(FX_LPCWSTR text, int32_t charset, const CPVT_Sec Props * pSecProps,
981 const CPVT_WordProps * pWordProps) 981 const CPVT_WordProps * pWordProps)
982 { 982 {
983 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace())); 983 DeleteWords(CPVT_WordRange(GetBeginWordPlace(), GetEndWordPlace()));
984 CFX_WideString swText = text; 984 CFX_WideString swText = text;
985 CPVT_WordPlace wp(0, 0, -1); 985 CPVT_WordPlace wp(0, 0, -1);
986 CPVT_SectionInfo secinfo; 986 CPVT_SectionInfo secinfo;
987 if (m_bRichText) { 987 if (m_bRichText) {
988 if (pSecProps) { 988 if (pSecProps) {
989 secinfo.pSecProps = new CPVT_SecProps(*pSecProps); 989 secinfo.pSecProps = new CPVT_SecProps(*pSecProps);
990 } 990 }
991 if (pWordProps) { 991 if (pWordProps) {
992 secinfo.pWordProps = new CPVT_WordProps(*pWordProps); 992 secinfo.pWordProps = new CPVT_WordProps(*pWordProps);
993 } 993 }
994 } 994 }
995 if (CSection * pSection = m_SectionArray.GetAt(0)) { 995 if (CSection * pSection = m_SectionArray.GetAt(0)) {
996 pSection->m_SecInfo = secinfo; 996 pSection->m_SecInfo = secinfo;
997 } 997 }
998 FX_INT32 nCharCount = 0; 998 int32_t nCharCount = 0;
999 for (FX_INT32 i = 0, sz = swText.GetLength(); i < sz; i++) { 999 for (int32_t i = 0, sz = swText.GetLength(); i < sz; i++) {
1000 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) { 1000 if (m_nLimitChar > 0 && nCharCount >= m_nLimitChar) {
1001 break; 1001 break;
1002 } 1002 }
1003 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) { 1003 if (m_nCharArray > 0 && nCharCount >= m_nCharArray) {
1004 break; 1004 break;
1005 } 1005 }
1006 FX_WORD word = swText.GetAt(i); 1006 FX_WORD word = swText.GetAt(i);
1007 switch (word) { 1007 switch (word) {
1008 case 0x0D: 1008 case 0x0D:
1009 if (m_bMultiLine) { 1009 if (m_bMultiLine) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 place = GetBeginWordPlace(); 1042 place = GetBeginWordPlace();
1043 } 1043 }
1044 if (place.nSecIndex >= m_SectionArray.GetSize()) { 1044 if (place.nSecIndex >= m_SectionArray.GetSize()) {
1045 place = GetEndWordPlace(); 1045 place = GetEndWordPlace();
1046 } 1046 }
1047 place = AjustLineHeader(place, TRUE); 1047 place = AjustLineHeader(place, TRUE);
1048 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1048 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1049 pSection->UpdateWordPlace(place); 1049 pSection->UpdateWordPlace(place);
1050 } 1050 }
1051 } 1051 }
1052 FX_INT32 CPDF_VariableText::WordPlaceToWordIndex(const CPVT_WordPlace & place) c onst 1052 int32_t CPDF_VariableText::WordPlaceToWordIndex(const CPVT_WordPlace & place) co nst
1053 { 1053 {
1054 CPVT_WordPlace newplace = place; 1054 CPVT_WordPlace newplace = place;
1055 UpdateWordPlace(newplace); 1055 UpdateWordPlace(newplace);
1056 FX_INT32 nIndex = 0; 1056 int32_t nIndex = 0;
1057 FX_INT32 i = 0; 1057 int32_t i = 0;
1058 FX_INT32 sz = 0; 1058 int32_t sz = 0;
1059 for (i = 0, sz = m_SectionArray.GetSize(); i < sz && i < newplace.nSecIndex; i++) { 1059 for (i = 0, sz = m_SectionArray.GetSize(); i < sz && i < newplace.nSecIndex; i++) {
1060 if (CSection * pSection = m_SectionArray.GetAt(i)) { 1060 if (CSection * pSection = m_SectionArray.GetAt(i)) {
1061 nIndex += pSection->m_WordArray.GetSize(); 1061 nIndex += pSection->m_WordArray.GetSize();
1062 if (i != m_SectionArray.GetSize() - 1) { 1062 if (i != m_SectionArray.GetSize() - 1) {
1063 nIndex += PVT_RETURN_LENGTH; 1063 nIndex += PVT_RETURN_LENGTH;
1064 } 1064 }
1065 } 1065 }
1066 } 1066 }
1067 if (i >= 0 && i < m_SectionArray.GetSize()) { 1067 if (i >= 0 && i < m_SectionArray.GetSize()) {
1068 nIndex += newplace.nWordIndex + PVT_RETURN_LENGTH; 1068 nIndex += newplace.nWordIndex + PVT_RETURN_LENGTH;
1069 } 1069 }
1070 return nIndex; 1070 return nIndex;
1071 } 1071 }
1072 CPVT_WordPlace CPDF_VariableText::WordIndexToWordPlace(FX_INT32 index) const 1072 CPVT_WordPlace CPDF_VariableText::WordIndexToWordPlace(int32_t index) const
1073 { 1073 {
1074 CPVT_WordPlace place = GetBeginWordPlace(); 1074 CPVT_WordPlace place = GetBeginWordPlace();
1075 FX_INT32 nOldIndex = 0 , nIndex = 0; 1075 int32_t nOldIndex = 0 , nIndex = 0;
1076 FX_BOOL bFind = FALSE; 1076 FX_BOOL bFind = FALSE;
1077 for (FX_INT32 i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) { 1077 for (int32_t i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) {
1078 if (CSection * pSection = m_SectionArray.GetAt(i)) { 1078 if (CSection * pSection = m_SectionArray.GetAt(i)) {
1079 nIndex += pSection->m_WordArray.GetSize(); 1079 nIndex += pSection->m_WordArray.GetSize();
1080 if (nIndex == index) { 1080 if (nIndex == index) {
1081 place = pSection->GetEndWordPlace(); 1081 place = pSection->GetEndWordPlace();
1082 bFind = TRUE; 1082 bFind = TRUE;
1083 break; 1083 break;
1084 } else if (nIndex > index) { 1084 } else if (nIndex > index) {
1085 place.nSecIndex = i; 1085 place.nSecIndex = i;
1086 place.nWordIndex = index - nOldIndex - 1; 1086 place.nWordIndex = index - nOldIndex - 1;
1087 pSection->UpdateWordPlace(place); 1087 pSection->UpdateWordPlace(place);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 } else { 1149 } else {
1150 return pSection->GetNextWordPlace(place); 1150 return pSection->GetNextWordPlace(place);
1151 } 1151 }
1152 } 1152 }
1153 return place; 1153 return place;
1154 } 1154 }
1155 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons t 1155 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons t
1156 { 1156 {
1157 CPDF_Point pt = OutToIn(point); 1157 CPDF_Point pt = OutToIn(point);
1158 CPVT_WordPlace place = GetBeginWordPlace(); 1158 CPVT_WordPlace place = GetBeginWordPlace();
1159 FX_INT32 nLeft = 0; 1159 int32_t nLeft = 0;
1160 FX_INT32 nRight = m_SectionArray.GetSize() - 1; 1160 int32_t nRight = m_SectionArray.GetSize() - 1;
1161 FX_INT32 nMid = m_SectionArray.GetSize() / 2; 1161 int32_t nMid = m_SectionArray.GetSize() / 2;
1162 FX_BOOL bUp = TRUE; 1162 FX_BOOL bUp = TRUE;
1163 FX_BOOL bDown = TRUE; 1163 FX_BOOL bDown = TRUE;
1164 while (nLeft <= nRight) { 1164 while (nLeft <= nRight) {
1165 if (CSection * pSection = m_SectionArray.GetAt(nMid)) { 1165 if (CSection * pSection = m_SectionArray.GetAt(nMid)) {
1166 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) { 1166 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) {
1167 bUp = FALSE; 1167 bUp = FALSE;
1168 } 1168 }
1169 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) { 1169 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) {
1170 bDown = FALSE; 1170 bDown = FALSE;
1171 } 1171 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 { 1248 {
1249 return CPVT_WordPlace(place.nSecIndex, 0, -1); 1249 return CPVT_WordPlace(place.nSecIndex, 0, -1);
1250 } 1250 }
1251 CPVT_WordPlace CPDF_VariableText::GetSectionEndPlace(const CPVT_WordPlace & plac e) const 1251 CPVT_WordPlace CPDF_VariableText::GetSectionEndPlace(const CPVT_WordPlace & plac e) const
1252 { 1252 {
1253 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1253 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1254 return pSection->GetEndWordPlace(); 1254 return pSection->GetEndWordPlace();
1255 } 1255 }
1256 return place; 1256 return place;
1257 } 1257 }
1258 FX_INT32 CPDF_VariableText::GetTotalWords() const 1258 int32_t CPDF_VariableText::GetTotalWords() const
1259 { 1259 {
1260 FX_INT32 nTotal = 0; 1260 int32_t nTotal = 0;
1261 for (FX_INT32 i = 0, sz = m_SectionArray.GetSize(); i < sz; i++) 1261 for (int32_t i = 0, sz = m_SectionArray.GetSize(); i < sz; i++)
1262 if (CSection * pSection = m_SectionArray.GetAt(i)) { 1262 if (CSection * pSection = m_SectionArray.GetAt(i)) {
1263 nTotal += (pSection->m_WordArray.GetSize() + PVT_RETURN_LENGTH); 1263 nTotal += (pSection->m_WordArray.GetSize() + PVT_RETURN_LENGTH);
1264 } 1264 }
1265 return nTotal - PVT_RETURN_LENGTH; 1265 return nTotal - PVT_RETURN_LENGTH;
1266 } 1266 }
1267 void CPDF_VariableText::ResetSectionArray() 1267 void CPDF_VariableText::ResetSectionArray()
1268 { 1268 {
1269 for (FX_INT32 s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1269 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1270 delete m_SectionArray.GetAt(s); 1270 delete m_SectionArray.GetAt(s);
1271 } 1271 }
1272 m_SectionArray.RemoveAll(); 1272 m_SectionArray.RemoveAll();
1273 } 1273 }
1274 CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo) 1274 CPVT_WordPlace CPDF_VariableText::AddSection(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo)
1275 { 1275 {
1276 if (IsValid() && !m_bMultiLine) { 1276 if (IsValid() && !m_bMultiLine) {
1277 return place; 1277 return place;
1278 } 1278 }
1279 FX_INT32 nSecIndex = FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSi ze()), 0); 1279 int32_t nSecIndex = FPDF_MAX(FPDF_MIN(place.nSecIndex, m_SectionArray.GetSiz e()), 0);
1280 CSection * pSection = new CSection(this); 1280 CSection * pSection = new CSection(this);
1281 pSection->m_SecInfo = secinfo; 1281 pSection->m_SecInfo = secinfo;
1282 pSection->SecPlace.nSecIndex = nSecIndex; 1282 pSection->SecPlace.nSecIndex = nSecIndex;
1283 if (nSecIndex == m_SectionArray.GetSize()) { 1283 if (nSecIndex == m_SectionArray.GetSize()) {
1284 m_SectionArray.Add(pSection); 1284 m_SectionArray.Add(pSection);
1285 } else { 1285 } else {
1286 m_SectionArray.InsertAt(nSecIndex, pSection); 1286 m_SectionArray.InsertAt(nSecIndex, pSection);
1287 } 1287 }
1288 return place; 1288 return place;
1289 } 1289 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1348 return FALSE; 1348 return FALSE;
1349 } 1349 }
1350 CPDF_Rect CPDF_VariableText::GetContentRect() const 1350 CPDF_Rect CPDF_VariableText::GetContentRect() const
1351 { 1351 {
1352 return InToOut(CPDF_EditContainer::GetContentRect()); 1352 return InToOut(CPDF_EditContainer::GetContentRect());
1353 } 1353 }
1354 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_B OOL bFactFontSize) 1354 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_B OOL bFactFontSize)
1355 { 1355 {
1356 return m_bRichText && WordInfo.pWordProps ? (WordInfo.pWordProps->nScriptTyp e == PVTWORD_SCRIPT_NORMAL || bFactFontSize ? WordInfo.pWordProps->fFontSize : W ordInfo.pWordProps->fFontSize * PVT_HALF) : GetFontSize(); 1356 return m_bRichText && WordInfo.pWordProps ? (WordInfo.pWordProps->nScriptTyp e == PVTWORD_SCRIPT_NORMAL || bFactFontSize ? WordInfo.pWordProps->fFontSize : W ordInfo.pWordProps->fFontSize * PVT_HALF) : GetFontSize();
1357 } 1357 }
1358 FX_INT32 CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo & WordInfo) 1358 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo & WordInfo)
1359 { 1359 {
1360 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nFontIndex : WordInfo.nFontIndex; 1360 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nFontIndex : WordInfo.nFontIndex;
1361 } 1361 }
1362 FX_FLOAT CPDF_VariableText::GetWordWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_W ORD SubWord, 1362 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, FX_WORD Word, FX_WO RD SubWord,
1363 FX_FLOAT fCharSpace, FX_INT32 nHorzScale, 1363 FX_FLOAT fCharSpace, int32_t nHorzScale,
1364 FX_FLOAT fFontSize, FX_FLOAT fWordTail, FX_INT32 nWordStyle) 1364 FX_FLOAT fFontSize, FX_FLOAT fWordTail, int32_t nWordStyle)
1365 { 1365 {
1366 return (GetCharWidth(nFontIndex, Word, SubWord, nWordStyle) * fFontSize * PV T_FONTSCALE + fCharSpace) * nHorzScale * PVT_PERCENT + fWordTail; 1366 return (GetCharWidth(nFontIndex, Word, SubWord, nWordStyle) * fFontSize * PV T_FONTSCALE + fCharSpace) * nHorzScale * PVT_PERCENT + fWordTail;
1367 } 1367 }
1368 FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo & WordInfo) 1368 FX_FLOAT CPDF_VariableText::GetWordWidth(const CPVT_WordInfo & WordInfo)
1369 { 1369 {
1370 return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(), GetCharSpace(WordInfo), GetHorzScale(WordInfo), 1370 return GetWordWidth(GetWordFontIndex(WordInfo), WordInfo.Word, GetSubWord(), GetCharSpace(WordInfo), GetHorzScale(WordInfo),
1371 GetWordFontSize(WordInfo), WordInfo.fWordTail, 1371 GetWordFontSize(WordInfo), WordInfo.fWordTail,
1372 WordInfo.pWordProps ? WordInfo.pWordProps->nWordStyle : 0); 1372 WordInfo.pWordProps ? WordInfo.pWordProps->nWordStyle : 0);
1373 } 1373 }
1374 FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo & SecInfo) 1374 FX_FLOAT CPDF_VariableText::GetLineAscent(const CPVT_SectionInfo & SecInfo)
1375 { 1375 {
1376 return m_bRichText && SecInfo.pWordProps ? GetFontAscent(SecInfo.pWordProps- >nFontIndex, SecInfo.pWordProps->fFontSize) : 1376 return m_bRichText && SecInfo.pWordProps ? GetFontAscent(SecInfo.pWordProps- >nFontIndex, SecInfo.pWordProps->fFontSize) :
1377 GetFontAscent(GetDefaultFontIndex(), GetFontSize()); 1377 GetFontAscent(GetDefaultFontIndex(), GetFontSize());
1378 } 1378 }
1379 FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo & SecInfo) 1379 FX_FLOAT CPDF_VariableText::GetLineDescent(const CPVT_SectionInfo & SecInfo)
1380 { 1380 {
1381 return m_bRichText && SecInfo.pWordProps ? GetFontDescent(SecInfo.pWordProps ->nFontIndex, SecInfo.pWordProps->fFontSize) : 1381 return m_bRichText && SecInfo.pWordProps ? GetFontDescent(SecInfo.pWordProps ->nFontIndex, SecInfo.pWordProps->fFontSize) :
1382 GetFontDescent(GetDefaultFontIndex(), GetFontSize()); 1382 GetFontDescent(GetDefaultFontIndex(), GetFontSize());
1383 } 1383 }
1384 FX_FLOAT CPDF_VariableText::GetFontAscent(FX_INT32 nFontIndex, FX_FLOAT fFontSiz e) 1384 FX_FLOAT CPDF_VariableText::GetFontAscent(int32_t nFontIndex, FX_FLOAT fFontSize )
1385 { 1385 {
1386 return (FX_FLOAT)GetTypeAscent(nFontIndex) * fFontSize * PVT_FONTSCALE; 1386 return (FX_FLOAT)GetTypeAscent(nFontIndex) * fFontSize * PVT_FONTSCALE;
1387 } 1387 }
1388 FX_FLOAT CPDF_VariableText::GetFontDescent(FX_INT32 nFontIndex, FX_FLOAT fFontSi ze) 1388 FX_FLOAT CPDF_VariableText::GetFontDescent(int32_t nFontIndex, FX_FLOAT fFontSiz e)
1389 { 1389 {
1390 return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * PVT_FONTSCALE; 1390 return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * PVT_FONTSCALE;
1391 } 1391 }
1392 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLO AT fFontSize) 1392 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLO AT fFontSize)
1393 { 1393 {
1394 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize); 1394 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize);
1395 } 1395 }
1396 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FL OAT fFontSize) 1396 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FL OAT fFontSize)
1397 { 1397 {
1398 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize); 1398 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize);
1399 } 1399 }
1400 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOO L bFactFontSize) 1400 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOO L bFactFontSize)
1401 { 1401 {
1402 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, b FactFontSize)); 1402 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, b FactFontSize));
1403 } 1403 }
1404 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BO OL bFactFontSize) 1404 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BO OL bFactFontSize)
1405 { 1405 {
1406 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, bFactFontSize)); 1406 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, bFactFontSize));
1407 } 1407 }
1408 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo & SecInfo) 1408 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo & SecInfo)
1409 { 1409 {
1410 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineLeading : m_fLineLeading; 1410 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineLeading : m_fLineLeading;
1411 } 1411 }
1412 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo & SecInfo) 1412 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo & SecInfo)
1413 { 1413 {
1414 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineIndent : 0 .0f; 1414 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineIndent : 0 .0f;
1415 } 1415 }
1416 FX_INT32 CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo) 1416 int32_t CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo)
1417 { 1417 {
1418 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->nAlignment : th is->m_nAlignment; 1418 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->nAlignment : th is->m_nAlignment;
1419 } 1419 }
1420 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo & WordInfo) 1420 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo & WordInfo)
1421 { 1421 {
1422 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace : m_fCharSpace; 1422 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace : m_fCharSpace;
1423 } 1423 }
1424 FX_INT32 CPDF_VariableText::GetHorzScale(const CPVT_WordInfo & WordInfo) 1424 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo & WordInfo)
1425 { 1425 {
1426 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale : m_nHorzScale; 1426 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale : m_nHorzScale;
1427 } 1427 }
1428 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place) 1428 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place)
1429 { 1429 {
1430 CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE); 1430 CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE);
1431 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1431 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1432 for (FX_INT32 w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWo rdIndex; w--) { 1432 for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWor dIndex; w--) {
1433 delete pSection->m_WordArray.GetAt(w); 1433 delete pSection->m_WordArray.GetAt(w);
1434 pSection->m_WordArray.RemoveAt(w); 1434 pSection->m_WordArray.RemoveAt(w);
1435 } 1435 }
1436 } 1436 }
1437 } 1437 }
1438 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const 1438 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const
1439 { 1439 {
1440 if (place.nWordIndex < 0 && place.nLineIndex > 0) { 1440 if (place.nWordIndex < 0 && place.nLineIndex > 0) {
1441 if (bPrevOrNext) { 1441 if (bPrevOrNext) {
1442 return GetPrevWordPlace(place); 1442 return GetPrevWordPlace(place);
(...skipping 13 matching lines...) Expand all
1456 delete pSection; 1456 delete pSection;
1457 m_SectionArray.RemoveAt(place.nSecIndex); 1457 m_SectionArray.RemoveAt(place.nSecIndex);
1458 return TRUE; 1458 return TRUE;
1459 } 1459 }
1460 } 1460 }
1461 return FALSE; 1461 return FALSE;
1462 } 1462 }
1463 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange & PlaceRange) 1463 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange & PlaceRange)
1464 { 1464 {
1465 CPVT_WordPlace wordplace; 1465 CPVT_WordPlace wordplace;
1466 for (FX_INT32 s = PlaceRange.EndPos.nSecIndex; s > PlaceRange.BeginPos.nSecI ndex; s--) { 1466 for (int32_t s = PlaceRange.EndPos.nSecIndex; s > PlaceRange.BeginPos.nSecIn dex; s--) {
1467 wordplace.nSecIndex = s; 1467 wordplace.nSecIndex = s;
1468 ClearEmptySection(wordplace); 1468 ClearEmptySection(wordplace);
1469 } 1469 }
1470 } 1470 }
1471 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace & place) 1471 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace & place)
1472 { 1472 {
1473 CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE); 1473 CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE);
1474 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { 1474 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) {
1475 if (CSection * pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { 1475 if (CSection * pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) {
1476 for (FX_INT32 w = 0, sz = pNextSection->m_WordArray.GetSize(); w < s z; w++) { 1476 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz ; w++) {
1477 if (CPVT_WordInfo * pWord = pNextSection->m_WordArray.GetAt(w)) { 1477 if (CPVT_WordInfo * pWord = pNextSection->m_WordArray.GetAt(w)) {
1478 oldplace.nWordIndex ++; 1478 oldplace.nWordIndex ++;
1479 pSection->AddWord(oldplace, *pWord); 1479 pSection->AddWord(oldplace, *pWord);
1480 } 1480 }
1481 } 1481 }
1482 } 1482 }
1483 delete pNextSection; 1483 delete pNextSection;
1484 m_SectionArray.RemoveAt(place.nSecIndex + 1); 1484 m_SectionArray.RemoveAt(place.nSecIndex + 1);
1485 } 1485 }
1486 } 1486 }
1487 void CPDF_VariableText::ClearWords(const CPVT_WordRange & PlaceRange) 1487 void CPDF_VariableText::ClearWords(const CPVT_WordRange & PlaceRange)
1488 { 1488 {
1489 CPVT_WordRange NewRange; 1489 CPVT_WordRange NewRange;
1490 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE); 1490 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE);
1491 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE); 1491 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE);
1492 for (FX_INT32 s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecInde x; s--) { 1492 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex ; s--) {
1493 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1493 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1494 pSection->ClearWords(NewRange); 1494 pSection->ClearWords(NewRange);
1495 } 1495 }
1496 } 1496 }
1497 } 1497 }
1498 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace & place) 1498 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace & place)
1499 { 1499 {
1500 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1500 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1501 CPVT_WordPlace leftplace = this->GetPrevWordPlace(place); 1501 CPVT_WordPlace leftplace = this->GetPrevWordPlace(place);
1502 if (leftplace != place) { 1502 if (leftplace != place) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 rcRet = RearrangeSections(CPVT_WordRange(GetBeginWordPlace(), GetEnd WordPlace())); 1545 rcRet = RearrangeSections(CPVT_WordRange(GetBeginWordPlace(), GetEnd WordPlace()));
1546 } else { 1546 } else {
1547 rcRet = RearrangeSections(PlaceRange); 1547 rcRet = RearrangeSections(PlaceRange);
1548 } 1548 }
1549 } 1549 }
1550 SetContentRect(rcRet); 1550 SetContentRect(rcRet);
1551 return rcRet; 1551 return rcRet;
1552 } 1552 }
1553 FX_FLOAT CPDF_VariableText::GetAutoFontSize() 1553 FX_FLOAT CPDF_VariableText::GetAutoFontSize()
1554 { 1554 {
1555 FX_INT32 nTotal = sizeof(gFontSizeSteps) / sizeof(FX_BYTE); 1555 int32_t nTotal = sizeof(gFontSizeSteps) / sizeof(uint8_t);
1556 if (IsMultiLine()) { 1556 if (IsMultiLine()) {
1557 nTotal /= 4; 1557 nTotal /= 4;
1558 } 1558 }
1559 if (nTotal <= 0) { 1559 if (nTotal <= 0) {
1560 return 0; 1560 return 0;
1561 } 1561 }
1562 if (GetPlateWidth() <= 0) { 1562 if (GetPlateWidth() <= 0) {
1563 return 0; 1563 return 0;
1564 } 1564 }
1565 FX_INT32 nLeft = 0; 1565 int32_t nLeft = 0;
1566 FX_INT32 nRight = nTotal - 1; 1566 int32_t nRight = nTotal - 1;
1567 FX_INT32 nMid = nTotal / 2; 1567 int32_t nMid = nTotal / 2;
1568 while (nLeft <= nRight) { 1568 while (nLeft <= nRight) {
1569 if (IsBigger(gFontSizeSteps[nMid])) { 1569 if (IsBigger(gFontSizeSteps[nMid])) {
1570 nRight = nMid - 1; 1570 nRight = nMid - 1;
1571 nMid = (nLeft + nRight) / 2; 1571 nMid = (nLeft + nRight) / 2;
1572 continue; 1572 continue;
1573 } else { 1573 } else {
1574 nLeft = nMid + 1; 1574 nLeft = nMid + 1;
1575 nMid = (nLeft + nRight) / 2; 1575 nMid = (nLeft + nRight) / 2;
1576 continue; 1576 continue;
1577 } 1577 }
1578 } 1578 }
1579 return (FX_FLOAT)gFontSizeSteps[nMid]; 1579 return (FX_FLOAT)gFontSizeSteps[nMid];
1580 } 1580 }
1581 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) 1581 FX_BOOL CPDF_VariableText::IsBigger(FX_FLOAT fFontSize)
1582 { 1582 {
1583 FX_BOOL bBigger = FALSE; 1583 FX_BOOL bBigger = FALSE;
1584 CPVT_Size szTotal; 1584 CPVT_Size szTotal;
1585 for (FX_INT32 s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1585 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1586 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1586 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1587 CPVT_Size size = pSection->GetSectionSize(fFontSize); 1587 CPVT_Size size = pSection->GetSectionSize(fFontSize);
1588 szTotal.x = FPDF_MAX(size.x, szTotal.x); 1588 szTotal.x = FPDF_MAX(size.x, szTotal.x);
1589 szTotal.y += size.y; 1589 szTotal.y += size.y;
1590 if (IsFloatBigger(szTotal.x, GetPlateWidth()) 1590 if (IsFloatBigger(szTotal.x, GetPlateWidth())
1591 || IsFloatBigger(szTotal.y, GetPlateHeight()) 1591 || IsFloatBigger(szTotal.y, GetPlateHeight())
1592 ) { 1592 ) {
1593 bBigger = TRUE; 1593 bBigger = TRUE;
1594 break; 1594 break;
1595 } 1595 }
1596 } 1596 }
1597 } 1597 }
1598 return bBigger; 1598 return bBigger;
1599 } 1599 }
1600 CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place Range) 1600 CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place Range)
1601 { 1601 {
1602 CPVT_WordPlace place; 1602 CPVT_WordPlace place;
1603 FX_FLOAT fPosY = 0; 1603 FX_FLOAT fPosY = 0;
1604 FX_FLOAT fOldHeight; 1604 FX_FLOAT fOldHeight;
1605 FX_INT32 nSSecIndex = PlaceRange.BeginPos.nSecIndex; 1605 int32_t nSSecIndex = PlaceRange.BeginPos.nSecIndex;
1606 FX_INT32 nESecIndex = PlaceRange.EndPos.nSecIndex; 1606 int32_t nESecIndex = PlaceRange.EndPos.nSecIndex;
1607 CPVT_FloatRect rcRet; 1607 CPVT_FloatRect rcRet;
1608 for (FX_INT32 s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1608 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1609 place.nSecIndex = s; 1609 place.nSecIndex = s;
1610 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1610 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1611 pSection->SecPlace = place; 1611 pSection->SecPlace = place;
1612 CPVT_FloatRect rcSec = pSection->m_SecInfo.rcSection; 1612 CPVT_FloatRect rcSec = pSection->m_SecInfo.rcSection;
1613 if (s >= nSSecIndex) { 1613 if (s >= nSSecIndex) {
1614 if (s <= nESecIndex) { 1614 if (s <= nESecIndex) {
1615 rcSec = pSection->Rearrange(); 1615 rcSec = pSection->Rearrange();
1616 rcSec.top += fPosY; 1616 rcSec.top += fPosY;
1617 rcSec.bottom += fPosY; 1617 rcSec.bottom += fPosY;
1618 } else { 1618 } else {
(...skipping 10 matching lines...) Expand all
1629 rcRet.left = FPDF_MIN(rcSec.left, rcRet.left); 1629 rcRet.left = FPDF_MIN(rcSec.left, rcRet.left);
1630 rcRet.top = FPDF_MIN(rcSec.top, rcRet.top); 1630 rcRet.top = FPDF_MIN(rcSec.top, rcRet.top);
1631 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right); 1631 rcRet.right = FPDF_MAX(rcSec.right, rcRet.right);
1632 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom); 1632 rcRet.bottom = FPDF_MAX(rcSec.bottom, rcRet.bottom);
1633 } 1633 }
1634 fPosY += rcSec.Height(); 1634 fPosY += rcSec.Height();
1635 } 1635 }
1636 } 1636 }
1637 return rcRet; 1637 return rcRet;
1638 } 1638 }
1639 FX_INT32 CPDF_VariableText::GetCharWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_W ORD SubWord, FX_INT32 nWordStyle) 1639 int32_t CPDF_VariableText::GetCharWidth(int32_t nFontIndex, FX_WORD Word, FX_WOR D SubWord, int32_t nWordStyle)
1640 { 1640 {
1641 if (m_pVTProvider) { 1641 if (m_pVTProvider) {
1642 if (SubWord > 0) { 1642 if (SubWord > 0) {
1643 return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle); 1643 return m_pVTProvider->GetCharWidth(nFontIndex, SubWord, nWordStyle);
1644 } else { 1644 } else {
1645 return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle); 1645 return m_pVTProvider->GetCharWidth(nFontIndex, Word, nWordStyle);
1646 } 1646 }
1647 } 1647 }
1648 return 0; 1648 return 0;
1649 } 1649 }
1650 FX_INT32 CPDF_VariableText::GetTypeAscent(FX_INT32 nFontIndex) 1650 int32_t CPDF_VariableText::GetTypeAscent(int32_t nFontIndex)
1651 { 1651 {
1652 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0; 1652 return m_pVTProvider ? m_pVTProvider->GetTypeAscent(nFontIndex) : 0;
1653 } 1653 }
1654 FX_INT32 CPDF_VariableText::GetTypeDescent(FX_INT32 nFontIndex) 1654 int32_t CPDF_VariableText::GetTypeDescent(int32_t nFontIndex)
1655 { 1655 {
1656 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0; 1656 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0;
1657 } 1657 }
1658 FX_INT32 CPDF_VariableText::GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_ INT32 nFontIndex) 1658 int32_t CPDF_VariableText::GetWordFontIndex(FX_WORD word, int32_t charset, int32 _t nFontIndex)
1659 { 1659 {
1660 return m_pVTProvider ? m_pVTProvider->GetWordFontIndex(word, charset, nFontI ndex) : -1; 1660 return m_pVTProvider ? m_pVTProvider->GetWordFontIndex(word, charset, nFontI ndex) : -1;
1661 } 1661 }
1662 FX_INT32 CPDF_VariableText::GetDefaultFontIndex() 1662 int32_t CPDF_VariableText::GetDefaultFontIndex()
1663 { 1663 {
1664 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; 1664 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1;
1665 } 1665 }
1666 FX_BOOL CPDF_VariableText::IsLatinWord(FX_WORD word) 1666 FX_BOOL CPDF_VariableText::IsLatinWord(FX_WORD word)
1667 { 1667 {
1668 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : FALSE; 1668 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : FALSE;
1669 } 1669 }
1670 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator() 1670 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator()
1671 { 1671 {
1672 if (!m_pVTIterator) { 1672 if (!m_pVTIterator) {
1673 m_pVTIterator = new CPDF_VariableText_Iterator(this); 1673 m_pVTIterator = new CPDF_VariableText_Iterator(this);
1674 } 1674 }
1675 return m_pVTIterator; 1675 return m_pVTIterator;
1676 } 1676 }
1677 IPDF_VariableText_Provider* CPDF_VariableText::SetProvider(IPDF_VariableText _Provider * pProvider) 1677 IPDF_VariableText_Provider* CPDF_VariableText::SetProvider(IPDF_VariableText _Provider * pProvider)
1678 { 1678 {
1679 IPDF_VariableText_Provider* pOld = m_pVTProvider; 1679 IPDF_VariableText_Provider* pOld = m_pVTProvider;
1680 m_pVTProvider = pProvider; 1680 m_pVTProvider = pProvider;
1681 return pOld; 1681 return pOld;
1682 } 1682 }
1683 CPDF_VariableText_Iterator::CPDF_VariableText_Iterator(CPDF_VariableText * pVT): 1683 CPDF_VariableText_Iterator::CPDF_VariableText_Iterator(CPDF_VariableText * pVT):
1684 m_CurPos(-1, -1, -1), 1684 m_CurPos(-1, -1, -1),
1685 m_pVT(pVT) 1685 m_pVT(pVT)
1686 { 1686 {
1687 } 1687 }
1688 CPDF_VariableText_Iterator::~CPDF_VariableText_Iterator() 1688 CPDF_VariableText_Iterator::~CPDF_VariableText_Iterator()
1689 { 1689 {
1690 } 1690 }
1691 void CPDF_VariableText_Iterator::SetAt(FX_INT32 nWordIndex) 1691 void CPDF_VariableText_Iterator::SetAt(int32_t nWordIndex)
1692 { 1692 {
1693 ASSERT(m_pVT != NULL); 1693 ASSERT(m_pVT != NULL);
1694 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); 1694 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex);
1695 } 1695 }
1696 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) 1696 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place)
1697 { 1697 {
1698 ASSERT(m_pVT != NULL); 1698 ASSERT(m_pVT != NULL);
1699 m_CurPos = place; 1699 m_CurPos = place;
1700 } 1700 }
1701 FX_BOOL CPDF_VariableText_Iterator::NextWord() 1701 FX_BOOL CPDF_VariableText_Iterator::NextWord()
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 if (pSection->m_SecInfo.pSecProps) { 1848 if (pSection->m_SecInfo.pSecProps) {
1849 *pSection->m_SecInfo.pSecProps = section.SecProps; 1849 *pSection->m_SecInfo.pSecProps = section.SecProps;
1850 } 1850 }
1851 if (pSection->m_SecInfo.pWordProps) { 1851 if (pSection->m_SecInfo.pWordProps) {
1852 *pSection->m_SecInfo.pWordProps = section.WordProps; 1852 *pSection->m_SecInfo.pWordProps = section.WordProps;
1853 } 1853 }
1854 return TRUE; 1854 return TRUE;
1855 } 1855 }
1856 return FALSE; 1856 return FALSE;
1857 } 1857 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_viewerPreferences.cpp ('k') | core/src/fpdfdoc/pdf_vt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698