John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/pdfwindow/PWL_Edit.h" |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 8 | |
Dan Sinclair | 3ebd121 | 2016-03-09 09:59:23 -0500 | [diff] [blame] | 9 | #include <vector> |
| 10 | |
dan sinclair | 61b2fc7 | 2016-03-23 19:21:44 -0400 | [diff] [blame] | 11 | #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 12 | #include "core/fpdfdoc/include/cpvt_word.h" |
Dan Sinclair | a8a28e0 | 2016-03-23 15:41:39 -0400 | [diff] [blame] | 13 | #include "core/fxcrt/include/fx_safe_types.h" |
| 14 | #include "core/fxcrt/include/fx_xml.h" |
dsinclair | 48baa5f | 2016-04-06 10:00:40 -0700 | [diff] [blame] | 15 | #include "core/fxge/include/fx_ge.h" |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 16 | #include "fpdfsdk/pdfwindow/PWL_Caret.h" |
| 17 | #include "fpdfsdk/pdfwindow/PWL_EditCtrl.h" |
| 18 | #include "fpdfsdk/pdfwindow/PWL_FontMap.h" |
| 19 | #include "fpdfsdk/pdfwindow/PWL_ScrollBar.h" |
| 20 | #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
| 21 | #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 22 | #include "public/fpdf_fwlevent.h" |
Tom Sepez | ab27768 | 2016-02-17 10:07:21 -0800 | [diff] [blame] | 23 | #include "third_party/base/stl_util.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 25 | CPWL_Edit::CPWL_Edit() |
dsinclair | 8da140e | 2016-04-07 12:39:44 -0700 | [diff] [blame] | 26 | : m_pFillerNotify(nullptr), m_bFocus(FALSE), m_pFormFiller(nullptr) {} |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 27 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 28 | CPWL_Edit::~CPWL_Edit() { |
| 29 | ASSERT(m_bFocus == FALSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 30 | } |
| 31 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 32 | CFX_ByteString CPWL_Edit::GetClassName() const { |
| 33 | return PWL_CLASSNAME_EDIT; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 36 | void CPWL_Edit::OnDestroy() {} |
| 37 | |
| 38 | void CPWL_Edit::SetText(const FX_WCHAR* csText) { |
| 39 | CFX_WideString swText = csText; |
| 40 | |
| 41 | if (HasFlag(PES_RICH)) { |
| 42 | CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText); |
| 43 | |
| 44 | if (CXML_Element* pXML = |
| 45 | CXML_Element::Parse(sValue.c_str(), sValue.GetLength())) { |
| 46 | int32_t nCount = pXML->CountChildren(); |
| 47 | FX_BOOL bFirst = TRUE; |
| 48 | |
tsepez | 774bdde | 2016-04-14 09:49:44 -0700 | [diff] [blame] | 49 | swText.clear(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 50 | |
| 51 | for (int32_t i = 0; i < nCount; i++) { |
| 52 | if (CXML_Element* pSubElement = pXML->GetElement(i)) { |
| 53 | CFX_ByteString tag = pSubElement->GetTagName(); |
| 54 | if (tag.EqualNoCase("p")) { |
| 55 | int nChild = pSubElement->CountChildren(); |
| 56 | CFX_WideString swSection; |
| 57 | for (int32_t j = 0; j < nChild; j++) { |
| 58 | swSection += pSubElement->GetContent(j); |
| 59 | } |
| 60 | |
| 61 | if (bFirst) |
| 62 | bFirst = FALSE; |
| 63 | else |
| 64 | swText += FWL_VKEY_Return; |
| 65 | swText += swSection; |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | delete pXML; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | m_pEdit->SetText(swText.c_str()); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 75 | } |
| 76 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 77 | void CPWL_Edit::RePosChildWnd() { |
| 78 | if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 79 | CFX_FloatRect rcWindow = m_rcOldWindow; |
| 80 | CFX_FloatRect rcVScroll = |
| 81 | CFX_FloatRect(rcWindow.right, rcWindow.bottom, |
| 82 | rcWindow.right + PWL_SCROLLBAR_WIDTH, rcWindow.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 83 | pVSB->Move(rcVScroll, TRUE, FALSE); |
| 84 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 85 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 86 | if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW)) |
| 87 | m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( |
Dan Sinclair | 50cce60 | 2016-02-24 09:51:16 -0500 | [diff] [blame] | 88 | GetClientRect(), 1.0f)); // +1 for caret beside border |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 89 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 90 | CPWL_EditCtrl::RePosChildWnd(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 93 | CFX_FloatRect CPWL_Edit::GetClientRect() const { |
| 94 | CFX_FloatRect rcClient = CPWL_Utils::DeflateRect( |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 95 | GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth())); |
| 96 | |
| 97 | if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { |
| 98 | if (pVSB->IsVisible()) { |
| 99 | rcClient.right -= PWL_SCROLLBAR_WIDTH; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | return rcClient; |
| 104 | } |
| 105 | |
| 106 | void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 107 | FX_BOOL bPaint) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 108 | m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint); |
| 109 | } |
| 110 | |
| 111 | void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 112 | FX_BOOL bPaint) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 113 | m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint); |
| 114 | } |
| 115 | |
| 116 | FX_BOOL CPWL_Edit::CanSelectAll() const { |
| 117 | return GetSelectWordRange() != m_pEdit->GetWholeWordRange(); |
| 118 | } |
| 119 | |
| 120 | FX_BOOL CPWL_Edit::CanClear() const { |
| 121 | return !IsReadOnly() && m_pEdit->IsSelected(); |
| 122 | } |
| 123 | |
| 124 | FX_BOOL CPWL_Edit::CanCopy() const { |
| 125 | return !HasFlag(PES_PASSWORD) && !HasFlag(PES_NOREAD) && |
| 126 | m_pEdit->IsSelected(); |
| 127 | } |
| 128 | |
| 129 | FX_BOOL CPWL_Edit::CanCut() const { |
| 130 | return CanCopy() && !IsReadOnly(); |
| 131 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 132 | void CPWL_Edit::CutText() { |
| 133 | if (!CanCut()) |
| 134 | return; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 135 | m_pEdit->Clear(); |
| 136 | } |
| 137 | |
| 138 | void CPWL_Edit::OnCreated() { |
| 139 | CPWL_EditCtrl::OnCreated(); |
| 140 | |
| 141 | if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 142 | pScroll->RemoveFlag(PWS_AUTOTRANSPARENT); |
| 143 | pScroll->SetTransparency(255); |
| 144 | } |
| 145 | |
| 146 | SetParamByFlag(); |
| 147 | |
| 148 | m_rcOldWindow = GetWindowRect(); |
| 149 | |
| 150 | m_pEdit->SetOprNotify(this); |
| 151 | m_pEdit->EnableOprNotify(TRUE); |
| 152 | } |
| 153 | |
| 154 | void CPWL_Edit::SetParamByFlag() { |
| 155 | if (HasFlag(PES_RIGHT)) { |
| 156 | m_pEdit->SetAlignmentH(2, FALSE); |
| 157 | } else if (HasFlag(PES_MIDDLE)) { |
| 158 | m_pEdit->SetAlignmentH(1, FALSE); |
| 159 | } else { |
| 160 | m_pEdit->SetAlignmentH(0, FALSE); |
| 161 | } |
| 162 | |
| 163 | if (HasFlag(PES_BOTTOM)) { |
| 164 | m_pEdit->SetAlignmentV(2, FALSE); |
| 165 | } else if (HasFlag(PES_CENTER)) { |
| 166 | m_pEdit->SetAlignmentV(1, FALSE); |
| 167 | } else { |
| 168 | m_pEdit->SetAlignmentV(0, FALSE); |
| 169 | } |
| 170 | |
| 171 | if (HasFlag(PES_PASSWORD)) { |
| 172 | m_pEdit->SetPasswordChar('*', FALSE); |
| 173 | } |
| 174 | |
| 175 | m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE); |
| 176 | m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE); |
| 177 | m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE); |
| 178 | m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE); |
| 179 | m_pEdit->EnableUndo(HasFlag(PES_UNDO)); |
| 180 | |
| 181 | if (HasFlag(PES_TEXTOVERFLOW)) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 182 | SetClipRect(CFX_FloatRect(0.0f, 0.0f, 0.0f, 0.0f)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 183 | m_pEdit->SetTextOverflow(TRUE, FALSE); |
| 184 | } else { |
| 185 | if (m_pEditCaret) { |
| 186 | m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect( |
Dan Sinclair | 50cce60 | 2016-02-24 09:51:16 -0500 | [diff] [blame] | 187 | GetClientRect(), 1.0f)); // +1 for caret beside border |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 188 | } |
| 189 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 190 | } |
| 191 | |
| 192 | void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) { |
| 193 | CPWL_Wnd::GetThisAppearanceStream(sAppStream); |
| 194 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 195 | CFX_FloatRect rcClient = GetClientRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 196 | CFX_ByteTextBuf sLine; |
| 197 | |
| 198 | int32_t nCharArray = m_pEdit->GetCharArray(); |
| 199 | |
| 200 | if (nCharArray > 0) { |
| 201 | switch (GetBorderStyle()) { |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 202 | case BorderStyle::SOLID: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 203 | sLine << "q\n" << GetBorderWidth() << " w\n" |
| 204 | << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 205 | .AsStringC() |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 206 | << " 2 J 0 j\n"; |
| 207 | |
| 208 | for (int32_t i = 1; i < nCharArray; i++) { |
| 209 | sLine << rcClient.left + |
| 210 | ((rcClient.right - rcClient.left) / nCharArray) * i |
| 211 | << " " << rcClient.bottom << " m\n" |
| 212 | << rcClient.left + |
| 213 | ((rcClient.right - rcClient.left) / nCharArray) * i |
| 214 | << " " << rcClient.top << " l S\n"; |
| 215 | } |
| 216 | |
| 217 | sLine << "Q\n"; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 218 | break; |
| 219 | } |
| 220 | case BorderStyle::DASH: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 221 | sLine << "q\n" << GetBorderWidth() << " w\n" |
| 222 | << CPWL_Utils::GetColorAppStream(GetBorderColor(), FALSE) |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 223 | .AsStringC() |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 224 | << " 2 J 0 j\n" |
| 225 | << "[" << GetBorderDash().nDash << " " << GetBorderDash().nGap |
| 226 | << "] " << GetBorderDash().nPhase << " d\n"; |
| 227 | |
| 228 | for (int32_t i = 1; i < nCharArray; i++) { |
| 229 | sLine << rcClient.left + |
| 230 | ((rcClient.right - rcClient.left) / nCharArray) * i |
| 231 | << " " << rcClient.bottom << " m\n" |
| 232 | << rcClient.left + |
| 233 | ((rcClient.right - rcClient.left) / nCharArray) * i |
| 234 | << " " << rcClient.top << " l S\n"; |
| 235 | } |
| 236 | |
| 237 | sLine << "Q\n"; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 238 | break; |
| 239 | } |
| 240 | default: |
| 241 | break; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 242 | } |
| 243 | } |
| 244 | |
| 245 | sAppStream << sLine; |
| 246 | |
| 247 | CFX_ByteTextBuf sText; |
| 248 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 249 | CFX_FloatPoint ptOffset = CFX_FloatPoint(0.0f, 0.0f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 250 | |
| 251 | CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange(); |
| 252 | CPVT_WordRange wrSelect = GetSelectWordRange(); |
| 253 | CPVT_WordRange wrVisible = |
| 254 | (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange()); |
| 255 | CPVT_WordRange wrSelBefore(wrWhole.BeginPos, wrSelect.BeginPos); |
| 256 | CPVT_WordRange wrSelAfter(wrSelect.EndPos, wrWhole.EndPos); |
| 257 | |
| 258 | CPVT_WordRange wrTemp = |
| 259 | CPWL_Utils::OverlapWordRange(GetSelectWordRange(), wrVisible); |
| 260 | CFX_ByteString sEditSel = |
| 261 | CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wrTemp); |
| 262 | |
| 263 | if (sEditSel.GetLength() > 0) |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 264 | sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR).AsStringC() |
| 265 | << sEditSel.AsStringC(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 266 | |
| 267 | wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelBefore); |
| 268 | CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream( |
| 269 | m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
| 270 | m_pEdit->GetPasswordChar()); |
| 271 | |
| 272 | if (sEditBefore.GetLength() > 0) |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 273 | sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() |
| 274 | << sEditBefore.AsStringC() << "ET\n"; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 275 | |
| 276 | wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelect); |
| 277 | CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream( |
| 278 | m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
| 279 | m_pEdit->GetPasswordChar()); |
| 280 | |
| 281 | if (sEditMid.GetLength() > 0) |
| 282 | sText << "BT\n" |
| 283 | << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY, 1)) |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 284 | .AsStringC() |
| 285 | << sEditMid.AsStringC() << "ET\n"; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 286 | |
| 287 | wrTemp = CPWL_Utils::OverlapWordRange(wrVisible, wrSelAfter); |
| 288 | CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream( |
| 289 | m_pEdit, ptOffset, &wrTemp, !HasFlag(PES_CHARARRAY), |
| 290 | m_pEdit->GetPasswordChar()); |
| 291 | |
| 292 | if (sEditAfter.GetLength() > 0) |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 293 | sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() |
| 294 | << sEditAfter.AsStringC() << "ET\n"; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 295 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 296 | if (sText.GetLength() > 0) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 297 | CFX_FloatRect rcClient = GetClientRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 298 | sAppStream << "q\n/Tx BMC\n"; |
| 299 | |
| 300 | if (!HasFlag(PES_TEXTOVERFLOW)) |
| 301 | sAppStream << rcClient.left << " " << rcClient.bottom << " " |
| 302 | << rcClient.right - rcClient.left << " " |
| 303 | << rcClient.top - rcClient.bottom << " re W n\n"; |
| 304 | |
| 305 | sAppStream << sText; |
| 306 | |
| 307 | sAppStream << "EMC\nQ\n"; |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 312 | CFX_Matrix* pUser2Device) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 313 | CPWL_Wnd::DrawThisAppearance(pDevice, pUser2Device); |
| 314 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 315 | CFX_FloatRect rcClient = GetClientRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 316 | CFX_ByteTextBuf sLine; |
| 317 | |
| 318 | int32_t nCharArray = m_pEdit->GetCharArray(); |
| 319 | FX_SAFE_INT32 nCharArraySafe = nCharArray; |
| 320 | nCharArraySafe -= 1; |
| 321 | nCharArraySafe *= 2; |
| 322 | |
| 323 | if (nCharArray > 0 && nCharArraySafe.IsValid()) { |
| 324 | switch (GetBorderStyle()) { |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 325 | case BorderStyle::SOLID: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 326 | CFX_GraphStateData gsd; |
| 327 | gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 328 | |
| 329 | CFX_PathData path; |
| 330 | path.SetPointCount(nCharArraySafe.ValueOrDie()); |
| 331 | |
| 332 | for (int32_t i = 0; i < nCharArray - 1; i++) { |
| 333 | path.SetPoint( |
| 334 | i * 2, |
| 335 | rcClient.left + |
| 336 | ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 337 | rcClient.bottom, FXPT_MOVETO); |
| 338 | path.SetPoint( |
| 339 | i * 2 + 1, |
| 340 | rcClient.left + |
| 341 | ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 342 | rcClient.top, FXPT_LINETO); |
| 343 | } |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 344 | if (path.GetPointCount() > 0) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 345 | pDevice->DrawPath( |
| 346 | &path, pUser2Device, &gsd, 0, |
| 347 | CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
| 348 | FXFILL_ALTERNATE); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 349 | } |
| 350 | break; |
| 351 | } |
| 352 | case BorderStyle::DASH: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 353 | CFX_GraphStateData gsd; |
| 354 | gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth(); |
| 355 | |
| 356 | gsd.SetDashCount(2); |
| 357 | gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash; |
| 358 | gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap; |
| 359 | gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase; |
| 360 | |
| 361 | CFX_PathData path; |
| 362 | path.SetPointCount(nCharArraySafe.ValueOrDie()); |
| 363 | |
| 364 | for (int32_t i = 0; i < nCharArray - 1; i++) { |
| 365 | path.SetPoint( |
| 366 | i * 2, |
| 367 | rcClient.left + |
| 368 | ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 369 | rcClient.bottom, FXPT_MOVETO); |
| 370 | path.SetPoint( |
| 371 | i * 2 + 1, |
| 372 | rcClient.left + |
| 373 | ((rcClient.right - rcClient.left) / nCharArray) * (i + 1), |
| 374 | rcClient.top, FXPT_LINETO); |
| 375 | } |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 376 | if (path.GetPointCount() > 0) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 377 | pDevice->DrawPath( |
| 378 | &path, pUser2Device, &gsd, 0, |
| 379 | CPWL_Utils::PWLColorToFXColor(GetBorderColor(), 255), |
| 380 | FXFILL_ALTERNATE); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame^] | 381 | } |
| 382 | break; |
| 383 | } |
| 384 | default: |
| 385 | break; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 389 | CFX_FloatRect rcClip; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 390 | CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange(); |
| 391 | CPVT_WordRange* pRange = NULL; |
| 392 | |
| 393 | if (!HasFlag(PES_TEXTOVERFLOW)) { |
| 394 | rcClip = GetClientRect(); |
| 395 | pRange = &wrRange; |
| 396 | } |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 397 | CFX_SystemHandler* pSysHandler = GetSystemHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 398 | IFX_Edit::DrawEdit( |
| 399 | pDevice, pUser2Device, m_pEdit, |
| 400 | CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 401 | CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(), GetTransparency()), |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 402 | rcClip, CFX_FloatPoint(0.0f, 0.0f), pRange, pSysHandler, m_pFormFiller); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 403 | } |
| 404 | |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 405 | FX_BOOL CPWL_Edit::OnLButtonDown(const CFX_FloatPoint& point, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 406 | CPWL_Wnd::OnLButtonDown(point, nFlag); |
| 407 | |
| 408 | if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
| 409 | if (m_bMouseDown) |
| 410 | InvalidateRect(); |
| 411 | |
| 412 | m_bMouseDown = TRUE; |
| 413 | SetCapture(); |
| 414 | |
| 415 | m_pEdit->OnMouseDown(point, IsSHIFTpressed(nFlag), IsCTRLpressed(nFlag)); |
| 416 | } |
| 417 | |
| 418 | return TRUE; |
| 419 | } |
| 420 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 421 | FX_BOOL CPWL_Edit::OnLButtonDblClk(const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 422 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 423 | CPWL_Wnd::OnLButtonDblClk(point, nFlag); |
| 424 | |
| 425 | if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point)) { |
| 426 | m_pEdit->SelectAll(); |
| 427 | } |
| 428 | |
| 429 | return TRUE; |
| 430 | } |
| 431 | |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 432 | FX_BOOL CPWL_Edit::OnRButtonUp(const CFX_FloatPoint& point, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 433 | if (m_bMouseDown) |
| 434 | return FALSE; |
| 435 | |
| 436 | CPWL_Wnd::OnRButtonUp(point, nFlag); |
| 437 | |
| 438 | if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) |
| 439 | return TRUE; |
| 440 | |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 441 | CFX_SystemHandler* pSH = GetSystemHandler(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 442 | if (!pSH) |
| 443 | return FALSE; |
| 444 | |
| 445 | SetFocus(); |
| 446 | |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 447 | return FALSE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | void CPWL_Edit::OnSetFocus() { |
| 451 | SetEditCaret(TRUE); |
| 452 | |
| 453 | if (!IsReadOnly()) { |
| 454 | if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) |
| 455 | pFocusHandler->OnSetFocus(this); |
| 456 | } |
| 457 | |
| 458 | m_bFocus = TRUE; |
| 459 | } |
| 460 | |
| 461 | void CPWL_Edit::OnKillFocus() { |
| 462 | ShowVScrollBar(FALSE); |
| 463 | |
| 464 | m_pEdit->SelectNone(); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 465 | SetCaret(FALSE, CFX_FloatPoint(0.0f, 0.0f), CFX_FloatPoint(0.0f, 0.0f)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 466 | |
| 467 | SetCharSet(0); |
| 468 | |
| 469 | if (!IsReadOnly()) { |
| 470 | if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler()) |
| 471 | pFocusHandler->OnKillFocus(this); |
| 472 | } |
| 473 | |
| 474 | m_bFocus = FALSE; |
| 475 | } |
| 476 | |
| 477 | void CPWL_Edit::SetHorzScale(int32_t nHorzScale, FX_BOOL bPaint /* = TRUE*/) { |
| 478 | m_pEdit->SetHorzScale(nHorzScale, bPaint); |
| 479 | } |
| 480 | |
| 481 | void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint /* = TRUE*/) { |
| 482 | m_pEdit->SetCharSpace(fCharSpace, bPaint); |
| 483 | } |
| 484 | |
| 485 | void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, |
| 486 | FX_BOOL bPaint /* = TRUE*/) { |
| 487 | m_pEdit->SetLineLeading(fLineLeading, bPaint); |
| 488 | } |
| 489 | |
| 490 | CFX_ByteString CPWL_Edit::GetSelectAppearanceStream( |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 491 | const CFX_FloatPoint& ptOffset) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 492 | CPVT_WordRange wr = GetSelectWordRange(); |
| 493 | return CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset, &wr); |
| 494 | } |
| 495 | |
| 496 | CPVT_WordRange CPWL_Edit::GetSelectWordRange() const { |
| 497 | if (m_pEdit->IsSelected()) { |
| 498 | int32_t nStart = -1; |
| 499 | int32_t nEnd = -1; |
| 500 | |
| 501 | m_pEdit->GetSel(nStart, nEnd); |
| 502 | |
| 503 | CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart); |
| 504 | CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd); |
| 505 | |
| 506 | return CPVT_WordRange(wpStart, wpEnd); |
| 507 | } |
| 508 | |
| 509 | return CPVT_WordRange(); |
| 510 | } |
| 511 | |
| 512 | CFX_ByteString CPWL_Edit::GetTextAppearanceStream( |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 513 | const CFX_FloatPoint& ptOffset) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 514 | CFX_ByteTextBuf sRet; |
| 515 | CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 516 | if (sEdit.GetLength() > 0) { |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 517 | sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()).AsStringC() |
| 518 | << sEdit.AsStringC() << "ET\n"; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 519 | } |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 520 | return sRet.MakeString(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | CFX_ByteString CPWL_Edit::GetCaretAppearanceStream( |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 524 | const CFX_FloatPoint& ptOffset) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 525 | if (m_pEditCaret) |
| 526 | return m_pEditCaret->GetCaretAppearanceStream(ptOffset); |
| 527 | |
| 528 | return CFX_ByteString(); |
| 529 | } |
| 530 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 531 | CFX_FloatPoint CPWL_Edit::GetWordRightBottomPoint( |
| 532 | const CPVT_WordPlace& wpWord) { |
| 533 | CFX_FloatPoint pt(0.0f, 0.0f); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 534 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 535 | IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
| 536 | CPVT_WordPlace wpOld = pIterator->GetAt(); |
| 537 | pIterator->SetAt(wpWord); |
| 538 | CPVT_Word word; |
| 539 | if (pIterator->GetWord(word)) { |
| 540 | pt = CFX_FloatPoint(word.ptWord.x + word.fWidth, |
| 541 | word.ptWord.y + word.fDescent); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 542 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 543 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 544 | pIterator->SetAt(wpOld); |
| 545 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 546 | return pt; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 547 | } |
| 548 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 549 | FX_BOOL CPWL_Edit::IsTextFull() const { |
| 550 | return m_pEdit->IsTextFull(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 551 | } |
| 552 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 553 | FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 554 | const CFX_FloatRect& rcPlate, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 555 | int32_t nCharArray) { |
| 556 | if (pFont && !pFont->IsStandardFont()) { |
| 557 | FX_RECT rcBBox; |
| 558 | pFont->GetFontBBox(rcBBox); |
| 559 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 560 | CFX_FloatRect rcCell = rcPlate; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 561 | FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width(); |
| 562 | FX_FLOAT ydiv = -rcCell.Height() * 1000.0f / rcBBox.Height(); |
| 563 | |
| 564 | return xdiv < ydiv ? xdiv : ydiv; |
| 565 | } |
| 566 | |
| 567 | return 0.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 568 | } |
| 569 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 570 | void CPWL_Edit::SetCharArray(int32_t nCharArray) { |
| 571 | if (HasFlag(PES_CHARARRAY) && nCharArray > 0) { |
| 572 | m_pEdit->SetCharArray(nCharArray); |
| 573 | m_pEdit->SetTextOverflow(TRUE); |
| 574 | |
| 575 | if (HasFlag(PWS_AUTOFONTSIZE)) { |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 576 | if (IPVT_FontMap* pFontMap = GetFontMap()) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 577 | FX_FLOAT fFontSize = GetCharArrayAutoFontSize( |
| 578 | pFontMap->GetPDFFont(0), GetClientRect(), nCharArray); |
| 579 | if (fFontSize > 0.0f) { |
| 580 | m_pEdit->SetAutoFontSize(FALSE); |
| 581 | m_pEdit->SetFontSize(fFontSize); |
| 582 | } |
| 583 | } |
| 584 | } |
| 585 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 586 | } |
| 587 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 588 | void CPWL_Edit::SetLimitChar(int32_t nLimitChar) { |
| 589 | m_pEdit->SetLimitChar(nLimitChar); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 590 | } |
| 591 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 592 | void CPWL_Edit::ReplaceSel(const FX_WCHAR* csText) { |
| 593 | m_pEdit->Clear(); |
| 594 | m_pEdit->InsertText(csText); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 597 | CFX_FloatRect CPWL_Edit::GetFocusRect() const { |
| 598 | return CFX_FloatRect(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 599 | } |
| 600 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 601 | void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow) { |
| 602 | if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 603 | if (bShow) { |
| 604 | if (!pScroll->IsVisible()) { |
| 605 | pScroll->SetVisible(TRUE); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 606 | CFX_FloatRect rcWindow = GetWindowRect(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 607 | m_rcOldWindow = rcWindow; |
| 608 | rcWindow.right += PWL_SCROLLBAR_WIDTH; |
| 609 | Move(rcWindow, TRUE, TRUE); |
| 610 | } |
| 611 | } else { |
| 612 | if (pScroll->IsVisible()) { |
| 613 | pScroll->SetVisible(FALSE); |
| 614 | Move(m_rcOldWindow, TRUE, TRUE); |
| 615 | } |
| 616 | } |
| 617 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 618 | } |
| 619 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 620 | FX_BOOL CPWL_Edit::IsVScrollBarVisible() const { |
| 621 | if (CPWL_ScrollBar* pScroll = GetVScrollBar()) { |
| 622 | return pScroll->IsVisible(); |
| 623 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 624 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 625 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 626 | } |
| 627 | |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 628 | FX_BOOL CPWL_Edit::OnKeyDown(uint16_t nChar, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 629 | if (m_bMouseDown) |
| 630 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 631 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 632 | if (nChar == FWL_VKEY_Delete) { |
| 633 | if (m_pFillerNotify) { |
| 634 | FX_BOOL bRC = TRUE; |
| 635 | FX_BOOL bExit = FALSE; |
| 636 | CFX_WideString strChange; |
| 637 | CFX_WideString strChangeEx; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 638 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 639 | int nSelStart = 0; |
| 640 | int nSelEnd = 0; |
| 641 | GetSel(nSelStart, nSelEnd); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 642 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 643 | if (nSelStart == nSelEnd) |
| 644 | nSelEnd = nSelStart + 1; |
Lei Zhang | a5b4704 | 2015-10-19 14:32:16 -0700 | [diff] [blame] | 645 | m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), strChange, |
| 646 | strChangeEx, nSelStart, nSelEnd, TRUE, |
| 647 | bRC, bExit, nFlag); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 648 | if (!bRC) |
| 649 | return FALSE; |
| 650 | if (bExit) |
| 651 | return FALSE; |
| 652 | } |
| 653 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 654 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 655 | FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 656 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 657 | // In case of implementation swallow the OnKeyDown event. |
| 658 | if (IsProceedtoOnChar(nChar, nFlag)) |
| 659 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 660 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 661 | return bRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | /** |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 665 | *In case of implementation swallow the OnKeyDown event. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 666 | *If the event is swallowed, implementation may do other unexpected things, which |
| 667 | *is not the control means to do. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 668 | */ |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 669 | FX_BOOL CPWL_Edit::IsProceedtoOnChar(uint16_t nKeyCode, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 670 | FX_BOOL bCtrl = IsCTRLpressed(nFlag); |
| 671 | FX_BOOL bAlt = IsALTpressed(nFlag); |
| 672 | if (bCtrl && !bAlt) { |
| 673 | // hot keys for edit control. |
| 674 | switch (nKeyCode) { |
| 675 | case 'C': |
| 676 | case 'V': |
| 677 | case 'X': |
| 678 | case 'A': |
| 679 | case 'Z': |
| 680 | return TRUE; |
| 681 | default: |
| 682 | break; |
| 683 | } |
| 684 | } |
| 685 | // control characters. |
| 686 | switch (nKeyCode) { |
| 687 | case FWL_VKEY_Escape: |
| 688 | case FWL_VKEY_Back: |
| 689 | case FWL_VKEY_Return: |
| 690 | case FWL_VKEY_Space: |
| 691 | return TRUE; |
| 692 | default: |
Lei Zhang | a5b4704 | 2015-10-19 14:32:16 -0700 | [diff] [blame] | 693 | return FALSE; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 694 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 695 | } |
| 696 | |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 697 | FX_BOOL CPWL_Edit::OnChar(uint16_t nChar, uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 698 | if (m_bMouseDown) |
| 699 | return TRUE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 700 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 701 | FX_BOOL bRC = TRUE; |
| 702 | FX_BOOL bExit = FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 703 | |
Lei Zhang | a5b4704 | 2015-10-19 14:32:16 -0700 | [diff] [blame] | 704 | if (!IsCTRLpressed(nFlag)) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 705 | if (m_pFillerNotify) { |
| 706 | CFX_WideString swChange; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 707 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 708 | int nSelStart = 0; |
| 709 | int nSelEnd = 0; |
| 710 | GetSel(nSelStart, nSelEnd); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 711 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 712 | switch (nChar) { |
| 713 | case FWL_VKEY_Back: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 714 | if (nSelStart == nSelEnd) |
| 715 | nSelStart = nSelEnd - 1; |
| 716 | break; |
| 717 | case FWL_VKEY_Return: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 718 | break; |
| 719 | default: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 720 | swChange += nChar; |
| 721 | break; |
| 722 | } |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 723 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 724 | CFX_WideString strChangeEx; |
Lei Zhang | a5b4704 | 2015-10-19 14:32:16 -0700 | [diff] [blame] | 725 | m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swChange, |
| 726 | strChangeEx, nSelStart, nSelEnd, TRUE, |
| 727 | bRC, bExit, nFlag); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 728 | } |
| 729 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 730 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 731 | if (!bRC) |
| 732 | return TRUE; |
| 733 | if (bExit) |
| 734 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 735 | |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 736 | if (IPVT_FontMap* pFontMap = GetFontMap()) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 737 | int32_t nOldCharSet = GetCharSet(); |
| 738 | int32_t nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET); |
| 739 | if (nOldCharSet != nNewCharSet) { |
| 740 | SetCharSet(nNewCharSet); |
| 741 | } |
| 742 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 743 | |
Lei Zhang | a5b4704 | 2015-10-19 14:32:16 -0700 | [diff] [blame] | 744 | return CPWL_EditCtrl::OnChar(nChar, nFlag); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 745 | } |
| 746 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 747 | FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 748 | const CFX_FloatPoint& point, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 749 | uint32_t nFlag) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 750 | if (HasFlag(PES_MULTILINE)) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 751 | CFX_FloatPoint ptScroll = GetScrollPos(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 752 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 753 | if (zDelta > 0) { |
| 754 | ptScroll.y += GetFontSize(); |
| 755 | } else { |
| 756 | ptScroll.y -= GetFontSize(); |
| 757 | } |
| 758 | SetScrollPos(ptScroll); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 759 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 760 | return TRUE; |
| 761 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 762 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 763 | return FALSE; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 764 | } |
| 765 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 766 | void CPWL_Edit::OnInsertReturn(const CPVT_WordPlace& place, |
| 767 | const CPVT_WordPlace& oldplace) { |
| 768 | if (HasFlag(PES_SPELLCHECK)) { |
| 769 | m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 770 | GetLatinWordsRange(place))); |
| 771 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 772 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 773 | if (m_pEditNotify) { |
| 774 | m_pEditNotify->OnInsertReturn(place, oldplace); |
| 775 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 776 | } |
| 777 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 778 | void CPWL_Edit::OnBackSpace(const CPVT_WordPlace& place, |
| 779 | const CPVT_WordPlace& oldplace) { |
| 780 | if (HasFlag(PES_SPELLCHECK)) { |
| 781 | m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 782 | GetLatinWordsRange(place))); |
| 783 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 784 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 785 | if (m_pEditNotify) { |
| 786 | m_pEditNotify->OnBackSpace(place, oldplace); |
| 787 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 788 | } |
| 789 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 790 | void CPWL_Edit::OnDelete(const CPVT_WordPlace& place, |
| 791 | const CPVT_WordPlace& oldplace) { |
| 792 | if (HasFlag(PES_SPELLCHECK)) { |
| 793 | m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 794 | GetLatinWordsRange(place))); |
| 795 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 796 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 797 | if (m_pEditNotify) { |
| 798 | m_pEditNotify->OnDelete(place, oldplace); |
| 799 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 800 | } |
| 801 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 802 | void CPWL_Edit::OnClear(const CPVT_WordPlace& place, |
| 803 | const CPVT_WordPlace& oldplace) { |
| 804 | if (HasFlag(PES_SPELLCHECK)) { |
| 805 | m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 806 | GetLatinWordsRange(place))); |
| 807 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 808 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 809 | if (m_pEditNotify) { |
| 810 | m_pEditNotify->OnClear(place, oldplace); |
| 811 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 812 | } |
| 813 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 814 | void CPWL_Edit::OnInsertWord(const CPVT_WordPlace& place, |
| 815 | const CPVT_WordPlace& oldplace) { |
| 816 | if (HasFlag(PES_SPELLCHECK)) { |
| 817 | m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 818 | GetLatinWordsRange(place))); |
| 819 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 820 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 821 | if (m_pEditNotify) { |
| 822 | m_pEditNotify->OnInsertWord(place, oldplace); |
| 823 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 824 | } |
| 825 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 826 | void CPWL_Edit::OnSetText(const CPVT_WordPlace& place, |
| 827 | const CPVT_WordPlace& oldplace) {} |
| 828 | |
| 829 | void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place, |
| 830 | const CPVT_WordPlace& oldplace) { |
| 831 | if (HasFlag(PES_SPELLCHECK)) { |
| 832 | m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace), |
| 833 | GetLatinWordsRange(place))); |
| 834 | } |
| 835 | |
| 836 | if (m_pEditNotify) { |
| 837 | m_pEditNotify->OnInsertText(place, oldplace); |
| 838 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 839 | } |
| 840 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 841 | void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem) { |
| 842 | if (m_pEditNotify) { |
| 843 | m_pEditNotify->OnAddUndo(this); |
| 844 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 845 | } |
| 846 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 847 | CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1, |
| 848 | const CPVT_WordRange& wr2) { |
| 849 | CPVT_WordRange wrRet; |
| 850 | |
| 851 | if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) { |
| 852 | wrRet.BeginPos = wr1.BeginPos; |
| 853 | } else { |
| 854 | wrRet.BeginPos = wr2.BeginPos; |
| 855 | } |
| 856 | |
| 857 | if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
| 858 | wrRet.EndPos = wr2.EndPos; |
| 859 | } else { |
| 860 | wrRet.EndPos = wr1.EndPos; |
| 861 | } |
| 862 | |
| 863 | return wrRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 864 | } |
| 865 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 866 | CPVT_WordRange CPWL_Edit::GetLatinWordsRange( |
| 867 | const CFX_FloatPoint& point) const { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 868 | return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 869 | } |
| 870 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 871 | CPVT_WordRange CPWL_Edit::GetLatinWordsRange( |
| 872 | const CPVT_WordPlace& place) const { |
| 873 | return GetSameWordsRange(place, TRUE, FALSE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 874 | } |
| 875 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 876 | CPVT_WordRange CPWL_Edit::GetArabicWordsRange( |
| 877 | const CPVT_WordPlace& place) const { |
| 878 | return GetSameWordsRange(place, FALSE, TRUE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 879 | } |
| 880 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 881 | #define PWL_ISARABICWORD(word) \ |
| 882 | ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC)) |
| 883 | |
| 884 | CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace& place, |
| 885 | FX_BOOL bLatin, |
| 886 | FX_BOOL bArabic) const { |
| 887 | CPVT_WordRange range; |
| 888 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 889 | IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator(); |
| 890 | CPVT_Word wordinfo; |
| 891 | CPVT_WordPlace wpStart(place), wpEnd(place); |
| 892 | pIterator->SetAt(place); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 893 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 894 | if (bLatin) { |
| 895 | while (pIterator->NextWord()) { |
| 896 | if (!pIterator->GetWord(wordinfo) || |
| 897 | !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 898 | break; |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 899 | } |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 900 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 901 | wpEnd = pIterator->GetAt(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 902 | } |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 903 | } else if (bArabic) { |
| 904 | while (pIterator->NextWord()) { |
| 905 | if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
| 906 | break; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 907 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 908 | wpEnd = pIterator->GetAt(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 909 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 910 | } |
| 911 | |
thestig | 821d59e | 2016-05-11 12:59:22 -0700 | [diff] [blame] | 912 | pIterator->SetAt(place); |
| 913 | |
| 914 | if (bLatin) { |
| 915 | do { |
| 916 | if (!pIterator->GetWord(wordinfo) || |
| 917 | !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 918 | break; |
| 919 | } |
| 920 | |
| 921 | wpStart = pIterator->GetAt(); |
| 922 | } while (pIterator->PrevWord()); |
| 923 | } else if (bArabic) { |
| 924 | do { |
| 925 | if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
| 926 | break; |
| 927 | |
| 928 | wpStart = pIterator->GetAt(); |
| 929 | } while (pIterator->PrevWord()); |
| 930 | } |
| 931 | |
| 932 | range.Set(wpStart, wpEnd); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 933 | return range; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 934 | } |
| 935 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 936 | void CPWL_Edit::GeneratePageObjects( |
Tom Sepez | 2398d89 | 2016-02-17 16:46:26 -0800 | [diff] [blame] | 937 | CPDF_PageObjectHolder* pObjectHolder, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 938 | const CFX_FloatPoint& ptOffset, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 939 | CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 940 | IFX_Edit::GeneratePageObjects( |
Tom Sepez | 2398d89 | 2016-02-17 16:46:26 -0800 | [diff] [blame] | 941 | pObjectHolder, m_pEdit, ptOffset, NULL, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 942 | CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 943 | ObjArray); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 944 | } |
| 945 | |
Tom Sepez | 2398d89 | 2016-02-17 16:46:26 -0800 | [diff] [blame] | 946 | void CPWL_Edit::GeneratePageObjects(CPDF_PageObjectHolder* pObjectHolder, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 947 | const CFX_FloatPoint& ptOffset) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 948 | CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 949 | IFX_Edit::GeneratePageObjects( |
Tom Sepez | 2398d89 | 2016-02-17 16:46:26 -0800 | [diff] [blame] | 950 | pObjectHolder, m_pEdit, ptOffset, NULL, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 951 | CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 952 | ObjArray); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 953 | } |