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 "fpdfsdk/include/fxedit/fxet_edit.h" | 7 #include "fpdfsdk/include/fxedit/fxet_edit.h" |
8 | 8 |
| 9 #include <algorithm> |
| 10 |
9 #include "core/include/fpdfapi/fpdf_resource.h" | 11 #include "core/include/fpdfapi/fpdf_resource.h" |
10 | 12 |
11 #define FX_EDIT_UNDO_MAXITEM 10000 | 13 #define FX_EDIT_UNDO_MAXITEM 10000 |
12 | 14 |
13 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, | 15 CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit, |
14 IPDF_VariableText_Iterator* pVTIterator) | 16 IPDF_VariableText_Iterator* pVTIterator) |
15 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {} | 17 : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {} |
16 | 18 |
17 CFX_Edit_Iterator::~CFX_Edit_Iterator() {} | 19 CFX_Edit_Iterator::~CFX_Edit_Iterator() {} |
18 | 20 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 if (CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i)) | 171 if (CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i)) |
170 m_RefreshRects.Add(pNewRect->m_rcLine); | 172 m_RefreshRects.Add(pNewRect->m_rcLine); |
171 } | 173 } |
172 } | 174 } |
173 | 175 |
174 void CFX_Edit_Refresh::Analyse(int32_t nAlignment) { | 176 void CFX_Edit_Refresh::Analyse(int32_t nAlignment) { |
175 FX_BOOL bLineTopChanged = FALSE; | 177 FX_BOOL bLineTopChanged = FALSE; |
176 CPDF_Rect rcResult; | 178 CPDF_Rect rcResult; |
177 FX_FLOAT fWidthDiff; | 179 FX_FLOAT fWidthDiff; |
178 | 180 |
179 int32_t szMax = | 181 int32_t szMax = std::max(m_OldLineRects.GetSize(), m_NewLineRects.GetSize()); |
180 FX_EDIT_MAX(m_OldLineRects.GetSize(), m_NewLineRects.GetSize()); | |
181 int32_t i = 0; | 182 int32_t i = 0; |
182 | 183 |
183 while (i < szMax) { | 184 while (i < szMax) { |
184 CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i); | 185 CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i); |
185 CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i); | 186 CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i); |
186 | 187 |
187 if (pOldRect) { | 188 if (pOldRect) { |
188 if (pNewRect) { | 189 if (pNewRect) { |
189 if (bLineTopChanged) { | 190 if (bLineTopChanged) { |
190 rcResult = pOldRect->m_rcLine; | 191 rcResult = pOldRect->m_rcLine; |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 m_pNotify->IOnContentChange(rcContent); | 1720 m_pNotify->IOnContentChange(rcContent); |
1720 m_bNotifyFlag = FALSE; | 1721 m_bNotifyFlag = FALSE; |
1721 } | 1722 } |
1722 m_rcOldContent = rcContent; | 1723 m_rcOldContent = rcContent; |
1723 } | 1724 } |
1724 } | 1725 } |
1725 } | 1726 } |
1726 | 1727 |
1727 void CFX_Edit::SelectAll() { | 1728 void CFX_Edit::SelectAll() { |
1728 if (m_pVT->IsValid()) { | 1729 if (m_pVT->IsValid()) { |
1729 m_SelState = GetWholeWordRange(); | 1730 m_SelState = CFX_Edit_Select(GetWholeWordRange()); |
1730 SetCaret(m_SelState.EndPos); | 1731 SetCaret(m_SelState.EndPos); |
1731 | 1732 |
1732 ScrollToCaret(); | 1733 ScrollToCaret(); |
1733 CPVT_WordRange wrVisible = GetVisibleWordRange(); | 1734 CPVT_WordRange wrVisible = GetVisibleWordRange(); |
1734 Refresh(RP_OPTIONAL, &wrVisible); | 1735 Refresh(RP_OPTIONAL, &wrVisible); |
1735 SetCaretInfo(); | 1736 SetCaretInfo(); |
1736 } | 1737 } |
1737 } | 1738 } |
1738 | 1739 |
1739 void CFX_Edit::SelectNone() { | 1740 void CFX_Edit::SelectNone() { |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 if (m_bOprNotify && m_pOprNotify) | 3021 if (m_bOprNotify && m_pOprNotify) |
3021 m_pOprNotify->OnAddUndo(pEditUndoItem); | 3022 m_pOprNotify->OnAddUndo(pEditUndoItem); |
3022 } | 3023 } |
3023 } | 3024 } |
3024 | 3025 |
3025 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { | 3026 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { |
3026 m_Undo.AddItem(pUndoItem); | 3027 m_Undo.AddItem(pUndoItem); |
3027 if (m_bOprNotify && m_pOprNotify) | 3028 if (m_bOprNotify && m_pOprNotify) |
3028 m_pOprNotify->OnAddUndo(pUndoItem); | 3029 m_pOprNotify->OnAddUndo(pUndoItem); |
3029 } | 3030 } |
OLD | NEW |