| 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 #include <memory> |
| 11 #include <utility> |
| 10 | 12 |
| 11 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" | 13 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
| 12 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 14 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
| 13 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" | 15 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobjectholder.h" |
| 14 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" | 16 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" |
| 15 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" | 17 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" |
| 16 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" | 18 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" |
| 17 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" | 19 #include "core/fpdfapi/fpdf_render/include/cpdf_renderoptions.h" |
| 18 #include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h" | 20 #include "core/fpdfapi/fpdf_render/include/cpdf_textrenderer.h" |
| 19 #include "core/fpdfdoc/include/cpvt_section.h" | 21 #include "core/fpdfdoc/include/cpvt_section.h" |
| 20 #include "core/fpdfdoc/include/cpvt_word.h" | 22 #include "core/fpdfdoc/include/cpvt_word.h" |
| 21 #include "core/fpdfdoc/include/ipvt_fontmap.h" | 23 #include "core/fpdfdoc/include/ipvt_fontmap.h" |
| 22 #include "core/fxge/include/cfx_graphstatedata.h" | 24 #include "core/fxge/include/cfx_graphstatedata.h" |
| 23 #include "core/fxge/include/cfx_pathdata.h" | 25 #include "core/fxge/include/cfx_pathdata.h" |
| 24 #include "core/fxge/include/cfx_renderdevice.h" | 26 #include "core/fxge/include/cfx_renderdevice.h" |
| 25 #include "fpdfsdk/cfx_systemhandler.h" | 27 #include "fpdfsdk/cfx_systemhandler.h" |
| 26 #include "fpdfsdk/fxedit/include/fx_edit.h" | 28 #include "fpdfsdk/fxedit/include/fx_edit.h" |
| 27 #include "fpdfsdk/fxedit/include/fxet_edit.h" | |
| 28 #include "fpdfsdk/pdfwindow/PWL_Edit.h" | 29 #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
| 29 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" | 30 #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const int kEditUndoMaxItems = 10000; | 34 const int kEditUndoMaxItems = 10000; |
| 34 | 35 |
| 35 CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) { | 36 CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) { |
| 36 if (strWords.GetLength() > 0) | 37 if (strWords.GetLength() > 0) |
| 37 return PDF_EncodeString(strWords) + " Tj\n"; | 38 return PDF_EncodeString(strWords) + " Tj\n"; |
| (...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 ASSERT(!m_pGroupUndoItem); | 1019 ASSERT(!m_pGroupUndoItem); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 void CFX_Edit::Initialize() { | 1022 void CFX_Edit::Initialize() { |
| 1022 m_pVT->Initialize(); | 1023 m_pVT->Initialize(); |
| 1023 SetCaret(m_pVT->GetBeginWordPlace()); | 1024 SetCaret(m_pVT->GetBeginWordPlace()); |
| 1024 SetCaretOrigin(); | 1025 SetCaretOrigin(); |
| 1025 } | 1026 } |
| 1026 | 1027 |
| 1027 void CFX_Edit::SetFontMap(IPVT_FontMap* pFontMap) { | 1028 void CFX_Edit::SetFontMap(IPVT_FontMap* pFontMap) { |
| 1028 m_pVTProvider.reset(new CFX_Edit_Provider(pFontMap)); | 1029 m_pVTProvider = WrapUnique(new CFX_Edit_Provider(pFontMap)); |
| 1029 m_pVT->SetProvider(m_pVTProvider.get()); | 1030 m_pVT->SetProvider(m_pVTProvider.get()); |
| 1030 } | 1031 } |
| 1031 | 1032 |
| 1032 void CFX_Edit::SetNotify(CPWL_EditCtrl* pNotify) { | 1033 void CFX_Edit::SetNotify(CPWL_EditCtrl* pNotify) { |
| 1033 m_pNotify = pNotify; | 1034 m_pNotify = pNotify; |
| 1034 } | 1035 } |
| 1035 | 1036 |
| 1036 void CFX_Edit::SetOprNotify(CPWL_Edit* pOprNotify) { | 1037 void CFX_Edit::SetOprNotify(CPWL_Edit* pOprNotify) { |
| 1037 m_pOprNotify = pOprNotify; | 1038 m_pOprNotify = pOprNotify; |
| 1038 } | 1039 } |
| 1039 | 1040 |
| 1040 CFX_Edit_Iterator* CFX_Edit::GetIterator() { | 1041 CFX_Edit_Iterator* CFX_Edit::GetIterator() { |
| 1041 if (!m_pIterator) | 1042 if (!m_pIterator) |
| 1042 m_pIterator.reset(new CFX_Edit_Iterator(this, m_pVT->GetIterator())); | 1043 m_pIterator = WrapUnique(new CFX_Edit_Iterator(this, m_pVT->GetIterator())); |
| 1043 return m_pIterator.get(); | 1044 return m_pIterator.get(); |
| 1044 } | 1045 } |
| 1045 | 1046 |
| 1046 IPVT_FontMap* CFX_Edit::GetFontMap() { | 1047 IPVT_FontMap* CFX_Edit::GetFontMap() { |
| 1047 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; | 1048 return m_pVTProvider ? m_pVTProvider->GetFontMap() : nullptr; |
| 1048 } | 1049 } |
| 1049 | 1050 |
| 1050 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { | 1051 void CFX_Edit::SetPlateRect(const CFX_FloatRect& rect) { |
| 1051 m_pVT->SetPlateRect(rect); | 1052 m_pVT->SetPlateRect(rect); |
| 1052 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); | 1053 m_ptScrollPos = CFX_FloatPoint(rect.left, rect.top); |
| (...skipping 1469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2522 int32_t CFX_Edit_RectArray::GetSize() const { | 2523 int32_t CFX_Edit_RectArray::GetSize() const { |
| 2523 return m_Rects.GetSize(); | 2524 return m_Rects.GetSize(); |
| 2524 } | 2525 } |
| 2525 | 2526 |
| 2526 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { | 2527 CFX_FloatRect* CFX_Edit_RectArray::GetAt(int32_t nIndex) const { |
| 2527 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) | 2528 if (nIndex < 0 || nIndex >= m_Rects.GetSize()) |
| 2528 return nullptr; | 2529 return nullptr; |
| 2529 | 2530 |
| 2530 return m_Rects.GetAt(nIndex); | 2531 return m_Rects.GetAt(nIndex); |
| 2531 } | 2532 } |
| OLD | NEW |