Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: fpdfsdk/fxedit/fxet_edit.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fxedit/fxet_ap.cpp ('k') | fpdfsdk/fxedit/fxet_list.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "fpdfsdk/include/fxedit/fxet_edit.h" 7 #include "fpdfsdk/include/fxedit/fxet_edit.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ASSERT(m_pFontMap); 93 ASSERT(m_pFontMap);
94 } 94 }
95 95
96 CFX_Edit_Provider::~CFX_Edit_Provider() {} 96 CFX_Edit_Provider::~CFX_Edit_Provider() {}
97 97
98 IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() { 98 IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() {
99 return m_pFontMap; 99 return m_pFontMap;
100 } 100 }
101 101
102 int32_t CFX_Edit_Provider::GetCharWidth(int32_t nFontIndex, 102 int32_t CFX_Edit_Provider::GetCharWidth(int32_t nFontIndex,
103 FX_WORD word, 103 uint16_t word,
104 int32_t nWordStyle) { 104 int32_t nWordStyle) {
105 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) { 105 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) {
106 FX_DWORD charcode = word; 106 FX_DWORD charcode = word;
107 107
108 if (pPDFFont->IsUnicodeCompatible()) 108 if (pPDFFont->IsUnicodeCompatible())
109 charcode = pPDFFont->CharCodeFromUnicode(word); 109 charcode = pPDFFont->CharCodeFromUnicode(word);
110 else 110 else
111 charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word); 111 charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word);
112 112
113 if (charcode != -1) 113 if (charcode != -1)
(...skipping 10 matching lines...) Expand all
124 return 0; 124 return 0;
125 } 125 }
126 126
127 int32_t CFX_Edit_Provider::GetTypeDescent(int32_t nFontIndex) { 127 int32_t CFX_Edit_Provider::GetTypeDescent(int32_t nFontIndex) {
128 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) 128 if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
129 return pPDFFont->GetTypeDescent(); 129 return pPDFFont->GetTypeDescent();
130 130
131 return 0; 131 return 0;
132 } 132 }
133 133
134 int32_t CFX_Edit_Provider::GetWordFontIndex(FX_WORD word, 134 int32_t CFX_Edit_Provider::GetWordFontIndex(uint16_t word,
135 int32_t charset, 135 int32_t charset,
136 int32_t nFontIndex) { 136 int32_t nFontIndex) {
137 return m_pFontMap->GetWordFontIndex(word, charset, nFontIndex); 137 return m_pFontMap->GetWordFontIndex(word, charset, nFontIndex);
138 } 138 }
139 139
140 int32_t CFX_Edit_Provider::GetDefaultFontIndex() { 140 int32_t CFX_Edit_Provider::GetDefaultFontIndex() {
141 return 0; 141 return 0;
142 } 142 }
143 143
144 FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word) { 144 FX_BOOL CFX_Edit_Provider::IsLatinWord(uint16_t word) {
145 return FX_EDIT_ISLATINWORD(word); 145 return FX_EDIT_ISLATINWORD(word);
146 } 146 }
147 147
148 CFX_Edit_Refresh::CFX_Edit_Refresh() {} 148 CFX_Edit_Refresh::CFX_Edit_Refresh() {}
149 149
150 CFX_Edit_Refresh::~CFX_Edit_Refresh() {} 150 CFX_Edit_Refresh::~CFX_Edit_Refresh() {}
151 151
152 void CFX_Edit_Refresh::BeginRefresh() { 152 void CFX_Edit_Refresh::BeginRefresh() {
153 m_RefreshRects.Empty(); 153 m_RefreshRects.Empty();
154 m_OldLineRects = m_NewLineRects; 154 m_OldLineRects = m_NewLineRects;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 402 }
403 } 403 }
404 404
405 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() { 405 CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() {
406 return m_sTitle; 406 return m_sTitle;
407 } 407 }
408 408
409 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit* pEdit, 409 CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit* pEdit,
410 const CPVT_WordPlace& wpOldPlace, 410 const CPVT_WordPlace& wpOldPlace,
411 const CPVT_WordPlace& wpNewPlace, 411 const CPVT_WordPlace& wpNewPlace,
412 FX_WORD word, 412 uint16_t word,
413 int32_t charset, 413 int32_t charset,
414 const CPVT_WordProps* pWordProps) 414 const CPVT_WordProps* pWordProps)
415 : m_pEdit(pEdit), 415 : m_pEdit(pEdit),
416 m_wpOld(wpOldPlace), 416 m_wpOld(wpOldPlace),
417 m_wpNew(wpNewPlace), 417 m_wpNew(wpNewPlace),
418 m_Word(word), 418 m_Word(word),
419 m_nCharset(charset), 419 m_nCharset(charset),
420 m_WordProps() { 420 m_WordProps() {
421 if (pWordProps) 421 if (pWordProps)
422 m_WordProps = *pWordProps; 422 m_WordProps = *pWordProps;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 if (m_pEdit) { 470 if (m_pEdit) {
471 m_pEdit->SelectNone(); 471 m_pEdit->SelectNone();
472 m_pEdit->SetCaret(m_wpNew); 472 m_pEdit->SetCaret(m_wpNew);
473 m_pEdit->Backspace(FALSE, TRUE); 473 m_pEdit->Backspace(FALSE, TRUE);
474 } 474 }
475 } 475 }
476 476
477 CFXEU_Backspace::CFXEU_Backspace(CFX_Edit* pEdit, 477 CFXEU_Backspace::CFXEU_Backspace(CFX_Edit* pEdit,
478 const CPVT_WordPlace& wpOldPlace, 478 const CPVT_WordPlace& wpOldPlace,
479 const CPVT_WordPlace& wpNewPlace, 479 const CPVT_WordPlace& wpNewPlace,
480 FX_WORD word, 480 uint16_t word,
481 int32_t charset, 481 int32_t charset,
482 const CPVT_SecProps& SecProps, 482 const CPVT_SecProps& SecProps,
483 const CPVT_WordProps& WordProps) 483 const CPVT_WordProps& WordProps)
484 : m_pEdit(pEdit), 484 : m_pEdit(pEdit),
485 m_wpOld(wpOldPlace), 485 m_wpOld(wpOldPlace),
486 m_wpNew(wpNewPlace), 486 m_wpNew(wpNewPlace),
487 m_Word(word), 487 m_Word(word),
488 m_nCharset(charset), 488 m_nCharset(charset),
489 m_SecProps(SecProps), 489 m_SecProps(SecProps),
490 m_WordProps(WordProps) {} 490 m_WordProps(WordProps) {}
(...skipping 16 matching lines...) Expand all
507 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE); 507 m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE);
508 } else { 508 } else {
509 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE); 509 m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE);
510 } 510 }
511 } 511 }
512 } 512 }
513 513
514 CFXEU_Delete::CFXEU_Delete(CFX_Edit* pEdit, 514 CFXEU_Delete::CFXEU_Delete(CFX_Edit* pEdit,
515 const CPVT_WordPlace& wpOldPlace, 515 const CPVT_WordPlace& wpOldPlace,
516 const CPVT_WordPlace& wpNewPlace, 516 const CPVT_WordPlace& wpNewPlace,
517 FX_WORD word, 517 uint16_t word,
518 int32_t charset, 518 int32_t charset,
519 const CPVT_SecProps& SecProps, 519 const CPVT_SecProps& SecProps,
520 const CPVT_WordProps& WordProps, 520 const CPVT_WordProps& WordProps,
521 FX_BOOL bSecEnd) 521 FX_BOOL bSecEnd)
522 : m_pEdit(pEdit), 522 : m_pEdit(pEdit),
523 m_wpOld(wpOldPlace), 523 m_wpOld(wpOldPlace),
524 m_wpNew(wpNewPlace), 524 m_wpNew(wpNewPlace),
525 m_Word(word), 525 m_Word(word),
526 m_nCharset(charset), 526 m_nCharset(charset),
527 m_SecProps(SecProps), 527 m_SecProps(SecProps),
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, 572 m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE,
573 TRUE); 573 TRUE);
574 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos); 574 m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
575 } 575 }
576 } 576 }
577 577
578 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit, 578 CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit,
579 const CPVT_WordPlace& wpOldPlace, 579 const CPVT_WordPlace& wpOldPlace,
580 const CPVT_WordPlace& wpNewPlace, 580 const CPVT_WordPlace& wpNewPlace,
581 const CPVT_WordRange& wrSel, 581 const CPVT_WordRange& wrSel,
582 FX_WORD word, 582 uint16_t word,
583 int32_t charset, 583 int32_t charset,
584 const CPVT_SecProps& SecProps, 584 const CPVT_SecProps& SecProps,
585 const CPVT_WordProps& WordProps) 585 const CPVT_WordProps& WordProps)
586 : m_pEdit(pEdit), 586 : m_pEdit(pEdit),
587 m_wpOld(wpOldPlace), 587 m_wpOld(wpOldPlace),
588 m_wpNew(wpNewPlace), 588 m_wpNew(wpNewPlace),
589 m_wrSel(wrSel), 589 m_wrSel(wrSel),
590 m_Word(word), 590 m_Word(word),
591 m_nCharset(charset), 591 m_nCharset(charset),
592 m_SecProps(SecProps), 592 m_SecProps(SecProps),
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 if (bPaint) 826 if (bPaint)
827 Paint(); 827 Paint();
828 } 828 }
829 829
830 void CFX_Edit::SetAlignmentV(int32_t nFormat, FX_BOOL bPaint) { 830 void CFX_Edit::SetAlignmentV(int32_t nFormat, FX_BOOL bPaint) {
831 m_nAlignment = nFormat; 831 m_nAlignment = nFormat;
832 if (bPaint) 832 if (bPaint)
833 Paint(); 833 Paint();
834 } 834 }
835 835
836 void CFX_Edit::SetPasswordChar(FX_WORD wSubWord, FX_BOOL bPaint) { 836 void CFX_Edit::SetPasswordChar(uint16_t wSubWord, FX_BOOL bPaint) {
837 m_pVT->SetPasswordChar(wSubWord); 837 m_pVT->SetPasswordChar(wSubWord);
838 if (bPaint) 838 if (bPaint)
839 Paint(); 839 Paint();
840 } 840 }
841 841
842 void CFX_Edit::SetLimitChar(int32_t nLimitChar, FX_BOOL bPaint) { 842 void CFX_Edit::SetLimitChar(int32_t nLimitChar, FX_BOOL bPaint) {
843 m_pVT->SetLimitChar(nLimitChar); 843 m_pVT->SetLimitChar(nLimitChar);
844 if (bPaint) 844 if (bPaint)
845 Paint(); 845 Paint();
846 } 846 }
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1582 return FALSE; 1582 return FALSE;
1583 } 1583 }
1584 1584
1585 void CFX_Edit::SetText(const FX_WCHAR* text, 1585 void CFX_Edit::SetText(const FX_WCHAR* text,
1586 int32_t charset, 1586 int32_t charset,
1587 const CPVT_SecProps* pSecProps, 1587 const CPVT_SecProps* pSecProps,
1588 const CPVT_WordProps* pWordProps) { 1588 const CPVT_WordProps* pWordProps) {
1589 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE); 1589 SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE);
1590 } 1590 }
1591 1591
1592 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, 1592 FX_BOOL CFX_Edit::InsertWord(uint16_t word,
1593 int32_t charset, 1593 int32_t charset,
1594 const CPVT_WordProps* pWordProps) { 1594 const CPVT_WordProps* pWordProps) {
1595 return InsertWord(word, charset, pWordProps, TRUE, TRUE); 1595 return InsertWord(word, charset, pWordProps, TRUE, TRUE);
1596 } 1596 }
1597 1597
1598 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps, 1598 FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps,
1599 const CPVT_WordProps* pWordProps) { 1599 const CPVT_WordProps* pWordProps) {
1600 return InsertReturn(pSecProps, pWordProps, TRUE, TRUE); 1600 return InsertReturn(pSecProps, pWordProps, TRUE, TRUE);
1601 } 1601 }
1602 1602
(...skipping 13 matching lines...) Expand all
1616 int32_t charset, 1616 int32_t charset,
1617 const CPVT_SecProps* pSecProps, 1617 const CPVT_SecProps* pSecProps,
1618 const CPVT_WordProps* pWordProps) { 1618 const CPVT_WordProps* pWordProps) {
1619 return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE); 1619 return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE);
1620 } 1620 }
1621 1621
1622 FX_FLOAT CFX_Edit::GetFontSize() const { 1622 FX_FLOAT CFX_Edit::GetFontSize() const {
1623 return m_pVT->GetFontSize(); 1623 return m_pVT->GetFontSize();
1624 } 1624 }
1625 1625
1626 FX_WORD CFX_Edit::GetPasswordChar() const { 1626 uint16_t CFX_Edit::GetPasswordChar() const {
1627 return m_pVT->GetPasswordChar(); 1627 return m_pVT->GetPasswordChar();
1628 } 1628 }
1629 1629
1630 int32_t CFX_Edit::GetCharArray() const { 1630 int32_t CFX_Edit::GetCharArray() const {
1631 return m_pVT->GetCharArray(); 1631 return m_pVT->GetCharArray();
1632 } 1632 }
1633 1633
1634 CFX_FloatRect CFX_Edit::GetPlateRect() const { 1634 CFX_FloatRect CFX_Edit::GetPlateRect() const {
1635 return m_pVT->GetPlateRect(); 1635 return m_pVT->GetPlateRect();
1636 } 1636 }
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 FX_BOOL bAddUndo, 2460 FX_BOOL bAddUndo,
2461 FX_BOOL bPaint) { 2461 FX_BOOL bPaint) {
2462 Empty(); 2462 Empty();
2463 DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps); 2463 DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps);
2464 if (bPaint) 2464 if (bPaint)
2465 Paint(); 2465 Paint();
2466 if (m_bOprNotify && m_pOprNotify) 2466 if (m_bOprNotify && m_pOprNotify)
2467 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret); 2467 m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret);
2468 } 2468 }
2469 2469
2470 FX_BOOL CFX_Edit::InsertWord(FX_WORD word, 2470 FX_BOOL CFX_Edit::InsertWord(uint16_t word,
2471 int32_t charset, 2471 int32_t charset,
2472 const CPVT_WordProps* pWordProps, 2472 const CPVT_WordProps* pWordProps,
2473 FX_BOOL bAddUndo, 2473 FX_BOOL bAddUndo,
2474 FX_BOOL bPaint) { 2474 FX_BOOL bPaint) {
2475 if (IsTextOverflow()) 2475 if (IsTextOverflow())
2476 return FALSE; 2476 return FALSE;
2477 2477
2478 if (m_pVT->IsValid()) { 2478 if (m_pVT->IsValid()) {
2479 m_pVT->UpdateWordPlace(m_wpCaret); 2479 m_pVT->UpdateWordPlace(m_wpCaret);
2480 2480
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 const FX_WCHAR* text, 2965 const FX_WCHAR* text,
2966 int32_t charset, 2966 int32_t charset,
2967 const CPVT_SecProps* pSecProps, 2967 const CPVT_SecProps* pSecProps,
2968 const CPVT_WordProps* pWordProps) { 2968 const CPVT_WordProps* pWordProps) {
2969 CPVT_WordPlace wp = place; 2969 CPVT_WordPlace wp = place;
2970 2970
2971 if (m_pVT->IsValid()) { 2971 if (m_pVT->IsValid()) {
2972 CFX_WideString sText = text; 2972 CFX_WideString sText = text;
2973 2973
2974 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) { 2974 for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) {
2975 FX_WORD word = sText[i]; 2975 uint16_t word = sText[i];
2976 switch (word) { 2976 switch (word) {
2977 case 0x0D: 2977 case 0x0D:
2978 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); 2978 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps);
2979 if (sText[i + 1] == 0x0A) 2979 if (sText[i + 1] == 0x0A)
2980 i++; 2980 i++;
2981 break; 2981 break;
2982 case 0x0A: 2982 case 0x0A:
2983 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps); 2983 wp = m_pVT->InsertSection(wp, pSecProps, pWordProps);
2984 if (sText[i + 1] == 0x0D) 2984 if (sText[i + 1] == 0x0D)
2985 i++; 2985 i++;
2986 break; 2986 break;
2987 case 0x09: 2987 case 0x09:
2988 word = 0x20; 2988 word = 0x20;
2989 default: 2989 default:
2990 wp = m_pVT->InsertWord(wp, word, GetCharSetFromUnicode(word, charset), 2990 wp = m_pVT->InsertWord(wp, word, GetCharSetFromUnicode(word, charset),
2991 pWordProps); 2991 pWordProps);
2992 break; 2992 break;
2993 } 2993 }
2994 } 2994 }
2995 } 2995 }
2996 2996
2997 return wp; 2997 return wp;
2998 } 2998 }
2999 2999
3000 int32_t CFX_Edit::GetCharSetFromUnicode(FX_WORD word, int32_t nOldCharset) { 3000 int32_t CFX_Edit::GetCharSetFromUnicode(uint16_t word, int32_t nOldCharset) {
3001 if (IFX_Edit_FontMap* pFontMap = GetFontMap()) 3001 if (IFX_Edit_FontMap* pFontMap = GetFontMap())
3002 return pFontMap->CharSetFromUnicode(word, nOldCharset); 3002 return pFontMap->CharSetFromUnicode(word, nOldCharset);
3003 return nOldCharset; 3003 return nOldCharset;
3004 } 3004 }
3005 3005
3006 void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) { 3006 void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) {
3007 ASSERT(!m_pGroupUndoItem); 3007 ASSERT(!m_pGroupUndoItem);
3008 3008
3009 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle); 3009 m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle);
3010 } 3010 }
(...skipping 14 matching lines...) Expand all
3025 if (m_bOprNotify && m_pOprNotify) 3025 if (m_bOprNotify && m_pOprNotify)
3026 m_pOprNotify->OnAddUndo(pEditUndoItem); 3026 m_pOprNotify->OnAddUndo(pEditUndoItem);
3027 } 3027 }
3028 } 3028 }
3029 3029
3030 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) { 3030 void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) {
3031 m_Undo.AddItem(pUndoItem); 3031 m_Undo.AddItem(pUndoItem);
3032 if (m_bOprNotify && m_pOprNotify) 3032 if (m_bOprNotify && m_pOprNotify)
3033 m_pOprNotify->OnAddUndo(pUndoItem); 3033 m_pOprNotify->OnAddUndo(pUndoItem);
3034 } 3034 }
OLDNEW
« no previous file with comments | « fpdfsdk/fxedit/fxet_ap.cpp ('k') | fpdfsdk/fxedit/fxet_list.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698