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

Side by Side Diff: xfa/fde/cfde_txtedtengine.cpp

Issue 2557103002: Cleanup FWL default values part II. (Closed)
Patch Set: Rebase to master Created 4 years 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 | « xfa/fde/cfde_txtedtengine.h ('k') | xfa/fwl/core/cfwl_combobox.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 "xfa/fde/cfde_txtedtengine.h" 7 #include "xfa/fde/cfde_txtedtengine.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "third_party/base/ptr_util.h"
11 #include "xfa/fde/cfde_txtedtbuf.h" 12 #include "xfa/fde/cfde_txtedtbuf.h"
12 #include "xfa/fde/cfde_txtedtbufiter.h" 13 #include "xfa/fde/cfde_txtedtbufiter.h"
13 #include "xfa/fde/cfde_txtedtdorecord_deleterange.h" 14 #include "xfa/fde/cfde_txtedtdorecord_deleterange.h"
14 #include "xfa/fde/cfde_txtedtdorecord_insert.h" 15 #include "xfa/fde/cfde_txtedtdorecord_insert.h"
15 #include "xfa/fde/cfde_txtedtpage.h" 16 #include "xfa/fde/cfde_txtedtpage.h"
16 #include "xfa/fde/cfde_txtedtparag.h" 17 #include "xfa/fde/cfde_txtedtparag.h"
17 #include "xfa/fde/ifx_chariter.h" 18 #include "xfa/fde/ifx_chariter.h"
18 #include "xfa/fde/tto/fde_textout.h" 19 #include "xfa/fde/tto/fde_textout.h"
19 #include "xfa/fgas/layout/fgas_textbreak.h" 20 #include "xfa/fgas/layout/fgas_textbreak.h"
20 #include "xfa/fwl/core/cfwl_edit.h" 21 #include "xfa/fwl/core/cfwl_edit.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 m_nCaret = nIndex; 201 m_nCaret = nIndex;
201 MovePage2Char(m_nCaret); 202 MovePage2Char(m_nCaret);
202 GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); 203 GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore);
203 if (!m_bBefore) { 204 if (!m_bBefore) {
204 m_nCaret++; 205 m_nCaret++;
205 m_bBefore = true; 206 m_bBefore = true;
206 } 207 }
207 m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) 208 m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical)
208 ? m_rtCaret.top 209 ? m_rtCaret.top
209 : m_rtCaret.left; 210 : m_rtCaret.left;
210 m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); 211 m_Param.pEventSink->OnCaretChanged();
211 m_nAnchorPos = -1; 212 m_nAnchorPos = -1;
212 return m_nCaret; 213 return m_nCaret;
213 } 214 }
214 215
215 int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret, 216 int32_t CFDE_TxtEdtEngine::MoveCaretPos(FDE_TXTEDTMOVECARET eMoveCaret,
216 bool bShift, 217 bool bShift,
217 bool bCtrl) { 218 bool bCtrl) {
218 if (IsLocked()) { 219 if (IsLocked()) {
219 return 0; 220 return 0;
220 } 221 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 break; 317 break;
317 case MC_End: 318 case MC_End:
318 MoveEnd(); 319 MoveEnd();
319 break; 320 break;
320 default: 321 default:
321 break; 322 break;
322 } 323 }
323 if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) { 324 if (bShift && m_nAnchorPos != -1 && (m_nAnchorPos != m_nCaret)) {
324 AddSelRange(std::min(m_nAnchorPos, m_nCaret), 325 AddSelRange(std::min(m_nAnchorPos, m_nCaret),
325 FXSYS_abs(m_nAnchorPos - m_nCaret)); 326 FXSYS_abs(m_nAnchorPos - m_nCaret));
326 m_Param.pEventSink->On_SelChanged(this); 327 m_Param.pEventSink->OnSelChanged();
327 } 328 }
328 if (bSelChange) { 329 if (bSelChange)
329 m_Param.pEventSink->On_SelChanged(this); 330 m_Param.pEventSink->OnSelChanged();
330 } 331
331 return m_nCaret; 332 return m_nCaret;
332 } 333 }
333 334
334 void CFDE_TxtEdtEngine::Lock() { 335 void CFDE_TxtEdtEngine::Lock() {
335 m_bLock = true; 336 m_bLock = true;
336 } 337 }
337 338
338 void CFDE_TxtEdtEngine::Unlock() { 339 void CFDE_TxtEdtEngine::Unlock() {
339 m_bLock = false; 340 m_bLock = false;
340 } 341 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 } 400 }
400 if (nLength == 0) { 401 if (nLength == 0) {
401 return FDE_TXTEDT_MODIFY_RET_F_Full; 402 return FDE_TXTEDT_MODIFY_RET_F_Full;
402 } 403 }
403 if (nLength < nTemp) { 404 if (nLength < nTemp) {
404 bPart = true; 405 bPart = true;
405 } 406 }
406 } 407 }
407 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { 408 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
408 CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength); 409 CFX_WideString wsText = GetPreInsertText(m_nCaret, lpBuffer, nLength);
409 if (!m_Param.pEventSink->On_Validate(this, wsText)) { 410 if (!m_Param.pEventSink->OnValidate(wsText))
410 return FDE_TXTEDT_MODIFY_RET_F_Invalidate; 411 return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
411 }
412 } 412 }
413 if (IsSelect()) { 413 if (IsSelect()) {
414 DeleteSelect(); 414 DeleteSelect();
415 } 415 }
416 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) 416 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo))
417 m_Param.pEventSink->On_AddDoRecord( 417 m_Param.pEventSink->OnAddDoRecord(
418 this, 418 pdfium::MakeUnique<CFDE_TxtEdtDoRecord_Insert>(this, m_nCaret, lpBuffer,
419 new CFDE_TxtEdtDoRecord_Insert(this, m_nCaret, lpBuffer, nLength)); 419 nLength));
420 420
421 m_ChangeInfo.wsPrevText = GetText(0); 421 m_ChangeInfo.wsPrevText = GetText(0, -1);
422 Inner_Insert(m_nCaret, lpBuffer, nLength); 422 Inner_Insert(m_nCaret, lpBuffer, nLength);
423 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert; 423 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Insert;
424 m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength); 424 m_ChangeInfo.wsInsert = CFX_WideString(lpBuffer, nLength);
425 nStart = m_nCaret; 425 nStart = m_nCaret;
426 nStart += nLength; 426 nStart += nLength;
427 FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); 427 FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1);
428 bool bBefore = true; 428 bool bBefore = true;
429 if (wChar != L'\n' && wChar != L'\r') { 429 if (wChar != L'\n' && wChar != L'\r') {
430 nStart--; 430 nStart--;
431 bBefore = false; 431 bBefore = false;
432 } 432 }
433 SetCaretPos(nStart, bBefore); 433 SetCaretPos(nStart, bBefore);
434 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); 434 m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
435 return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal; 435 return bPart ? FDE_TXTEDT_MODIFY_RET_S_Part : FDE_TXTEDT_MODIFY_RET_S_Normal;
436 } 436 }
437 437
438 int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) { 438 int32_t CFDE_TxtEdtEngine::Delete(int32_t nStart, bool bBackspace) {
439 if (IsLocked()) { 439 if (IsLocked()) {
440 return FDE_TXTEDT_MODIFY_RET_F_Locked; 440 return FDE_TXTEDT_MODIFY_RET_F_Locked;
441 } 441 }
442 if (IsSelect()) { 442 if (IsSelect()) {
443 DeleteSelect(); 443 DeleteSelect();
444 return FDE_TXTEDT_MODIFY_RET_S_Normal; 444 return FDE_TXTEDT_MODIFY_RET_S_Normal;
(...skipping 15 matching lines...) Expand all
460 return FDE_TXTEDT_MODIFY_RET_F_Full; 460 return FDE_TXTEDT_MODIFY_RET_F_Full;
461 } 461 }
462 if ((nStart + 1 < GetTextBufLength()) && 462 if ((nStart + 1 < GetTextBufLength()) &&
463 (m_pTxtBuf->GetCharByIndex(nStart) == L'\r') && 463 (m_pTxtBuf->GetCharByIndex(nStart) == L'\r') &&
464 (m_pTxtBuf->GetCharByIndex(nStart + 1) == L'\n')) { 464 (m_pTxtBuf->GetCharByIndex(nStart + 1) == L'\n')) {
465 nCount++; 465 nCount++;
466 } 466 }
467 } 467 }
468 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { 468 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
469 CFX_WideString wsText = GetPreDeleteText(nStart, nCount); 469 CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
470 if (!m_Param.pEventSink->On_Validate(this, wsText)) { 470 if (!m_Param.pEventSink->OnValidate(wsText))
471 return FDE_TXTEDT_MODIFY_RET_F_Invalidate; 471 return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
472 }
473 } 472 }
474 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { 473 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
475 CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount); 474 CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount);
476 m_Param.pEventSink->On_AddDoRecord( 475 m_Param.pEventSink->OnAddDoRecord(
477 this, 476 pdfium::MakeUnique<CFDE_TxtEdtDoRecord_DeleteRange>(this, nStart,
478 new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, wsRange)); 477 m_nCaret, wsRange));
479 } 478 }
480 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; 479 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
481 m_ChangeInfo.wsDelete = GetText(nStart, nCount); 480 m_ChangeInfo.wsDelete = GetText(nStart, nCount);
482 Inner_DeleteRange(nStart, nCount); 481 Inner_DeleteRange(nStart, nCount);
483 SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0), 482 SetCaretPos(nStart + ((!bBackspace && nStart > 0) ? -1 : 0),
484 (bBackspace || nStart == 0)); 483 (bBackspace || nStart == 0));
485 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); 484 m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
486 return FDE_TXTEDT_MODIFY_RET_S_Normal; 485 return FDE_TXTEDT_MODIFY_RET_S_Normal;
487 } 486 }
488 487
489 int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) { 488 int32_t CFDE_TxtEdtEngine::DeleteRange(int32_t nStart, int32_t nCount) {
490 if (IsLocked()) { 489 if (IsLocked())
491 return FDE_TXTEDT_MODIFY_RET_F_Locked; 490 return FDE_TXTEDT_MODIFY_RET_F_Locked;
492 } 491 if (nCount == -1)
493 if (nCount == -1) {
494 nCount = GetTextBufLength(); 492 nCount = GetTextBufLength();
495 } 493 if (nCount == 0)
496 if (nCount == 0) {
497 return FDE_TXTEDT_MODIFY_RET_S_Normal; 494 return FDE_TXTEDT_MODIFY_RET_S_Normal;
498 }
499 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { 495 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
500 CFX_WideString wsText = GetPreDeleteText(nStart, nCount); 496 CFX_WideString wsText = GetPreDeleteText(nStart, nCount);
501 if (!m_Param.pEventSink->On_Validate(this, wsText)) { 497 if (!m_Param.pEventSink->OnValidate(wsText))
502 return FDE_TXTEDT_MODIFY_RET_F_Invalidate; 498 return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
503 }
504 } 499 }
505 DeleteRange_DoRecord(nStart, nCount); 500 DeleteRange_DoRecord(nStart, nCount);
506 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); 501 m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
507 SetCaretPos(nStart, true); 502 SetCaretPos(nStart, true);
508 return FDE_TXTEDT_MODIFY_RET_S_Normal; 503 return FDE_TXTEDT_MODIFY_RET_S_Normal;
509 } 504 }
510 505
511 int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart, 506 int32_t CFDE_TxtEdtEngine::Replace(int32_t nStart,
512 int32_t nLength, 507 int32_t nLength,
513 const CFX_WideString& wsReplace) { 508 const CFX_WideString& wsReplace) {
514 if (IsLocked()) { 509 if (IsLocked())
515 return FDE_TXTEDT_MODIFY_RET_F_Locked; 510 return FDE_TXTEDT_MODIFY_RET_F_Locked;
516 } 511 if (nStart < 0 || (nStart + nLength > GetTextBufLength()))
517 if (nStart < 0 || (nStart + nLength > GetTextBufLength())) {
518 return FDE_TXTEDT_MODIFY_RET_F_Boundary; 512 return FDE_TXTEDT_MODIFY_RET_F_Boundary;
519 }
520 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) { 513 if (m_Param.dwMode & FDE_TEXTEDITMODE_Validate) {
521 CFX_WideString wsText = GetPreReplaceText( 514 CFX_WideString wsText = GetPreReplaceText(
522 nStart, nLength, wsReplace.c_str(), wsReplace.GetLength()); 515 nStart, nLength, wsReplace.c_str(), wsReplace.GetLength());
523 if (!m_Param.pEventSink->On_Validate(this, wsText)) { 516 if (!m_Param.pEventSink->OnValidate(wsText))
524 return FDE_TXTEDT_MODIFY_RET_F_Invalidate; 517 return FDE_TXTEDT_MODIFY_RET_F_Invalidate;
525 }
526 } 518 }
527 if (IsSelect()) { 519 if (IsSelect())
528 ClearSelection(); 520 ClearSelection();
529 } 521
530 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace; 522 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Replace;
531 m_ChangeInfo.wsDelete = GetText(nStart, nLength); 523 m_ChangeInfo.wsDelete = GetText(nStart, nLength);
532 if (nLength > 0) { 524 if (nLength > 0)
533 Inner_DeleteRange(nStart, nLength); 525 Inner_DeleteRange(nStart, nLength);
534 } 526
535 int32_t nTextLength = wsReplace.GetLength(); 527 int32_t nTextLength = wsReplace.GetLength();
536 if (nTextLength > 0) { 528 if (nTextLength > 0)
537 Inner_Insert(nStart, wsReplace.c_str(), nTextLength); 529 Inner_Insert(nStart, wsReplace.c_str(), nTextLength);
538 } 530
539 m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength); 531 m_ChangeInfo.wsInsert = CFX_WideString(wsReplace.c_str(), nTextLength);
540 nStart += nTextLength; 532 nStart += nTextLength;
541 FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1); 533 FX_WCHAR wChar = m_pTxtBuf->GetCharByIndex(nStart - 1);
542 bool bBefore = true; 534 bool bBefore = true;
543 if (wChar != L'\n' && wChar != L'\r') { 535 if (wChar != L'\n' && wChar != L'\r') {
544 nStart--; 536 nStart--;
545 bBefore = false; 537 bBefore = false;
546 } 538 }
547 SetCaretPos(nStart, bBefore); 539 SetCaretPos(nStart, bBefore);
548 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 540 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
549 m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); 541 m_Param.pEventSink->OnPageLoad(m_nCaretPage);
550 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); 542 m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
551 return FDE_TXTEDT_MODIFY_RET_S_Normal; 543 return FDE_TXTEDT_MODIFY_RET_S_Normal;
552 } 544 }
553 545
554 void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) { 546 void CFDE_TxtEdtEngine::SetLimit(int32_t nLimit) {
555 m_nLimit = nLimit; 547 m_nLimit = nLimit;
556 } 548 }
557 549
558 void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) { 550 void CFDE_TxtEdtEngine::SetAliasChar(FX_WCHAR wcAlias) {
559 m_wcAliasChar = wcAlias; 551 m_wcAliasChar = wcAlias;
560 } 552 }
(...skipping 15 matching lines...) Expand all
576 void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) { 568 void CFDE_TxtEdtEngine::AddSelRange(int32_t nStart, int32_t nCount) {
577 if (nCount == -1) { 569 if (nCount == -1) {
578 nCount = GetTextLength() - nStart; 570 nCount = GetTextLength() - nStart;
579 } 571 }
580 int32_t nSize = m_SelRangePtrArr.GetSize(); 572 int32_t nSize = m_SelRangePtrArr.GetSize();
581 if (nSize <= 0) { 573 if (nSize <= 0) {
582 FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE; 574 FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE;
583 lpSelRange->nStart = nStart; 575 lpSelRange->nStart = nStart;
584 lpSelRange->nCount = nCount; 576 lpSelRange->nCount = nCount;
585 m_SelRangePtrArr.Add(lpSelRange); 577 m_SelRangePtrArr.Add(lpSelRange);
586 m_Param.pEventSink->On_SelChanged(this); 578 m_Param.pEventSink->OnSelChanged();
587 return; 579 return;
588 } 580 }
589 FDE_TXTEDTSELRANGE* lpTemp = nullptr; 581 FDE_TXTEDTSELRANGE* lpTemp = nullptr;
590 lpTemp = m_SelRangePtrArr[nSize - 1]; 582 lpTemp = m_SelRangePtrArr[nSize - 1];
591 if (nStart >= lpTemp->nStart + lpTemp->nCount) { 583 if (nStart >= lpTemp->nStart + lpTemp->nCount) {
592 FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE; 584 FDE_TXTEDTSELRANGE* lpSelRange = new FDE_TXTEDTSELRANGE;
593 lpSelRange->nStart = nStart; 585 lpSelRange->nStart = nStart;
594 lpSelRange->nCount = nCount; 586 lpSelRange->nCount = nCount;
595 m_SelRangePtrArr.Add(lpSelRange); 587 m_SelRangePtrArr.Add(lpSelRange);
596 m_Param.pEventSink->On_SelChanged(this); 588 m_Param.pEventSink->OnSelChanged();
597 return; 589 return;
598 } 590 }
599 int32_t nEnd = nStart + nCount - 1; 591 int32_t nEnd = nStart + nCount - 1;
600 bool bBegin = false; 592 bool bBegin = false;
601 int32_t nRangeBgn = 0; 593 int32_t nRangeBgn = 0;
602 int32_t nRangeCnt = 0; 594 int32_t nRangeCnt = 0;
603 for (int32_t i = 0; i < nSize; i++) { 595 for (int32_t i = 0; i < nSize; i++) {
604 lpTemp = m_SelRangePtrArr[i]; 596 lpTemp = m_SelRangePtrArr[i];
605 int32_t nTempBgn = lpTemp->nStart; 597 int32_t nTempBgn = lpTemp->nStart;
606 int32_t nTempEnd = nTempBgn + lpTemp->nCount - 1; 598 int32_t nTempEnd = nTempBgn + lpTemp->nCount - 1;
(...skipping 25 matching lines...) Expand all
632 lpTemp = m_SelRangePtrArr[nRangeBgn]; 624 lpTemp = m_SelRangePtrArr[nRangeBgn];
633 lpTemp->nStart = nStart; 625 lpTemp->nStart = nStart;
634 lpTemp->nCount = nCount; 626 lpTemp->nCount = nCount;
635 nRangeCnt--; 627 nRangeCnt--;
636 nRangeBgn++; 628 nRangeBgn++;
637 while (nRangeCnt--) { 629 while (nRangeCnt--) {
638 delete m_SelRangePtrArr[nRangeBgn]; 630 delete m_SelRangePtrArr[nRangeBgn];
639 m_SelRangePtrArr.RemoveAt(nRangeBgn); 631 m_SelRangePtrArr.RemoveAt(nRangeBgn);
640 } 632 }
641 } 633 }
642 m_Param.pEventSink->On_SelChanged(this); 634 m_Param.pEventSink->OnSelChanged();
643 } 635 }
644 636
645 int32_t CFDE_TxtEdtEngine::CountSelRanges() const { 637 int32_t CFDE_TxtEdtEngine::CountSelRanges() const {
646 return m_SelRangePtrArr.GetSize(); 638 return m_SelRangePtrArr.GetSize();
647 } 639 }
648 640
649 int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t& nStart) const { 641 int32_t CFDE_TxtEdtEngine::GetSelRange(int32_t nIndex, int32_t* nStart) const {
650 nStart = m_SelRangePtrArr[nIndex]->nStart; 642 if (nStart)
643 *nStart = m_SelRangePtrArr[nIndex]->nStart;
651 return m_SelRangePtrArr[nIndex]->nCount; 644 return m_SelRangePtrArr[nIndex]->nCount;
652 } 645 }
653 646
654 void CFDE_TxtEdtEngine::ClearSelection() { 647 void CFDE_TxtEdtEngine::ClearSelection() {
655 int32_t nCount = m_SelRangePtrArr.GetSize(); 648 int32_t nCount = m_SelRangePtrArr.GetSize();
656 for (int i = 0; i < nCount; ++i) 649 for (int i = 0; i < nCount; ++i)
657 delete m_SelRangePtrArr[i]; 650 delete m_SelRangePtrArr[i];
658 m_SelRangePtrArr.RemoveAll(); 651 m_SelRangePtrArr.RemoveAll();
659 if (nCount && m_Param.pEventSink) 652 if (nCount && m_Param.pEventSink)
660 m_Param.pEventSink->On_SelChanged(this); 653 m_Param.pEventSink->OnSelChanged();
661 } 654 }
662 655
663 bool CFDE_TxtEdtEngine::Redo(const IFDE_TxtEdtDoRecord* pDoRecord) { 656 bool CFDE_TxtEdtEngine::Redo(const IFDE_TxtEdtDoRecord* pDoRecord) {
664 if (IsLocked()) 657 if (IsLocked())
665 return false; 658 return false;
666 if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo) 659 if (m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)
667 return false; 660 return false;
668 return pDoRecord->Redo(); 661 return pDoRecord->Redo();
669 } 662 }
670 663
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } 773 }
781 774
782 CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex, 775 CFX_WideString CFDE_TxtEdtEngine::GetPreInsertText(int32_t nIndex,
783 const FX_WCHAR* lpText, 776 const FX_WCHAR* lpText,
784 int32_t nLength) { 777 int32_t nLength) {
785 CFX_WideString wsText = GetText(0, GetTextBufLength()); 778 CFX_WideString wsText = GetText(0, GetTextBufLength());
786 int32_t nSelIndex = 0; 779 int32_t nSelIndex = 0;
787 int32_t nSelLength = 0; 780 int32_t nSelLength = 0;
788 int32_t nSelCount = CountSelRanges(); 781 int32_t nSelCount = CountSelRanges();
789 while (nSelCount--) { 782 while (nSelCount--) {
790 nSelLength = GetSelRange(nSelCount, nSelIndex); 783 nSelLength = GetSelRange(nSelCount, &nSelIndex);
791 wsText.Delete(nSelIndex, nSelLength); 784 wsText.Delete(nSelIndex, nSelLength);
792 nIndex = nSelIndex; 785 nIndex = nSelIndex;
793 } 786 }
794 CFX_WideString wsTemp; 787 CFX_WideString wsTemp;
795 int32_t nOldLength = wsText.GetLength(); 788 int32_t nOldLength = wsText.GetLength();
796 const FX_WCHAR* pOldBuffer = wsText.c_str(); 789 const FX_WCHAR* pOldBuffer = wsText.c_str();
797 FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nOldLength + nLength); 790 FX_WCHAR* lpBuffer = wsTemp.GetBuffer(nOldLength + nLength);
798 FXSYS_memcpy(lpBuffer, pOldBuffer, (nIndex) * sizeof(FX_WCHAR)); 791 FXSYS_memcpy(lpBuffer, pOldBuffer, (nIndex) * sizeof(FX_WCHAR));
799 FXSYS_memcpy(lpBuffer + nIndex, lpText, nLength * sizeof(FX_WCHAR)); 792 FXSYS_memcpy(lpBuffer + nIndex, lpText, nLength * sizeof(FX_WCHAR));
800 FXSYS_memcpy(lpBuffer + nIndex + nLength, pOldBuffer + nIndex, 793 FXSYS_memcpy(lpBuffer + nIndex + nLength, pOldBuffer + nIndex,
801 (nOldLength - nIndex) * sizeof(FX_WCHAR)); 794 (nOldLength - nIndex) * sizeof(FX_WCHAR));
802 wsTemp.ReleaseBuffer(nOldLength + nLength); 795 wsTemp.ReleaseBuffer(nOldLength + nLength);
803 wsText = wsTemp; 796 wsText = wsTemp;
804 return wsText; 797 return wsText;
805 } 798 }
806 799
807 CFX_WideString CFDE_TxtEdtEngine::GetPreReplaceText(int32_t nIndex, 800 CFX_WideString CFDE_TxtEdtEngine::GetPreReplaceText(int32_t nIndex,
808 int32_t nOriginLength, 801 int32_t nOriginLength,
809 const FX_WCHAR* lpText, 802 const FX_WCHAR* lpText,
810 int32_t nLength) { 803 int32_t nLength) {
811 CFX_WideString wsText = GetText(0, GetTextBufLength()); 804 CFX_WideString wsText = GetText(0, GetTextBufLength());
812 int32_t nSelIndex = 0; 805 int32_t nSelIndex = 0;
813 int32_t nSelLength = 0; 806 int32_t nSelLength = 0;
814 int32_t nSelCount = CountSelRanges(); 807 int32_t nSelCount = CountSelRanges();
815 while (nSelCount--) { 808 while (nSelCount--) {
816 nSelLength = GetSelRange(nSelCount, nSelIndex); 809 nSelLength = GetSelRange(nSelCount, &nSelIndex);
817 wsText.Delete(nSelIndex, nSelLength); 810 wsText.Delete(nSelIndex, nSelLength);
818 } 811 }
819 wsText.Delete(nIndex, nOriginLength); 812 wsText.Delete(nIndex, nOriginLength);
820 int32_t i = 0; 813 int32_t i = 0;
821 for (i = 0; i < nLength; i++) 814 for (i = 0; i < nLength; i++)
822 wsText.Insert(nIndex++, lpText[i]); 815 wsText.Insert(nIndex++, lpText[i]);
823 816
824 return wsText; 817 return wsText;
825 } 818 }
826 819
827 void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart, 820 void CFDE_TxtEdtEngine::Inner_Insert(int32_t nStart,
828 const FX_WCHAR* lpText, 821 const FX_WCHAR* lpText,
829 int32_t nLength) { 822 int32_t nLength) {
830 ASSERT(nLength > 0); 823 ASSERT(nLength > 0);
831 FDE_TXTEDTPARAGPOS ParagPos; 824 FDE_TXTEDTPARAGPOS ParagPos;
832 TextPos2ParagPos(nStart, ParagPos); 825 TextPos2ParagPos(nStart, ParagPos);
833 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 826 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
834 int32_t nParagCount = m_ParagPtrArray.GetSize(); 827 int32_t nParagCount = m_ParagPtrArray.GetSize();
835 int32_t i = 0; 828 int32_t i = 0;
836 for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++) 829 for (i = ParagPos.nParagIndex + 1; i < nParagCount; i++)
837 m_ParagPtrArray[i]->IncrementStartIndex(nLength); 830 m_ParagPtrArray[i]->IncrementStartIndex(nLength);
838 831
839 CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex]; 832 CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPos.nParagIndex];
840 int32_t nReserveLineCount = pParag->GetLineCount(); 833 int32_t nReserveLineCount = pParag->GetLineCount();
841 int32_t nReserveCharStart = pParag->GetStartIndex(); 834 int32_t nReserveCharStart = pParag->GetStartIndex();
842 int32_t nLeavePart = ParagPos.nCharIndex; 835 int32_t nLeavePart = ParagPos.nCharIndex;
843 int32_t nCutPart = pParag->GetTextLength() - ParagPos.nCharIndex; 836 int32_t nCutPart = pParag->GetTextLength() - ParagPos.nCharIndex;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 m_ParagPtrArray.InsertAt(++nParagIndex, pParag); 870 m_ParagPtrArray.InsertAt(++nParagIndex, pParag);
878 } 871 }
879 m_pTxtBuf->Insert(nStart, lpText, nLength); 872 m_pTxtBuf->Insert(nStart, lpText, nLength);
880 int32_t nTotalLineCount = 0; 873 int32_t nTotalLineCount = 0;
881 for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) { 874 for (i = ParagPos.nParagIndex; i <= nParagIndex; i++) {
882 pParag = m_ParagPtrArray[i]; 875 pParag = m_ParagPtrArray[i];
883 pParag->CalcLines(); 876 pParag->CalcLines();
884 nTotalLineCount += pParag->GetLineCount(); 877 nTotalLineCount += pParag->GetLineCount();
885 } 878 }
886 m_nLineCount += nTotalLineCount - nReserveLineCount; 879 m_nLineCount += nTotalLineCount - nReserveLineCount;
887 m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); 880 m_Param.pEventSink->OnPageLoad(m_nCaretPage);
888 UpdatePages(); 881 UpdatePages();
889 } 882 }
890 883
891 void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) { 884 void CFDE_TxtEdtEngine::Inner_DeleteRange(int32_t nStart, int32_t nCount) {
892 if (nCount == -1) { 885 if (nCount == -1) {
893 nCount = m_pTxtBuf->GetTextLength() - nStart; 886 nCount = m_pTxtBuf->GetTextLength() - nStart;
894 } 887 }
895 int32_t nEnd = nStart + nCount - 1; 888 int32_t nEnd = nStart + nCount - 1;
896 ASSERT(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength()); 889 ASSERT(nStart >= 0 && nEnd < m_pTxtBuf->GetTextLength());
897 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 890 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
898 FDE_TXTEDTPARAGPOS ParagPosBgn, ParagPosEnd; 891 FDE_TXTEDTPARAGPOS ParagPosBgn, ParagPosEnd;
899 TextPos2ParagPos(nStart, ParagPosBgn); 892 TextPos2ParagPos(nStart, ParagPosBgn);
900 TextPos2ParagPos(nEnd, ParagPosEnd); 893 TextPos2ParagPos(nEnd, ParagPosEnd);
901 CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPosEnd.nParagIndex]; 894 CFDE_TxtEdtParag* pParag = m_ParagPtrArray[ParagPosEnd.nParagIndex];
902 bool bLastParag = false; 895 bool bLastParag = false;
903 if (ParagPosEnd.nCharIndex == pParag->GetTextLength() - 1) { 896 if (ParagPosEnd.nCharIndex == pParag->GetTextLength() - 1) {
904 if (ParagPosEnd.nParagIndex < m_ParagPtrArray.GetSize() - 1) { 897 if (ParagPosEnd.nParagIndex < m_ParagPtrArray.GetSize() - 1) {
905 ParagPosEnd.nParagIndex++; 898 ParagPosEnd.nParagIndex++;
906 } else { 899 } else {
907 bLastParag = true; 900 bLastParag = true;
(...skipping 25 matching lines...) Expand all
933 int32_t nParagCount = m_ParagPtrArray.GetSize(); 926 int32_t nParagCount = m_ParagPtrArray.GetSize();
934 for (i = nNextParagIndex; i < nParagCount; i++) 927 for (i = nNextParagIndex; i < nParagCount; i++)
935 m_ParagPtrArray[i]->DecrementStartIndex(nCount); 928 m_ParagPtrArray[i]->DecrementStartIndex(nCount);
936 929
937 m_nLineCount -= nTotalLineCount; 930 m_nLineCount -= nTotalLineCount;
938 UpdatePages(); 931 UpdatePages();
939 int32_t nPageCount = CountPages(); 932 int32_t nPageCount = CountPages();
940 if (m_nCaretPage >= nPageCount) { 933 if (m_nCaretPage >= nPageCount) {
941 m_nCaretPage = nPageCount - 1; 934 m_nCaretPage = nPageCount - 1;
942 } 935 }
943 m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); 936 m_Param.pEventSink->OnPageLoad(m_nCaretPage);
944 } 937 }
945 938
946 void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart, 939 void CFDE_TxtEdtEngine::DeleteRange_DoRecord(int32_t nStart,
947 int32_t nCount, 940 int32_t nCount,
948 bool bSel) { 941 bool bSel) {
949 ASSERT(nStart >= 0); 942 ASSERT(nStart >= 0);
950 if (nCount == -1) { 943 if (nCount == -1) {
951 nCount = GetTextLength() - nStart; 944 nCount = GetTextLength() - nStart;
952 } 945 }
953 ASSERT((nStart + nCount) <= m_pTxtBuf->GetTextLength()); 946 ASSERT((nStart + nCount) <= m_pTxtBuf->GetTextLength());
954 947
955 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) { 948 if (!(m_Param.dwMode & FDE_TEXTEDITMODE_NoRedoUndo)) {
956 CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount); 949 CFX_WideString wsRange = m_pTxtBuf->GetRange(nStart, nCount);
957 m_Param.pEventSink->On_AddDoRecord( 950 m_Param.pEventSink->OnAddDoRecord(
958 this, new CFDE_TxtEdtDoRecord_DeleteRange(this, nStart, m_nCaret, 951 pdfium::MakeUnique<CFDE_TxtEdtDoRecord_DeleteRange>(
959 wsRange, bSel)); 952 this, nStart, m_nCaret, wsRange, bSel));
960 } 953 }
961 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete; 954 m_ChangeInfo.nChangeType = FDE_TXTEDT_TEXTCHANGE_TYPE_Delete;
962 m_ChangeInfo.wsDelete = GetText(nStart, nCount); 955 m_ChangeInfo.wsDelete = GetText(nStart, nCount);
963 Inner_DeleteRange(nStart, nCount); 956 Inner_DeleteRange(nStart, nCount);
964 } 957 }
965 958
966 void CFDE_TxtEdtEngine::ResetEngine() { 959 void CFDE_TxtEdtEngine::ResetEngine() {
967 RemoveAllPages(); 960 RemoveAllPages();
968 RemoveAllParags(); 961 RemoveAllParags();
969 ClearSelection(); 962 ClearSelection();
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 *lpBuf = wc; 1221 *lpBuf = wc;
1229 } 1222 }
1230 } 1223 }
1231 } 1224 }
1232 1225
1233 int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) { 1226 int32_t CFDE_TxtEdtEngine::MovePage2Char(int32_t nIndex) {
1234 ASSERT(nIndex >= 0); 1227 ASSERT(nIndex >= 0);
1235 ASSERT(nIndex <= m_pTxtBuf->GetTextLength()); 1228 ASSERT(nIndex <= m_pTxtBuf->GetTextLength());
1236 if (m_nCaretPage >= 0) { 1229 if (m_nCaretPage >= 0) {
1237 IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; 1230 IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
1238 m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); 1231 m_Param.pEventSink->OnPageLoad(m_nCaretPage);
1239 int32_t nPageCharStart = pPage->GetCharStart(); 1232 int32_t nPageCharStart = pPage->GetCharStart();
1240 int32_t nPageCharCount = pPage->GetCharCount(); 1233 int32_t nPageCharCount = pPage->GetCharCount();
1241 if (nIndex >= nPageCharStart && nIndex < nPageCharStart + nPageCharCount) { 1234 if (nIndex >= nPageCharStart && nIndex < nPageCharStart + nPageCharCount) {
1242 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 1235 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
1243 return m_nCaretPage; 1236 return m_nCaretPage;
1244 } 1237 }
1245 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 1238 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
1246 } 1239 }
1247 CFDE_TxtEdtParag* pParag = nullptr; 1240 CFDE_TxtEdtParag* pParag = nullptr;
1248 int32_t nLineCount = 0; 1241 int32_t nLineCount = 0;
1249 int32_t nParagCount = m_ParagPtrArray.GetSize(); 1242 int32_t nParagCount = m_ParagPtrArray.GetSize();
1250 int32_t i = 0; 1243 int32_t i = 0;
1251 for (i = 0; i < nParagCount; i++) { 1244 for (i = 0; i < nParagCount; i++) {
1252 pParag = m_ParagPtrArray[i]; 1245 pParag = m_ParagPtrArray[i];
1253 if (pParag->GetStartIndex() <= nIndex && 1246 if (pParag->GetStartIndex() <= nIndex &&
1254 nIndex < (pParag->GetStartIndex() + pParag->GetTextLength())) { 1247 nIndex < (pParag->GetStartIndex() + pParag->GetTextLength())) {
1255 break; 1248 break;
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1545 GetCaretRect(m_rtCaret, m_nCaretPage, nIndex, bBefore); 1538 GetCaretRect(m_rtCaret, m_nCaretPage, nIndex, bBefore);
1546 m_nCaret = nIndex; 1539 m_nCaret = nIndex;
1547 m_bBefore = bBefore; 1540 m_bBefore = bBefore;
1548 if (!m_bBefore) { 1541 if (!m_bBefore) {
1549 m_nCaret++; 1542 m_nCaret++;
1550 m_bBefore = true; 1543 m_bBefore = true;
1551 } 1544 }
1552 m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) 1545 m_fCaretPosReserve = (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical)
1553 ? m_rtCaret.top 1546 ? m_rtCaret.top
1554 : m_rtCaret.left; 1547 : m_rtCaret.left;
1555 m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage, 0); 1548 m_Param.pEventSink->OnCaretChanged();
1556 } 1549 }
1557 1550
1558 void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret, 1551 void CFDE_TxtEdtEngine::GetCaretRect(CFX_RectF& rtCaret,
1559 int32_t nPageIndex, 1552 int32_t nPageIndex,
1560 int32_t nCaret, 1553 int32_t nCaret,
1561 bool bBefore) { 1554 bool bBefore) {
1562 IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; 1555 IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
1563 m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); 1556 m_Param.pEventSink->OnPageLoad(m_nCaretPage);
1564 bool bCombText = !!(m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText); 1557 bool bCombText = !!(m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_CombText);
1565 int32_t nIndexInpage = nCaret - pPage->GetCharStart(); 1558 int32_t nIndexInpage = nCaret - pPage->GetCharStart();
1566 if (bBefore && bCombText && nIndexInpage > 0) { 1559 if (bBefore && bCombText && nIndexInpage > 0) {
1567 nIndexInpage--; 1560 nIndexInpage--;
1568 bBefore = false; 1561 bBefore = false;
1569 } 1562 }
1570 int32_t nBIDILevel = pPage->GetCharRect(nIndexInpage, rtCaret, bCombText); 1563 int32_t nBIDILevel = pPage->GetCharRect(nIndexInpage, rtCaret, bCombText);
1571 if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) { 1564 if (m_Param.dwLayoutStyles & FDE_TEXTEDITLAYOUT_DocVertical) {
1572 if ((!FX_IsOdd(nBIDILevel) && !bBefore) || 1565 if ((!FX_IsOdd(nBIDILevel) && !bBefore) ||
1573 (FX_IsOdd(nBIDILevel) && bBefore)) { 1566 (FX_IsOdd(nBIDILevel) && bBefore)) {
1574 rtCaret.Offset(0, rtCaret.height - 1.0f); 1567 rtCaret.Offset(0, rtCaret.height - 1.0f);
1575 } 1568 }
1576 if (rtCaret.height == 0 && rtCaret.top > 1.0f) 1569 if (rtCaret.height == 0 && rtCaret.top > 1.0f)
1577 rtCaret.top -= 1.0f; 1570 rtCaret.top -= 1.0f;
1578 1571
1579 rtCaret.height = 1.0f; 1572 rtCaret.height = 1.0f;
1580 } else { 1573 } else {
1581 if ((!FX_IsOdd(nBIDILevel) && !bBefore) || 1574 if ((!FX_IsOdd(nBIDILevel) && !bBefore) ||
1582 (FX_IsOdd(nBIDILevel) && bBefore)) { 1575 (FX_IsOdd(nBIDILevel) && bBefore)) {
1583 rtCaret.Offset(rtCaret.width - 1.0f, 0); 1576 rtCaret.Offset(rtCaret.width - 1.0f, 0);
1584 } 1577 }
1585 if (rtCaret.width == 0 && rtCaret.left > 1.0f) 1578 if (rtCaret.width == 0 && rtCaret.left > 1.0f)
1586 rtCaret.left -= 1.0f; 1579 rtCaret.left -= 1.0f;
1587 1580
1588 rtCaret.width = 1.0f; 1581 rtCaret.width = 1.0f;
1589 } 1582 }
1590 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 1583 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
1591 } 1584 }
1592 1585
1593 void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) { 1586 void CFDE_TxtEdtEngine::UpdateCaretIndex(const CFX_PointF& ptCaret) {
1594 IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage]; 1587 IFDE_TxtEdtPage* pPage = m_PagePtrArray[m_nCaretPage];
1595 m_Param.pEventSink->On_PageLoad(this, m_nCaretPage, 0); 1588 m_Param.pEventSink->OnPageLoad(m_nCaretPage);
1596 m_nCaret = pPage->GetCharIndex(ptCaret, m_bBefore); 1589 m_nCaret = pPage->GetCharIndex(ptCaret, m_bBefore);
1597 GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore); 1590 GetCaretRect(m_rtCaret, m_nCaretPage, m_nCaret, m_bBefore);
1598 if (!m_bBefore) { 1591 if (!m_bBefore) {
1599 m_nCaret++; 1592 m_nCaret++;
1600 m_bBefore = true; 1593 m_bBefore = true;
1601 } 1594 }
1602 m_Param.pEventSink->On_CaretChanged(this, m_nCaretPage); 1595 m_Param.pEventSink->OnCaretChanged();
1603 m_Param.pEventSink->On_PageUnload(this, m_nCaretPage, 0); 1596 m_Param.pEventSink->OnPageUnload(m_nCaretPage);
1604 } 1597 }
1605 1598
1606 bool CFDE_TxtEdtEngine::IsSelect() { 1599 bool CFDE_TxtEdtEngine::IsSelect() {
1607 return m_SelRangePtrArr.GetSize() > 0; 1600 return m_SelRangePtrArr.GetSize() > 0;
1608 } 1601 }
1609 1602
1610 void CFDE_TxtEdtEngine::DeleteSelect() { 1603 void CFDE_TxtEdtEngine::DeleteSelect() {
1611 int32_t nCountRange = CountSelRanges(); 1604 int32_t nCountRange = CountSelRanges();
1612 if (nCountRange > 0) { 1605 if (nCountRange > 0) {
1613 int32_t nSelStart = 0; 1606 int32_t nSelStart = 0;
1614 while (nCountRange > 0) { 1607 while (nCountRange > 0) {
1615 int32_t nSelCount = GetSelRange(--nCountRange, nSelStart); 1608 int32_t nSelCount = GetSelRange(--nCountRange, &nSelStart);
1616 delete m_SelRangePtrArr[nCountRange]; 1609 delete m_SelRangePtrArr[nCountRange];
1617 m_SelRangePtrArr.RemoveAt(nCountRange); 1610 m_SelRangePtrArr.RemoveAt(nCountRange);
1618 DeleteRange_DoRecord(nSelStart, nSelCount, true); 1611 DeleteRange_DoRecord(nSelStart, nSelCount, true);
1619 } 1612 }
1620 ClearSelection(); 1613 ClearSelection();
1621 m_Param.pEventSink->On_TextChanged(this, m_ChangeInfo); 1614 m_Param.pEventSink->OnTextChanged(m_ChangeInfo);
1622 m_Param.pEventSink->On_SelChanged(this); 1615 m_Param.pEventSink->OnSelChanged();
1623 SetCaretPos(nSelStart, true); 1616 SetCaretPos(nSelStart, true);
1624 return; 1617 return;
1625 } 1618 }
1626 } 1619 }
OLDNEW
« no previous file with comments | « xfa/fde/cfde_txtedtengine.h ('k') | xfa/fwl/core/cfwl_combobox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698