| OLD | NEW |
| 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/fxedit/fxet_stub.h" | 7 #include "../../include/fxedit/fxet_stub.h" |
| 8 #include "../../include/fxedit/fxet_edit.h" | 8 #include "../../include/fxedit/fxet_edit.h" |
| 9 | 9 |
| 10 #define FX_EDIT_UNDO_MAXITEM 10000 | 10 #define FX_EDIT_UNDO_MAXITEM 10000 |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize()) | 446 if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize()) |
| 447 return m_UndoItemStack.GetAt(nIndex); | 447 return m_UndoItemStack.GetAt(nIndex); |
| 448 | 448 |
| 449 return NULL; | 449 return NULL; |
| 450 } | 450 } |
| 451 | 451 |
| 452 void CFX_Edit_Undo::RemoveHeads() | 452 void CFX_Edit_Undo::RemoveHeads() |
| 453 { | 453 { |
| 454 ASSERT(m_UndoItemStack.GetSize() > 1); | 454 ASSERT(m_UndoItemStack.GetSize() > 1); |
| 455 | 455 |
| 456 » IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(0); | 456 » delete m_UndoItemStack.GetAt(0); |
| 457 » ASSERT(pItem != NULL); | |
| 458 | |
| 459 » pItem->Release(); | |
| 460 m_UndoItemStack.RemoveAt(0); | 457 m_UndoItemStack.RemoveAt(0); |
| 461 } | 458 } |
| 462 | 459 |
| 463 void CFX_Edit_Undo::RemoveTails() | 460 void CFX_Edit_Undo::RemoveTails() |
| 464 { | 461 { |
| 465 for (FX_INT32 i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--) | 462 for (FX_INT32 i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--) |
| 466 { | 463 { |
| 467 » » IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(i); | 464 » » delete m_UndoItemStack.GetAt(i); |
| 468 » » ASSERT(pItem != NULL); | |
| 469 | |
| 470 » » pItem->Release(); | |
| 471 m_UndoItemStack.RemoveAt(i); | 465 m_UndoItemStack.RemoveAt(i); |
| 472 } | 466 } |
| 473 } | 467 } |
| 474 | 468 |
| 475 void CFX_Edit_Undo::Reset() | 469 void CFX_Edit_Undo::Reset() |
| 476 { | 470 { |
| 477 for (FX_INT32 i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++) | 471 for (FX_INT32 i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++) |
| 478 { | 472 { |
| 479 » » IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(i); | 473 » » delete m_UndoItemStack.GetAt(i); |
| 480 » » ASSERT(pItem != NULL); | |
| 481 | |
| 482 » » pItem->Release(); | |
| 483 } | 474 } |
| 484 m_nCurUndoPos = 0; | 475 m_nCurUndoPos = 0; |
| 485 m_UndoItemStack.RemoveAll(); | 476 m_UndoItemStack.RemoveAll(); |
| 486 } | 477 } |
| 487 | 478 |
| 488 /* -------------------------------- CFX_Edit_GroupUndoItem ---------------------
----------- */ | 479 /* -------------------------------- CFX_Edit_GroupUndoItem ---------------------
----------- */ |
| 489 | 480 |
| 490 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) : m
_sTitle(sTitle) | 481 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) : m
_sTitle(sTitle) |
| 491 { | 482 { |
| 492 } | 483 } |
| 493 | 484 |
| 494 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() | 485 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() |
| 495 { | 486 { |
| 496 for (int i=0,sz=m_Items.GetSize(); i<sz; i++) | 487 for (int i=0,sz=m_Items.GetSize(); i<sz; i++) |
| 497 { | 488 { |
| 498 » » CFX_Edit_UndoItem* pUndoItem = m_Items[i]; | 489 » » delete m_Items[i]; |
| 499 » » ASSERT(pUndoItem != NULL); | |
| 500 | |
| 501 » » pUndoItem->Release(); | |
| 502 } | 490 } |
| 503 | 491 |
| 504 m_Items.RemoveAll(); | 492 m_Items.RemoveAll(); |
| 505 } | 493 } |
| 506 | 494 |
| 507 void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem) | 495 void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem) |
| 508 { | 496 { |
| 509 ASSERT(pUndoItem != NULL); | 497 ASSERT(pUndoItem != NULL); |
| 510 | 498 |
| 511 pUndoItem->SetFirst(FALSE); | 499 pUndoItem->SetFirst(FALSE); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 | 539 |
| 552 pUndoItem->Redo(); | 540 pUndoItem->Redo(); |
| 553 } | 541 } |
| 554 } | 542 } |
| 555 | 543 |
| 556 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() | 544 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() |
| 557 { | 545 { |
| 558 return m_sTitle; | 546 return m_sTitle; |
| 559 } | 547 } |
| 560 | 548 |
| 561 void CFX_Edit_GroupUndoItem::Release() | |
| 562 { | |
| 563 delete this; | |
| 564 } | |
| 565 | |
| 566 /* ------------------------------------- CFX_Edit_UndoItem derived classes -----
-------------------------------- */ | 549 /* ------------------------------------- CFX_Edit_UndoItem derived classes -----
-------------------------------- */ |
| 567 | 550 |
| 568 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOl
dPlace, const CPVT_WordPlace & wpNewPlace, | 551 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOl
dPlace, const CPVT_WordPlace & wpNewPlace, |
| 569 FX_WORD word, F
X_INT32 charset, const CPVT_WordProps * pWordProps) | 552 FX_WORD word, F
X_INT32 charset, const CPVT_WordProps * pWordProps) |
| 570 : m_pEdit(pEdit), m_wpOld(wpOldPlace), m_wpNew(wpNewPlace), m_Word(word)
, m_nCharset(charset), m_WordProps() | 553 : m_pEdit(pEdit), m_wpOld(wpOldPlace), m_wpNew(wpNewPlace), m_Word(word)
, m_nCharset(charset), m_WordProps() |
| 571 { | 554 { |
| 572 if (pWordProps) | 555 if (pWordProps) |
| 573 m_WordProps = *pWordProps; | 556 m_WordProps = *pWordProps; |
| 574 } | 557 } |
| 575 | 558 |
| (...skipping 3025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3601 } | 3584 } |
| 3602 } | 3585 } |
| 3603 | 3586 |
| 3604 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) | 3587 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) |
| 3605 { | 3588 { |
| 3606 m_Undo.AddItem(pUndoItem); | 3589 m_Undo.AddItem(pUndoItem); |
| 3607 if (m_bOprNotify && m_pOprNotify) | 3590 if (m_bOprNotify && m_pOprNotify) |
| 3608 m_pOprNotify->OnAddUndo(pUndoItem); | 3591 m_pOprNotify->OnAddUndo(pUndoItem); |
| 3609 } | 3592 } |
| 3610 | 3593 |
| OLD | NEW |