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/fxedit/include/fxet_edit.h" | 7 #include "fpdfsdk/fxedit/include/fxet_edit.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 } | 357 } |
358 | 358 |
359 void CFX_Edit_Undo::Reset() { | 359 void CFX_Edit_Undo::Reset() { |
360 for (int32_t i = 0, sz = m_UndoItemStack.GetSize(); i < sz; i++) { | 360 for (int32_t i = 0, sz = m_UndoItemStack.GetSize(); i < sz; i++) { |
361 delete m_UndoItemStack.GetAt(i); | 361 delete m_UndoItemStack.GetAt(i); |
362 } | 362 } |
363 m_nCurUndoPos = 0; | 363 m_nCurUndoPos = 0; |
364 m_UndoItemStack.RemoveAll(); | 364 m_UndoItemStack.RemoveAll(); |
365 } | 365 } |
366 | 366 |
| 367 CFX_Edit_UndoItem::CFX_Edit_UndoItem() : m_bFirst(TRUE), m_bLast(TRUE) {} |
| 368 |
| 369 CFX_Edit_UndoItem::~CFX_Edit_UndoItem() {} |
| 370 |
| 371 CFX_WideString CFX_Edit_UndoItem::GetUndoTitle() { |
| 372 return L""; |
| 373 } |
| 374 |
| 375 void CFX_Edit_UndoItem::SetFirst(FX_BOOL bFirst) { |
| 376 m_bFirst = bFirst; |
| 377 } |
| 378 |
| 379 FX_BOOL CFX_Edit_UndoItem::IsFirst() { |
| 380 return m_bFirst; |
| 381 } |
| 382 |
| 383 void CFX_Edit_UndoItem::SetLast(FX_BOOL bLast) { |
| 384 m_bLast = bLast; |
| 385 } |
| 386 |
| 387 FX_BOOL CFX_Edit_UndoItem::IsLast() { |
| 388 return m_bLast; |
| 389 } |
| 390 |
367 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) | 391 CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) |
368 : m_sTitle(sTitle) {} | 392 : m_sTitle(sTitle) {} |
369 | 393 |
370 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() { | 394 CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() { |
371 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { | 395 for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) { |
372 delete m_Items[i]; | 396 delete m_Items[i]; |
373 } | 397 } |
374 | 398 |
375 m_Items.RemoveAll(); | 399 m_Items.RemoveAll(); |
376 } | 400 } |
(...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2972 if (m_bOprNotify && m_pOprNotify) | 2996 if (m_bOprNotify && m_pOprNotify) |
2973 m_pOprNotify->OnAddUndo(pEditUndoItem); | 2997 m_pOprNotify->OnAddUndo(pEditUndoItem); |
2974 } | 2998 } |
2975 } | 2999 } |
2976 | 3000 |
2977 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { | 3001 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { |
2978 m_Undo.AddItem(pUndoItem); | 3002 m_Undo.AddItem(pUndoItem); |
2979 if (m_bOprNotify && m_pOprNotify) | 3003 if (m_bOprNotify && m_pOprNotify) |
2980 m_pOprNotify->OnAddUndo(pUndoItem); | 3004 m_pOprNotify->OnAddUndo(pUndoItem); |
2981 } | 3005 } |
| 3006 |
| 3007 CFX_Edit_LineRectArray::CFX_Edit_LineRectArray() {} |
| 3008 |
| 3009 CFX_Edit_LineRectArray::~CFX_Edit_LineRectArray() { |
| 3010 Empty(); |
| 3011 } |
| 3012 |
| 3013 void CFX_Edit_LineRectArray::Empty() { |
| 3014 for (int32_t i = 0, sz = m_LineRects.GetSize(); i < sz; i++) |
| 3015 delete m_LineRects.GetAt(i); |
| 3016 |
| 3017 m_LineRects.RemoveAll(); |
| 3018 } |
| 3019 |
| 3020 void CFX_Edit_LineRectArray::RemoveAll() { |
| 3021 m_LineRects.RemoveAll(); |
| 3022 } |
| 3023 |
| 3024 void CFX_Edit_LineRectArray::operator=(CFX_Edit_LineRectArray& rects) { |
| 3025 Empty(); |
| 3026 for (int32_t i = 0, sz = rects.GetSize(); i < sz; i++) |
| 3027 m_LineRects.Add(rects.GetAt(i)); |
| 3028 |
| 3029 rects.RemoveAll(); |
| 3030 } |
| 3031 |
| 3032 void CFX_Edit_LineRectArray::Add(const CPVT_WordRange& wrLine, |
| 3033 const CFX_FloatRect& rcLine) { |
| 3034 m_LineRects.Add(new CFX_Edit_LineRect(wrLine, rcLine)); |
| 3035 } |
| 3036 |
| 3037 int32_t CFX_Edit_LineRectArray::GetSize() const { |
| 3038 return m_LineRects.GetSize(); |
| 3039 } |
| 3040 |
| 3041 CFX_Edit_LineRect* CFX_Edit_LineRectArray::GetAt(int32_t nIndex) const { |
| 3042 if (nIndex < 0 || nIndex >= m_LineRects.GetSize()) |
| 3043 return nullptr; |
| 3044 |
| 3045 return m_LineRects.GetAt(nIndex); |
| 3046 } |
| 3047 |
| 3048 CFX_Edit_Select::CFX_Edit_Select() {} |
| 3049 |
| 3050 CFX_Edit_Select::CFX_Edit_Select(const CPVT_WordPlace& begin, |
| 3051 const CPVT_WordPlace& end) { |
| 3052 Set(begin, end); |
| 3053 } |
| 3054 |
| 3055 CFX_Edit_Select::CFX_Edit_Select(const CPVT_WordRange& range) { |
| 3056 Set(range.BeginPos, range.EndPos); |
| 3057 } |
| 3058 |
| 3059 CPVT_WordRange CFX_Edit_Select::ConvertToWordRange() const { |
| 3060 return CPVT_WordRange(BeginPos, EndPos); |
| 3061 } |
| 3062 |
| 3063 void CFX_Edit_Select::Default() { |
| 3064 BeginPos.Default(); |
| 3065 EndPos.Default(); |
| 3066 } |
| 3067 |
| 3068 void CFX_Edit_Select::Set(const CPVT_WordPlace& begin, |
| 3069 const CPVT_WordPlace& end) { |
| 3070 BeginPos = begin; |
| 3071 EndPos = end; |
| 3072 } |
| 3073 |
| 3074 void CFX_Edit_Select::SetBeginPos(const CPVT_WordPlace& begin) { |
| 3075 BeginPos = begin; |
| 3076 } |
| 3077 |
| 3078 void CFX_Edit_Select::SetEndPos(const CPVT_WordPlace& end) { |
| 3079 EndPos = end; |
| 3080 } |
| 3081 |
| 3082 FX_BOOL CFX_Edit_Select::IsExist() const { |
| 3083 return BeginPos != EndPos; |
| 3084 } |
| 3085 |
| 3086 FX_BOOL CFX_Edit_Select::operator!=(const CPVT_WordRange& wr) const { |
| 3087 return wr.BeginPos != BeginPos || wr.EndPos != EndPos; |
| 3088 } |
| 3089 |
| 3090 CFX_Edit_RectArray::CFX_Edit_RectArray() {} |
| 3091 |
| 3092 CFX_Edit_RectArray::~CFX_Edit_RectArray() { |
| 3093 Empty(); |
| 3094 } |
| 3095 |
| 3096 void CFX_Edit_RectArray::Empty() { |
| 3097 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) |
| 3098 delete m_Rects.GetAt(i); |
| 3099 |
| 3100 m_Rects.RemoveAll(); |
| 3101 } |
| 3102 |
| 3103 void CFX_Edit_RectArray::Add(const CFX_FloatRect& rect) { |
| 3104 // check for overlapped area |
| 3105 for (int32_t i = 0, sz = m_Rects.GetSize(); i < sz; i++) { |
| 3106 CFX_FloatRect* pRect = m_Rects.GetAt(i); |
| 3107 if (pRect && pRect->Contains(rect)) |
| 3108 return; |
| 3109 } |
| 3110 |
| 3111 m_Rects.Add(new CFX_FloatRect(rect)); |
| 3112 } |
| 3113 |
| 3114 int32_t CFX_Edit_RectArray::GetSize() const { |
| 3115 return m_Rects.GetSize(); |
| 3116 } |
| 3117 |
| 3118 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
| 3119 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 3120 return nullptr; |
| 3121 |
| 3122 return m_Rects.GetAt(nIndex); |
| 3123 } |
OLD | NEW |