| 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 "xfa/fwl/lightwidget/cfwl_edit.h" | 7 #include "xfa/fwl/lightwidget/cfwl_edit.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "xfa/fwl/basewidget/ifwl_edit.h" | 12 #include "xfa/fwl/basewidget/ifwl_edit.h" |
| 13 | 13 |
| 14 CFWL_Edit* CFWL_Edit::Create() { | 14 CFWL_Edit* CFWL_Edit::Create() { |
| 15 return new CFWL_Edit; | 15 return new CFWL_Edit; |
| 16 } | 16 } |
| 17 | 17 |
| 18 FWL_ERR CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { | 18 FWL_Error CFWL_Edit::Initialize(const CFWL_WidgetProperties* pProperties) { |
| 19 if (m_pIface) | 19 if (m_pIface) |
| 20 return FWL_ERR_Indefinite; | 20 return FWL_Error::Indefinite; |
| 21 if (pProperties) { | 21 if (pProperties) { |
| 22 *m_pProperties = *pProperties; | 22 *m_pProperties = *pProperties; |
| 23 } | 23 } |
| 24 std::unique_ptr<IFWL_Edit> pEdit(IFWL_Edit::Create( | 24 std::unique_ptr<IFWL_Edit> pEdit(IFWL_Edit::Create( |
| 25 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); | 25 m_pProperties->MakeWidgetImpProperties(nullptr), nullptr)); |
| 26 FWL_ERR ret = pEdit->Initialize(); | 26 FWL_Error ret = pEdit->Initialize(); |
| 27 if (ret != FWL_ERR_Succeeded) { | 27 if (ret != FWL_Error::Succeeded) { |
| 28 return ret; | 28 return ret; |
| 29 } | 29 } |
| 30 m_pIface = pEdit.release(); | 30 m_pIface = pEdit.release(); |
| 31 CFWL_Widget::Initialize(); | 31 CFWL_Widget::Initialize(); |
| 32 return FWL_ERR_Succeeded; | 32 return FWL_Error::Succeeded; |
| 33 } | 33 } |
| 34 | 34 |
| 35 FWL_ERR CFWL_Edit::SetText(const CFX_WideString& wsText) { | 35 FWL_Error CFWL_Edit::SetText(const CFX_WideString& wsText) { |
| 36 if (!m_pIface) | 36 if (!m_pIface) |
| 37 return FWL_ERR_Indefinite; | 37 return FWL_Error::Indefinite; |
| 38 return static_cast<IFWL_Edit*>(m_pIface)->SetText(wsText); | 38 return static_cast<IFWL_Edit*>(m_pIface)->SetText(wsText); |
| 39 } | 39 } |
| 40 | 40 |
| 41 int32_t CFWL_Edit::GetTextLength() const { | 41 int32_t CFWL_Edit::GetTextLength() const { |
| 42 if (!m_pIface) | 42 if (!m_pIface) |
| 43 return 0; | 43 return 0; |
| 44 return static_cast<IFWL_Edit*>(m_pIface)->GetTextLength(); | 44 return static_cast<IFWL_Edit*>(m_pIface)->GetTextLength(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 FWL_ERR CFWL_Edit::GetText(CFX_WideString& wsText, | 47 FWL_Error CFWL_Edit::GetText(CFX_WideString& wsText, |
| 48 int32_t nStart, | 48 int32_t nStart, |
| 49 int32_t nCount) const { | 49 int32_t nCount) const { |
| 50 if (!m_pIface) | 50 if (!m_pIface) |
| 51 return FWL_ERR_Indefinite; | 51 return FWL_Error::Indefinite; |
| 52 return static_cast<IFWL_Edit*>(m_pIface)->GetText(wsText, nStart, nCount); | 52 return static_cast<IFWL_Edit*>(m_pIface)->GetText(wsText, nStart, nCount); |
| 53 } | 53 } |
| 54 | 54 |
| 55 FWL_ERR CFWL_Edit::ClearText() { | 55 FWL_Error CFWL_Edit::ClearText() { |
| 56 if (!m_pIface) | 56 if (!m_pIface) |
| 57 return FWL_ERR_Indefinite; | 57 return FWL_Error::Indefinite; |
| 58 return static_cast<IFWL_Edit*>(m_pIface)->ClearText(); | 58 return static_cast<IFWL_Edit*>(m_pIface)->ClearText(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 int32_t CFWL_Edit::GetCaretPos() const { | 61 int32_t CFWL_Edit::GetCaretPos() const { |
| 62 if (!m_pIface) | 62 if (!m_pIface) |
| 63 return -1; | 63 return -1; |
| 64 return static_cast<IFWL_Edit*>(m_pIface)->GetCaretPos(); | 64 return static_cast<IFWL_Edit*>(m_pIface)->GetCaretPos(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { | 67 int32_t CFWL_Edit::SetCaretPos(int32_t nIndex, FX_BOOL bBefore) { |
| 68 if (!m_pIface) | 68 if (!m_pIface) |
| 69 return -1; | 69 return -1; |
| 70 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(nIndex, bBefore); | 70 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(nIndex, bBefore); |
| 71 } | 71 } |
| 72 | 72 |
| 73 FWL_ERR CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { | 73 int32_t CFWL_Edit::AddSelRange(int32_t nStart, int32_t nCount) { |
| 74 if (!m_pIface) | 74 if (!m_pIface) |
| 75 return FWL_ERR_Indefinite; | 75 return -1; |
| 76 static_cast<IFWL_Edit*>(m_pIface)->AddSelRange(nStart, nCount); | 76 static_cast<IFWL_Edit*>(m_pIface)->AddSelRange(nStart, nCount); |
| 77 int32_t pos = 0; | 77 int32_t pos = 0; |
| 78 int32_t sum = static_cast<IFWL_Edit*>(m_pIface)->GetTextLength(); | 78 int32_t sum = static_cast<IFWL_Edit*>(m_pIface)->GetTextLength(); |
| 79 if (nCount == -1) { | 79 if (nCount == -1) { |
| 80 pos = sum; | 80 pos = sum; |
| 81 } else { | 81 } else { |
| 82 pos = nStart + nCount; | 82 pos = nStart + nCount; |
| 83 } | 83 } |
| 84 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(pos); | 84 return static_cast<IFWL_Edit*>(m_pIface)->SetCaretPos(pos); |
| 85 } | 85 } |
| 86 | 86 |
| 87 int32_t CFWL_Edit::CountSelRanges() { | 87 int32_t CFWL_Edit::CountSelRanges() { |
| 88 if (!m_pIface) | 88 if (!m_pIface) |
| 89 return 0; | 89 return 0; |
| 90 return static_cast<IFWL_Edit*>(m_pIface)->CountSelRanges(); | 90 return static_cast<IFWL_Edit*>(m_pIface)->CountSelRanges(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { | 93 int32_t CFWL_Edit::GetSelRange(int32_t nIndex, int32_t& nStart) { |
| 94 if (!m_pIface) | 94 if (!m_pIface) |
| 95 return 0; | 95 return 0; |
| 96 return static_cast<IFWL_Edit*>(m_pIface)->GetSelRange(nIndex, nStart); | 96 return static_cast<IFWL_Edit*>(m_pIface)->GetSelRange(nIndex, nStart); |
| 97 } | 97 } |
| 98 | 98 |
| 99 FWL_ERR CFWL_Edit::ClearSelections() { | 99 FWL_Error CFWL_Edit::ClearSelections() { |
| 100 if (!m_pIface) | 100 if (!m_pIface) |
| 101 return FWL_ERR_Indefinite; | 101 return FWL_Error::Indefinite; |
| 102 return static_cast<IFWL_Edit*>(m_pIface)->ClearSelections(); | 102 return static_cast<IFWL_Edit*>(m_pIface)->ClearSelections(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 int32_t CFWL_Edit::GetLimit() { | 105 int32_t CFWL_Edit::GetLimit() { |
| 106 if (!m_pIface) | 106 if (!m_pIface) |
| 107 return -1; | 107 return -1; |
| 108 return static_cast<IFWL_Edit*>(m_pIface)->GetLimit(); | 108 return static_cast<IFWL_Edit*>(m_pIface)->GetLimit(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 FWL_ERR CFWL_Edit::SetLimit(int32_t nLimit) { | 111 FWL_Error CFWL_Edit::SetLimit(int32_t nLimit) { |
| 112 if (!m_pIface) | 112 if (!m_pIface) |
| 113 return FWL_ERR_Indefinite; | 113 return FWL_Error::Indefinite; |
| 114 return static_cast<IFWL_Edit*>(m_pIface)->SetLimit(nLimit); | 114 return static_cast<IFWL_Edit*>(m_pIface)->SetLimit(nLimit); |
| 115 } | 115 } |
| 116 | 116 |
| 117 FWL_ERR CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { | 117 FWL_Error CFWL_Edit::SetAliasChar(FX_WCHAR wAlias) { |
| 118 if (!m_pIface) | 118 if (!m_pIface) |
| 119 return FWL_ERR_Indefinite; | 119 return FWL_Error::Indefinite; |
| 120 return static_cast<IFWL_Edit*>(m_pIface)->SetAliasChar(wAlias); | 120 return static_cast<IFWL_Edit*>(m_pIface)->SetAliasChar(wAlias); |
| 121 } | 121 } |
| 122 | 122 |
| 123 FWL_ERR CFWL_Edit::Insert(int32_t nStart, | 123 FWL_Error CFWL_Edit::Insert(int32_t nStart, |
| 124 const FX_WCHAR* lpText, | 124 const FX_WCHAR* lpText, |
| 125 int32_t nLen) { | 125 int32_t nLen) { |
| 126 if (!m_pIface) | 126 if (!m_pIface) |
| 127 return FWL_ERR_Indefinite; | 127 return FWL_Error::Indefinite; |
| 128 return static_cast<IFWL_Edit*>(m_pIface)->Insert(nStart, lpText, nLen); | 128 return static_cast<IFWL_Edit*>(m_pIface)->Insert(nStart, lpText, nLen); |
| 129 } | 129 } |
| 130 | 130 |
| 131 FWL_ERR CFWL_Edit::DeleteSelections() { | 131 FWL_Error CFWL_Edit::DeleteSelections() { |
| 132 if (!m_pIface) | 132 if (!m_pIface) |
| 133 return FWL_ERR_Indefinite; | 133 return FWL_Error::Indefinite; |
| 134 return static_cast<IFWL_Edit*>(m_pIface)->DeleteSelections(); | 134 return static_cast<IFWL_Edit*>(m_pIface)->DeleteSelections(); |
| 135 } | 135 } |
| 136 | 136 |
| 137 FWL_ERR CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { | 137 FWL_Error CFWL_Edit::DeleteRange(int32_t nStart, int32_t nCount) { |
| 138 if (!m_pIface) | 138 if (!m_pIface) |
| 139 return FWL_ERR_Indefinite; | 139 return FWL_Error::Indefinite; |
| 140 return static_cast<IFWL_Edit*>(m_pIface)->DeleteRange(nStart, nCount); | 140 return static_cast<IFWL_Edit*>(m_pIface)->DeleteRange(nStart, nCount); |
| 141 } | 141 } |
| 142 | 142 |
| 143 FWL_ERR CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { | 143 FWL_Error CFWL_Edit::ReplaceSelections(const CFX_WideStringC& wsReplace) { |
| 144 if (!m_pIface) | 144 if (!m_pIface) |
| 145 return FWL_ERR_Indefinite; | 145 return FWL_Error::Indefinite; |
| 146 return static_cast<IFWL_Edit*>(m_pIface)->ReplaceSelections(wsReplace); | 146 return static_cast<IFWL_Edit*>(m_pIface)->ReplaceSelections(wsReplace); |
| 147 } | 147 } |
| 148 | 148 |
| 149 FWL_ERR CFWL_Edit::Replace(int32_t nStart, | 149 FWL_Error CFWL_Edit::Replace(int32_t nStart, |
| 150 int32_t nLen, | 150 int32_t nLen, |
| 151 const CFX_WideStringC& wsReplace) { | 151 const CFX_WideStringC& wsReplace) { |
| 152 if (!m_pIface) | 152 if (!m_pIface) |
| 153 return FWL_ERR_Indefinite; | 153 return FWL_Error::Indefinite; |
| 154 return static_cast<IFWL_Edit*>(m_pIface)->Replace(nStart, nLen, wsReplace); | 154 return static_cast<IFWL_Edit*>(m_pIface)->Replace(nStart, nLen, wsReplace); |
| 155 } | 155 } |
| 156 | 156 |
| 157 FWL_ERR CFWL_Edit::DoClipboard(int32_t iCmd) { | 157 FWL_Error CFWL_Edit::DoClipboard(int32_t iCmd) { |
| 158 if (!m_pIface) | 158 if (!m_pIface) |
| 159 return FWL_ERR_Indefinite; | 159 return FWL_Error::Indefinite; |
| 160 return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd); | 160 return static_cast<IFWL_Edit*>(m_pIface)->DoClipboard(iCmd); |
| 161 } | 161 } |
| 162 | 162 |
| 163 FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { | 163 FX_BOOL CFWL_Edit::Redo(const CFX_ByteStringC& bsRecord) { |
| 164 if (!m_pIface) | 164 if (!m_pIface) |
| 165 return FALSE; | 165 return FALSE; |
| 166 return static_cast<IFWL_Edit*>(m_pIface)->Redo(bsRecord); | 166 return static_cast<IFWL_Edit*>(m_pIface)->Redo(bsRecord); |
| 167 } | 167 } |
| 168 | 168 |
| 169 FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { | 169 FX_BOOL CFWL_Edit::Undo(const CFX_ByteStringC& bsRecord) { |
| 170 if (!m_pIface) | 170 if (!m_pIface) |
| 171 return FALSE; | 171 return FALSE; |
| 172 return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord); | 172 return static_cast<IFWL_Edit*>(m_pIface)->Undo(bsRecord); |
| 173 } | 173 } |
| 174 | 174 |
| 175 FWL_ERR CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { | 175 FWL_Error CFWL_Edit::SetTabWidth(FX_FLOAT fTabWidth, FX_BOOL bEquidistant) { |
| 176 if (!m_pIface) | 176 if (!m_pIface) |
| 177 return FWL_ERR_Indefinite; | 177 return FWL_Error::Indefinite; |
| 178 return static_cast<IFWL_Edit*>(m_pIface) | 178 return static_cast<IFWL_Edit*>(m_pIface) |
| 179 ->SetTabWidth(fTabWidth, bEquidistant); | 179 ->SetTabWidth(fTabWidth, bEquidistant); |
| 180 } | 180 } |
| 181 | 181 |
| 182 FWL_ERR CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { | 182 FWL_Error CFWL_Edit::SetNumberRange(int32_t iMin, int32_t iMax) { |
| 183 if (iMin > iMax) { | 183 if (iMin > iMax) { |
| 184 return FWL_ERR_Parameter_Invalid; | 184 return FWL_Error::ParameterInvalid; |
| 185 } | 185 } |
| 186 return static_cast<IFWL_Edit*>(m_pIface)->SetNumberRange(iMin, iMax); | 186 return static_cast<IFWL_Edit*>(m_pIface)->SetNumberRange(iMin, iMax); |
| 187 } | 187 } |
| 188 | 188 |
| 189 FWL_ERR CFWL_Edit::SetBackColor(uint32_t dwColor) { | 189 FWL_Error CFWL_Edit::SetBackColor(uint32_t dwColor) { |
| 190 if (!m_pIface) | 190 if (!m_pIface) |
| 191 return FWL_ERR_Indefinite; | 191 return FWL_Error::Indefinite; |
| 192 return static_cast<IFWL_Edit*>(m_pIface)->SetBackColor(dwColor); | 192 return static_cast<IFWL_Edit*>(m_pIface)->SetBackColor(dwColor); |
| 193 } | 193 } |
| 194 | 194 |
| 195 FWL_ERR CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { | 195 FWL_Error CFWL_Edit::SetFont(const CFX_WideString& wsFont, FX_FLOAT fSize) { |
| 196 if (!m_pIface) | 196 if (!m_pIface) |
| 197 return FWL_ERR_Indefinite; | 197 return FWL_Error::Indefinite; |
| 198 return static_cast<IFWL_Edit*>(m_pIface)->SetFont(wsFont, fSize); | 198 return static_cast<IFWL_Edit*>(m_pIface)->SetFont(wsFont, fSize); |
| 199 } | 199 } |
| 200 | 200 |
| 201 FX_BOOL CFWL_Edit::CanUndo() { | 201 FX_BOOL CFWL_Edit::CanUndo() { |
| 202 return static_cast<IFWL_Edit*>(m_pIface)->CanUndo(); | 202 return static_cast<IFWL_Edit*>(m_pIface)->CanUndo(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 FX_BOOL CFWL_Edit::CanRedo() { | 205 FX_BOOL CFWL_Edit::CanRedo() { |
| 206 return static_cast<IFWL_Edit*>(m_pIface)->CanRedo(); | 206 return static_cast<IFWL_Edit*>(m_pIface)->CanRedo(); |
| 207 } | 207 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 | 241 |
| 242 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, | 242 FX_BOOL CFWL_Edit::ReplaceSpellCheckWord(CFX_PointF pointf, |
| 243 const CFX_ByteStringC& bsReplace) { | 243 const CFX_ByteStringC& bsReplace) { |
| 244 return static_cast<IFWL_Edit*>(m_pIface) | 244 return static_cast<IFWL_Edit*>(m_pIface) |
| 245 ->ReplaceSpellCheckWord(pointf, bsReplace); | 245 ->ReplaceSpellCheckWord(pointf, bsReplace); |
| 246 } | 246 } |
| 247 | 247 |
| 248 CFWL_Edit::CFWL_Edit() {} | 248 CFWL_Edit::CFWL_Edit() {} |
| 249 | 249 |
| 250 CFWL_Edit::~CFWL_Edit() {} | 250 CFWL_Edit::~CFWL_Edit() {} |
| OLD | NEW |