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/fxet_edit.h" | 7 #include "fpdfsdk/fxedit/fxet_edit.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "core/fpdfdoc/cpvt_section.h" | 21 #include "core/fpdfdoc/cpvt_section.h" |
22 #include "core/fpdfdoc/cpvt_word.h" | 22 #include "core/fpdfdoc/cpvt_word.h" |
23 #include "core/fpdfdoc/ipvt_fontmap.h" | 23 #include "core/fpdfdoc/ipvt_fontmap.h" |
24 #include "core/fxge/cfx_graphstatedata.h" | 24 #include "core/fxge/cfx_graphstatedata.h" |
25 #include "core/fxge/cfx_pathdata.h" | 25 #include "core/fxge/cfx_pathdata.h" |
26 #include "core/fxge/cfx_renderdevice.h" | 26 #include "core/fxge/cfx_renderdevice.h" |
27 #include "fpdfsdk/cfx_systemhandler.h" | 27 #include "fpdfsdk/cfx_systemhandler.h" |
28 #include "fpdfsdk/fxedit/fx_edit.h" | 28 #include "fpdfsdk/fxedit/fx_edit.h" |
29 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 29 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
30 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 30 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
| 31 #include "third_party/base/ptr_util.h" |
31 | 32 |
32 namespace { | 33 namespace { |
33 | 34 |
34 const int kEditUndoMaxItems = 10000; | 35 const int kEditUndoMaxItems = 10000; |
35 | 36 |
36 CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) { | 37 CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) { |
37 if (strWords.GetLength() > 0) | 38 if (strWords.GetLength() > 0) |
38 return PDF_EncodeString(strWords) + " Tj\n"; | 39 return PDF_EncodeString(strWords) + " Tj\n"; |
39 return CFX_ByteString(); | 40 return CFX_ByteString(); |
40 } | 41 } |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1019 ASSERT(!m_pGroupUndoItem); | 1020 ASSERT(!m_pGroupUndoItem); |
1020 } | 1021 } |
1021 | 1022 |
1022 void CFX_Edit::Initialize() { | 1023 void CFX_Edit::Initialize() { |
1023 m_pVT->Initialize(); | 1024 m_pVT->Initialize(); |
1024 SetCaret(m_pVT->GetBeginWordPlace()); | 1025 SetCaret(m_pVT->GetBeginWordPlace()); |
1025 SetCaretOrigin(); | 1026 SetCaretOrigin(); |
1026 } | 1027 } |
1027 | 1028 |
1028 void CFX_Edit::SetFontMap(IPVT_FontMap* pFontMap) { | 1029 void CFX_Edit::SetFontMap(IPVT_FontMap* pFontMap) { |
1029 m_pVTProvider = WrapUnique(new CFX_Edit_Provider(pFontMap)); | 1030 m_pVTProvider = pdfium::MakeUnique<CFX_Edit_Provider>(pFontMap); |
1030 m_pVT->SetProvider(m_pVTProvider.get()); | 1031 m_pVT->SetProvider(m_pVTProvider.get()); |
1031 } | 1032 } |
1032 | 1033 |
1033 void CFX_Edit::SetNotify(CPWL_EditCtrl* pNotify) { | 1034 void CFX_Edit::SetNotify(CPWL_EditCtrl* pNotify) { |
1034 m_pNotify = pNotify; | 1035 m_pNotify = pNotify; |
1035 } | 1036 } |
1036 | 1037 |
1037 void CFX_Edit::SetOprNotify(CPWL_Edit* pOprNotify) { | 1038 void CFX_Edit::SetOprNotify(CPWL_Edit* pOprNotify) { |
1038 m_pOprNotify = pOprNotify; | 1039 m_pOprNotify = pOprNotify; |
1039 } | 1040 } |
1040 | 1041 |
1041 CFX_Edit_Iterator* CFX_Edit::GetIterator() { | 1042 CFX_Edit_Iterator* CFX_Edit::GetIterator() { |
1042 if (!m_pIterator) | 1043 if (!m_pIterator) { |
1043 m_pIterator = WrapUnique(new CFX_Edit_Iterator(this, m_pVT->GetIterator())); | 1044 m_pIterator = |
| 1045 pdfium::MakeUnique<CFX_Edit_Iterator>(this, m_pVT->GetIterator()); |
| 1046 } |
1044 return m_pIterator.get(); | 1047 return m_pIterator.get(); |
1045 } | 1048 } |
1046 | 1049 |
1047 IPVT_FontMap* CFX_Edit::GetFontMap() { | 1050 IPVT_FontMap* CFX_Edit::GetFontMap() { |
1048 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; | 1051 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; |
1049 } | 1052 } |
1050 | 1053 |
1051 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { | 1054 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { |
1052 m_pVT->SetPlateRect(rect); | 1055 m_pVT->SetPlateRect(rect); |
1053 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); | 1056 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); |
(...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 int32_t CFX_Edit_RectArray::GetSize() const { | 2526 int32_t CFX_Edit_RectArray::GetSize() const { |
2524 return m_Rects.GetSize(); | 2527 return m_Rects.GetSize(); |
2525 } | 2528 } |
2526 | 2529 |
2527 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 2530 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
2528 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 2531 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
2529 return nullptr; | 2532 return nullptr; |
2530 | 2533 |
2531 return m_Rects.GetAt(nIndex); | 2534 return m_Rects.GetAt(nIndex); |
2532 } | 2535 } |
OLD | NEW |