| 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 |
| 11 | 11 |
| 12 /* ---------------------------- CFX_Edit_Iterator ---------------------------- *
/ | 12 /* ---------------------------- CFX_Edit_Iterator ---------------------------- *
/ |
| 13 | 13 |
| 14 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator
* pVTIterator) : | 14 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator
* pVTIterator) : |
| 15 m_pEdit(pEdit), | 15 m_pEdit(pEdit), |
| 16 m_pVTIterator(pVTIterator) | 16 m_pVTIterator(pVTIterator) |
| 17 { | 17 { |
| 18 } | 18 } |
| 19 | 19 |
| 20 CFX_Edit_Iterator::~CFX_Edit_Iterator() | 20 CFX_Edit_Iterator::~CFX_Edit_Iterator() |
| 21 { | 21 { |
| 22 } | 22 } |
| 23 | 23 |
| 24 FX_BOOL CFX_Edit_Iterator::NextWord() | 24 FX_BOOL CFX_Edit_Iterator::NextWord() |
| 25 { | 25 { |
| 26 ASSERT(m_pVTIterator != NULL); | |
| 27 | |
| 28 return m_pVTIterator->NextWord(); | 26 return m_pVTIterator->NextWord(); |
| 29 } | 27 } |
| 30 | 28 |
| 31 FX_BOOL CFX_Edit_Iterator::NextLine() | 29 FX_BOOL CFX_Edit_Iterator::NextLine() |
| 32 { | 30 { |
| 33 ASSERT(m_pVTIterator != NULL); | |
| 34 | |
| 35 return m_pVTIterator->NextLine(); | 31 return m_pVTIterator->NextLine(); |
| 36 } | 32 } |
| 37 | 33 |
| 38 FX_BOOL CFX_Edit_Iterator::NextSection() | 34 FX_BOOL CFX_Edit_Iterator::NextSection() |
| 39 { | 35 { |
| 40 ASSERT(m_pVTIterator != NULL); | |
| 41 | |
| 42 return m_pVTIterator->NextSection(); | 36 return m_pVTIterator->NextSection(); |
| 43 } | 37 } |
| 44 | 38 |
| 45 FX_BOOL CFX_Edit_Iterator::PrevWord() | 39 FX_BOOL CFX_Edit_Iterator::PrevWord() |
| 46 { | 40 { |
| 47 ASSERT(m_pVTIterator != NULL); | |
| 48 | |
| 49 return m_pVTIterator->PrevWord(); | 41 return m_pVTIterator->PrevWord(); |
| 50 } | 42 } |
| 51 | 43 |
| 52 FX_BOOL CFX_Edit_Iterator::PrevLine() | 44 FX_BOOL CFX_Edit_Iterator::PrevLine() |
| 53 { | 45 { |
| 54 ASSERT(m_pVTIterator != NULL); | |
| 55 | |
| 56 return m_pVTIterator->PrevLine(); | 46 return m_pVTIterator->PrevLine(); |
| 57 } | 47 } |
| 58 | 48 |
| 59 FX_BOOL CFX_Edit_Iterator::PrevSection() | 49 FX_BOOL CFX_Edit_Iterator::PrevSection() |
| 60 { | 50 { |
| 61 ASSERT(m_pVTIterator != NULL); | |
| 62 | |
| 63 return m_pVTIterator->PrevSection(); | 51 return m_pVTIterator->PrevSection(); |
| 64 } | 52 } |
| 65 | 53 |
| 66 FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word & word) const | 54 FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word & word) const |
| 67 { | 55 { |
| 68 » ASSERT(m_pEdit != NULL); | 56 » ASSERT(m_pEdit); |
| 69 » ASSERT(m_pVTIterator != NULL); | |
| 70 | 57 |
| 71 if (m_pVTIterator->GetWord(word)) | 58 if (m_pVTIterator->GetWord(word)) |
| 72 { | 59 { |
| 73 word.ptWord = m_pEdit->VTToEdit(word.ptWord); | 60 word.ptWord = m_pEdit->VTToEdit(word.ptWord); |
| 74 return TRUE; | 61 return TRUE; |
| 75 } | 62 } |
| 76 | |
| 77 return FALSE; | 63 return FALSE; |
| 78 } | 64 } |
| 79 | 65 |
| 80 FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line & line) const | 66 FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line & line) const |
| 81 { | 67 { |
| 82 » ASSERT(m_pEdit != NULL); | 68 » ASSERT(m_pEdit); |
| 83 » ASSERT(m_pVTIterator != NULL); | |
| 84 | 69 |
| 85 if (m_pVTIterator->GetLine(line)) | 70 if (m_pVTIterator->GetLine(line)) |
| 86 { | 71 { |
| 87 line.ptLine = m_pEdit->VTToEdit(line.ptLine); | 72 line.ptLine = m_pEdit->VTToEdit(line.ptLine); |
| 88 return TRUE; | 73 return TRUE; |
| 89 } | 74 } |
| 90 | |
| 91 return FALSE; | 75 return FALSE; |
| 92 } | 76 } |
| 93 | 77 |
| 94 FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section & section) const | 78 FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section & section) const |
| 95 { | 79 { |
| 96 » ASSERT(m_pEdit != NULL); | 80 » ASSERT(m_pEdit); |
| 97 » ASSERT(m_pVTIterator != NULL); | |
| 98 | 81 |
| 99 if (m_pVTIterator->GetSection(section)) | 82 if (m_pVTIterator->GetSection(section)) |
| 100 { | 83 { |
| 101 section.rcSection = m_pEdit->VTToEdit(section.rcSection); | 84 section.rcSection = m_pEdit->VTToEdit(section.rcSection); |
| 102 return TRUE; | 85 return TRUE; |
| 103 } | 86 } |
| 104 | |
| 105 return FALSE; | 87 return FALSE; |
| 106 } | 88 } |
| 107 | 89 |
| 108 void CFX_Edit_Iterator::SetAt(int32_t nWordIndex) | 90 void CFX_Edit_Iterator::SetAt(int32_t nWordIndex) |
| 109 { | 91 { |
| 110 ASSERT(m_pVTIterator != NULL); | |
| 111 | |
| 112 m_pVTIterator->SetAt(nWordIndex); | 92 m_pVTIterator->SetAt(nWordIndex); |
| 113 } | 93 } |
| 114 | 94 |
| 115 void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace & place) | 95 void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace & place) |
| 116 { | 96 { |
| 117 ASSERT(m_pVTIterator != NULL); | |
| 118 | |
| 119 m_pVTIterator->SetAt(place); | 97 m_pVTIterator->SetAt(place); |
| 120 } | 98 } |
| 121 | 99 |
| 122 const CPVT_WordPlace & CFX_Edit_Iterator::GetAt() const | 100 const CPVT_WordPlace & CFX_Edit_Iterator::GetAt() const |
| 123 { | 101 { |
| 124 ASSERT(m_pVTIterator != NULL); | |
| 125 | |
| 126 return m_pVTIterator->GetAt(); | 102 return m_pVTIterator->GetAt(); |
| 127 } | 103 } |
| 128 | 104 |
| 129 IFX_Edit* CFX_Edit_Iterator::GetEdit() const | 105 IFX_Edit* CFX_Edit_Iterator::GetEdit() const |
| 130 { | 106 { |
| 131 return m_pEdit; | 107 return m_pEdit; |
| 132 } | 108 } |
| 133 | 109 |
| 134 /* --------------------------- CFX_Edit_Provider -------------------------------
*/ | 110 /* --------------------------- CFX_Edit_Provider -------------------------------
*/ |
| 135 | 111 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 } | 404 } |
| 429 | 405 |
| 430 m_UndoItemStack.Add(pItem); | 406 m_UndoItemStack.Add(pItem); |
| 431 m_nCurUndoPos = m_UndoItemStack.GetSize(); | 407 m_nCurUndoPos = m_UndoItemStack.GetSize(); |
| 432 | 408 |
| 433 m_bModified = (m_nCurUndoPos != 0); | 409 m_bModified = (m_nCurUndoPos != 0); |
| 434 } | 410 } |
| 435 | 411 |
| 436 FX_BOOL CFX_Edit_Undo::IsModified() const | 412 FX_BOOL CFX_Edit_Undo::IsModified() const |
| 437 { | 413 { |
| 438 » if (m_bVirgin) | 414 » return m_bVirgin ? m_bModified : TRUE; |
| 439 » » return m_bModified; | |
| 440 » else | |
| 441 » » return TRUE; | |
| 442 } | 415 } |
| 443 | 416 |
| 444 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex) | 417 IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex) |
| 445 { | 418 { |
| 446 if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize()) | 419 if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize()) |
| 447 return m_UndoItemStack.GetAt(nIndex); | 420 return m_UndoItemStack.GetAt(nIndex); |
| 448 | 421 |
| 449 return NULL; | 422 return NULL; |
| 450 } | 423 } |
| 451 | 424 |
| (...skipping 3121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3573 } | 3546 } |
| 3574 } | 3547 } |
| 3575 | 3548 |
| 3576 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) | 3549 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) |
| 3577 { | 3550 { |
| 3578 m_Undo.AddItem(pUndoItem); | 3551 m_Undo.AddItem(pUndoItem); |
| 3579 if (m_bOprNotify && m_pOprNotify) | 3552 if (m_bOprNotify && m_pOprNotify) |
| 3580 m_pOprNotify->OnAddUndo(pUndoItem); | 3553 m_pOprNotify->OnAddUndo(pUndoItem); |
| 3581 } | 3554 } |
| 3582 | 3555 |
| OLD | NEW |