Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" | |
| 8 | |
| 7 #include "core/include/fxcrt/fx_safe_types.h" | 9 #include "core/include/fxcrt/fx_safe_types.h" |
| 8 #include "core/include/fxcrt/fx_xml.h" | 10 #include "core/include/fxcrt/fx_xml.h" |
| 9 #include "fpdfsdk/include/pdfwindow/PDFWindow.h" | |
| 10 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" | 11 #include "fpdfsdk/include/pdfwindow/PWL_Caret.h" |
| 11 #include "fpdfsdk/include/pdfwindow/PWL_Edit.h" | |
| 12 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" | 12 #include "fpdfsdk/include/pdfwindow/PWL_EditCtrl.h" |
| 13 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" | 13 #include "fpdfsdk/include/pdfwindow/PWL_FontMap.h" |
| 14 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" | 14 #include "fpdfsdk/include/pdfwindow/PWL_ScrollBar.h" |
| 15 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 15 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
| 16 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 16 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
| 17 | 17 #include "public/fpdf_fwlevent.h" |
| 18 /* ---------------------------- CPWL_Edit ------------------------------ */ | |
| 19 | 18 |
| 20 CPWL_Edit::CPWL_Edit() | 19 CPWL_Edit::CPWL_Edit() |
| 21 : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) { | 20 : m_pFillerNotify(NULL), m_pSpellCheck(NULL), m_bFocus(FALSE) { |
| 22 m_pFormFiller = NULL; | 21 m_pFormFiller = NULL; |
| 23 } | 22 } |
| 24 | 23 |
| 25 CPWL_Edit::~CPWL_Edit() { | 24 CPWL_Edit::~CPWL_Edit() { |
| 26 ASSERT(m_bFocus == FALSE); | 25 ASSERT(m_bFocus == FALSE); |
| 27 } | 26 } |
| 28 | 27 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { | 93 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) { |
| 95 if (pVSB->IsVisible()) { | 94 if (pVSB->IsVisible()) { |
| 96 rcClient.right -= PWL_SCROLLBAR_WIDTH; | 95 rcClient.right -= PWL_SCROLLBAR_WIDTH; |
| 97 } | 96 } |
| 98 } | 97 } |
| 99 | 98 |
| 100 return rcClient; | 99 return rcClient; |
| 101 } | 100 } |
| 102 | 101 |
| 103 void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, | 102 void CPWL_Edit::SetAlignFormatH(PWL_EDIT_ALIGNFORMAT_H nFormat, |
| 104 FX_BOOL bPaint /* = TRUE*/) { | 103 FX_BOOL bPaint) { |
| 105 m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint); | 104 m_pEdit->SetAlignmentH((int32_t)nFormat, bPaint); |
| 106 } | 105 } |
| 107 | 106 |
| 108 void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, | 107 void CPWL_Edit::SetAlignFormatV(PWL_EDIT_ALIGNFORMAT_V nFormat, |
| 109 FX_BOOL bPaint /* = TRUE*/) { | 108 FX_BOOL bPaint) { |
| 110 m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint); | 109 m_pEdit->SetAlignmentV((int32_t)nFormat, bPaint); |
| 111 } | 110 } |
| 112 | 111 |
| 113 FX_BOOL CPWL_Edit::CanSelectAll() const { | 112 FX_BOOL CPWL_Edit::CanSelectAll() const { |
| 114 return GetSelectWordRange() != m_pEdit->GetWholeWordRange(); | 113 return GetSelectWordRange() != m_pEdit->GetWholeWordRange(); |
| 115 } | 114 } |
| 116 | 115 |
| 117 FX_BOOL CPWL_Edit::CanClear() const { | 116 FX_BOOL CPWL_Edit::CanClear() const { |
| 118 return !IsReadOnly() && m_pEdit->IsSelected(); | 117 return !IsReadOnly() && m_pEdit->IsSelected(); |
| 119 } | 118 } |
| (...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1119 FX_BOOL bArabic) const { | 1118 FX_BOOL bArabic) const { |
| 1120 CPVT_WordRange range; | 1119 CPVT_WordRange range; |
| 1121 | 1120 |
| 1122 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { | 1121 if (IFX_Edit_Iterator* pIterator = m_pEdit->GetIterator()) { |
| 1123 CPVT_Word wordinfo; | 1122 CPVT_Word wordinfo; |
| 1124 CPVT_WordPlace wpStart(place), wpEnd(place); | 1123 CPVT_WordPlace wpStart(place), wpEnd(place); |
| 1125 pIterator->SetAt(place); | 1124 pIterator->SetAt(place); |
| 1126 | 1125 |
| 1127 if (bLatin) { | 1126 if (bLatin) { |
| 1128 while (pIterator->NextWord()) { | 1127 while (pIterator->NextWord()) { |
| 1129 if (pIterator->GetWord(wordinfo) && | 1128 if (!pIterator->GetWord(wordinfo) || FX_EDIT_ISLATINWORD(wordinfo.Word)) |
|
Tom Sepez
2016/01/04 20:23:12
missing ! on FX_EDIT_ISLATINWORD()
Lei Zhang
2016/01/05 02:27:09
Done.
| |
| 1130 FX_EDIT_ISLATINWORD(wordinfo.Word)) { | |
| 1131 wpEnd = pIterator->GetAt(); | |
| 1132 continue; | |
| 1133 } else | |
| 1134 break; | 1129 break; |
| 1135 }; | 1130 |
| 1131 wpEnd = pIterator->GetAt(); | |
| 1132 } | |
| 1136 } else if (bArabic) { | 1133 } else if (bArabic) { |
| 1137 while (pIterator->NextWord()) { | 1134 while (pIterator->NextWord()) { |
| 1138 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word)) { | 1135 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
| 1139 wpEnd = pIterator->GetAt(); | |
| 1140 continue; | |
| 1141 } else | |
| 1142 break; | 1136 break; |
| 1143 }; | 1137 |
| 1138 wpEnd = pIterator->GetAt(); | |
| 1139 } | |
| 1144 } | 1140 } |
| 1145 | 1141 |
| 1146 pIterator->SetAt(place); | 1142 pIterator->SetAt(place); |
| 1147 | 1143 |
| 1148 if (bLatin) { | 1144 if (bLatin) { |
| 1149 do { | 1145 do { |
| 1150 if (pIterator->GetWord(wordinfo) && | 1146 if (!pIterator->GetWord(wordinfo) || |
| 1151 FX_EDIT_ISLATINWORD(wordinfo.Word)) { | 1147 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
| 1152 continue; | |
| 1153 } else { | |
| 1154 wpStart = pIterator->GetAt(); | |
| 1155 break; | 1148 break; |
| 1156 } | 1149 } |
| 1150 | |
| 1151 wpStart = pIterator->GetAt(); | |
| 1157 } while (pIterator->PrevWord()); | 1152 } while (pIterator->PrevWord()); |
| 1158 } else if (bArabic) { | 1153 } else if (bArabic) { |
| 1159 do { | 1154 do { |
| 1160 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word)) { | 1155 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
| 1161 continue; | |
| 1162 } else { | |
| 1163 wpStart = pIterator->GetAt(); | |
| 1164 break; | 1156 break; |
| 1165 } | 1157 |
| 1158 wpStart = pIterator->GetAt(); | |
| 1166 } while (pIterator->PrevWord()); | 1159 } while (pIterator->PrevWord()); |
| 1167 } | 1160 } |
| 1168 | 1161 |
| 1169 range.Set(wpStart, wpEnd); | 1162 range.Set(wpStart, wpEnd); |
| 1170 } | 1163 } |
| 1171 | 1164 |
| 1172 return range; | 1165 return range; |
| 1173 } | 1166 } |
| 1174 | 1167 |
| 1175 void CPWL_Edit::GeneratePageObjects( | 1168 void CPWL_Edit::GeneratePageObjects( |
| 1176 CPDF_PageObjects* pPageObjects, | 1169 CPDF_PageObjects* pPageObjects, |
| 1177 const CPDF_Point& ptOffset, | 1170 const CPDF_Point& ptOffset, |
| 1178 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 1171 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
| 1179 IFX_Edit::GeneratePageObjects( | 1172 IFX_Edit::GeneratePageObjects( |
| 1180 pPageObjects, m_pEdit, ptOffset, NULL, | 1173 pPageObjects, m_pEdit, ptOffset, NULL, |
| 1181 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1174 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 1182 ObjArray); | 1175 ObjArray); |
| 1183 } | 1176 } |
| 1184 | 1177 |
| 1185 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, | 1178 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, |
| 1186 const CPDF_Point& ptOffset) { | 1179 const CPDF_Point& ptOffset) { |
| 1187 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1180 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
| 1188 IFX_Edit::GeneratePageObjects( | 1181 IFX_Edit::GeneratePageObjects( |
| 1189 pPageObjects, m_pEdit, ptOffset, NULL, | 1182 pPageObjects, m_pEdit, ptOffset, NULL, |
| 1190 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1183 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
| 1191 ObjArray); | 1184 ObjArray); |
| 1192 } | 1185 } |
| OLD | NEW |