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

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

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 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 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}; 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};
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 176 }
177 } else { 177 } else {
178 break; 178 break;
179 } 179 }
180 } 180 }
181 } 181 }
182 CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point & point) const 182 CPVT_WordPlace CSection::SearchWordPlace(const CPDF_Point & point) const
183 { 183 {
184 ASSERT(m_pVT != NULL); 184 ASSERT(m_pVT != NULL);
185 CPVT_WordPlace place = GetBeginWordPlace(); 185 CPVT_WordPlace place = GetBeginWordPlace();
186 FX_BOOL bUp = TRUE; 186 bool bUp = true;
187 FX_BOOL bDown = TRUE; 187 bool bDown = true;
188 int32_t nLeft = 0; 188 int32_t nLeft = 0;
189 int32_t nRight = m_LineArray.GetSize() - 1; 189 int32_t nRight = m_LineArray.GetSize() - 1;
190 int32_t nMid = m_LineArray.GetSize() / 2; 190 int32_t nMid = m_LineArray.GetSize() / 2;
191 FX_FLOAT fTop = 0; 191 FX_FLOAT fTop = 0;
192 FX_FLOAT fBottom = 0; 192 FX_FLOAT fBottom = 0;
193 while (nLeft <= nRight) { 193 while (nLeft <= nRight) {
194 if (CLine * pLine = m_LineArray.GetAt(nMid)) { 194 if (CLine * pLine = m_LineArray.GetAt(nMid)) {
195 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_ pVT->GetLineLeading(m_SecInfo); 195 fTop = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineAscent - m_ pVT->GetLineLeading(m_SecInfo);
196 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent; 196 fBottom = pLine->m_LineInfo.fLineY - pLine->m_LineInfo.fLineDescent;
197 if (IsFloatBigger(point.y, fTop)) { 197 if (IsFloatBigger(point.y, fTop)) {
198 bUp = FALSE; 198 bUp = false;
199 } 199 }
200 if (IsFloatSmaller(point.y, fBottom)) { 200 if (IsFloatSmaller(point.y, fBottom)) {
201 bDown = FALSE; 201 bDown = false;
202 } 202 }
203 if (IsFloatSmaller(point.y, fTop)) { 203 if (IsFloatSmaller(point.y, fTop)) {
204 nRight = nMid - 1; 204 nRight = nMid - 1;
205 nMid = (nLeft + nRight) / 2; 205 nMid = (nLeft + nRight) / 2;
206 continue; 206 continue;
207 } else if (IsFloatBigger(point.y, fBottom)) { 207 } else if (IsFloatBigger(point.y, fBottom)) {
208 nLeft = nMid + 1; 208 nLeft = nMid + 1;
209 nMid = (nLeft + nRight) / 2; 209 nMid = (nLeft + nRight) / 2;
210 continue; 210 continue;
211 } else { 211 } else {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 pLine->m_LineInfo.fLineAscent = fLineAscent; 387 pLine->m_LineInfo.fLineAscent = fLineAscent;
388 pLine->m_LineInfo.fLineDescent = fLineDescent; 388 pLine->m_LineInfo.fLineDescent = fLineDescent;
389 y += (-fLineDescent); 389 y += (-fLineDescent);
390 } 390 }
391 return m_rcRet = CPVT_FloatRect(0, 0, x, y); 391 return m_rcRet = CPVT_FloatRect(0, 0, x, y);
392 } 392 }
393 CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize) 393 CPVT_Size CTypeset::GetEditSize(FX_FLOAT fFontSize)
394 { 394 {
395 ASSERT(m_pSection != NULL); 395 ASSERT(m_pSection != NULL);
396 ASSERT(m_pVT != NULL); 396 ASSERT(m_pVT != NULL);
397 SplitLines(FALSE, fFontSize); 397 SplitLines(false, fFontSize);
398 return CPVT_Size(m_rcRet.Width(), m_rcRet.Height()); 398 return CPVT_Size(m_rcRet.Width(), m_rcRet.Height());
399 } 399 }
400 CPVT_FloatRect CTypeset::Typeset() 400 CPVT_FloatRect CTypeset::Typeset()
401 { 401 {
402 ASSERT(m_pSection != NULL); 402 ASSERT(m_pSection != NULL);
403 ASSERT(m_pVT != NULL); 403 ASSERT(m_pVT != NULL);
404 m_pSection->m_LineArray.Empty(); 404 m_pSection->m_LineArray.Empty();
405 SplitLines(TRUE, 0.0f); 405 SplitLines(true, 0.0f);
406 m_pSection->m_LineArray.Clear(); 406 m_pSection->m_LineArray.Clear();
407 OutputLines(); 407 OutputLines();
408 return m_rcRet; 408 return m_rcRet;
409 } 409 }
410 static int special_chars[128] = { 410 static int special_chars[128] = {
411 0x0000, 0x000C, 0x0008, 0x000C, 0x0008, 0x0000, 0x0020, 0x0000, 411 0x0000, 0x000C, 0x0008, 0x000C, 0x0008, 0x0000, 0x0020, 0x0000,
412 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 412 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
413 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 413 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
414 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 414 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
415 0x0000, 0x0008, 0x0008, 0x0000, 0x0010, 0x0000, 0x0000, 0x0028, 415 0x0000, 0x0008, 0x0008, 0x0000, 0x0010, 0x0000, 0x0000, 0x0028,
416 0x000C, 0x0008, 0x0000, 0x0000, 0x0028, 0x0028, 0x0028, 0x0028, 416 0x000C, 0x0008, 0x0000, 0x0000, 0x0028, 0x0028, 0x0028, 0x0028,
417 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 417 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002,
418 0x0002, 0x0002, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0008, 418 0x0002, 0x0002, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0008,
419 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 419 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
420 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 420 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
421 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 421 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
422 0x0001, 0x0001, 0x0001, 0x000C, 0x0000, 0x0008, 0x0000, 0x0000, 422 0x0001, 0x0001, 0x0001, 0x000C, 0x0000, 0x0008, 0x0000, 0x0000,
423 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 423 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
424 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 424 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
425 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 425 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
426 0x0001, 0x0001, 0x0001, 0x000C, 0x0000, 0x0008, 0x0000, 0x0000, 426 0x0001, 0x0001, 0x0001, 0x000C, 0x0000, 0x0008, 0x0000, 0x0000,
427 }; 427 };
428 static FX_BOOL IsLatin(FX_WORD word) 428 static bool IsLatin(FX_WORD word)
429 { 429 {
430 if (word <= 0x007F) { 430 if (word <= 0x007F) {
431 if (special_chars[word] & 0x0001) { 431 if (special_chars[word] & 0x0001) {
432 return TRUE; 432 return true;
433 } 433 }
434 } 434 }
435 if ((word >= 0x00C0 && word <= 0x00FF) || 435 if ((word >= 0x00C0 && word <= 0x00FF) ||
436 (word >= 0x0100 && word <= 0x024F) || 436 (word >= 0x0100 && word <= 0x024F) ||
437 (word >= 0x1E00 && word <= 0x1EFF) || 437 (word >= 0x1E00 && word <= 0x1EFF) ||
438 (word >= 0x2C60 && word <= 0x2C7F) || 438 (word >= 0x2C60 && word <= 0x2C7F) ||
439 (word >= 0xA720 && word <= 0xA7FF) || 439 (word >= 0xA720 && word <= 0xA7FF) ||
440 (word >= 0xFF21 && word <= 0xFF3A) || 440 (word >= 0xFF21 && word <= 0xFF3A) ||
441 (word >= 0xFF41 && word <= 0xFF5A)) { 441 (word >= 0xFF41 && word <= 0xFF5A)) {
442 return TRUE; 442 return true;
443 } 443 }
444 return FALSE; 444 return false;
445 } 445 }
446 static FX_BOOL IsDigit(FX_DWORD word) 446 static bool IsDigit(FX_DWORD word)
447 { 447 {
448 return (word >= 0x0030 && word <= 0x0039) ? TRUE : FALSE; 448 return (word >= 0x0030 && word <= 0x0039) ? true : false;
449 } 449 }
450 static FX_BOOL IsCJK(FX_DWORD word) 450 static bool IsCJK(FX_DWORD word)
451 { 451 {
452 if ((word >= 0x1100 && word <= 0x11FF) || 452 if ((word >= 0x1100 && word <= 0x11FF) ||
453 (word >= 0x2E80 && word <= 0x2FFF) || 453 (word >= 0x2E80 && word <= 0x2FFF) ||
454 (word >= 0x3040 && word <= 0x9FBF) || 454 (word >= 0x3040 && word <= 0x9FBF) ||
455 (word >= 0xAC00 && word <= 0xD7AF) || 455 (word >= 0xAC00 && word <= 0xD7AF) ||
456 (word >= 0xF900 && word <= 0xFAFF) || 456 (word >= 0xF900 && word <= 0xFAFF) ||
457 (word >= 0xFE30 && word <= 0xFE4F) || 457 (word >= 0xFE30 && word <= 0xFE4F) ||
458 (word >= 0x20000 && word <= 0x2A6DF) || 458 (word >= 0x20000 && word <= 0x2A6DF) ||
459 (word >= 0x2F800 && word <= 0x2FA1F)) { 459 (word >= 0x2F800 && word <= 0x2FA1F)) {
460 return TRUE; 460 return true;
461 } 461 }
462 if (word >= 0x3000 && word <= 0x303F) { 462 if (word >= 0x3000 && word <= 0x303F) {
463 if (word == 0x3005 || word == 0x3006 || word == 0x3021 || word == 0x3022 || 463 if (word == 0x3005 || word == 0x3006 || word == 0x3021 || word == 0x3022 ||
464 word == 0x3023 || word == 0x3024 || word == 0x3025 || word == 0x 3026 || 464 word == 0x3023 || word == 0x3024 || word == 0x3025 || word == 0x 3026 ||
465 word == 0x3027 || word == 0x3028 || word == 0x3029 || word == 0x 3031 || 465 word == 0x3027 || word == 0x3028 || word == 0x3029 || word == 0x 3031 ||
466 word == 0x3032 || word == 0x3033 || word == 0x3034 || word == 0x 3035) { 466 word == 0x3032 || word == 0x3033 || word == 0x3034 || word == 0x 3035) {
467 return TRUE; 467 return true;
468 } 468 }
469 return FALSE; 469 return false;
470 } 470 }
471 if (word >= 0xFF66 && word <= 0xFF9D) { 471 if (word >= 0xFF66 && word <= 0xFF9D) {
472 return TRUE; 472 return true;
473 } 473 }
474 return FALSE; 474 return false;
475 } 475 }
476 static FX_BOOL IsPunctuation(FX_DWORD word) 476 static bool IsPunctuation(FX_DWORD word)
477 { 477 {
478 if (word <= 0x007F) { 478 if (word <= 0x007F) {
479 if ((special_chars[word] >> 3) & 1) { 479 if ((special_chars[word] >> 3) & 1) {
480 return TRUE; 480 return true;
481 } 481 }
482 } else if (word >= 0x0080 && word <= 0x00FF) { 482 } else if (word >= 0x0080 && word <= 0x00FF) {
483 if (word == 0x0082 || word == 0x0084 || word == 0x0085 || word == 0x0091 || 483 if (word == 0x0082 || word == 0x0084 || word == 0x0085 || word == 0x0091 ||
484 word == 0x0092 || word == 0x0093 || word <= 0x0094 || word == 0x 0096 || 484 word == 0x0092 || word == 0x0093 || word <= 0x0094 || word == 0x 0096 ||
485 word == 0x00B4 || word == 0x00B8) { 485 word == 0x00B4 || word == 0x00B8) {
486 return TRUE; 486 return true;
487 } 487 }
488 } else if (word >= 0x2000 && word <= 0x206F) { 488 } else if (word >= 0x2000 && word <= 0x206F) {
489 if (word == 0x2010 || word == 0x2011 || word == 0x2012 || word == 0x2013 || 489 if (word == 0x2010 || word == 0x2011 || word == 0x2012 || word == 0x2013 ||
490 word == 0x2018 || word == 0x2019 || word == 0x201A || word == 0x 201B || 490 word == 0x2018 || word == 0x2019 || word == 0x201A || word == 0x 201B ||
491 word == 0x201C || word == 0x201D || word == 0x201E || word == 0x 201F || 491 word == 0x201C || word == 0x201D || word == 0x201E || word == 0x 201F ||
492 word == 0x2032 || word == 0x2033 || word == 0x2034 || word == 0x 2035 || 492 word == 0x2032 || word == 0x2033 || word == 0x2034 || word == 0x 2035 ||
493 word == 0x2036 || word == 0x2037 || word == 0x203C || word == 0x 203D || 493 word == 0x2036 || word == 0x2037 || word == 0x203C || word == 0x 203D ||
494 word == 0x203E || word == 0x2044) { 494 word == 0x203E || word == 0x2044) {
495 return TRUE; 495 return true;
496 } 496 }
497 } else if (word >= 0x3000 && word <= 0x303F) { 497 } else if (word >= 0x3000 && word <= 0x303F) {
498 if (word == 0x3001 || word == 0x3002 || word == 0x3003 || word == 0x3005 || 498 if (word == 0x3001 || word == 0x3002 || word == 0x3003 || word == 0x3005 ||
499 word == 0x3009 || word == 0x300A || word == 0x300B || word == 0x 300C || 499 word == 0x3009 || word == 0x300A || word == 0x300B || word == 0x 300C ||
500 word == 0x300D || word == 0x300F || word == 0x300E || word == 0x 3010 || 500 word == 0x300D || word == 0x300F || word == 0x300E || word == 0x 3010 ||
501 word == 0x3011 || word == 0x3014 || word == 0x3015 || word == 0x 3016 || 501 word == 0x3011 || word == 0x3014 || word == 0x3015 || word == 0x 3016 ||
502 word == 0x3017 || word == 0x3018 || word == 0x3019 || word == 0x 301A || 502 word == 0x3017 || word == 0x3018 || word == 0x3019 || word == 0x 301A ||
503 word == 0x301B || word == 0x301D || word == 0x301E || word == 0x 301F) { 503 word == 0x301B || word == 0x301D || word == 0x301E || word == 0x 301F) {
504 return TRUE; 504 return true;
505 } 505 }
506 } else if (word >= 0xFE50 && word <= 0xFE6F) { 506 } else if (word >= 0xFE50 && word <= 0xFE6F) {
507 if ((word >= 0xFE50 && word <= 0xFE5E) || word == 0xFE63) { 507 if ((word >= 0xFE50 && word <= 0xFE5E) || word == 0xFE63) {
508 return TRUE; 508 return true;
509 } 509 }
510 } else if (word >= 0xFF00 && word <= 0xFFEF) { 510 } else if (word >= 0xFF00 && word <= 0xFFEF) {
511 if (word == 0xFF01 || word == 0xFF02 || word == 0xFF07 || word == 0xFF08 || 511 if (word == 0xFF01 || word == 0xFF02 || word == 0xFF07 || word == 0xFF08 ||
512 word == 0xFF09 || word == 0xFF0C || word == 0xFF0E || word == 0x FF0F || 512 word == 0xFF09 || word == 0xFF0C || word == 0xFF0E || word == 0x FF0F ||
513 word == 0xFF1A || word == 0xFF1B || word == 0xFF1F || word == 0x FF3B || 513 word == 0xFF1A || word == 0xFF1B || word == 0xFF1F || word == 0x FF3B ||
514 word == 0xFF3D || word == 0xFF40 || word == 0xFF5B || word == 0x FF5C || 514 word == 0xFF3D || word == 0xFF40 || word == 0xFF5B || word == 0x FF5C ||
515 word == 0xFF5D || word == 0xFF61 || word == 0xFF62 || word == 0x FF63 || 515 word == 0xFF5D || word == 0xFF61 || word == 0xFF62 || word == 0x FF63 ||
516 word == 0xFF64 || word == 0xFF65 || word == 0xFF9E || word == 0x FF9F) { 516 word == 0xFF64 || word == 0xFF65 || word == 0xFF9E || word == 0x FF9F) {
517 return TRUE; 517 return true;
518 } 518 }
519 } 519 }
520 return FALSE; 520 return false;
521 } 521 }
522 static FX_BOOL IsConnectiveSymbol(FX_DWORD word) 522 static bool IsConnectiveSymbol(FX_DWORD word)
523 { 523 {
524 if (word <= 0x007F) { 524 if (word <= 0x007F) {
525 if ((special_chars[word] >> 5) & 1) { 525 if ((special_chars[word] >> 5) & 1) {
526 return TRUE; 526 return true;
527 } 527 }
528 } 528 }
529 return FALSE; 529 return false;
530 } 530 }
531 static FX_BOOL IsOpenStylePunctuation(FX_DWORD word) 531 static bool IsOpenStylePunctuation(FX_DWORD word)
532 { 532 {
533 if (word <= 0x007F) { 533 if (word <= 0x007F) {
534 if ((special_chars[word] >> 2) & 1) { 534 if ((special_chars[word] >> 2) & 1) {
535 return TRUE; 535 return true;
536 } 536 }
537 } else if (word == 0x300A || word == 0x300C || word == 0x300E || word == 0x3 010 || 537 } else if (word == 0x300A || word == 0x300C || word == 0x300E || word == 0x3 010 ||
538 word == 0x3014 || word == 0x3016 || word == 0x3018 || word == 0x3 01A || 538 word == 0x3014 || word == 0x3016 || word == 0x3018 || word == 0x3 01A ||
539 word == 0xFF08 || word == 0xFF3B || word == 0xFF5B || word == 0xF F62) { 539 word == 0xFF08 || word == 0xFF3B || word == 0xFF5B || word == 0xF F62) {
540 return TRUE; 540 return true;
541 } 541 }
542 return FALSE; 542 return false;
543 } 543 }
544 static FX_BOOL IsCurrencySymbol(FX_WORD word) 544 static bool IsCurrencySymbol(FX_WORD word)
545 { 545 {
546 if (word == 0x0024 || word == 0x0080 || word == 0x00A2 || word == 0x00A3 || 546 if (word == 0x0024 || word == 0x0080 || word == 0x00A2 || word == 0x00A3 ||
547 word == 0x00A4 || word == 0x00A5 || (word >= 0x20A0 && word <= 0x20C F) || 547 word == 0x00A4 || word == 0x00A5 || (word >= 0x20A0 && word <= 0x20C F) ||
548 word == 0xFE69 || word == 0xFF04 || word == 0xFFE0 || word == 0xFFE1 || 548 word == 0xFE69 || word == 0xFF04 || word == 0xFFE0 || word == 0xFFE1 ||
549 word == 0xFFE5 || word == 0xFFE6) { 549 word == 0xFFE5 || word == 0xFFE6) {
550 return TRUE; 550 return true;
551 } 551 }
552 return FALSE; 552 return false;
553 } 553 }
554 static FX_BOOL IsPrefixSymbol(FX_WORD word) 554 static bool IsPrefixSymbol(FX_WORD word)
555 { 555 {
556 if (IsCurrencySymbol(word)) { 556 if (IsCurrencySymbol(word)) {
557 return TRUE; 557 return true;
558 } 558 }
559 if (word == 0x2116) { 559 if (word == 0x2116) {
560 return TRUE; 560 return true;
561 } 561 }
562 return FALSE; 562 return false;
563 } 563 }
564 static FX_BOOL IsSpace(FX_WORD word) 564 static bool IsSpace(FX_WORD word)
565 { 565 {
566 return (word == 0x0020 || word == 0x3000) ? TRUE : FALSE; 566 return (word == 0x0020 || word == 0x3000) ? true : false;
567 } 567 }
568 static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) 568 static bool NeedDivision(FX_WORD prevWord, FX_WORD curWord)
569 { 569 {
570 if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit (curWord))) { 570 if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit (curWord))) {
571 return FALSE; 571 return false;
572 } 572 }
573 if (IsSpace(curWord) || IsPunctuation(curWord)) { 573 if (IsSpace(curWord) || IsPunctuation(curWord)) {
574 return FALSE; 574 return false;
575 } 575 }
576 if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { 576 if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) {
577 return FALSE; 577 return false;
578 } 578 }
579 if (IsSpace(prevWord) || IsPunctuation(prevWord)) { 579 if (IsSpace(prevWord) || IsPunctuation(prevWord)) {
580 return TRUE; 580 return true;
581 } 581 }
582 if (IsPrefixSymbol(prevWord)) { 582 if (IsPrefixSymbol(prevWord)) {
583 return FALSE; 583 return false;
584 } 584 }
585 if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { 585 if (IsPrefixSymbol(curWord) || IsCJK(curWord)) {
586 return TRUE; 586 return true;
587 } 587 }
588 if (IsCJK(prevWord)) { 588 if (IsCJK(prevWord)) {
589 return TRUE; 589 return true;
590 } 590 }
591 return FALSE; 591 return false;
592 } 592 }
593 void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) 593 void CTypeset::SplitLines(bool bTypeset, FX_FLOAT fFontSize)
594 { 594 {
595 ASSERT(m_pVT != NULL); 595 ASSERT(m_pVT != NULL);
596 ASSERT(m_pSection != NULL); 596 ASSERT(m_pSection != NULL);
597 int32_t nLineHead = 0; 597 int32_t nLineHead = 0;
598 int32_t nLineTail = 0; 598 int32_t nLineTail = 0;
599 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f; 599 FX_FLOAT fMaxX = 0.0f, fMaxY = 0.0f;
600 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f; 600 FX_FLOAT fLineWidth = 0.0f, fBackupLineWidth = 0.0f;
601 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f; 601 FX_FLOAT fLineAscent = 0.0f, fBackupLineAscent = 0.0f;
602 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f; 602 FX_FLOAT fLineDescent = 0.0f, fBackupLineDescent = 0.0f;
603 int32_t nWordStartPos = 0; 603 int32_t nWordStartPos = 0;
604 FX_BOOL bFullWord = FALSE; 604 bool bFullWord = false;
605 int32_t nLineFullWordIndex = 0; 605 int32_t nLineFullWordIndex = 0;
606 int32_t nCharIndex = 0; 606 int32_t nCharIndex = 0;
607 CPVT_LineInfo line; 607 CPVT_LineInfo line;
608 FX_FLOAT fWordWidth = 0; 608 FX_FLOAT fWordWidth = 0;
609 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - m_pVT->GetLineInd ent(m_pSection->m_SecInfo), 0.0f); 609 FX_FLOAT fTypesetWidth = FPDF_MAX(m_pVT->GetPlateWidth() - m_pVT->GetLineInd ent(m_pSection->m_SecInfo), 0.0f);
610 int32_t nTotalWords = m_pSection->m_WordArray.GetSize(); 610 int32_t nTotalWords = m_pSection->m_WordArray.GetSize();
611 FX_BOOL bOpened = FALSE; 611 bool bOpened = false;
612 if (nTotalWords > 0) { 612 if (nTotalWords > 0) {
613 int32_t i = 0; 613 int32_t i = 0;
614 while (i < nTotalWords) { 614 while (i < nTotalWords) {
615 CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(i); 615 CPVT_WordInfo * pWord = m_pSection->m_WordArray.GetAt(i);
616 CPVT_WordInfo* pOldWord = pWord; 616 CPVT_WordInfo* pOldWord = pWord;
617 if (i > 0) { 617 if (i > 0) {
618 pOldWord = m_pSection->m_WordArray.GetAt(i - 1); 618 pOldWord = m_pSection->m_WordArray.GetAt(i - 1);
619 } 619 }
620 if (pWord) { 620 if (pWord) {
621 if (bTypeset) { 621 if (bTypeset) {
622 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, TRUE)); 622 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, true));
623 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, TRUE)); 623 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, true));
624 fWordWidth = m_pVT->GetWordWidth(*pWord); 624 fWordWidth = m_pVT->GetWordWidth(*pWord);
625 } else { 625 } else {
626 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, fFontSize)); 626 fLineAscent = FPDF_MAX(fLineAscent, m_pVT->GetWordAscent(*pW ord, fFontSize));
627 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, fFontSize)); 627 fLineDescent = FPDF_MIN(fLineDescent, m_pVT->GetWordDescent( *pWord, fFontSize));
628 fWordWidth = m_pVT->GetWordWidth(pWord->nFontIndex, 628 fWordWidth = m_pVT->GetWordWidth(pWord->nFontIndex,
629 pWord->Word, 629 pWord->Word,
630 m_pVT->m_wSubWord, 630 m_pVT->m_wSubWord,
631 m_pVT->m_fCharSpace, 631 m_pVT->m_fCharSpace,
632 m_pVT->m_nHorzScale, 632 m_pVT->m_nHorzScale,
633 fFontSize, 633 fFontSize,
634 pWord->fWordTail, 634 pWord->fWordTail,
635 0); 635 0);
636 } 636 }
637 if (!bOpened) { 637 if (!bOpened) {
638 if (IsOpenStylePunctuation(pWord->Word)) { 638 if (IsOpenStylePunctuation(pWord->Word)) {
639 bOpened = TRUE; 639 bOpened = true;
640 bFullWord = TRUE; 640 bFullWord = true;
641 } else if (pOldWord != NULL) { 641 } else if (pOldWord != NULL) {
642 if (NeedDivision(pOldWord->Word, pWord->Word)) { 642 if (NeedDivision(pOldWord->Word, pWord->Word)) {
643 bFullWord = TRUE; 643 bFullWord = true;
644 } 644 }
645 } 645 }
646 } else { 646 } else {
647 if (!IsSpace(pWord->Word) && !IsOpenStylePunctuation(pWord-> Word)) { 647 if (!IsSpace(pWord->Word) && !IsOpenStylePunctuation(pWord-> Word)) {
648 bOpened = FALSE; 648 bOpened = false;
649 } 649 }
650 } 650 }
651 if (bFullWord) { 651 if (bFullWord) {
652 bFullWord = FALSE; 652 bFullWord = false;
653 if (nCharIndex > 0) { 653 if (nCharIndex > 0) {
654 nLineFullWordIndex ++; 654 nLineFullWordIndex ++;
655 } 655 }
656 nWordStartPos = i; 656 nWordStartPos = i;
657 fBackupLineWidth = fLineWidth; 657 fBackupLineWidth = fLineWidth;
658 fBackupLineAscent = fLineAscent; 658 fBackupLineAscent = fLineAscent;
659 fBackupLineDescent = fLineDescent; 659 fBackupLineDescent = fLineDescent;
660 } 660 }
661 nCharIndex++; 661 nCharIndex++;
662 } 662 }
(...skipping 21 matching lines...) Expand all
684 } 684 }
685 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecI nfo)); 685 fMaxY += (fLineAscent + m_pVT->GetLineLeading(m_pSection->m_SecI nfo));
686 fMaxY += (-fLineDescent); 686 fMaxY += (-fLineDescent);
687 fMaxX = FPDF_MAX(fLineWidth, fMaxX); 687 fMaxX = FPDF_MAX(fLineWidth, fMaxX);
688 nLineHead = i; 688 nLineHead = i;
689 fLineWidth = 0.0f; 689 fLineWidth = 0.0f;
690 fLineAscent = 0.0f; 690 fLineAscent = 0.0f;
691 fLineDescent = 0.0f; 691 fLineDescent = 0.0f;
692 nCharIndex = 0; 692 nCharIndex = 0;
693 nLineFullWordIndex = 0; 693 nLineFullWordIndex = 0;
694 bFullWord = FALSE; 694 bFullWord = false;
695 } else { 695 } else {
696 fLineWidth += fWordWidth; 696 fLineWidth += fWordWidth;
697 i++; 697 i++;
698 } 698 }
699 } 699 }
700 if (nLineHead <= nTotalWords - 1) { 700 if (nLineHead <= nTotalWords - 1) {
701 nLineTail = nTotalWords - 1; 701 nLineTail = nTotalWords - 1;
702 if (bTypeset) { 702 if (bTypeset) {
703 line.nBeginWordIndex = nLineHead; 703 line.nBeginWordIndex = nLineHead;
704 line.nEndWordIndex = nLineTail; 704 line.nEndWordIndex = nLineTail;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 802 }
803 fPosY += (-pLine->m_LineInfo.fLineDescent); 803 fPosY += (-pLine->m_LineInfo.fLineDescent);
804 } 804 }
805 } 805 }
806 } 806 }
807 m_rcRet = CPVT_FloatRect(fMinX, fMinY, fMaxX, fMaxY); 807 m_rcRet = CPVT_FloatRect(fMinX, fMinY, fMaxX, fMaxY);
808 } 808 }
809 CPDF_VariableText::CPDF_VariableText() : 809 CPDF_VariableText::CPDF_VariableText() :
810 m_nLimitChar(0), 810 m_nLimitChar(0),
811 m_nCharArray(0), 811 m_nCharArray(0),
812 m_bMultiLine(FALSE), 812 m_bMultiLine(false),
813 m_bLimitWidth(FALSE), 813 m_bLimitWidth(false),
814 m_bAutoFontSize(FALSE), 814 m_bAutoFontSize(false),
815 m_nAlignment(0), 815 m_nAlignment(0),
816 m_fLineLeading(0.0f), 816 m_fLineLeading(0.0f),
817 m_fCharSpace(0.0f), 817 m_fCharSpace(0.0f),
818 m_nHorzScale(100), 818 m_nHorzScale(100),
819 m_wSubWord(0), 819 m_wSubWord(0),
820 m_fFontSize(0.0f), 820 m_fFontSize(0.0f),
821 m_bInitial(FALSE), 821 m_bInitial(false),
822 m_bRichText(FALSE), 822 m_bRichText(false),
823 m_pVTProvider(NULL), 823 m_pVTProvider(NULL),
824 m_pVTIterator(NULL) 824 m_pVTIterator(NULL)
825 { 825 {
826 } 826 }
827 CPDF_VariableText::~CPDF_VariableText() 827 CPDF_VariableText::~CPDF_VariableText()
828 { 828 {
829 delete m_pVTIterator; 829 delete m_pVTIterator;
830 m_pVTIterator = NULL; 830 m_pVTIterator = NULL;
831 ResetAll(); 831 ResetAll();
832 } 832 }
833 void CPDF_VariableText::Initialize() 833 void CPDF_VariableText::Initialize()
834 { 834 {
835 if (!m_bInitial) { 835 if (!m_bInitial) {
836 CPVT_SectionInfo secinfo; 836 CPVT_SectionInfo secinfo;
837 if (m_bRichText) { 837 if (m_bRichText) {
838 secinfo.pSecProps = new CPVT_SecProps(0.0f, 0.0f, 0); 838 secinfo.pSecProps = new CPVT_SecProps(0.0f, 0.0f, 0);
839 secinfo.pWordProps = new CPVT_WordProps(GetDefaultFontIndex(), PVT_D EFAULT_FONTSIZE, 0, 0, 0); 839 secinfo.pWordProps = new CPVT_WordProps(GetDefaultFontIndex(), PVT_D EFAULT_FONTSIZE, 0, 0, 0);
840 } 840 }
841 CPVT_WordPlace place; 841 CPVT_WordPlace place;
842 place.nSecIndex = 0; 842 place.nSecIndex = 0;
843 AddSection(place, secinfo); 843 AddSection(place, secinfo);
844 CPVT_LineInfo lineinfo; 844 CPVT_LineInfo lineinfo;
845 lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize( )); 845 lineinfo.fLineAscent = GetFontAscent(GetDefaultFontIndex(), GetFontSize( ));
846 lineinfo.fLineDescent = GetFontDescent(GetDefaultFontIndex(), GetFontSiz e()); 846 lineinfo.fLineDescent = GetFontDescent(GetDefaultFontIndex(), GetFontSiz e());
847 AddLine(place, lineinfo); 847 AddLine(place, lineinfo);
848 if (CSection * pSection = m_SectionArray.GetAt(0)) { 848 if (CSection * pSection = m_SectionArray.GetAt(0)) {
849 pSection->ResetLinePlace(); 849 pSection->ResetLinePlace();
850 } 850 }
851 m_bInitial = TRUE; 851 m_bInitial = true;
852 } 852 }
853 } 853 }
854 void CPDF_VariableText::ResetAll() 854 void CPDF_VariableText::ResetAll()
855 { 855 {
856 m_bInitial = FALSE; 856 m_bInitial = false;
857 ResetSectionArray(); 857 ResetSectionArray();
858 } 858 }
859 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO RD word, int32_t charset, 859 CPVT_WordPlace CPDF_VariableText::InsertWord(const CPVT_WordPlace & place, FX_WO RD word, int32_t charset,
860 const CPVT_WordProps * pWordProps) 860 const CPVT_WordProps * pWordProps)
861 { 861 {
862 int32_t nTotlaWords = GetTotalWords(); 862 int32_t nTotlaWords = GetTotalWords();
863 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) { 863 if (m_nLimitChar > 0 && nTotlaWords >= m_nLimitChar) {
864 return place; 864 return place;
865 } 865 }
866 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) { 866 if (m_nCharArray > 0 && nTotlaWords >= m_nCharArray) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 break; 949 break;
950 } 950 }
951 if (wp == oldwp) { 951 if (wp == oldwp) {
952 break; 952 break;
953 } 953 }
954 } 954 }
955 return wp; 955 return wp;
956 } 956 }
957 CPVT_WordPlace CPDF_VariableText::DeleteWords(const CPVT_WordRange & PlaceRange) 957 CPVT_WordPlace CPDF_VariableText::DeleteWords(const CPVT_WordRange & PlaceRange)
958 { 958 {
959 FX_BOOL bLastSecPos = FALSE; 959 bool bLastSecPos = false;
960 if (CSection * pSection = m_SectionArray.GetAt(PlaceRange.EndPos.nSecIndex)) { 960 if (CSection * pSection = m_SectionArray.GetAt(PlaceRange.EndPos.nSecIndex)) {
961 bLastSecPos = (PlaceRange.EndPos == pSection->GetEndWordPlace()); 961 bLastSecPos = (PlaceRange.EndPos == pSection->GetEndWordPlace());
962 } 962 }
963 ClearWords(PlaceRange); 963 ClearWords(PlaceRange);
964 if (PlaceRange.BeginPos.nSecIndex != PlaceRange.EndPos.nSecIndex) { 964 if (PlaceRange.BeginPos.nSecIndex != PlaceRange.EndPos.nSecIndex) {
965 ClearEmptySections(PlaceRange); 965 ClearEmptySections(PlaceRange);
966 if (!bLastSecPos) { 966 if (!bLastSecPos) {
967 LinkLatterSection(PlaceRange.BeginPos); 967 LinkLatterSection(PlaceRange.BeginPos);
968 } 968 }
969 } 969 }
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(const FX_WCHAR* text, int32_t charset, const CPV T_SecProps * pSecProps, 980 void CPDF_VariableText::SetText(const FX_WCHAR* text, int32_t charset, const CPV T_SecProps * 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) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 } 1037 }
1038 } 1038 }
1039 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace & place) const 1039 void CPDF_VariableText::UpdateWordPlace(CPVT_WordPlace & place) const
1040 { 1040 {
1041 if (place.nSecIndex < 0) { 1041 if (place.nSecIndex < 0) {
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 int32_t CPDF_VariableText::WordPlaceToWordIndex(const CPVT_WordPlace & place) co nst 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 int32_t nIndex = 0; 1056 int32_t nIndex = 0;
1057 int32_t i = 0; 1057 int32_t i = 0;
1058 int32_t 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(int32_t 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 int32_t nOldIndex = 0 , nIndex = 0; 1075 int32_t nOldIndex = 0 , nIndex = 0;
1076 FX_BOOL bFind = FALSE; 1076 bool bFind = false;
1077 for (int32_t 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);
1088 bFind = TRUE; 1088 bFind = true;
1089 break; 1089 break;
1090 } 1090 }
1091 if (i != m_SectionArray.GetSize() - 1) { 1091 if (i != m_SectionArray.GetSize() - 1) {
1092 nIndex += PVT_RETURN_LENGTH; 1092 nIndex += PVT_RETURN_LENGTH;
1093 } 1093 }
1094 nOldIndex = nIndex; 1094 nOldIndex = nIndex;
1095 } 1095 }
1096 } 1096 }
1097 if (!bFind) { 1097 if (!bFind) {
1098 place = GetEndWordPlace(); 1098 place = GetEndWordPlace();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 } 1148 }
1149 return place; 1149 return place;
1150 } 1150 }
1151 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons t 1151 CPVT_WordPlace CPDF_VariableText::SearchWordPlace(const CPDF_Point & point) cons t
1152 { 1152 {
1153 CPDF_Point pt = OutToIn(point); 1153 CPDF_Point pt = OutToIn(point);
1154 CPVT_WordPlace place = GetBeginWordPlace(); 1154 CPVT_WordPlace place = GetBeginWordPlace();
1155 int32_t nLeft = 0; 1155 int32_t nLeft = 0;
1156 int32_t nRight = m_SectionArray.GetSize() - 1; 1156 int32_t nRight = m_SectionArray.GetSize() - 1;
1157 int32_t nMid = m_SectionArray.GetSize() / 2; 1157 int32_t nMid = m_SectionArray.GetSize() / 2;
1158 FX_BOOL bUp = TRUE; 1158 bool bUp = true;
1159 FX_BOOL bDown = TRUE; 1159 bool bDown = true;
1160 while (nLeft <= nRight) { 1160 while (nLeft <= nRight) {
1161 if (CSection * pSection = m_SectionArray.GetAt(nMid)) { 1161 if (CSection * pSection = m_SectionArray.GetAt(nMid)) {
1162 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) { 1162 if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.top)) {
1163 bUp = FALSE; 1163 bUp = false;
1164 } 1164 }
1165 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) { 1165 if (IsFloatBigger(pSection->m_SecInfo.rcSection.bottom, pt.y)) {
1166 bDown = FALSE; 1166 bDown = false;
1167 } 1167 }
1168 if (IsFloatSmaller(pt.y, pSection->m_SecInfo.rcSection.top)) { 1168 if (IsFloatSmaller(pt.y, pSection->m_SecInfo.rcSection.top)) {
1169 nRight = nMid - 1; 1169 nRight = nMid - 1;
1170 nMid = (nLeft + nRight) / 2; 1170 nMid = (nLeft + nRight) / 2;
1171 continue; 1171 continue;
1172 } else if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.bottom) ) { 1172 } else if (IsFloatBigger(pt.y, pSection->m_SecInfo.rcSection.bottom) ) {
1173 nLeft = nMid + 1; 1173 nLeft = nMid + 1;
1174 nMid = (nLeft + nRight) / 2; 1174 nMid = (nLeft + nRight) / 2;
1175 continue; 1175 continue;
1176 } else { 1176 } else {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 if (m_SectionArray.GetSize() <= 0) { 1296 if (m_SectionArray.GetSize() <= 0) {
1297 return place; 1297 return place;
1298 } 1298 }
1299 CPVT_WordPlace newplace = place; 1299 CPVT_WordPlace newplace = place;
1300 newplace.nSecIndex = FPDF_MAX(FPDF_MIN(newplace.nSecIndex, m_SectionArray.Ge tSize() - 1), 0); 1300 newplace.nSecIndex = FPDF_MAX(FPDF_MIN(newplace.nSecIndex, m_SectionArray.Ge tSize() - 1), 0);
1301 if (CSection * pSection = m_SectionArray.GetAt(newplace.nSecIndex)) { 1301 if (CSection * pSection = m_SectionArray.GetAt(newplace.nSecIndex)) {
1302 return pSection->AddWord(newplace, wordinfo); 1302 return pSection->AddWord(newplace, wordinfo);
1303 } 1303 }
1304 return place; 1304 return place;
1305 } 1305 }
1306 FX_BOOL CPDF_VariableText::GetWordInfo(const CPVT_WordPlace & place, CPVT_WordIn fo & wordinfo) 1306 bool CPDF_VariableText::GetWordInfo(const CPVT_WordPlace & place, CPVT_WordInfo & wordinfo)
1307 { 1307 {
1308 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1308 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1309 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(place.nWordIndex )) { 1309 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(place.nWordIndex )) {
1310 wordinfo = *pWord; 1310 wordinfo = *pWord;
1311 return TRUE; 1311 return true;
1312 } 1312 }
1313 } 1313 }
1314 return FALSE; 1314 return false;
1315 } 1315 }
1316 FX_BOOL CPDF_VariableText::SetWordInfo(const CPVT_WordPlace & place, const CPVT_ WordInfo & wordinfo) 1316 bool CPDF_VariableText::SetWordInfo(const CPVT_WordPlace & place, const CPVT_Wor dInfo & wordinfo)
1317 { 1317 {
1318 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1318 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1319 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(place.nWordIndex )) { 1319 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(place.nWordIndex )) {
1320 *pWord = wordinfo; 1320 *pWord = wordinfo;
1321 return TRUE; 1321 return true;
1322 } 1322 }
1323 } 1323 }
1324 return FALSE; 1324 return false;
1325 } 1325 }
1326 FX_BOOL CPDF_VariableText::GetLineInfo(const CPVT_WordPlace & place, CPVT_LineIn fo & lineinfo) 1326 bool CPDF_VariableText::GetLineInfo(const CPVT_WordPlace & place, CPVT_LineInfo & lineinfo)
1327 { 1327 {
1328 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1328 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1329 if (CLine * pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) { 1329 if (CLine * pLine = pSection->m_LineArray.GetAt(place.nLineIndex)) {
1330 lineinfo = pLine->m_LineInfo; 1330 lineinfo = pLine->m_LineInfo;
1331 return TRUE; 1331 return true;
1332 } 1332 }
1333 } 1333 }
1334 return FALSE; 1334 return false;
1335 } 1335 }
1336 FX_BOOL CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace & place, CPVT_Sec tionInfo & secinfo) 1336 bool CPDF_VariableText::GetSectionInfo(const CPVT_WordPlace & place, CPVT_Sectio nInfo & secinfo)
1337 { 1337 {
1338 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1338 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1339 secinfo = pSection->m_SecInfo; 1339 secinfo = pSection->m_SecInfo;
1340 return TRUE; 1340 return true;
1341 } 1341 }
1342 return FALSE; 1342 return false;
1343 } 1343 }
1344 CPDF_Rect CPDF_VariableText::GetContentRect() const 1344 CPDF_Rect CPDF_VariableText::GetContentRect() const
1345 { 1345 {
1346 return InToOut(CPDF_EditContainer::GetContentRect()); 1346 return InToOut(CPDF_EditContainer::GetContentRect());
1347 } 1347 }
1348 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_B OOL bFactFontSize) 1348 FX_FLOAT CPDF_VariableText::GetWordFontSize(const CPVT_WordInfo & WordInfo, bool bFactFontSize)
1349 { 1349 {
1350 return m_bRichText && WordInfo.pWordProps ? (WordInfo.pWordProps->nScriptTyp e == PVTWORD_SCRIPT_NORMAL || bFactFontSize ? WordInfo.pWordProps->fFontSize : W ordInfo.pWordProps->fFontSize * PVT_HALF) : GetFontSize(); 1350 return m_bRichText && WordInfo.pWordProps ? (WordInfo.pWordProps->nScriptTyp e == PVTWORD_SCRIPT_NORMAL || bFactFontSize ? WordInfo.pWordProps->fFontSize : W ordInfo.pWordProps->fFontSize * PVT_HALF) : GetFontSize();
1351 } 1351 }
1352 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo & WordInfo) 1352 int32_t CPDF_VariableText::GetWordFontIndex(const CPVT_WordInfo & WordInfo)
1353 { 1353 {
1354 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nFontIndex : WordInfo.nFontIndex; 1354 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nFontIndex : WordInfo.nFontIndex;
1355 } 1355 }
1356 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, FX_WORD Word, FX_WO RD SubWord, 1356 FX_FLOAT CPDF_VariableText::GetWordWidth(int32_t nFontIndex, FX_WORD Word, FX_WO RD SubWord,
1357 FX_FLOAT fCharSpace, int32_t nHorzScale, 1357 FX_FLOAT fCharSpace, int32_t nHorzScale,
1358 FX_FLOAT fFontSize, FX_FLOAT fWordTail, int32_t nWordStyle) 1358 FX_FLOAT fFontSize, FX_FLOAT fWordTail, int32_t nWordStyle)
(...skipping 25 matching lines...) Expand all
1384 return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * PVT_FONTSCALE; 1384 return (FX_FLOAT)GetTypeDescent(nFontIndex) * fFontSize * PVT_FONTSCALE;
1385 } 1385 }
1386 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLO AT fFontSize) 1386 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLO AT fFontSize)
1387 { 1387 {
1388 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize); 1388 return GetFontAscent(GetWordFontIndex(WordInfo), fFontSize);
1389 } 1389 }
1390 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FL OAT fFontSize) 1390 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FL OAT fFontSize)
1391 { 1391 {
1392 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize); 1392 return GetFontDescent(GetWordFontIndex(WordInfo), fFontSize);
1393 } 1393 }
1394 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOO L bFactFontSize) 1394 FX_FLOAT CPDF_VariableText::GetWordAscent(const CPVT_WordInfo & WordInfo, bool b FactFontSize)
1395 { 1395 {
1396 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, b FactFontSize)); 1396 return GetFontAscent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, b FactFontSize));
1397 } 1397 }
1398 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BO OL bFactFontSize) 1398 FX_FLOAT CPDF_VariableText::GetWordDescent(const CPVT_WordInfo & WordInfo, bool bFactFontSize)
1399 { 1399 {
1400 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, bFactFontSize)); 1400 return GetFontDescent(GetWordFontIndex(WordInfo), GetWordFontSize(WordInfo, bFactFontSize));
1401 } 1401 }
1402 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo & SecInfo) 1402 FX_FLOAT CPDF_VariableText::GetLineLeading(const CPVT_SectionInfo & SecInfo)
1403 { 1403 {
1404 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineLeading : m_fLineLeading; 1404 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineLeading : m_fLineLeading;
1405 } 1405 }
1406 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo & SecInfo) 1406 FX_FLOAT CPDF_VariableText::GetLineIndent(const CPVT_SectionInfo & SecInfo)
1407 { 1407 {
1408 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineIndent : 0 .0f; 1408 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->fLineIndent : 0 .0f;
1409 } 1409 }
1410 int32_t CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo) 1410 int32_t CPDF_VariableText::GetAlignment(const CPVT_SectionInfo& SecInfo)
1411 { 1411 {
1412 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->nAlignment : m_ nAlignment; 1412 return m_bRichText && SecInfo.pSecProps ? SecInfo.pSecProps->nAlignment : m_ nAlignment;
1413 } 1413 }
1414 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo & WordInfo) 1414 FX_FLOAT CPDF_VariableText::GetCharSpace(const CPVT_WordInfo & WordInfo)
1415 { 1415 {
1416 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace : m_fCharSpace; 1416 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->fCharSpace : m_fCharSpace;
1417 } 1417 }
1418 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo & WordInfo) 1418 int32_t CPDF_VariableText::GetHorzScale(const CPVT_WordInfo & WordInfo)
1419 { 1419 {
1420 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale : m_nHorzScale; 1420 return m_bRichText && WordInfo.pWordProps ? WordInfo.pWordProps->nHorzScale : m_nHorzScale;
1421 } 1421 }
1422 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place) 1422 void CPDF_VariableText::ClearSectionRightWords(const CPVT_WordPlace & place)
1423 { 1423 {
1424 CPVT_WordPlace wordplace = AjustLineHeader(place, TRUE); 1424 CPVT_WordPlace wordplace = AjustLineHeader(place, true);
1425 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1425 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1426 for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWor dIndex; w--) { 1426 for (int32_t w = pSection->m_WordArray.GetSize() - 1; w > wordplace.nWor dIndex; w--) {
1427 delete pSection->m_WordArray.GetAt(w); 1427 delete pSection->m_WordArray.GetAt(w);
1428 pSection->m_WordArray.RemoveAt(w); 1428 pSection->m_WordArray.RemoveAt(w);
1429 } 1429 }
1430 } 1430 }
1431 } 1431 }
1432 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const 1432 CPVT_WordPlace CPDF_VariableText::AjustLineHeader(const CPVT_WordPlace & place, bool bPrevOrNext) const
1433 { 1433 {
1434 if (place.nWordIndex < 0 && place.nLineIndex > 0) { 1434 if (place.nWordIndex < 0 && place.nLineIndex > 0) {
1435 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place); 1435 return bPrevOrNext ? GetPrevWordPlace(place) : GetNextWordPlace(place);
1436 } 1436 }
1437 return place; 1437 return place;
1438 } 1438 }
1439 FX_BOOL CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace & place) 1439 bool CPDF_VariableText::ClearEmptySection(const CPVT_WordPlace & place)
1440 { 1440 {
1441 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) { 1441 if (place.nSecIndex == 0 && m_SectionArray.GetSize() == 1) {
1442 return FALSE; 1442 return false;
1443 } 1443 }
1444 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1444 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1445 if (pSection->m_WordArray.GetSize() == 0) { 1445 if (pSection->m_WordArray.GetSize() == 0) {
1446 delete pSection; 1446 delete pSection;
1447 m_SectionArray.RemoveAt(place.nSecIndex); 1447 m_SectionArray.RemoveAt(place.nSecIndex);
1448 return TRUE; 1448 return true;
1449 } 1449 }
1450 } 1450 }
1451 return FALSE; 1451 return false;
1452 } 1452 }
1453 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange & PlaceRange) 1453 void CPDF_VariableText::ClearEmptySections(const CPVT_WordRange & PlaceRange)
1454 { 1454 {
1455 CPVT_WordPlace wordplace; 1455 CPVT_WordPlace wordplace;
1456 for (int32_t s = PlaceRange.EndPos.nSecIndex; s > PlaceRange.BeginPos.nSecIn dex; s--) { 1456 for (int32_t s = PlaceRange.EndPos.nSecIndex; s > PlaceRange.BeginPos.nSecIn dex; s--) {
1457 wordplace.nSecIndex = s; 1457 wordplace.nSecIndex = s;
1458 ClearEmptySection(wordplace); 1458 ClearEmptySection(wordplace);
1459 } 1459 }
1460 } 1460 }
1461 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace & place) 1461 void CPDF_VariableText::LinkLatterSection(const CPVT_WordPlace & place)
1462 { 1462 {
1463 CPVT_WordPlace oldplace = AjustLineHeader(place, TRUE); 1463 CPVT_WordPlace oldplace = AjustLineHeader(place, true);
1464 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) { 1464 if (CSection * pNextSection = m_SectionArray.GetAt(place.nSecIndex + 1)) {
1465 if (CSection * pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) { 1465 if (CSection * pSection = m_SectionArray.GetAt(oldplace.nSecIndex)) {
1466 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz ; w++) { 1466 for (int32_t w = 0, sz = pNextSection->m_WordArray.GetSize(); w < sz ; w++) {
1467 if (CPVT_WordInfo * pWord = pNextSection->m_WordArray.GetAt(w)) { 1467 if (CPVT_WordInfo * pWord = pNextSection->m_WordArray.GetAt(w)) {
1468 oldplace.nWordIndex ++; 1468 oldplace.nWordIndex ++;
1469 pSection->AddWord(oldplace, *pWord); 1469 pSection->AddWord(oldplace, *pWord);
1470 } 1470 }
1471 } 1471 }
1472 } 1472 }
1473 delete pNextSection; 1473 delete pNextSection;
1474 m_SectionArray.RemoveAt(place.nSecIndex + 1); 1474 m_SectionArray.RemoveAt(place.nSecIndex + 1);
1475 } 1475 }
1476 } 1476 }
1477 void CPDF_VariableText::ClearWords(const CPVT_WordRange & PlaceRange) 1477 void CPDF_VariableText::ClearWords(const CPVT_WordRange & PlaceRange)
1478 { 1478 {
1479 CPVT_WordRange NewRange; 1479 CPVT_WordRange NewRange;
1480 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, TRUE); 1480 NewRange.BeginPos = AjustLineHeader(PlaceRange.BeginPos, true);
1481 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, TRUE); 1481 NewRange.EndPos = AjustLineHeader(PlaceRange.EndPos, true);
1482 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex ; s--) { 1482 for (int32_t s = NewRange.EndPos.nSecIndex; s >= NewRange.BeginPos.nSecIndex ; s--) {
1483 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1483 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1484 pSection->ClearWords(NewRange); 1484 pSection->ClearWords(NewRange);
1485 } 1485 }
1486 } 1486 }
1487 } 1487 }
1488 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace & place) 1488 CPVT_WordPlace CPDF_VariableText::ClearLeftWord(const CPVT_WordPlace & place)
1489 { 1489 {
1490 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1490 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1491 CPVT_WordPlace leftplace = GetPrevWordPlace(place); 1491 CPVT_WordPlace leftplace = GetPrevWordPlace(place);
1492 if (leftplace != place) { 1492 if (leftplace != place) {
1493 if (leftplace.nSecIndex != place.nSecIndex) { 1493 if (leftplace.nSecIndex != place.nSecIndex) {
1494 if (pSection->m_WordArray.GetSize() == 0) { 1494 if (pSection->m_WordArray.GetSize() == 0) {
1495 ClearEmptySection(place); 1495 ClearEmptySection(place);
1496 } else { 1496 } else {
1497 LinkLatterSection(leftplace); 1497 LinkLatterSection(leftplace);
1498 } 1498 }
1499 } else { 1499 } else {
1500 pSection->ClearWord(place); 1500 pSection->ClearWord(place);
1501 } 1501 }
1502 } 1502 }
1503 return leftplace; 1503 return leftplace;
1504 } 1504 }
1505 return place; 1505 return place;
1506 } 1506 }
1507 CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace & place) 1507 CPVT_WordPlace CPDF_VariableText::ClearRightWord(const CPVT_WordPlace & place)
1508 { 1508 {
1509 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) { 1509 if (CSection * pSection = m_SectionArray.GetAt(place.nSecIndex)) {
1510 CPVT_WordPlace rightplace = AjustLineHeader(GetNextWordPlace(place), FAL SE); 1510 CPVT_WordPlace rightplace = AjustLineHeader(GetNextWordPlace(place), fal se);
1511 if (rightplace != place) { 1511 if (rightplace != place) {
1512 if(rightplace.nSecIndex != place.nSecIndex) { 1512 if(rightplace.nSecIndex != place.nSecIndex) {
1513 LinkLatterSection(place); 1513 LinkLatterSection(place);
1514 } else { 1514 } else {
1515 pSection->ClearWord(rightplace); 1515 pSection->ClearWord(rightplace);
1516 } 1516 }
1517 } 1517 }
1518 } 1518 }
1519 return place; 1519 return place;
1520 } 1520 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1561 nMid = (nLeft + nRight) / 2; 1561 nMid = (nLeft + nRight) / 2;
1562 continue; 1562 continue;
1563 } else { 1563 } else {
1564 nLeft = nMid + 1; 1564 nLeft = nMid + 1;
1565 nMid = (nLeft + nRight) / 2; 1565 nMid = (nLeft + nRight) / 2;
1566 continue; 1566 continue;
1567 } 1567 }
1568 } 1568 }
1569 return (FX_FLOAT)gFontSizeSteps[nMid]; 1569 return (FX_FLOAT)gFontSizeSteps[nMid];
1570 } 1570 }
1571 FX_BOOL»CPDF_VariableText::IsBigger(FX_FLOAT fFontSize) 1571 bool» CPDF_VariableText::IsBigger(FX_FLOAT fFontSize)
1572 { 1572 {
1573 FX_BOOL bBigger = FALSE; 1573 bool bBigger = false;
1574 CPVT_Size szTotal; 1574 CPVT_Size szTotal;
1575 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) { 1575 for (int32_t s = 0, sz = m_SectionArray.GetSize(); s < sz; s++) {
1576 if (CSection * pSection = m_SectionArray.GetAt(s)) { 1576 if (CSection * pSection = m_SectionArray.GetAt(s)) {
1577 CPVT_Size size = pSection->GetSectionSize(fFontSize); 1577 CPVT_Size size = pSection->GetSectionSize(fFontSize);
1578 szTotal.x = FPDF_MAX(size.x, szTotal.x); 1578 szTotal.x = FPDF_MAX(size.x, szTotal.x);
1579 szTotal.y += size.y; 1579 szTotal.y += size.y;
1580 if (IsFloatBigger(szTotal.x, GetPlateWidth()) 1580 if (IsFloatBigger(szTotal.x, GetPlateWidth())
1581 || IsFloatBigger(szTotal.y, GetPlateHeight()) 1581 || IsFloatBigger(szTotal.y, GetPlateHeight())
1582 ) { 1582 ) {
1583 bBigger = TRUE; 1583 bBigger = true;
1584 break; 1584 break;
1585 } 1585 }
1586 } 1586 }
1587 } 1587 }
1588 return bBigger; 1588 return bBigger;
1589 } 1589 }
1590 CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place Range) 1590 CPVT_FloatRect CPDF_VariableText::RearrangeSections(const CPVT_WordRange & Place Range)
1591 { 1591 {
1592 CPVT_WordPlace place; 1592 CPVT_WordPlace place;
1593 FX_FLOAT fPosY = 0; 1593 FX_FLOAT fPosY = 0;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0; 1645 return m_pVTProvider ? m_pVTProvider->GetTypeDescent(nFontIndex) : 0;
1646 } 1646 }
1647 int32_t CPDF_VariableText::GetWordFontIndex(FX_WORD word, int32_t charset, int32 _t nFontIndex) 1647 int32_t CPDF_VariableText::GetWordFontIndex(FX_WORD word, int32_t charset, int32 _t nFontIndex)
1648 { 1648 {
1649 return m_pVTProvider ? m_pVTProvider->GetWordFontIndex(word, charset, nFontI ndex) : -1; 1649 return m_pVTProvider ? m_pVTProvider->GetWordFontIndex(word, charset, nFontI ndex) : -1;
1650 } 1650 }
1651 int32_t CPDF_VariableText::GetDefaultFontIndex() 1651 int32_t CPDF_VariableText::GetDefaultFontIndex()
1652 { 1652 {
1653 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1; 1653 return m_pVTProvider ? m_pVTProvider->GetDefaultFontIndex() : -1;
1654 } 1654 }
1655 FX_BOOL»CPDF_VariableText::IsLatinWord(FX_WORD word) 1655 bool» CPDF_VariableText::IsLatinWord(FX_WORD word)
1656 { 1656 {
1657 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : FALSE; 1657 return m_pVTProvider ? m_pVTProvider->IsLatinWord(word) : false;
1658 } 1658 }
1659 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator() 1659 IPDF_VariableText_Iterator * CPDF_VariableText::GetIterator()
1660 { 1660 {
1661 if (!m_pVTIterator) { 1661 if (!m_pVTIterator) {
1662 m_pVTIterator = new CPDF_VariableText_Iterator(this); 1662 m_pVTIterator = new CPDF_VariableText_Iterator(this);
1663 } 1663 }
1664 return m_pVTIterator; 1664 return m_pVTIterator;
1665 } 1665 }
1666 IPDF_VariableText_Provider* CPDF_VariableText::SetProvider(IPDF_VariableText _Provider * pProvider) 1666 IPDF_VariableText_Provider* CPDF_VariableText::SetProvider(IPDF_VariableText _Provider * pProvider)
1667 { 1667 {
(...skipping 12 matching lines...) Expand all
1680 void CPDF_VariableText_Iterator::SetAt(int32_t nWordIndex) 1680 void CPDF_VariableText_Iterator::SetAt(int32_t nWordIndex)
1681 { 1681 {
1682 ASSERT(m_pVT != NULL); 1682 ASSERT(m_pVT != NULL);
1683 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex); 1683 m_CurPos = m_pVT->WordIndexToWordPlace(nWordIndex);
1684 } 1684 }
1685 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place) 1685 void CPDF_VariableText_Iterator::SetAt(const CPVT_WordPlace & place)
1686 { 1686 {
1687 ASSERT(m_pVT != NULL); 1687 ASSERT(m_pVT != NULL);
1688 m_CurPos = place; 1688 m_CurPos = place;
1689 } 1689 }
1690 FX_BOOL»CPDF_VariableText_Iterator::NextWord() 1690 bool» CPDF_VariableText_Iterator::NextWord()
1691 { 1691 {
1692 if (m_CurPos == m_pVT->GetEndWordPlace()) { 1692 if (m_CurPos == m_pVT->GetEndWordPlace()) {
1693 return FALSE; 1693 return false;
1694 } 1694 }
1695 m_CurPos = m_pVT->GetNextWordPlace(m_CurPos); 1695 m_CurPos = m_pVT->GetNextWordPlace(m_CurPos);
1696 return TRUE; 1696 return true;
1697 } 1697 }
1698 FX_BOOL»CPDF_VariableText_Iterator::PrevWord() 1698 bool» CPDF_VariableText_Iterator::PrevWord()
1699 { 1699 {
1700 if (m_CurPos == m_pVT->GetBeginWordPlace()) { 1700 if (m_CurPos == m_pVT->GetBeginWordPlace()) {
1701 return FALSE; 1701 return false;
1702 } 1702 }
1703 m_CurPos = m_pVT->GetPrevWordPlace(m_CurPos); 1703 m_CurPos = m_pVT->GetPrevWordPlace(m_CurPos);
1704 return TRUE; 1704 return true;
1705 } 1705 }
1706 FX_BOOL»CPDF_VariableText_Iterator::NextLine() 1706 bool» CPDF_VariableText_Iterator::NextLine()
1707 { 1707 {
1708 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1708 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1709 if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) { 1709 if (m_CurPos.nLineIndex < pSection->m_LineArray.GetSize() - 1) {
1710 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1); 1710 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex + 1, -1);
1711 return TRUE; 1711 return true;
1712 } 1712 }
1713 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { 1713 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) {
1714 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); 1714 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1);
1715 return TRUE; 1715 return true;
1716 } 1716 }
1717 } 1717 }
1718 return FALSE; 1718 return false;
1719 } 1719 }
1720 FX_BOOL»CPDF_VariableText_Iterator::PrevLine() 1720 bool» CPDF_VariableText_Iterator::PrevLine()
1721 { 1721 {
1722 if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1722 if (m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1723 if (m_CurPos.nLineIndex > 0) { 1723 if (m_CurPos.nLineIndex > 0) {
1724 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1); 1724 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex - 1, -1);
1725 return TRUE; 1725 return true;
1726 } 1726 }
1727 if (m_CurPos.nSecIndex > 0) { 1727 if (m_CurPos.nSecIndex > 0) {
1728 if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.n SecIndex - 1)) { 1728 if (CSection * pLastSection = m_pVT->m_SectionArray.GetAt(m_CurPos.n SecIndex - 1)) {
1729 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection-> m_LineArray.GetSize() - 1, -1); 1729 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, pLastSection-> m_LineArray.GetSize() - 1, -1);
1730 return TRUE; 1730 return true;
1731 } 1731 }
1732 } 1732 }
1733 } 1733 }
1734 return FALSE; 1734 return false;
1735 } 1735 }
1736 FX_BOOL»CPDF_VariableText_Iterator::NextSection() 1736 bool» CPDF_VariableText_Iterator::NextSection()
1737 { 1737 {
1738 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) { 1738 if (m_CurPos.nSecIndex < m_pVT->m_SectionArray.GetSize() - 1) {
1739 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1); 1739 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex + 1, 0, -1);
1740 return TRUE; 1740 return true;
1741 } 1741 }
1742 return FALSE; 1742 return false;
1743 } 1743 }
1744 FX_BOOL»CPDF_VariableText_Iterator::PrevSection() 1744 bool» CPDF_VariableText_Iterator::PrevSection()
1745 { 1745 {
1746 ASSERT(m_pVT != NULL); 1746 ASSERT(m_pVT != NULL);
1747 if (m_CurPos.nSecIndex > 0) { 1747 if (m_CurPos.nSecIndex > 0) {
1748 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, 0, -1); 1748 m_CurPos = CPVT_WordPlace(m_CurPos.nSecIndex - 1, 0, -1);
1749 return TRUE; 1749 return true;
1750 } 1750 }
1751 return FALSE; 1751 return false;
1752 } 1752 }
1753 FX_BOOL»CPDF_VariableText_Iterator::GetWord(CPVT_Word & word) const 1753 bool» CPDF_VariableText_Iterator::GetWord(CPVT_Word & word) const
1754 { 1754 {
1755 ASSERT(m_pVT != NULL); 1755 ASSERT(m_pVT != NULL);
1756 word.WordPlace = m_CurPos; 1756 word.WordPlace = m_CurPos;
1757 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1757 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1758 if (pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { 1758 if (pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) {
1759 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(m_CurPos.nWo rdIndex)) { 1759 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(m_CurPos.nWo rdIndex)) {
1760 word.Word = pWord->Word; 1760 word.Word = pWord->Word;
1761 word.nCharset = pWord->nCharset; 1761 word.nCharset = pWord->nCharset;
1762 word.fWidth = m_pVT->GetWordWidth(*pWord); 1762 word.fWidth = m_pVT->GetWordWidth(*pWord);
1763 word.ptWord = m_pVT->InToOut( 1763 word.ptWord = m_pVT->InToOut(
1764 CPDF_Point(pWord->fWordX + pSection->m_SecInfo .rcSection.left, 1764 CPDF_Point(pWord->fWordX + pSection->m_SecInfo .rcSection.left,
1765 pWord->fWordY + pSection->m_SecInfo .rcSection.top) ); 1765 pWord->fWordY + pSection->m_SecInfo .rcSection.top) );
1766 word.fAscent = m_pVT->GetWordAscent(*pWord); 1766 word.fAscent = m_pVT->GetWordAscent(*pWord);
1767 word.fDescent = m_pVT->GetWordDescent(*pWord); 1767 word.fDescent = m_pVT->GetWordDescent(*pWord);
1768 if (pWord->pWordProps) { 1768 if (pWord->pWordProps) {
1769 word.WordProps = *pWord->pWordProps; 1769 word.WordProps = *pWord->pWordProps;
1770 } 1770 }
1771 word.nFontIndex = m_pVT->GetWordFontIndex(*pWord); 1771 word.nFontIndex = m_pVT->GetWordFontIndex(*pWord);
1772 word.fFontSize = m_pVT->GetWordFontSize(*pWord); 1772 word.fFontSize = m_pVT->GetWordFontSize(*pWord);
1773 return TRUE; 1773 return true;
1774 } 1774 }
1775 } 1775 }
1776 } 1776 }
1777 return FALSE; 1777 return false;
1778 } 1778 }
1779 FX_BOOL»CPDF_VariableText_Iterator::SetWord(const CPVT_Word & word) 1779 bool» CPDF_VariableText_Iterator::SetWord(const CPVT_Word & word)
1780 { 1780 {
1781 ASSERT(m_pVT != NULL); 1781 ASSERT(m_pVT != NULL);
1782 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1782 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1783 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(m_CurPos.nWordIn dex)) { 1783 if (CPVT_WordInfo * pWord = pSection->m_WordArray.GetAt(m_CurPos.nWordIn dex)) {
1784 if (pWord->pWordProps) { 1784 if (pWord->pWordProps) {
1785 *pWord->pWordProps = word.WordProps; 1785 *pWord->pWordProps = word.WordProps;
1786 } 1786 }
1787 return TRUE; 1787 return true;
1788 } 1788 }
1789 } 1789 }
1790 return FALSE; 1790 return false;
1791 } 1791 }
1792 FX_BOOL»CPDF_VariableText_Iterator::GetLine(CPVT_Line & line) const 1792 bool» CPDF_VariableText_Iterator::GetLine(CPVT_Line & line) const
1793 { 1793 {
1794 ASSERT(m_pVT != NULL); 1794 ASSERT(m_pVT != NULL);
1795 line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1) ; 1795 line.lineplace = CPVT_WordPlace(m_CurPos.nSecIndex, m_CurPos.nLineIndex, -1) ;
1796 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1796 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1797 if (CLine * pLine = pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) { 1797 if (CLine * pLine = pSection->m_LineArray.GetAt(m_CurPos.nLineIndex)) {
1798 line.ptLine = m_pVT->InToOut( 1798 line.ptLine = m_pVT->InToOut(
1799 CPDF_Point(pLine->m_LineInfo.fLineX + pSection->m_ SecInfo.rcSection.left, 1799 CPDF_Point(pLine->m_LineInfo.fLineX + pSection->m_ SecInfo.rcSection.left,
1800 pLine->m_LineInfo.fLineY + pSection->m_ SecInfo.rcSection.top) ); 1800 pLine->m_LineInfo.fLineY + pSection->m_ SecInfo.rcSection.top) );
1801 line.fLineWidth = pLine->m_LineInfo.fLineWidth; 1801 line.fLineWidth = pLine->m_LineInfo.fLineWidth;
1802 line.fLineAscent = pLine->m_LineInfo.fLineAscent; 1802 line.fLineAscent = pLine->m_LineInfo.fLineAscent;
1803 line.fLineDescent = pLine->m_LineInfo.fLineDescent; 1803 line.fLineDescent = pLine->m_LineInfo.fLineDescent;
1804 line.lineEnd = pLine->GetEndWordPlace(); 1804 line.lineEnd = pLine->GetEndWordPlace();
1805 return TRUE; 1805 return true;
1806 } 1806 }
1807 } 1807 }
1808 return FALSE; 1808 return false;
1809 } 1809 }
1810 FX_BOOL»CPDF_VariableText_Iterator::GetSection(CPVT_Section & section) const 1810 bool» CPDF_VariableText_Iterator::GetSection(CPVT_Section & section) const
1811 { 1811 {
1812 ASSERT(m_pVT != NULL); 1812 ASSERT(m_pVT != NULL);
1813 section.secplace = CPVT_WordPlace(m_CurPos.nSecIndex, 0, -1); 1813 section.secplace = CPVT_WordPlace(m_CurPos.nSecIndex, 0, -1);
1814 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1814 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1815 section.rcSection = m_pVT->InToOut(pSection->m_SecInfo.rcSection); 1815 section.rcSection = m_pVT->InToOut(pSection->m_SecInfo.rcSection);
1816 if (pSection->m_SecInfo.pSecProps) { 1816 if (pSection->m_SecInfo.pSecProps) {
1817 section.SecProps = *pSection->m_SecInfo.pSecProps; 1817 section.SecProps = *pSection->m_SecInfo.pSecProps;
1818 } 1818 }
1819 if (pSection->m_SecInfo.pWordProps) { 1819 if (pSection->m_SecInfo.pWordProps) {
1820 section.WordProps = *pSection->m_SecInfo.pWordProps; 1820 section.WordProps = *pSection->m_SecInfo.pWordProps;
1821 } 1821 }
1822 return TRUE; 1822 return true;
1823 } 1823 }
1824 return FALSE; 1824 return false;
1825 } 1825 }
1826 FX_BOOL»CPDF_VariableText_Iterator::SetSection(const CPVT_Section & section) 1826 bool» CPDF_VariableText_Iterator::SetSection(const CPVT_Section & section)
1827 { 1827 {
1828 ASSERT(m_pVT != NULL); 1828 ASSERT(m_pVT != NULL);
1829 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) { 1829 if (CSection * pSection = m_pVT->m_SectionArray.GetAt(m_CurPos.nSecIndex)) {
1830 if (pSection->m_SecInfo.pSecProps) { 1830 if (pSection->m_SecInfo.pSecProps) {
1831 *pSection->m_SecInfo.pSecProps = section.SecProps; 1831 *pSection->m_SecInfo.pSecProps = section.SecProps;
1832 } 1832 }
1833 if (pSection->m_SecInfo.pWordProps) { 1833 if (pSection->m_SecInfo.pWordProps) {
1834 *pSection->m_SecInfo.pWordProps = section.WordProps; 1834 *pSection->m_SecInfo.pWordProps = section.WordProps;
1835 } 1835 }
1836 return TRUE; 1836 return true;
1837 } 1837 }
1838 return FALSE; 1838 return false;
1839 } 1839 }
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