blob: 1cbbf9a17e39d3833d079423552b1f2717dbbb82 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// 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.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "../../include/pdfwindow/PDFWindow.h"
8#include "../../include/pdfwindow/PWL_Wnd.h"
9#include "../../include/pdfwindow/PWL_EditCtrl.h"
10#include "../../include/pdfwindow/PWL_Edit.h"
11#include "../../include/pdfwindow/PWL_ScrollBar.h"
12#include "../../include/pdfwindow/PWL_Utils.h"
13#include "../../include/pdfwindow/PWL_Caret.h"
14#include "../../include/pdfwindow/PWL_FontMap.h"
Tom Sepez53476d62015-02-04 10:48:28 -080015#include "../../../core/src/fxcrt/fx_safe_types.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070016
17/* ---------------------------- CPWL_Edit ------------------------------ */
18
19CPWL_Edit::CPWL_Edit() : m_pFillerNotify(NULL),
20 m_pSpellCheck(NULL),
21 m_bFocus(FALSE)
22{
23 m_pFormFiller = NULL;
24}
25
26CPWL_Edit::~CPWL_Edit()
27{
28 ASSERT(m_bFocus == FALSE);
29}
30
31CFX_ByteString CPWL_Edit::GetClassName() const
32{
33 return PWL_CLASSNAME_EDIT;
34}
35
36void CPWL_Edit::OnDestroy()
37{
38}
39
40void CPWL_Edit::SetText(FX_LPCWSTR csText)
41{
42 CFX_WideString swText = csText;
43
44 if (HasFlag(PES_RICH))
45 {
46 CFX_ByteString sValue = CFX_ByteString::FromUnicode(swText);
47
Bo Xuc6164832014-12-30 16:56:12 -080048 if (CXML_Element * pXML = CXML_Element::Parse(sValue.c_str(), sValue.GetLength()))
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070049 {
50 FX_INT32 nCount = pXML->CountChildren();
51 FX_BOOL bFirst = TRUE;
52
53 swText.Empty();
54
55 for (FX_INT32 i=0; i<nCount; i++)
56 {
57 if (CXML_Element * pSubElement = pXML->GetElement(i))
58 {
59 CFX_ByteString tag=pSubElement->GetTagName();
60 if (tag.EqualNoCase("p"))
61 {
62 int nChild = pSubElement->CountChildren();
63 CFX_WideString swSection;
64 for(FX_INT32 j=0; j<nChild; j++)
65 {
66 swSection += pSubElement->GetContent(j);
67 }
68
69 if (bFirst)bFirst = FALSE;
70 else
71 swText += FWL_VKEY_Return;
72 swText += swSection;
73 }
74 }
75 }
76
77 delete pXML;
78 }
79 }
80
81 m_pEdit->SetText(swText);
82}
83
84void CPWL_Edit::RePosChildWnd()
85{
86 if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
87 {
88 //if (pVSB->IsVisible())
89 {
90 CPDF_Rect rcWindow = m_rcOldWindow;
91 CPDF_Rect rcVScroll = CPDF_Rect(rcWindow.right,
92 rcWindow.bottom,
93 rcWindow.right + PWL_SCROLLBAR_WIDTH,
94 rcWindow.top);
95 pVSB->Move(rcVScroll, TRUE, FALSE);
96 }
97 }
98
99 if (m_pEditCaret && !HasFlag(PES_TEXTOVERFLOW))
100 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(GetClientRect(),1.0f)); //+1 for caret beside border
101
102 CPWL_EditCtrl::RePosChildWnd();
103}
104
105CPDF_Rect CPWL_Edit::GetClientRect() const
106{
107 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
108
109 if (CPWL_ScrollBar * pVSB = this->GetVScrollBar())
110 {
111 if (pVSB->IsVisible())
112 {
113 rcClient.right -= PWL_SCROLLBAR_WIDTH;
114 }
115 }
116
117 return rcClient;
118}
119
120void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, FX_BOOL bPaint/* = TRUE*/)
121{
122 m_pEdit->SetAlignmentH((FX_INT32)nFormat, bPaint);
123}
124
125void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, FX_BOOL bPaint/* = TRUE*/)
126{
127 m_pEdit->SetAlignmentV((FX_INT32)nFormat, bPaint);
128}
129
130FX_BOOL CPWL_Edit::CanSelectAll() const
131{
132 return GetSelectWordRange() != m_pEdit->GetWholeWordRange();
133}
134
135FX_BOOL CPWL_Edit::CanClear() const
136{
137 return !IsReadOnly() && m_pEdit->IsSelected();
138}
139
140FX_BOOL CPWL_Edit::CanCopy() const
141{
142 return !HasFlag(PES_PASSWORD) && !HasFlag(PES_NOREAD) && m_pEdit->IsSelected();
143}
144
145FX_BOOL CPWL_Edit::CanCut() const
146{
147 return CanCopy() && !IsReadOnly();
148}
149
150FX_BOOL CPWL_Edit::CanPaste() const
151{
152 if (IsReadOnly()) return FALSE;
153
154 CFX_WideString swClipboard;
155 if (IFX_SystemHandler* pSH = GetSystemHandler())
156 swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
157
158 return !swClipboard.IsEmpty();
159}
160
161void CPWL_Edit::CopyText()
162{
163 if (!CanCopy()) return;
164
165 CFX_WideString str = m_pEdit->GetSelText();
166
167 if (IFX_SystemHandler* pSH = GetSystemHandler())
168 pSH->SetClipboardText(GetAttachedHWnd(), str);
169}
170
171void CPWL_Edit::PasteText()
172{
173 if (!CanPaste()) return;
174
175 CFX_WideString swClipboard;
176 if (IFX_SystemHandler* pSH = GetSystemHandler())
177 swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
178
179 if (m_pFillerNotify)
180 {
181 FX_BOOL bRC = TRUE;
182 FX_BOOL bExit = FALSE;
183 CFX_WideString strChangeEx;
184 int nSelStart = 0;
185 int nSelEnd = 0;
186 GetSel(nSelStart, nSelEnd);
187 m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), 0 , swClipboard, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, 0);
188 if (!bRC) return;
189 if (bExit) return;
190 }
191
192 if (swClipboard.GetLength() > 0)
193 {
194 Clear();
195 InsertText(swClipboard);
196 }
197
198 if (m_pFillerNotify)
199 {
200 FX_BOOL bExit = FALSE;
201 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,0);
202 if (bExit) return;
203 }
204}
205
206void CPWL_Edit::CutText()
207{
208 if (!CanCut()) return;
209
210 CFX_WideString str = m_pEdit->GetSelText();
211
212 if (IFX_SystemHandler* pSH = GetSystemHandler())
213 pSH->SetClipboardText(GetAttachedHWnd(), str);
214
215 m_pEdit->Clear();
216}
217
218void CPWL_Edit::OnCreated()
219{
220 CPWL_EditCtrl::OnCreated();
221
222 if (CPWL_ScrollBar * pScroll = GetVScrollBar())
223 {
224 pScroll->RemoveFlag(PWS_AUTOTRANSPARENT);
225 pScroll->SetTransparency(255);
226 }
227
228 SetParamByFlag();
229
230 m_rcOldWindow = GetWindowRect();
231
232 m_pEdit->SetOprNotify(this);
233 m_pEdit->EnableOprNotify(TRUE);
234}
235
236void CPWL_Edit::SetParamByFlag()
237{
238 if (HasFlag(PES_RIGHT))
239 {
240 m_pEdit->SetAlignmentH(2, FALSE);
241 }
242 else if (HasFlag(PES_MIDDLE))
243 {
244 m_pEdit->SetAlignmentH(1, FALSE);
245 }
246 else
247 {
248 m_pEdit->SetAlignmentH(0, FALSE);
249 }
250
251 if (HasFlag(PES_BOTTOM))
252 {
253 m_pEdit->SetAlignmentV(2, FALSE);
254 }
255 else if (HasFlag(PES_CENTER))
256 {
257 m_pEdit->SetAlignmentV(1, FALSE);
258 }
259 else
260 {
261 m_pEdit->SetAlignmentV(0, FALSE);
262 }
263
264 if (HasFlag(PES_PASSWORD))
265 {
266 m_pEdit->SetPasswordChar('*', FALSE);
267 }
268
269 m_pEdit->SetMultiLine(HasFlag(PES_MULTILINE), FALSE);
270 m_pEdit->SetAutoReturn(HasFlag(PES_AUTORETURN), FALSE);
271 m_pEdit->SetAutoFontSize(HasFlag(PWS_AUTOFONTSIZE), FALSE);
272 m_pEdit->SetAutoScroll(HasFlag(PES_AUTOSCROLL), FALSE);
273 m_pEdit->EnableUndo(HasFlag(PES_UNDO));
274
275 if (HasFlag(PES_TEXTOVERFLOW))
276 {
277 SetClipRect(CPDF_Rect(0.0f,0.0f,0.0f,0.0f));
278 m_pEdit->SetTextOverflow(TRUE, FALSE);
279 }
280 else
281 {
282 if (m_pEditCaret)
283 {
284 m_pEditCaret->SetClipRect(CPWL_Utils::InflateRect(GetClientRect(),1.0f)); //+1 for caret beside border
285 }
286 }
287
288 if (HasFlag(PES_SPELLCHECK))
289 {
290 m_pSpellCheck = GetCreationParam().pSpellCheck;
291 }
292}
293
294void CPWL_Edit::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
295{
296 CPWL_Wnd::GetThisAppearanceStream(sAppStream);
297
298 CPDF_Rect rcClient = GetClientRect();
299 CFX_ByteTextBuf sLine;
300
301 FX_INT32 nCharArray = m_pEdit->GetCharArray();
302
303 if (nCharArray > 0)
304 {
305 switch (GetBorderStyle())
306 {
307 case PBS_SOLID:
308 {
309 sLine << "q\n" << GetBorderWidth() << " w\n"
310 << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n";
311
312 for (FX_INT32 i=1;i<nCharArray;i++)
313 {
314 sLine << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
315 << rcClient.bottom << " m\n"
316 << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
317 << rcClient.top << " l S\n";
318 }
319
320 sLine << "Q\n";
321 }
322 break;
323 case PBS_DASH:
324 {
325 sLine << "q\n" << GetBorderWidth() << " w\n"
326 << CPWL_Utils::GetColorAppStream(GetBorderColor(),FALSE) << " 2 J 0 j\n"
327 << "[" << GetBorderDash().nDash << " "
328 << GetBorderDash().nGap << "] "
329 << GetBorderDash().nPhase << " d\n";
330
331 for (FX_INT32 i=1;i<nCharArray;i++)
332 {
333 sLine << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
334 << rcClient.bottom << " m\n"
335 << rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*i << " "
336 << rcClient.top << " l S\n";
337 }
338
339 sLine << "Q\n";
340 }
341 break;
342 }
343 }
344
345 sAppStream << sLine;
346
347 CFX_ByteTextBuf sText;
348
349 CPDF_Point ptOffset = CPDF_Point(0.0f,0.0f);
350
351 CPVT_WordRange wrWhole = m_pEdit->GetWholeWordRange();
352 CPVT_WordRange wrSelect = GetSelectWordRange();
353 CPVT_WordRange wrVisible = (HasFlag(PES_TEXTOVERFLOW) ? wrWhole : m_pEdit->GetVisibleWordRange());
354 CPVT_WordRange wrSelBefore(wrWhole.BeginPos,wrSelect.BeginPos);
355 CPVT_WordRange wrSelAfter(wrSelect.EndPos,wrWhole.EndPos);
356
357 CPVT_WordRange wrTemp = CPWL_Utils::OverlapWordRange(GetSelectWordRange(),wrVisible);
358 CFX_ByteString sEditSel = CPWL_Utils::GetEditSelAppStream(m_pEdit, ptOffset,
359 &wrTemp);
360
361 if (sEditSel.GetLength() > 0)
362 sText << CPWL_Utils::GetColorAppStream(PWL_DEFAULT_SELBACKCOLOR) << sEditSel ;
363
364 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelBefore);
365 CFX_ByteString sEditBefore = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,
366 &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());
367
368 if (sEditBefore.GetLength() > 0)
369 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditBefore << "ET\n";
370
371 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelect);
372 CFX_ByteString sEditMid = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,
373 &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());
374
375 if (sEditMid.GetLength() > 0)
376 sText << "BT\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_GRAY,1)) << sEditMid << "ET\n";
377
378 wrTemp = CPWL_Utils::OverlapWordRange(wrVisible,wrSelAfter);
379 CFX_ByteString sEditAfter = CPWL_Utils::GetEditAppStream(m_pEdit, ptOffset,
380 &wrTemp, !HasFlag(PES_CHARARRAY), m_pEdit->GetPasswordChar());
381
382 if (sEditAfter.GetLength() > 0)
383 sText << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEditAfter<< "ET\n";
384
385 if (HasFlag(PES_SPELLCHECK))
386 {
387 CFX_ByteString sSpellCheck = CPWL_Utils::GetSpellCheckAppStream(m_pEdit, m_pSpellCheck, ptOffset, &wrVisible);
388 if (sSpellCheck.GetLength() > 0)
389 sText << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB,1,0,0),FALSE) << sSpellCheck;
390 }
391
392 if (sText.GetLength() > 0)
393 {
394 CPDF_Rect rcClient = this->GetClientRect();
395 sAppStream << "q\n/Tx BMC\n";
396
397 if (!HasFlag(PES_TEXTOVERFLOW))
398 sAppStream << rcClient.left << " " << rcClient.bottom << " "
399 << rcClient.right - rcClient.left << " " << rcClient.top - rcClient.bottom << " re W n\n";
400
401 sAppStream << sText;
402
403 sAppStream << "EMC\nQ\n";
404 }
405}
406
407void CPWL_Edit::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
408{
409 CPWL_Wnd::DrawThisAppearance(pDevice,pUser2Device);
410
411 CPDF_Rect rcClient = GetClientRect();
412 CFX_ByteTextBuf sLine;
413
414 FX_INT32 nCharArray = m_pEdit->GetCharArray();
Bo Xua94019d2014-08-18 11:33:03 -0700415 FX_SAFE_INT32 nCharArraySafe = nCharArray;
416 nCharArraySafe -= 1;
417 nCharArraySafe *= 2;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700418
Bo Xua94019d2014-08-18 11:33:03 -0700419 if (nCharArray > 0 && nCharArraySafe.IsValid())
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700420 {
421 switch (GetBorderStyle())
422 {
423 case PBS_SOLID:
424 {
425 CFX_GraphStateData gsd;
426 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
427
428 CFX_PathData path;
Bo Xua94019d2014-08-18 11:33:03 -0700429 if (!path.SetPointCount(nCharArraySafe.ValueOrDie())) {
430 return;
431 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700432
433 for (FX_INT32 i=0; i<nCharArray-1; i++)
434 {
435 path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
436 rcClient.bottom, FXPT_MOVETO);
437 path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
438 rcClient.top, FXPT_LINETO);
439 }
440 if (path.GetPointCount() > 0)
441 pDevice->DrawPath(&path, pUser2Device, &gsd,0,
442 CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
443 }
444 break;
445 case PBS_DASH:
446 {
447 CFX_GraphStateData gsd;
448 gsd.m_LineWidth = (FX_FLOAT)GetBorderWidth();
449
450 gsd.SetDashCount(2);
451 gsd.m_DashArray[0] = (FX_FLOAT)GetBorderDash().nDash;
452 gsd.m_DashArray[1] = (FX_FLOAT)GetBorderDash().nGap;
453 gsd.m_DashPhase = (FX_FLOAT)GetBorderDash().nPhase;
454
455 CFX_PathData path;
Bo Xua94019d2014-08-18 11:33:03 -0700456 if (!path.SetPointCount(nCharArraySafe.ValueOrDie())) {
457 return;
458 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700459
460 for (FX_INT32 i=0; i<nCharArray-1; i++)
461 {
462 path.SetPoint(i*2, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
463 rcClient.bottom, FXPT_MOVETO);
464 path.SetPoint(i*2+1, rcClient.left + ((rcClient.right - rcClient.left)/nCharArray)*(i+1),
465 rcClient.top, FXPT_LINETO);
466 }
467 if (path.GetPointCount() > 0)
468 pDevice->DrawPath(&path, pUser2Device, &gsd,0,
469 CPWL_Utils::PWLColorToFXColor(GetBorderColor(),255), FXFILL_ALTERNATE);
470 }
471 break;
472 }
473 }
474
475 CPDF_Rect rcClip;
476 CPVT_WordRange wrRange = m_pEdit->GetVisibleWordRange();
477 CPVT_WordRange* pRange = NULL;
478
479 if (!HasFlag(PES_TEXTOVERFLOW))
480 {
481 rcClip = GetClientRect();
482 pRange = &wrRange;
483 }
484IFX_SystemHandler* pSysHandler = GetSystemHandler();
485 IFX_Edit::DrawEdit(pDevice,pUser2Device,m_pEdit,
486 CPWL_Utils::PWLColorToFXColor(GetTextColor(),this->GetTransparency()),
487 CPWL_Utils::PWLColorToFXColor(GetTextStrokeColor(),this->GetTransparency()),
488 rcClip,CPDF_Point(0.0f,0.0f),pRange, pSysHandler, m_pFormFiller);
489
490 if (HasFlag(PES_SPELLCHECK))
491 {
492 CPWL_Utils::DrawEditSpellCheck(pDevice,pUser2Device,m_pEdit,rcClip,
493 CPDF_Point(0.0f,0.0f),pRange, this->GetCreationParam().pSpellCheck);
494 }
495}
496
497FX_BOOL CPWL_Edit::OnLButtonDown(const CPDF_Point & point, FX_DWORD nFlag)
498{
499 CPWL_Wnd::OnLButtonDown(point,nFlag);
500
501 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
502 {
503 if (m_bMouseDown)
504 this->InvalidateRect();
505
506 m_bMouseDown = TRUE;
507 SetCapture();
508
509 m_pEdit->OnMouseDown(point,IsSHIFTpressed(nFlag),IsCTRLpressed(nFlag));
510 }
511
512 return TRUE;
513}
514
515FX_BOOL CPWL_Edit::OnLButtonDblClk(const CPDF_Point & point, FX_DWORD nFlag)
516{
517 CPWL_Wnd::OnLButtonDblClk(point, nFlag);
518
519 if (HasFlag(PES_TEXTOVERFLOW) || ClientHitTest(point))
520 {
521 m_pEdit->SelectAll();
522 }
523
524 return TRUE;
525}
526
527#define WM_PWLEDIT_UNDO 0x01
528#define WM_PWLEDIT_REDO 0x02
529#define WM_PWLEDIT_CUT 0x03
530#define WM_PWLEDIT_COPY 0x04
531#define WM_PWLEDIT_PASTE 0x05
532#define WM_PWLEDIT_DELETE 0x06
533#define WM_PWLEDIT_SELECTALL 0x07
534#define WM_PWLEDIT_SUGGEST 0x08
535
536FX_BOOL CPWL_Edit::OnRButtonUp(const CPDF_Point & point, FX_DWORD nFlag)
537{
538 if (m_bMouseDown) return FALSE;
539
540 CPWL_Wnd::OnRButtonUp(point, nFlag);
541
542 if (!HasFlag(PES_TEXTOVERFLOW) && !ClientHitTest(point)) return TRUE;
543
544 IFX_SystemHandler* pSH = GetSystemHandler();
545 if (!pSH) return FALSE;
546
547 this->SetFocus();
548
549 CPVT_WordRange wrLatin = GetLatinWordsRange(point);
550 CFX_WideString swLatin = m_pEdit->GetRangeText(wrLatin);
551
552 FX_HMENU hPopup = pSH->CreatePopupMenu();
553 if (!hPopup) return FALSE;
554
555 CFX_ByteStringArray sSuggestWords;
556 CPDF_Point ptPopup = point;
557
558 if (!IsReadOnly())
559 {
560 if (HasFlag(PES_SPELLCHECK) && !swLatin.IsEmpty())
561 {
562 if (m_pSpellCheck)
563 {
564 CFX_ByteString sLatin = CFX_ByteString::FromUnicode(swLatin);
565
566 if (!m_pSpellCheck->CheckWord(sLatin))
567 {
568 m_pSpellCheck->SuggestWords(sLatin,sSuggestWords);
569
570 FX_INT32 nSuggest = sSuggestWords.GetSize();
571
572 for (FX_INT32 nWord=0; nWord<nSuggest; nWord++)
573 {
574 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SUGGEST+nWord, sSuggestWords[nWord].UTF8Decode());
575 }
576
577 if (nSuggest > 0)
578 pSH->AppendMenuItem(hPopup, 0, L"");
579
580 ptPopup = GetWordRightBottomPoint(wrLatin.EndPos);
581 }
582 }
583 }
584 }
585
586 IPWL_Provider* pProvider = this->GetProvider();
587
588 if (HasFlag(PES_UNDO))
589 {
590 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_UNDO,
591 pProvider ? pProvider->LoadPopupMenuString(0) : L"&Undo");
592 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_REDO,
593 pProvider ? pProvider->LoadPopupMenuString(1) : L"&Redo");
594 pSH->AppendMenuItem(hPopup, 0, L"");
595
596 if (!m_pEdit->CanUndo())
597 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_UNDO, FALSE);
598 if (!m_pEdit->CanRedo())
599 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_REDO, FALSE);
600 }
601
602 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_CUT,
603 pProvider ? pProvider->LoadPopupMenuString(2) : L"Cu&t");
604 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_COPY,
605 pProvider ? pProvider->LoadPopupMenuString(3) : L"&Copy");
606 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_PASTE,
607 pProvider ? pProvider->LoadPopupMenuString(4) : L"&Paste");
608 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_DELETE,
609 pProvider ? pProvider->LoadPopupMenuString(5) : L"&Delete");
610
611 CFX_WideString swText = pSH->GetClipboardText(this->GetAttachedHWnd());
612 if (swText.IsEmpty())
613 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
614
615 if (!m_pEdit->IsSelected())
616 {
617 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
618 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
619 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
620 }
621
622 if (IsReadOnly())
623 {
624 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
625 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_DELETE, FALSE);
626 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_PASTE, FALSE);
627 }
628
629 if (HasFlag(PES_PASSWORD))
630 {
631 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
632 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
633 }
634
635 if (HasFlag(PES_NOREAD))
636 {
637 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_CUT, FALSE);
638 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_COPY, FALSE);
639 }
640
641 pSH->AppendMenuItem(hPopup, 0, L"");
642 pSH->AppendMenuItem(hPopup, WM_PWLEDIT_SELECTALL,
643 pProvider ? pProvider->LoadPopupMenuString(6) : L"&Select All");
644
645 if (m_pEdit->GetTotalWords() == 0)
646 {
647 pSH->EnableMenuItem(hPopup, WM_PWLEDIT_SELECTALL, FALSE);
648 }
649
650 FX_INT32 x, y;
651 PWLtoWnd(ptPopup, x, y);
652 pSH->ClientToScreen(GetAttachedHWnd(), x, y);
653 pSH->SetCursor(FXCT_ARROW);
654 FX_INT32 nCmd = pSH->TrackPopupMenu(hPopup,
655 x,
656 y,
657 GetAttachedHWnd());
658
659
660 switch (nCmd)
661 {
662 case WM_PWLEDIT_UNDO:
663 Undo();
664 break;
665 case WM_PWLEDIT_REDO:
666 Redo();
667 break;
668 case WM_PWLEDIT_CUT:
669 this->CutText();
670 break;
671 case WM_PWLEDIT_COPY:
672 this->CopyText();
673 break;
674 case WM_PWLEDIT_PASTE:
675 this->PasteText();
676 break;
677 case WM_PWLEDIT_DELETE:
678 this->Clear();
679 break;
680 case WM_PWLEDIT_SELECTALL:
681 this->SelectAll();
682 break;
683 case WM_PWLEDIT_SUGGEST + 0:
684 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
685 ReplaceSel(sSuggestWords[0].UTF8Decode());
686 break;
687 case WM_PWLEDIT_SUGGEST + 1:
688 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
689 ReplaceSel(sSuggestWords[1].UTF8Decode());
690 break;
691 case WM_PWLEDIT_SUGGEST + 2:
692 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
693 ReplaceSel(sSuggestWords[2].UTF8Decode());
694 break;
695 case WM_PWLEDIT_SUGGEST + 3:
696 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
697 ReplaceSel(sSuggestWords[3].UTF8Decode());
698 break;
699 case WM_PWLEDIT_SUGGEST + 4:
700 SetSel(m_pEdit->WordPlaceToWordIndex(wrLatin.BeginPos),m_pEdit->WordPlaceToWordIndex(wrLatin.EndPos));
701 ReplaceSel(sSuggestWords[4].UTF8Decode());
702 break;
703 default:
704 break;
705 }
706
707 pSH->DestroyMenu(hPopup);
708
709 return TRUE;
710}
711
712void CPWL_Edit::OnSetFocus()
713{
714 SetEditCaret(TRUE);
715
716 if (!IsReadOnly())
717 {
718 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
719 pFocusHandler->OnSetFocus(this);
720 }
721
722 m_bFocus = TRUE;
723}
724
725void CPWL_Edit::OnKillFocus()
726{
727 ShowVScrollBar(FALSE);
728
729 m_pEdit->SelectNone();
730 SetCaret(FALSE, CPDF_Point(0.0f,0.0f), CPDF_Point(0.0f,0.0f));
731
732 SetCharSet(0);
733
734 if (!IsReadOnly())
735 {
736 if (IPWL_FocusHandler* pFocusHandler = GetFocusHandler())
737 pFocusHandler->OnKillFocus(this);
738 }
739
740 m_bFocus = FALSE;
741}
742
743void CPWL_Edit::SetHorzScale(FX_INT32 nHorzScale, FX_BOOL bPaint/* = TRUE*/)
744{
745 m_pEdit->SetHorzScale(nHorzScale, bPaint);
746}
747
748void CPWL_Edit::SetCharSpace(FX_FLOAT fCharSpace, FX_BOOL bPaint/* = TRUE*/)
749{
750 m_pEdit->SetCharSpace(fCharSpace, bPaint);
751}
752
753void CPWL_Edit::SetLineLeading(FX_FLOAT fLineLeading, FX_BOOL bPaint/* = TRUE*/)
754{
755 m_pEdit->SetLineLeading(fLineLeading, bPaint);
756}
757
758CFX_ByteString CPWL_Edit::GetSelectAppearanceStream(const CPDF_Point & ptOffset) const
759{
760 CPVT_WordRange wr = GetSelectWordRange();
761 return CPWL_Utils::GetEditSelAppStream(m_pEdit,ptOffset,&wr);
762}
763
764CPVT_WordRange CPWL_Edit::GetSelectWordRange() const
765{
766 if (m_pEdit->IsSelected())
767 {
768 FX_INT32 nStart = -1;
769 FX_INT32 nEnd = -1;
770
771 m_pEdit->GetSel(nStart, nEnd);
772
773 CPVT_WordPlace wpStart = m_pEdit->WordIndexToWordPlace(nStart);
774 CPVT_WordPlace wpEnd = m_pEdit->WordIndexToWordPlace(nEnd);
775
776 return CPVT_WordRange(wpStart,wpEnd);
777 }
778
779 return CPVT_WordRange();
780}
781
782CFX_ByteString CPWL_Edit::GetTextAppearanceStream(const CPDF_Point & ptOffset) const
783{
784 CFX_ByteTextBuf sRet;
785 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(m_pEdit,ptOffset);
786
787 if (sEdit.GetLength() > 0)
788 {
789 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(GetTextColor()) << sEdit << "ET\n";
790 }
791
792 return sRet.GetByteString();
793}
794
795CFX_ByteString CPWL_Edit::GetCaretAppearanceStream(const CPDF_Point & ptOffset) const
796{
797 if (m_pEditCaret)
798 return m_pEditCaret->GetCaretAppearanceStream(ptOffset);
799
800 return CFX_ByteString();
801}
802
803CPDF_Point CPWL_Edit::GetWordRightBottomPoint(const CPVT_WordPlace& wpWord)
804{
805 CPDF_Point pt(0.0f, 0.0f);
806
807 if (IFX_Edit_Iterator * pIterator = m_pEdit->GetIterator())
808 {
809 CPVT_WordPlace wpOld = pIterator->GetAt();
810 pIterator->SetAt(wpWord);
811 CPVT_Word word;
812 if (pIterator->GetWord(word))
813 {
814 pt = CPDF_Point(word.ptWord.x + word.fWidth, word.ptWord.y + word.fDescent);
815 }
816
817 pIterator->SetAt(wpOld);
818 }
819
820 return pt;
821}
822
823FX_BOOL CPWL_Edit::IsTextFull() const
824{
825 return m_pEdit->IsTextFull();
826}
827
828FX_FLOAT CPWL_Edit::GetCharArrayAutoFontSize(CPDF_Font* pFont, const CPDF_Rect& rcPlate, FX_INT32 nCharArray)
829{
830 if (pFont && !pFont->IsStandardFont())
831 {
832 FX_RECT rcBBox;
833 pFont->GetFontBBox(rcBBox);
834
835 CPDF_Rect rcCell = rcPlate;
836 FX_FLOAT xdiv = rcCell.Width() / nCharArray * 1000.0f / rcBBox.Width();
837 FX_FLOAT ydiv = - rcCell.Height() * 1000.0f / rcBBox.Height();
838
839 return xdiv < ydiv ? xdiv : ydiv;
840 }
841
842 return 0.0f;
843}
844
845void CPWL_Edit::SetCharArray(FX_INT32 nCharArray)
846{
847 if (HasFlag(PES_CHARARRAY) && nCharArray > 0)
848 {
849 m_pEdit->SetCharArray(nCharArray);
850 m_pEdit->SetTextOverflow(TRUE);
851
852 if (HasFlag(PWS_AUTOFONTSIZE))
853 {
854 if (IFX_Edit_FontMap* pFontMap = this->GetFontMap())
855 {
856 FX_FLOAT fFontSize = GetCharArrayAutoFontSize(pFontMap->GetPDFFont(0), GetClientRect(), nCharArray);
857 if (fFontSize > 0.0f)
858 {
859 m_pEdit->SetAutoFontSize(FALSE);
860 m_pEdit->SetFontSize(fFontSize);
861 }
862 }
863 }
864 }
865}
866
867void CPWL_Edit::SetLimitChar(FX_INT32 nLimitChar)
868{
869 m_pEdit->SetLimitChar(nLimitChar);
870}
871
872void CPWL_Edit::ReplaceSel(FX_LPCWSTR csText)
873{
874 m_pEdit->Clear();
875 m_pEdit->InsertText(csText);
876}
877
878CPDF_Rect CPWL_Edit::GetFocusRect() const
879{
880 return CPDF_Rect();
881}
882
883void CPWL_Edit::ShowVScrollBar(FX_BOOL bShow)
884{
885 if (CPWL_ScrollBar * pScroll = GetVScrollBar())
886 {
887 if (bShow)
888 {
889 if (!pScroll->IsVisible())
890 {
891 pScroll->SetVisible(TRUE);
892 CPDF_Rect rcWindow = GetWindowRect();
893 m_rcOldWindow = rcWindow;
894 rcWindow.right += PWL_SCROLLBAR_WIDTH;
895 Move(rcWindow, TRUE, TRUE);
896 }
897 }
898 else
899 {
900 if (pScroll->IsVisible())
901 {
902 pScroll->SetVisible(FALSE);
903 Move(m_rcOldWindow, TRUE, TRUE);
904 }
905 }
906 }
907}
908
909FX_BOOL CPWL_Edit::IsVScrollBarVisible() const
910{
911 if (CPWL_ScrollBar * pScroll = GetVScrollBar())
912 {
913 return pScroll->IsVisible();
914 }
915
916 return FALSE;
917}
918
919void CPWL_Edit::EnableSpellCheck(FX_BOOL bEnabled)
920{
921 if (bEnabled)
922 AddFlag(PES_SPELLCHECK);
923 else
924 RemoveFlag(PES_SPELLCHECK);
925}
926
927FX_BOOL CPWL_Edit::OnKeyDown(FX_WORD nChar, FX_DWORD nFlag)
928{
929 if (m_bMouseDown) return TRUE;
930
931 if (nChar == FWL_VKEY_Delete)
932 {
933 if (m_pFillerNotify)
934 {
935 FX_BOOL bRC = TRUE;
936 FX_BOOL bExit = FALSE;
937 CFX_WideString strChange;
938 CFX_WideString strChangeEx;
939
940 int nSelStart = 0;
941 int nSelEnd = 0;
942 GetSel(nSelStart, nSelEnd);
943
944 if (nSelStart == nSelEnd)
945 nSelEnd = nSelStart + 1;
946 m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), FWL_VKEY_Delete, strChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
947 if (!bRC) return FALSE;
948 if (bExit) return FALSE;
949 }
950 }
951
952 FX_BOOL bRet = CPWL_EditCtrl::OnKeyDown(nChar, nFlag);
953
954 if (nChar == FWL_VKEY_Delete)
955 {
956 if (m_pFillerNotify)
957 {
958 FX_BOOL bExit = FALSE;
959 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,nFlag);
960 if (bExit) return FALSE;
961 }
962 }
963
964 //In case of implementation swallow the OnKeyDown event.
965 if(IsProceedtoOnChar(nChar, nFlag))
966 return TRUE;
967
968 return bRet;
969}
970
971/**
972*In case of implementation swallow the OnKeyDown event.
973*If the event is swallowed, implementation may do other unexpected things, which is not the control means to do.
974*/
975FX_BOOL CPWL_Edit::IsProceedtoOnChar(FX_WORD nKeyCode, FX_DWORD nFlag)
976{
977
978 FX_BOOL bCtrl = IsCTRLpressed(nFlag);
979 FX_BOOL bAlt = IsALTpressed(nFlag);
980 if(bCtrl && !bAlt)
981 {
982 //hot keys for edit control.
983 switch(nKeyCode)
984 {
985 case 'C':
986 case 'V':
987 case 'X':
988 case 'A':
989 case 'Z':
990 return TRUE;
991 default:
992 break;
993 }
994 }
995 //control characters.
996 switch(nKeyCode)
997 {
998 case FWL_VKEY_Escape:
999 case FWL_VKEY_Back:
1000 case FWL_VKEY_Return:
1001 case FWL_VKEY_Space:
1002 return TRUE;
1003 default:
1004 break;
1005 }
1006 return FALSE;
1007
1008}
1009
1010FX_BOOL CPWL_Edit::OnChar(FX_WORD nChar, FX_DWORD nFlag)
1011{
1012 if (m_bMouseDown) return TRUE;
1013
1014 FX_BOOL bRC = TRUE;
1015 FX_BOOL bExit = FALSE;
1016
1017 FX_BOOL bCtrl = IsCTRLpressed(nFlag);
1018 if (!bCtrl)
1019 {
1020 if (m_pFillerNotify)
1021 {
1022 CFX_WideString swChange;
1023 FX_INT32 nKeyCode;
1024
1025 int nSelStart = 0;
1026 int nSelEnd = 0;
1027 GetSel(nSelStart, nSelEnd);
1028
1029 switch (nChar)
1030 {
1031 case FWL_VKEY_Back:
1032 nKeyCode = nChar;
1033 if (nSelStart == nSelEnd)
1034 nSelStart = nSelEnd - 1;
1035 break;
1036 case FWL_VKEY_Return:
1037 nKeyCode = nChar;
1038 break;
1039 default:
1040 nKeyCode = 0;
1041 swChange += nChar;
1042 break;
1043 }
1044
1045 CFX_WideString strChangeEx;
1046 m_pFillerNotify->OnBeforeKeyStroke(TRUE, GetAttachedData(), nKeyCode, swChange, strChangeEx, nSelStart, nSelEnd, TRUE, bRC, bExit, nFlag);
1047 }
1048 }
1049
1050 if (!bRC) return TRUE;
1051 if (bExit) return FALSE;
1052
1053 if (IFX_Edit_FontMap * pFontMap = GetFontMap())
1054 {
1055 FX_INT32 nOldCharSet = GetCharSet();
1056 FX_INT32 nNewCharSet = pFontMap->CharSetFromUnicode(nChar, DEFAULT_CHARSET);
1057 if(nOldCharSet != nNewCharSet)
1058 {
1059 SetCharSet(nNewCharSet);
1060 }
1061 }
1062 FX_BOOL bRet = CPWL_EditCtrl::OnChar(nChar,nFlag);
1063
1064 if (!bCtrl)
1065 {
1066 if (m_pFillerNotify)
1067 {
1068 m_pFillerNotify->OnAfterKeyStroke(TRUE, GetAttachedData(), bExit,nFlag);
1069 if (bExit) return FALSE;
1070 }
1071 }
1072
1073 return bRet;
1074}
1075
1076FX_BOOL CPWL_Edit::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
1077{
1078 if (HasFlag(PES_MULTILINE))
1079 {
1080 CPDF_Point ptScroll = GetScrollPos();
1081
1082 if (zDelta > 0)
1083 {
1084 ptScroll.y += this->GetFontSize();
1085 }
1086 else
1087 {
1088 ptScroll.y -= this->GetFontSize();
1089 }
1090 this->SetScrollPos(ptScroll);
1091
1092 return TRUE;
1093 }
1094
1095 return FALSE;
1096}
1097
1098void CPWL_Edit::OnInsertReturn(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1099{
1100 if (HasFlag(PES_SPELLCHECK))
1101 {
1102 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),GetLatinWordsRange(place)));
1103 }
1104
1105 if (m_pEditNotify)
1106 {
1107 m_pEditNotify->OnInsertReturn(place, oldplace);
1108 }
1109}
1110
1111void CPWL_Edit::OnBackSpace(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1112{
1113 if (HasFlag(PES_SPELLCHECK))
1114 {
1115 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),GetLatinWordsRange(place)));
1116 }
1117
1118 if (m_pEditNotify)
1119 {
1120 m_pEditNotify->OnBackSpace(place, oldplace);
1121 }
1122}
1123
1124void CPWL_Edit::OnDelete(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1125{
1126 if (HasFlag(PES_SPELLCHECK))
1127 {
1128 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),GetLatinWordsRange(place)));
1129 }
1130
1131 if (m_pEditNotify)
1132 {
1133 m_pEditNotify->OnDelete(place, oldplace);
1134 }
1135}
1136
1137void CPWL_Edit::OnClear(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1138{
1139 if (HasFlag(PES_SPELLCHECK))
1140 {
1141 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),GetLatinWordsRange(place)));
1142 }
1143
1144 if (m_pEditNotify)
1145 {
1146 m_pEditNotify->OnClear(place, oldplace);
1147 }
1148}
1149
1150void CPWL_Edit::OnInsertWord(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1151{
1152 if (HasFlag(PES_SPELLCHECK))
1153 {
1154 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),GetLatinWordsRange(place)));
1155 }
1156
1157 if (m_pEditNotify)
1158 {
1159 m_pEditNotify->OnInsertWord(place, oldplace);
1160 }
1161}
1162
1163void CPWL_Edit::OnSetText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1164{
1165}
1166
1167void CPWL_Edit::OnInsertText(const CPVT_WordPlace& place, const CPVT_WordPlace& oldplace)
1168{
1169 if (HasFlag(PES_SPELLCHECK))
1170 {
1171 m_pEdit->RefreshWordRange(CombineWordRange(GetLatinWordsRange(oldplace),GetLatinWordsRange(place)));
1172 }
1173
1174 if (m_pEditNotify)
1175 {
1176 m_pEditNotify->OnInsertText(place, oldplace);
1177 }
1178}
1179
1180void CPWL_Edit::OnAddUndo(IFX_Edit_UndoItem* pUndoItem)
1181{
1182 if (m_pEditNotify)
1183 {
1184 m_pEditNotify->OnAddUndo(this);
1185 }
1186}
1187
1188CPVT_WordRange CPWL_Edit::CombineWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2)
1189{
1190 CPVT_WordRange wrRet;
1191
1192 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0)
1193 {
1194 wrRet.BeginPos = wr1.BeginPos;
1195 }
1196 else
1197 {
1198 wrRet.BeginPos = wr2.BeginPos;
1199 }
1200
1201 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0)
1202 {
1203 wrRet.EndPos = wr2.EndPos;
1204 }
1205 else
1206 {
1207 wrRet.EndPos = wr1.EndPos;
1208 }
1209
1210 return wrRet;
1211}
1212
1213CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPDF_Point& point) const
1214{
1215 return GetSameWordsRange(m_pEdit->SearchWordPlace(point), TRUE, FALSE);
1216}
1217
1218CPVT_WordRange CPWL_Edit::GetLatinWordsRange(const CPVT_WordPlace & place) const
1219{
1220 return GetSameWordsRange(place, TRUE, FALSE);
1221}
1222
1223CPVT_WordRange CPWL_Edit::GetArabicWordsRange(const CPVT_WordPlace & place) const
1224{
1225 return GetSameWordsRange(place, FALSE, TRUE);
1226}
1227
1228#define PWL_ISARABICWORD(word) ((word >= 0x0600 && word <= 0x06FF) || (word >= 0xFB50 && word <= 0xFEFC))
1229
1230CPVT_WordRange CPWL_Edit::GetSameWordsRange(const CPVT_WordPlace & place, FX_BOOL bLatin, FX_BOOL bArabic) const
1231{
1232 CPVT_WordRange range;
1233
1234 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator())
1235 {
1236 CPVT_Word wordinfo;
1237 CPVT_WordPlace wpStart(place),wpEnd(place);
1238 pIterator->SetAt(place);
1239
1240 if (bLatin)
1241 {
1242 while (pIterator->NextWord())
1243 {
1244 if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLATINWORD(wordinfo.Word))
1245 {
1246 wpEnd = pIterator->GetAt();
1247 continue;
1248 }
1249 else
1250 break;
1251 };
1252 }
1253 else if (bArabic)
1254 {
1255 while (pIterator->NextWord())
1256 {
1257 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
1258 {
1259 wpEnd = pIterator->GetAt();
1260 continue;
1261 }
1262 else
1263 break;
1264 };
1265 }
1266
1267 pIterator->SetAt(place);
1268
1269 if (bLatin)
1270 {
1271 do
1272 {
1273 if (pIterator->GetWord(wordinfo) && FX_EDIT_ISLATINWORD(wordinfo.Word))
1274 {
1275 continue;
1276 }
1277 else
1278 {
1279 wpStart = pIterator->GetAt();
1280 break;
1281 }
1282 }
1283 while (pIterator->PrevWord());
1284 }
1285 else if (bArabic)
1286 {
1287 do
1288 {
1289 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word))
1290 {
1291 continue;
1292 }
1293 else
1294 {
1295 wpStart = pIterator->GetAt();
1296 break;
1297 }
1298 }
1299 while (pIterator->PrevWord());
1300 }
1301
1302 range.Set(wpStart,wpEnd);
1303 }
1304
1305 return range;
1306}
1307
1308void CPWL_Edit::AjustArabicWords(const CPVT_WordRange& wr)
1309{
1310}
1311
1312void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
1313 const CPDF_Point& ptOffset, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray)
1314{
1315 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray);
1316}
1317
1318void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects,
1319 const CPDF_Point& ptOffset)
1320{
1321 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray;
1322 IFX_Edit::GeneratePageObjects(pPageObjects, m_pEdit, ptOffset, NULL, CPWL_Utils::PWLColorToFXColor(GetTextColor(),GetTransparency()), ObjArray);
1323}
1324