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) || |
1130 FX_EDIT_ISLATINWORD(wordinfo.Word)) { | 1129 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
1131 wpEnd = pIterator->GetAt(); | |
1132 continue; | |
1133 } else | |
1134 break; | 1130 break; |
1135 }; | 1131 } |
| 1132 |
| 1133 wpEnd = pIterator->GetAt(); |
| 1134 } |
1136 } else if (bArabic) { | 1135 } else if (bArabic) { |
1137 while (pIterator->NextWord()) { | 1136 while (pIterator->NextWord()) { |
1138 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word)) { | 1137 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
1139 wpEnd = pIterator->GetAt(); | |
1140 continue; | |
1141 } else | |
1142 break; | 1138 break; |
1143 }; | 1139 |
| 1140 wpEnd = pIterator->GetAt(); |
| 1141 } |
1144 } | 1142 } |
1145 | 1143 |
1146 pIterator->SetAt(place); | 1144 pIterator->SetAt(place); |
1147 | 1145 |
1148 if (bLatin) { | 1146 if (bLatin) { |
1149 do { | 1147 do { |
1150 if (pIterator->GetWord(wordinfo) && | 1148 if (!pIterator->GetWord(wordinfo) || |
1151 FX_EDIT_ISLATINWORD(wordinfo.Word)) { | 1149 !FX_EDIT_ISLATINWORD(wordinfo.Word)) { |
1152 continue; | |
1153 } else { | |
1154 wpStart = pIterator->GetAt(); | |
1155 break; | 1150 break; |
1156 } | 1151 } |
| 1152 |
| 1153 wpStart = pIterator->GetAt(); |
1157 } while (pIterator->PrevWord()); | 1154 } while (pIterator->PrevWord()); |
1158 } else if (bArabic) { | 1155 } else if (bArabic) { |
1159 do { | 1156 do { |
1160 if (pIterator->GetWord(wordinfo) && PWL_ISARABICWORD(wordinfo.Word)) { | 1157 if (!pIterator->GetWord(wordinfo) || !PWL_ISARABICWORD(wordinfo.Word)) |
1161 continue; | |
1162 } else { | |
1163 wpStart = pIterator->GetAt(); | |
1164 break; | 1158 break; |
1165 } | 1159 |
| 1160 wpStart = pIterator->GetAt(); |
1166 } while (pIterator->PrevWord()); | 1161 } while (pIterator->PrevWord()); |
1167 } | 1162 } |
1168 | 1163 |
1169 range.Set(wpStart, wpEnd); | 1164 range.Set(wpStart, wpEnd); |
1170 } | 1165 } |
1171 | 1166 |
1172 return range; | 1167 return range; |
1173 } | 1168 } |
1174 | 1169 |
1175 void CPWL_Edit::GeneratePageObjects( | 1170 void CPWL_Edit::GeneratePageObjects( |
1176 CPDF_PageObjects* pPageObjects, | 1171 CPDF_PageObjects* pPageObjects, |
1177 const CPDF_Point& ptOffset, | 1172 const CPDF_Point& ptOffset, |
1178 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { | 1173 CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) { |
1179 IFX_Edit::GeneratePageObjects( | 1174 IFX_Edit::GeneratePageObjects( |
1180 pPageObjects, m_pEdit, ptOffset, NULL, | 1175 pPageObjects, m_pEdit, ptOffset, NULL, |
1181 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1176 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1182 ObjArray); | 1177 ObjArray); |
1183 } | 1178 } |
1184 | 1179 |
1185 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, | 1180 void CPWL_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, |
1186 const CPDF_Point& ptOffset) { | 1181 const CPDF_Point& ptOffset) { |
1187 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; | 1182 CFX_ArrayTemplate<CPDF_TextObject*> ObjArray; |
1188 IFX_Edit::GeneratePageObjects( | 1183 IFX_Edit::GeneratePageObjects( |
1189 pPageObjects, m_pEdit, ptOffset, NULL, | 1184 pPageObjects, m_pEdit, ptOffset, NULL, |
1190 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), | 1185 CPWL_Utils::PWLColorToFXColor(GetTextColor(), GetTransparency()), |
1191 ObjArray); | 1186 ObjArray); |
1192 } | 1187 } |
OLD | NEW |