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 "../include/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fsdk_mgr.h" | 8 #include "../include/fsdk_mgr.h" |
9 #include "../include/fsdk_baseannot.h" | 9 #include "../include/fsdk_baseannot.h" |
10 #include "../include/fsdk_baseform.h" | 10 #include "../include/fsdk_baseform.h" |
11 #include "../include/formfiller/FFL_FormFiller.h" | 11 #include "../include/formfiller/FFL_FormFiller.h" |
12 #include "../include/fsdk_actionhandler.h" | 12 #include "../include/fsdk_actionhandler.h" |
13 | 13 |
14 #include "../include/javascript/IJavaScript.h" | 14 #include "../include/javascript/IJavaScript.h" |
15 | 15 |
16 //------------------------------------------------------------------------------
------ | 16 //------------------------------------------------------------------------------
------ |
17 //*» » » » » » » » » »
CPDFSDK_Widget | 17 //* |
| 18 //CPDFSDK_Widget |
18 //------------------------------------------------------------------------------
------ | 19 //------------------------------------------------------------------------------
------ |
19 | 20 |
20 #define IsFloatZero(f) ((f) < 0.01 && (
f) > -0.01) | 21 #define IsFloatZero(f) ((f) < 0.01 && (f) > -0.01) |
21 #define IsFloatBigger(fa,fb) ((fa) > (fb) && !IsFloat
Zero((fa) - (fb))) | 22 #define IsFloatBigger(fa, fb) ((fa) > (fb) && !IsFloatZero((fa) - (fb))) |
22 #define IsFloatSmaller(fa,fb) ((fa) < (fb) && !IsFloat
Zero((fa) - (fb))) | 23 #define IsFloatSmaller(fa, fb) ((fa) < (fb) && !IsFloatZero((fa) - (fb))) |
23 #define IsFloatEqual(fa,fb) IsFloatZero((fa)
-(fb)) | 24 #define IsFloatEqual(fa, fb) IsFloatZero((fa) - (fb)) |
24 | 25 |
25 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, CPDFSDK_PageView* pPageView,
CPDFSDK_InterForm* pInterForm) : | 26 CPDFSDK_Widget::CPDFSDK_Widget(CPDF_Annot* pAnnot, |
26 CPDFSDK_Annot(pAnnot, pPageView), | 27 CPDFSDK_PageView* pPageView, |
27 m_pInterForm(pInterForm), | 28 CPDFSDK_InterForm* pInterForm) |
28 m_nAppAge(0), | 29 : CPDFSDK_Annot(pAnnot, pPageView), |
29 m_nValueAge(0) | 30 m_pInterForm(pInterForm), |
30 { | 31 m_nAppAge(0), |
31 ASSERT(m_pInterForm != NULL); | 32 m_nValueAge(0) { |
32 } | 33 ASSERT(m_pInterForm != NULL); |
33 | 34 } |
34 CPDFSDK_Widget::~CPDFSDK_Widget() | 35 |
35 { | 36 CPDFSDK_Widget::~CPDFSDK_Widget() { |
36 | 37 } |
37 } | 38 |
38 | 39 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid( |
39 FX_BOOL CPDFSDK_Widget::IsWidgetAppearanceValid(CPDF_Annot::AppearanceMo
de mode) | 40 CPDF_Annot::AppearanceMode mode) { |
40 { | 41 ASSERT(m_pAnnot != NULL); |
41 ASSERT(m_pAnnot != NULL); | 42 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
42 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 43 |
43 | 44 CPDF_Dictionary* pAP = m_pAnnot->m_pAnnotDict->GetDict("AP"); |
44 CPDF_Dictionary* pAP = m_pAnnot->m_pAnnotDict->GetDict("AP"); | 45 if (pAP == NULL) |
45 if (pAP == NULL) return FALSE; | 46 return FALSE; |
46 | 47 |
47 // Choose the right sub-ap | 48 // Choose the right sub-ap |
48 const FX_CHAR* ap_entry = "N"; | 49 const FX_CHAR* ap_entry = "N"; |
49 if (mode == CPDF_Annot::Down) | 50 if (mode == CPDF_Annot::Down) |
50 ap_entry = "D"; | 51 ap_entry = "D"; |
51 else if (mode == CPDF_Annot::Rollover) | 52 else if (mode == CPDF_Annot::Rollover) |
52 ap_entry = "R"; | 53 ap_entry = "R"; |
53 if (!pAP->KeyExist(ap_entry)) | 54 if (!pAP->KeyExist(ap_entry)) |
54 ap_entry = "N"; | 55 ap_entry = "N"; |
55 | 56 |
56 // Get the AP stream or subdirectory | 57 // Get the AP stream or subdirectory |
57 CPDF_Object* psub = pAP->GetElementValue(ap_entry); | 58 CPDF_Object* psub = pAP->GetElementValue(ap_entry); |
58 if (psub == NULL) return FALSE; | 59 if (psub == NULL) |
59 | 60 return FALSE; |
60 int nFieldType = GetFieldType(); | 61 |
61 switch (nFieldType) | 62 int nFieldType = GetFieldType(); |
62 { | 63 switch (nFieldType) { |
63 case FIELDTYPE_PUSHBUTTON: | 64 case FIELDTYPE_PUSHBUTTON: |
64 case FIELDTYPE_COMBOBOX: | 65 case FIELDTYPE_COMBOBOX: |
65 case FIELDTYPE_LISTBOX: | 66 case FIELDTYPE_LISTBOX: |
66 case FIELDTYPE_TEXTFIELD: | 67 case FIELDTYPE_TEXTFIELD: |
67 case FIELDTYPE_SIGNATURE: | 68 case FIELDTYPE_SIGNATURE: |
68 return psub->GetType() == PDFOBJ_STREAM; | 69 return psub->GetType() == PDFOBJ_STREAM; |
69 case FIELDTYPE_CHECKBOX: | 70 case FIELDTYPE_CHECKBOX: |
70 case FIELDTYPE_RADIOBUTTON: | 71 case FIELDTYPE_RADIOBUTTON: |
71 if (psub->GetType() == PDFOBJ_DICTIONARY) | 72 if (psub->GetType() == PDFOBJ_DICTIONARY) { |
72 { | 73 CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub; |
73 CPDF_Dictionary* pSubDict = (CPDF_Dictionary*)psub; | 74 |
74 | 75 return pSubDict->GetStream(this->GetAppState()) != NULL; |
75 return pSubDict->GetStream(this->GetAppState()) != NULL; | 76 } else |
76 } | 77 return FALSE; |
77 else | 78 break; |
78 return FALSE; | 79 } |
79 break; | 80 |
80 } | 81 return TRUE; |
81 | 82 } |
82 return TRUE; | 83 |
83 } | 84 int CPDFSDK_Widget::GetFieldType() const { |
84 | 85 CPDF_FormField* pField = GetFormField(); |
85 int CPDFSDK_Widget::GetFieldType() const | 86 ASSERT(pField != NULL); |
86 { | 87 |
87 CPDF_FormField* pField = GetFormField(); | 88 return pField->GetFieldType(); |
88 ASSERT(pField != NULL); | 89 } |
89 | 90 |
90 return pField->GetFieldType(); | 91 int CPDFSDK_Widget::GetFieldFlags() const { |
91 } | 92 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
92 | 93 ASSERT(pPDFInterForm != NULL); |
93 int CPDFSDK_Widget::GetFieldFlags() const | 94 |
94 { | 95 CPDF_FormControl* pFormControl = |
95 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 96 pPDFInterForm->GetControlByDict(m_pAnnot->m_pAnnotDict); |
96 ASSERT(pPDFInterForm != NULL); | 97 CPDF_FormField* pFormField = pFormControl->GetField(); |
97 | 98 return pFormField->GetFieldFlags(); |
98 CPDF_FormControl* pFormControl = pPDFInterForm->GetControlByDict(m_pAnno
t->m_pAnnotDict); | 99 } |
99 CPDF_FormField* pFormField = pFormControl->GetField(); | 100 |
100 return pFormField->GetFieldFlags(); | 101 CFX_ByteString CPDFSDK_Widget::GetSubType() const { |
101 } | 102 int nType = GetFieldType(); |
102 | 103 |
103 CFX_ByteString CPDFSDK_Widget::GetSubType() const | 104 if (nType == FIELDTYPE_SIGNATURE) |
104 { | 105 return BFFT_SIGNATURE; |
105 int nType = GetFieldType(); | 106 return CPDFSDK_Annot::GetSubType(); |
106 | 107 } |
107 if (nType == FIELDTYPE_SIGNATURE) | 108 |
108 return BFFT_SIGNATURE; | 109 CPDF_FormField* CPDFSDK_Widget::GetFormField() const { |
109 return CPDFSDK_Annot::GetSubType(); | 110 ASSERT(m_pInterForm != NULL); |
110 } | 111 |
111 | 112 CPDF_FormControl* pCtrl = GetFormControl(); |
112 CPDF_FormField* CPDFSDK_Widget::GetFormField() const | 113 ASSERT(pCtrl != NULL); |
113 { | 114 |
114 ASSERT(m_pInterForm != NULL); | 115 return pCtrl->GetField(); |
115 | 116 } |
116 CPDF_FormControl* pCtrl = GetFormControl(); | 117 |
117 ASSERT(pCtrl != NULL); | 118 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const { |
118 | 119 ASSERT(m_pInterForm != NULL); |
119 return pCtrl->GetField(); | 120 |
120 } | 121 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); |
121 | 122 ASSERT(pPDFInterForm != NULL); |
122 CPDF_FormControl* CPDFSDK_Widget::GetFormControl() const | 123 |
123 { | 124 return pPDFInterForm->GetControlByDict(GetAnnotDict()); |
124 ASSERT(m_pInterForm != NULL); | 125 } |
125 | 126 static CPDF_Dictionary* BF_GetField(CPDF_Dictionary* pFieldDict, |
126 CPDF_InterForm* pPDFInterForm = m_pInterForm->GetInterForm(); | 127 const FX_CHAR* name) { |
127 ASSERT(pPDFInterForm != NULL); | 128 if (pFieldDict == NULL) |
128 | 129 return NULL; |
129 return pPDFInterForm->GetControlByDict(GetAnnotDict()); | 130 // First check the dictionary itself |
130 } | 131 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); |
131 static CPDF_Dictionary* BF_GetField(CPDF_Dictionary* pFieldDict, const FX_CHAR*
name) | 132 if (pAttr) |
132 { | 133 return pFieldDict; |
133 if (pFieldDict == NULL) return NULL; | 134 |
134 // First check the dictionary itself | 135 // Now we need to search from parents |
135 CPDF_Object* pAttr = pFieldDict->GetElementValue(name); | 136 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); |
136 if (pAttr) return pFieldDict; | 137 if (pParent == NULL) |
137 | 138 return NULL; |
138 // Now we need to search from parents | 139 |
139 CPDF_Dictionary* pParent = pFieldDict->GetDict("Parent"); | 140 return BF_GetField(pParent, name); |
140 if (pParent == NULL) return NULL; | 141 } |
141 | 142 |
142 return BF_GetField(pParent, name); | 143 CPDF_FormControl* CPDFSDK_Widget::GetFormControl(CPDF_InterForm* pInterForm, |
143 } | 144 CPDF_Dictionary* pAnnotDict) { |
144 | 145 ASSERT(pInterForm != NULL); |
145 CPDF_FormControl* CPDFSDK_Widget::GetFormControl(CPDF_InterForm* pInterForm, CPD
F_Dictionary* pAnnotDict) | 146 ASSERT(pAnnotDict != NULL); |
146 { | 147 |
147 ASSERT(pInterForm != NULL); | 148 CPDF_FormControl* pControl = pInterForm->GetControlByDict(pAnnotDict); |
148 ASSERT(pAnnotDict != NULL); | 149 |
149 | 150 return pControl; |
150 CPDF_FormControl* pControl = pInterForm->GetControlByDict(pAnnotDict); | 151 } |
151 | 152 |
152 return pControl; | 153 int CPDFSDK_Widget::GetRotate() const { |
153 } | 154 CPDF_FormControl* pCtrl = this->GetFormControl(); |
154 | 155 ASSERT(pCtrl != NULL); |
155 int CPDFSDK_Widget::GetRotate() const | 156 |
156 { | 157 return pCtrl->GetRotation() % 360; |
157 CPDF_FormControl* pCtrl = this->GetFormControl(); | 158 } |
158 ASSERT(pCtrl != NULL); | 159 |
159 | 160 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const { |
160 return pCtrl->GetRotation() % 360; | 161 CPDF_FormControl* pFormCtrl = GetFormControl(); |
161 } | 162 ASSERT(pFormCtrl != NULL); |
162 | 163 |
163 FX_BOOL CPDFSDK_Widget::GetFillColor(FX_COLORREF& color) const | 164 int iColorType = 0; |
164 { | 165 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); |
165 CPDF_FormControl* pFormCtrl = GetFormControl(); | 166 |
166 ASSERT(pFormCtrl != NULL); | 167 return iColorType != COLORTYPE_TRANSPARENT; |
167 | 168 } |
168 int iColorType = 0; | 169 |
169 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBackgroundColor(iColorType)); | 170 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const { |
170 | 171 CPDF_FormControl* pFormCtrl = GetFormControl(); |
171 return iColorType != COLORTYPE_TRANSPARENT; | 172 ASSERT(pFormCtrl != NULL); |
172 } | 173 |
173 | 174 int iColorType = 0; |
174 FX_BOOL CPDFSDK_Widget::GetBorderColor(FX_COLORREF& color) const | 175 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); |
175 { | 176 |
176 CPDF_FormControl* pFormCtrl = GetFormControl(); | 177 return iColorType != COLORTYPE_TRANSPARENT; |
177 ASSERT(pFormCtrl != NULL); | 178 } |
178 | 179 |
179 int iColorType = 0; | 180 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const { |
180 color = FX_ARGBTOCOLORREF(pFormCtrl->GetBorderColor(iColorType)); | 181 CPDF_FormControl* pFormCtrl = GetFormControl(); |
181 | 182 ASSERT(pFormCtrl != NULL); |
182 return iColorType != COLORTYPE_TRANSPARENT; | 183 |
183 } | 184 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
184 | 185 if (da.HasColor()) { |
185 FX_BOOL CPDFSDK_Widget::GetTextColor(FX_COLORREF& color) const | 186 FX_ARGB argb; |
186 { | 187 int iColorType = COLORTYPE_TRANSPARENT; |
187 CPDF_FormControl* pFormCtrl = GetFormControl(); | 188 da.GetColor(argb, iColorType); |
188 ASSERT(pFormCtrl != NULL); | 189 color = FX_ARGBTOCOLORREF(argb); |
189 | 190 |
190 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 191 return iColorType != COLORTYPE_TRANSPARENT; |
191 if (da.HasColor()) | 192 } |
192 { | 193 |
193 FX_ARGB argb; | 194 return FALSE; |
194 int iColorType = COLORTYPE_TRANSPARENT; | 195 } |
195 da.GetColor(argb, iColorType); | 196 |
196 color = FX_ARGBTOCOLORREF(argb); | 197 FX_FLOAT CPDFSDK_Widget::GetFontSize() const { |
197 | 198 CPDF_FormControl* pFormCtrl = GetFormControl(); |
198 return iColorType != COLORTYPE_TRANSPARENT; | 199 ASSERT(pFormCtrl != NULL); |
199 } | 200 |
200 | 201 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); |
201 return FALSE; | 202 CFX_ByteString csFont = ""; |
202 } | 203 FX_FLOAT fFontSize = 0.0f; |
203 | 204 pDa.GetFont(csFont, fFontSize); |
204 FX_FLOAT CPDFSDK_Widget::GetFontSize() const | 205 |
205 { | 206 return fFontSize; |
206 CPDF_FormControl* pFormCtrl = GetFormControl(); | 207 } |
207 ASSERT(pFormCtrl != NULL); | 208 |
208 | 209 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const { |
209 CPDF_DefaultAppearance pDa = pFormCtrl->GetDefaultAppearance(); | 210 CPDF_FormField* pFormField = GetFormField(); |
210 CFX_ByteString csFont = ""; | 211 ASSERT(pFormField != NULL); |
211 FX_FLOAT fFontSize = 0.0f; | 212 |
212 pDa.GetFont(csFont, fFontSize); | 213 return pFormField->GetSelectedIndex(nIndex); |
213 | 214 } |
214 return fFontSize; | 215 |
215 } | 216 CFX_WideString CPDFSDK_Widget::GetValue() const { |
216 | 217 CPDF_FormField* pFormField = GetFormField(); |
217 int CPDFSDK_Widget::GetSelectedIndex(int nIndex) const | 218 ASSERT(pFormField != NULL); |
218 { | 219 |
219 CPDF_FormField* pFormField = GetFormField(); | 220 return pFormField->GetValue(); |
220 ASSERT(pFormField != NULL); | 221 } |
221 | 222 |
222 return pFormField->GetSelectedIndex(nIndex); | 223 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const { |
223 } | 224 CPDF_FormField* pFormField = GetFormField(); |
224 | 225 ASSERT(pFormField != NULL); |
225 CFX_WideString CPDFSDK_Widget::GetValue() const | 226 |
226 { | 227 return pFormField->GetDefaultValue(); |
227 CPDF_FormField* pFormField = GetFormField(); | 228 } |
228 ASSERT(pFormField != NULL); | 229 |
229 | 230 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const { |
230 return pFormField->GetValue(); | 231 CPDF_FormField* pFormField = GetFormField(); |
231 } | 232 ASSERT(pFormField != NULL); |
232 | 233 |
233 CFX_WideString CPDFSDK_Widget::GetDefaultValue() const | 234 return pFormField->GetOptionLabel(nIndex); |
234 { | 235 } |
235 CPDF_FormField* pFormField = GetFormField(); | 236 |
236 ASSERT(pFormField != NULL); | 237 int CPDFSDK_Widget::CountOptions() const { |
237 | 238 CPDF_FormField* pFormField = GetFormField(); |
238 return pFormField->GetDefaultValue(); | 239 ASSERT(pFormField != NULL); |
239 } | 240 |
240 | 241 return pFormField->CountOptions(); |
241 CFX_WideString CPDFSDK_Widget::GetOptionLabel(int nIndex) const | 242 } |
242 { | 243 |
243 CPDF_FormField* pFormField = GetFormField(); | 244 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const { |
244 ASSERT(pFormField != NULL); | 245 CPDF_FormField* pFormField = GetFormField(); |
245 | 246 ASSERT(pFormField != NULL); |
246 return pFormField->GetOptionLabel(nIndex); | 247 |
247 } | 248 return pFormField->IsItemSelected(nIndex); |
248 | 249 } |
249 int CPDFSDK_Widget::CountOptions() const | 250 |
250 { | 251 int CPDFSDK_Widget::GetTopVisibleIndex() const { |
251 CPDF_FormField* pFormField = GetFormField(); | 252 CPDF_FormField* pFormField = GetFormField(); |
252 ASSERT(pFormField != NULL); | 253 ASSERT(pFormField != NULL); |
253 | 254 |
254 return pFormField->CountOptions(); | 255 return pFormField->GetTopVisibleIndex(); |
255 } | 256 } |
256 | 257 |
257 FX_BOOL CPDFSDK_Widget::IsOptionSelected(int nIndex) const | 258 FX_BOOL CPDFSDK_Widget::IsChecked() const { |
258 { | 259 CPDF_FormControl* pFormCtrl = GetFormControl(); |
259 CPDF_FormField* pFormField = GetFormField(); | 260 ASSERT(pFormCtrl != NULL); |
260 ASSERT(pFormField != NULL); | 261 |
261 | 262 return pFormCtrl->IsChecked(); |
262 return pFormField->IsItemSelected(nIndex); | 263 } |
263 } | 264 |
264 | 265 int CPDFSDK_Widget::GetAlignment() const { |
265 int CPDFSDK_Widget::GetTopVisibleIndex() const | 266 CPDF_FormControl* pFormCtrl = GetFormControl(); |
266 { | 267 ASSERT(pFormCtrl != NULL); |
267 CPDF_FormField* pFormField = GetFormField(); | 268 |
268 ASSERT(pFormField != NULL); | 269 return pFormCtrl->GetControlAlignment(); |
269 | 270 } |
270 return pFormField->GetTopVisibleIndex(); | 271 |
271 } | 272 int CPDFSDK_Widget::GetMaxLen() const { |
272 | 273 CPDF_FormField* pFormField = GetFormField(); |
273 FX_BOOL CPDFSDK_Widget::IsChecked() const | 274 ASSERT(pFormField != NULL); |
274 { | 275 |
275 CPDF_FormControl* pFormCtrl = GetFormControl(); | 276 return pFormField->GetMaxLen(); |
276 ASSERT(pFormCtrl != NULL); | 277 } |
277 | 278 |
278 return pFormCtrl->IsChecked(); | 279 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) { |
279 } | 280 CPDF_FormControl* pFormCtrl = GetFormControl(); |
280 | 281 ASSERT(pFormCtrl != NULL); |
281 int CPDFSDK_Widget::GetAlignment() const | 282 |
282 { | 283 CPDF_FormField* pFormField = pFormCtrl->GetField(); |
283 CPDF_FormControl* pFormCtrl = GetFormControl(); | 284 ASSERT(pFormField != NULL); |
284 ASSERT(pFormCtrl != NULL); | 285 |
285 | 286 pFormField->CheckControl( |
286 return pFormCtrl->GetControlAlignment(); | 287 pFormField->GetControlIndex(pFormCtrl), bChecked, bNotify); |
287 } | 288 } |
288 | 289 |
289 int CPDFSDK_Widget::GetMaxLen() const | 290 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) { |
290 { | 291 CPDF_FormField* pFormField = GetFormField(); |
291 CPDF_FormField* pFormField = GetFormField(); | 292 ASSERT(pFormField != NULL); |
292 ASSERT(pFormField != NULL); | 293 |
293 | 294 pFormField->SetValue(sValue, bNotify); |
294 return pFormField->GetMaxLen(); | 295 } |
295 } | 296 |
296 | 297 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) { |
297 void CPDFSDK_Widget::SetCheck(FX_BOOL bChecked, FX_BOOL bNotify) | 298 } |
298 { | 299 void CPDFSDK_Widget::SetOptionSelection(int index, |
299 CPDF_FormControl* pFormCtrl = GetFormControl(); | 300 FX_BOOL bSelected, |
300 ASSERT(pFormCtrl != NULL); | 301 FX_BOOL bNotify) { |
301 | 302 CPDF_FormField* pFormField = GetFormField(); |
302 CPDF_FormField* pFormField = pFormCtrl->GetField(); | 303 ASSERT(pFormField != NULL); |
303 ASSERT(pFormField != NULL); | 304 |
304 | 305 pFormField->SetItemSelection(index, bSelected, bNotify); |
305 pFormField->CheckControl(pFormField->GetControlIndex(pFormCtrl), bChecke
d, bNotify); | 306 } |
306 } | 307 |
307 | 308 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) { |
308 void CPDFSDK_Widget::SetValue(const CFX_WideString& sValue, FX_BOOL bNotify) | 309 CPDF_FormField* pFormField = GetFormField(); |
309 { | 310 ASSERT(pFormField != NULL); |
310 CPDF_FormField* pFormField = GetFormField(); | 311 |
311 ASSERT(pFormField != NULL); | 312 pFormField->ClearSelection(bNotify); |
312 | 313 } |
313 pFormField->SetValue(sValue, bNotify); | 314 |
314 } | 315 void CPDFSDK_Widget::SetTopVisibleIndex(int index) { |
315 | 316 } |
316 void CPDFSDK_Widget::SetDefaultValue(const CFX_WideString& sValue) | 317 |
317 { | 318 void CPDFSDK_Widget::SetAppModified() { |
318 } | 319 m_bAppModified = TRUE; |
319 void CPDFSDK_Widget::SetOptionSelection(int index, FX_BOOL bSelected, FX_BOOL bN
otify) | 320 } |
320 { | 321 |
321 CPDF_FormField* pFormField = GetFormField(); | 322 void CPDFSDK_Widget::ClearAppModified() { |
322 ASSERT(pFormField != NULL); | 323 m_bAppModified = FALSE; |
323 | 324 } |
324 pFormField->SetItemSelection(index, bSelected, bNotify); | 325 |
325 } | 326 FX_BOOL CPDFSDK_Widget::IsAppModified() const { |
326 | 327 return m_bAppModified; |
327 void CPDFSDK_Widget::ClearSelection(FX_BOOL bNotify) | 328 } |
328 { | 329 |
329 CPDF_FormField* pFormField = GetFormField(); | 330 void CPDFSDK_Widget::ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged) { |
330 ASSERT(pFormField != NULL); | 331 SetAppModified(); |
331 | 332 |
332 pFormField->ClearSelection(bNotify); | 333 m_nAppAge++; |
333 } | 334 if (m_nAppAge > 999999) |
334 | 335 m_nAppAge = 0; |
335 void CPDFSDK_Widget::SetTopVisibleIndex(int index) | 336 if (bValueChanged) |
336 { | 337 m_nValueAge++; |
337 } | 338 |
338 | 339 int nFieldType = GetFieldType(); |
339 void CPDFSDK_Widget::SetAppModified() | 340 |
340 { | 341 switch (nFieldType) { |
341 m_bAppModified = TRUE; | 342 case FIELDTYPE_PUSHBUTTON: |
342 } | 343 ResetAppearance_PushButton(); |
343 | 344 break; |
344 void CPDFSDK_Widget::ClearAppModified() | 345 case FIELDTYPE_CHECKBOX: |
345 { | 346 ResetAppearance_CheckBox(); |
346 m_bAppModified = FALSE; | 347 break; |
347 } | 348 case FIELDTYPE_RADIOBUTTON: |
348 | 349 ResetAppearance_RadioButton(); |
349 FX_BOOL CPDFSDK_Widget::IsAppModified() const | 350 break; |
350 { | 351 case FIELDTYPE_COMBOBOX: |
351 return m_bAppModified; | 352 ResetAppearance_ComboBox(sValue); |
352 } | 353 break; |
353 | 354 case FIELDTYPE_LISTBOX: |
354 void CPDFSDK_Widget::ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged) | 355 ResetAppearance_ListBox(); |
355 { | 356 break; |
356 SetAppModified(); | 357 case FIELDTYPE_TEXTFIELD: |
357 | 358 ResetAppearance_TextField(sValue); |
358 m_nAppAge++; | 359 break; |
359 if (m_nAppAge > 999999) | 360 } |
360 m_nAppAge = 0; | 361 |
361 if (bValueChanged) | 362 ASSERT(m_pAnnot != NULL); |
362 m_nValueAge++; | 363 m_pAnnot->ClearCachedAP(); |
363 | 364 } |
364 int nFieldType = GetFieldType(); | 365 |
365 | 366 CFX_WideString CPDFSDK_Widget::OnFormat(int nCommitKey, FX_BOOL& bFormated) { |
366 switch (nFieldType) | 367 CPDF_FormField* pFormField = GetFormField(); |
367 { | 368 ASSERT(pFormField != NULL); |
368 case FIELDTYPE_PUSHBUTTON: | 369 |
369 ResetAppearance_PushButton(); | 370 ASSERT(m_pInterForm != NULL); |
370 break; | 371 |
371 case FIELDTYPE_CHECKBOX: | 372 return m_pInterForm->OnFormat(pFormField, nCommitKey, bFormated); |
372 ResetAppearance_CheckBox(); | 373 } |
373 break; | 374 |
374 case FIELDTYPE_RADIOBUTTON: | 375 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) { |
375 ResetAppearance_RadioButton(); | 376 CPDF_FormField* pFormField = GetFormField(); |
376 break; | 377 ASSERT(pFormField != NULL); |
377 case FIELDTYPE_COMBOBOX: | 378 |
378 ResetAppearance_ComboBox(sValue); | 379 ASSERT(m_pInterForm != NULL); |
379 break; | 380 |
380 case FIELDTYPE_LISTBOX: | 381 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); |
381 ResetAppearance_ListBox(); | 382 } |
382 break; | 383 |
383 case FIELDTYPE_TEXTFIELD: | 384 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, |
384 ResetAppearance_TextField(sValue); | 385 const CPDF_Matrix* pUser2Device, |
385 break; | 386 CPDF_Annot::AppearanceMode mode, |
386 } | 387 const CPDF_RenderOptions* pOptions) { |
387 | 388 int nFieldType = GetFieldType(); |
388 ASSERT(m_pAnnot != NULL); | 389 |
389 m_pAnnot->ClearCachedAP(); | 390 if ((nFieldType == FIELDTYPE_CHECKBOX || |
390 } | 391 nFieldType == FIELDTYPE_RADIOBUTTON) && |
391 | 392 mode == CPDF_Annot::Normal && |
392 CFX_WideString CPDFSDK_Widget::OnFormat(int nCommitKey, FX_BOOL& bFormated) | 393 !this->IsWidgetAppearanceValid(CPDF_Annot::Normal)) { |
393 { | 394 CFX_PathData pathData; |
394 CPDF_FormField* pFormField = GetFormField(); | 395 |
395 ASSERT(pFormField != NULL); | 396 CPDF_Rect rcAnnot = this->GetRect(); |
396 | 397 |
397 ASSERT(m_pInterForm != NULL); | 398 pathData.AppendRect( |
398 | 399 rcAnnot.left, rcAnnot.bottom, rcAnnot.right, rcAnnot.top); |
399 return m_pInterForm->OnFormat(pFormField, nCommitKey, bFormated); | 400 |
400 | 401 CFX_GraphStateData gsd; |
401 } | 402 gsd.m_LineWidth = 0.0f; |
402 | 403 |
403 void CPDFSDK_Widget::ResetFieldAppearance(FX_BOOL bValueChanged) | 404 pDevice->DrawPath( |
404 { | 405 &pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA, FXFILL_ALTERNATE); |
405 CPDF_FormField* pFormField = GetFormField(); | 406 } else { |
406 ASSERT(pFormField != NULL); | 407 CPDFSDK_Annot::DrawAppearance(pDevice, pUser2Device, mode, pOptions); |
407 | 408 } |
408 ASSERT(m_pInterForm != NULL); | 409 } |
409 | 410 |
410 m_pInterForm->ResetFieldAppearance(pFormField, NULL, bValueChanged); | 411 void CPDFSDK_Widget::UpdateField() { |
411 } | 412 CPDF_FormField* pFormField = GetFormField(); |
412 | 413 ASSERT(pFormField != NULL); |
413 void CPDFSDK_Widget::DrawAppearance(CFX_RenderDevice* pDevice, const CPDF_Mat
rix* pUser2Device, | 414 |
414 CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOpti
ons) | 415 ASSERT(m_pInterForm != NULL); |
415 { | 416 m_pInterForm->UpdateField(pFormField); |
416 int nFieldType = GetFieldType(); | 417 } |
417 | 418 |
418 if ((nFieldType == FIELDTYPE_CHECKBOX || nFieldType == FIELDTYPE_RADIOBU
TTON) && | 419 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, |
419 mode == CPDF_Annot::Normal && | 420 CPDFSDK_PageView* pPageView) { |
420 !this->IsWidgetAppearanceValid(CPDF_Annot::Normal)) | 421 ASSERT(m_pInterForm != NULL); |
421 { | 422 |
422 CFX_PathData pathData; | 423 int nFieldType = GetFieldType(); |
423 | 424 if (m_pInterForm->IsNeedHighLight(nFieldType)) { |
424 CPDF_Rect rcAnnot = this->GetRect(); | 425 // if (nFieldType != FIELDTYPE_PUSHBUTTON) |
425 | 426 // { |
426 pathData.AppendRect(rcAnnot.left, rcAnnot.bottom, | 427 CPDF_Rect rc = GetRect(); |
427 rcAnnot.right, rcAnnot.top); | 428 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFieldType); |
428 | 429 FX_BYTE alpha = m_pInterForm->GetHighlightAlpha(); |
429 CFX_GraphStateData gsd; | 430 |
430 gsd.m_LineWidth = 0.0f; | 431 CFX_FloatRect rcDevice; |
431 | 432 ASSERT(m_pInterForm->GetDocument()); |
432 pDevice->DrawPath(&pathData, pUser2Device, &gsd, 0, 0xFFAAAAAA,
FXFILL_ALTERNATE); | 433 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()->GetEnv(); |
433 } | 434 if (!pEnv) |
434 else | 435 return; |
435 { | 436 CFX_AffineMatrix page2device; |
436 CPDFSDK_Annot::DrawAppearance(pDevice, pUser2Device, mode, pOpti
ons); | 437 pPageView->GetCurrentMatrix(page2device); |
437 } | 438 page2device.Transform(((FX_FLOAT)rc.left), |
438 } | 439 ((FX_FLOAT)rc.bottom), |
439 | 440 rcDevice.left, |
440 void CPDFSDK_Widget::UpdateField() | 441 rcDevice.bottom); |
441 { | 442 // pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.lef
t, rc.bottom, |
442 CPDF_FormField* pFormField = GetFormField(); | 443 // &rcDevice.left, &rcDevice.bottom); |
443 ASSERT(pFormField != NULL); | 444 // pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.rig
ht, rc.top, |
444 | 445 // &rcDevice.right, &rcDevice.top); |
445 ASSERT(m_pInterForm != NULL); | 446 page2device.Transform( |
446 m_pInterForm->UpdateField(pFormField); | 447 ((FX_FLOAT)rc.right), ((FX_FLOAT)rc.top), rcDevice.right, rcDevice.top); |
447 } | 448 |
448 | 449 rcDevice.Normalize(); |
449 void CPDFSDK_Widget::DrawShadow(CFX_RenderDevice* pDevice, CPDFSDK_PageView* pPa
geView) | 450 |
450 { | 451 FX_ARGB argb = ArgbEncode((int)alpha, color); |
451 ASSERT(m_pInterForm != NULL); | 452 FX_RECT rcDev((int)rcDevice.left, |
452 | 453 (int)rcDevice.top, |
453 int nFieldType = GetFieldType(); | 454 (int)rcDevice.right, |
454 if (m_pInterForm->IsNeedHighLight(nFieldType)) | 455 (int)rcDevice.bottom); |
455 { | 456 pDevice->FillRect(&rcDev, argb); |
456 | 457 /* }*/ |
457 // if (nFieldType != FIELDTYPE_PUSHBUTTON) | 458 } |
458 // { | 459 } |
459 CPDF_Rect rc = GetRect(); | 460 |
460 FX_COLORREF color = m_pInterForm->GetHighlightColor(nFie
ldType); | 461 void CPDFSDK_Widget::ResetAppearance_PushButton() { |
461 FX_BYTE alpha = m_pInterForm->GetHighlightAlpha(); | 462 CPDF_FormControl* pControl = GetFormControl(); |
462 | 463 ASSERT(pControl != NULL); |
463 CFX_FloatRect rcDevice; | 464 |
464 ASSERT(m_pInterForm->GetDocument()); | 465 CPDF_Rect rcWindow = GetRotatedRect(); |
465 CPDFDoc_Environment* pEnv = m_pInterForm->GetDocument()-
>GetEnv(); | 466 |
466 if(!pEnv) | 467 FX_INT32 nLayout = 0; |
467 return; | 468 |
468 CFX_AffineMatrix page2device; | 469 switch (pControl->GetTextPosition()) { |
469 pPageView->GetCurrentMatrix(page2device); | 470 case TEXTPOS_ICON: |
470 page2device.Transform(((FX_FLOAT)rc.left), ((FX_FLOAT)rc
.bottom), rcDevice.left, rcDevice.bottom); | 471 nLayout = PPBL_ICON; |
471 // pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.lef
t, rc.bottom, &rcDevice.left, &rcDevice.bottom); | 472 break; |
472 // pEnv->FFI_PageToDevice(m_pPageView->GetPDFPage(), rc.rig
ht, rc.top, &rcDevice.right, &rcDevice.top); | 473 case TEXTPOS_BELOW: |
473 page2device.Transform(((FX_FLOAT)rc.right), ((FX_FLOAT)r
c.top), rcDevice.right, rcDevice.top); | 474 nLayout = PPBL_ICONTOPLABELBOTTOM; |
474 | 475 break; |
475 rcDevice.Normalize(); | 476 case TEXTPOS_ABOVE: |
476 | 477 nLayout = PPBL_LABELTOPICONBOTTOM; |
477 FX_ARGB argb = ArgbEncode((int)alpha, color); | 478 break; |
478 FX_RECT rcDev((int)rcDevice.left,(int)rcDevice.top,(int)
rcDevice.right,(int)rcDevice.bottom); | 479 case TEXTPOS_RIGHT: |
479 pDevice->FillRect(&rcDev, argb); | 480 nLayout = PPBL_ICONLEFTLABELRIGHT; |
480 /* }*/ | 481 break; |
481 } | 482 case TEXTPOS_LEFT: |
482 } | 483 nLayout = PPBL_LABELLEFTICONRIGHT; |
483 | 484 break; |
484 void CPDFSDK_Widget::ResetAppearance_PushButton() | 485 case TEXTPOS_OVERLAID: |
485 { | 486 nLayout = PPBL_LABELOVERICON; |
486 CPDF_FormControl* pControl = GetFormControl(); | 487 break; |
487 ASSERT(pControl != NULL); | 488 default: |
488 | 489 nLayout = PPBL_LABEL; |
489 | 490 break; |
490 | 491 } |
491 CPDF_Rect rcWindow = GetRotatedRect(); | 492 |
492 | 493 CPWL_Color crBackground, crBorder; |
493 FX_INT32 nLayout = 0; | 494 |
494 | 495 int iColorType; |
495 switch (pControl->GetTextPosition()) | 496 FX_FLOAT fc[4]; |
496 { | 497 |
497 case TEXTPOS_ICON: | 498 pControl->GetOriginalBackgroundColor(iColorType, fc); |
498 nLayout = PPBL_ICON; | 499 if (iColorType > 0) |
499 break; | 500 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
500 case TEXTPOS_BELOW: | 501 |
501 nLayout = PPBL_ICONTOPLABELBOTTOM; | 502 pControl->GetOriginalBorderColor(iColorType, fc); |
502 break; | 503 if (iColorType > 0) |
503 case TEXTPOS_ABOVE: | 504 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
504 nLayout = PPBL_LABELTOPICONBOTTOM; | 505 |
505 break; | 506 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
506 case TEXTPOS_RIGHT: | 507 FX_INT32 nBorderStyle = 0; |
507 nLayout = PPBL_ICONLEFTLABELRIGHT; | 508 CPWL_Dash dsBorder(3, 0, 0); |
508 break; | 509 CPWL_Color crLeftTop, crRightBottom; |
509 case TEXTPOS_LEFT: | 510 |
510 nLayout = PPBL_LABELLEFTICONRIGHT; | 511 switch (GetBorderStyle()) { |
511 break; | 512 case BBS_DASH: |
512 case TEXTPOS_OVERLAID: | 513 nBorderStyle = PBS_DASH; |
513 nLayout = PPBL_LABELOVERICON; | 514 dsBorder = CPWL_Dash(3, 3, 0); |
514 break; | 515 break; |
515 default: | 516 case BBS_BEVELED: |
516 nLayout = PPBL_LABEL; | 517 nBorderStyle = PBS_BEVELED; |
517 break; | 518 fBorderWidth *= 2; |
518 } | 519 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); |
519 | 520 crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); |
520 CPWL_Color crBackground, crBorder; | 521 break; |
521 | 522 case BBS_INSET: |
522 int iColorType; | 523 nBorderStyle = PBS_INSET; |
523 FX_FLOAT fc[4]; | 524 fBorderWidth *= 2; |
524 | 525 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); |
525 pControl->GetOriginalBackgroundColor(iColorType, fc); | 526 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
526 if (iColorType > 0) | 527 break; |
527 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]
); | 528 case BBS_UNDERLINE: |
528 | 529 nBorderStyle = PBS_UNDERLINED; |
529 pControl->GetOriginalBorderColor(iColorType, fc); | 530 break; |
530 if (iColorType > 0) | 531 default: |
531 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 532 nBorderStyle = PBS_SOLID; |
532 | 533 break; |
533 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 534 } |
534 FX_INT32 nBorderStyle = 0; | 535 |
535 CPWL_Dash dsBorder(3,0,0); | 536 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
536 CPWL_Color crLeftTop,crRightBottom; | 537 |
537 | 538 CPWL_Color crText(COLORTYPE_GRAY, 0); |
538 switch (GetBorderStyle()) | 539 |
539 { | 540 FX_FLOAT fFontSize = 12.0f; |
540 case BBS_DASH: | 541 CFX_ByteString csNameTag; |
541 nBorderStyle = PBS_DASH; | 542 |
542 dsBorder = CPWL_Dash(3, 3, 0); | 543 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); |
543 break; | 544 if (da.HasColor()) { |
544 case BBS_BEVELED: | 545 da.GetColor(iColorType, fc); |
545 nBorderStyle = PBS_BEVELED; | 546 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
546 fBorderWidth *= 2; | 547 } |
547 crLeftTop = CPWL_Color(COLORTYPE_GRAY,1); | 548 |
548 crRightBottom = CPWL_Utils::DevideColor(crBackground,2); | 549 if (da.HasFont()) |
549 break; | 550 da.GetFont(csNameTag, fFontSize); |
550 case BBS_INSET: | 551 |
551 nBorderStyle = PBS_INSET; | 552 CFX_WideString csWCaption; |
552 fBorderWidth *= 2; | 553 CFX_WideString csNormalCaption, csRolloverCaption, csDownCaption; |
553 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5); | 554 |
554 crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75); | 555 if (pControl->HasMKEntry("CA")) { |
555 break; | 556 csNormalCaption = pControl->GetNormalCaption(); |
556 case BBS_UNDERLINE: | 557 } |
557 nBorderStyle = PBS_UNDERLINED; | 558 if (pControl->HasMKEntry("RC")) { |
558 break; | 559 csRolloverCaption = pControl->GetRolloverCaption(); |
559 default: | 560 } |
560 nBorderStyle = PBS_SOLID; | 561 if (pControl->HasMKEntry("AC")) { |
561 break; | 562 csDownCaption = pControl->GetDownCaption(); |
562 } | 563 } |
563 | 564 |
564 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth); | 565 CPDF_Stream* pNormalIcon = NULL; |
565 | 566 CPDF_Stream* pRolloverIcon = NULL; |
566 CPWL_Color crText(COLORTYPE_GRAY,0); | 567 CPDF_Stream* pDownIcon = NULL; |
567 | 568 |
568 FX_FLOAT fFontSize = 12.0f; | 569 if (pControl->HasMKEntry("I")) { |
569 CFX_ByteString csNameTag; | 570 pNormalIcon = pControl->GetNormalIcon(); |
570 | 571 } |
571 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); | 572 if (pControl->HasMKEntry("RI")) { |
572 if (da.HasColor()) | 573 pRolloverIcon = pControl->GetRolloverIcon(); |
573 { | 574 } |
574 da.GetColor(iColorType, fc); | 575 if (pControl->HasMKEntry("IX")) { |
575 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 576 pDownIcon = pControl->GetDownIcon(); |
576 } | 577 } |
577 | 578 |
578 if (da.HasFont()) | 579 if (pNormalIcon) { |
579 da.GetFont(csNameTag, fFontSize); | 580 if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) { |
580 | 581 if (pImageDict->GetString("Name").IsEmpty()) |
581 CFX_WideString csWCaption; | 582 pImageDict->SetAtString("Name", "ImgA"); |
582 CFX_WideString csNormalCaption, csRolloverCaption, csDownCaption; | 583 } |
583 | 584 } |
584 if (pControl->HasMKEntry("CA")) | 585 |
585 { | 586 if (pRolloverIcon) { |
586 csNormalCaption = pControl->GetNormalCaption(); | 587 if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) { |
587 } | 588 if (pImageDict->GetString("Name").IsEmpty()) |
588 if (pControl->HasMKEntry("RC")) | 589 pImageDict->SetAtString("Name", "ImgB"); |
589 { | 590 } |
590 csRolloverCaption = pControl->GetRolloverCaption(); | 591 } |
591 } | 592 |
592 if (pControl->HasMKEntry("AC")) | 593 if (pDownIcon) { |
593 { | 594 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) { |
594 csDownCaption = pControl->GetDownCaption(); | 595 if (pImageDict->GetString("Name").IsEmpty()) |
595 } | 596 pImageDict->SetAtString("Name", "ImgC"); |
596 | 597 } |
597 CPDF_Stream* pNormalIcon = NULL; | 598 } |
598 CPDF_Stream* pRolloverIcon = NULL; | 599 |
599 CPDF_Stream* pDownIcon = NULL; | 600 CPDF_IconFit iconFit = pControl->GetIconFit(); |
600 | 601 |
601 if (pControl->HasMKEntry("I")) | 602 // ASSERT(this->m_pBaseForm != NULL); |
602 { | 603 ASSERT(this->m_pInterForm != NULL); |
603 pNormalIcon = pControl->GetNormalIcon(); | 604 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
604 } | 605 ASSERT(pDoc != NULL); |
605 if (pControl->HasMKEntry("RI")) | 606 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
606 { | 607 |
607 pRolloverIcon = pControl->GetRolloverIcon(); | 608 CBA_FontMap FontMap( |
608 } | 609 this, |
609 if (pControl->HasMKEntry("IX")) | 610 pEnv->GetSysHandler()); //, |
610 { | 611 //ISystemHandle::GetSystemHandler(m_pBaseForm->Ge
tEnv())); |
611 pDownIcon = pControl->GetDownIcon(); | 612 FontMap.Initial(); |
612 } | 613 |
613 | 614 FontMap.SetAPType("N"); |
614 if (pNormalIcon) | 615 |
615 { | 616 CFX_ByteString csAP = |
616 if (CPDF_Dictionary* pImageDict = pNormalIcon->GetDict()) | 617 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
617 { | 618 CPWL_Utils::GetBorderAppStream(rcWindow, |
618 if (pImageDict->GetString("Name").IsEmpty()) | 619 fBorderWidth, |
619 pImageDict->SetAtString("Name", "ImgA"); | 620 crBorder, |
620 } | 621 crLeftTop, |
621 } | 622 crRightBottom, |
622 | 623 nBorderStyle, |
623 if (pRolloverIcon) | 624 dsBorder) + |
624 { | 625 CPWL_Utils::GetPushButtonAppStream( |
625 if (CPDF_Dictionary* pImageDict = pRolloverIcon->GetDict()) | 626 iconFit.GetFittingBounds() ? rcWindow : rcClient, |
626 { | 627 &FontMap, |
627 if (pImageDict->GetString("Name").IsEmpty()) | 628 pNormalIcon, |
628 pImageDict->SetAtString("Name", "ImgB"); | 629 iconFit, |
629 } | 630 csNormalCaption, |
630 } | 631 crText, |
631 | 632 fFontSize, |
632 if (pDownIcon) | 633 nLayout); |
633 { | 634 |
634 if (CPDF_Dictionary* pImageDict = pDownIcon->GetDict()) | 635 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP); |
635 { | 636 if (pNormalIcon) |
636 if (pImageDict->GetString("Name").IsEmpty()) | 637 AddImageToAppearance("N", pNormalIcon); |
637 pImageDict->SetAtString("Name", "ImgC"); | 638 |
638 } | 639 CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode(); |
639 } | 640 if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle) { |
640 | 641 if (csRolloverCaption.IsEmpty() && !pRolloverIcon) { |
641 CPDF_IconFit iconFit = pControl->GetIconFit(); | 642 csRolloverCaption = csNormalCaption; |
642 | 643 pRolloverIcon = pNormalIcon; |
643 // ASSERT(this->m_pBaseForm != NULL); | 644 } |
644 ASSERT(this->m_pInterForm != NULL); | 645 |
645 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 646 FontMap.SetAPType("R"); |
646 ASSERT(pDoc != NULL); | 647 |
647 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 648 csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
648 | 649 CPWL_Utils::GetBorderAppStream(rcWindow, |
649 CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandle::GetSy
stemHandler(m_pBaseForm->GetEnv())); | 650 fBorderWidth, |
650 FontMap.Initial(); | 651 crBorder, |
651 | 652 crLeftTop, |
652 FontMap.SetAPType("N"); | 653 crRightBottom, |
653 | 654 nBorderStyle, |
654 CFX_ByteString csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackg
round) + | 655 dsBorder) + |
655 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
crLeftTop, crRightBottom, nBorderStyle, dsBorder) + | 656 CPWL_Utils::GetPushButtonAppStream( |
656 CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBounds() ?
rcWindow : rcClient, &FontMap, pNormalIcon, iconFit, csNormalCaption, crText, fF
ontSize, nLayout); | 657 iconFit.GetFittingBounds() ? rcWindow : rcClient, |
657 | 658 &FontMap, |
658 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP); | 659 pRolloverIcon, |
659 if (pNormalIcon) | 660 iconFit, |
660 AddImageToAppearance("N", pNormalIcon); | 661 csRolloverCaption, |
661 | 662 crText, |
662 CPDF_FormControl::HighlightingMode eHLM = pControl->GetHighlightingMode(
); | 663 fFontSize, |
663 if (eHLM == CPDF_FormControl::Push || eHLM == CPDF_FormControl::Toggle) | 664 nLayout); |
664 { | 665 |
665 if (csRolloverCaption.IsEmpty() && !pRolloverIcon)
| 666 WriteAppearance("R", GetRotatedRect(), GetMatrix(), csAP); |
666 { | 667 if (pRolloverIcon) |
667 csRolloverCaption = csNormalCaption; | 668 AddImageToAppearance("R", pRolloverIcon); |
668 pRolloverIcon = pNormalIcon; | 669 |
669 } | 670 if (csDownCaption.IsEmpty() && !pDownIcon) { |
670 | 671 csDownCaption = csNormalCaption; |
671 FontMap.SetAPType("R"); | 672 pDownIcon = pNormalIcon; |
672 | 673 } |
673 csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground)
+ | 674 |
674 CPWL_Utils::GetBorderAppStream(rcWindow, fBorder
Width, crBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) + | 675 switch (nBorderStyle) { |
675 CPWL_Utils::GetPushButtonAppStream(iconFit.GetFi
ttingBounds() ? rcWindow : rcClient, &FontMap, pRolloverIcon, iconFit, csRollove
rCaption, crText, fFontSize, nLayout); | 676 case PBS_BEVELED: { |
676 | 677 CPWL_Color crTemp = crLeftTop; |
677 WriteAppearance("R", GetRotatedRect(), GetMatrix(), csAP); | 678 crLeftTop = crRightBottom; |
678 if (pRolloverIcon) | 679 crRightBottom = crTemp; |
679 AddImageToAppearance("R", pRolloverIcon); | 680 } break; |
680 | 681 case PBS_INSET: |
681 if (csDownCaption.IsEmpty() && !pDownIcon) | 682 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); |
682 { | 683 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); |
683 csDownCaption = csNormalCaption; | 684 break; |
684 pDownIcon = pNormalIcon; | 685 } |
685 } | 686 |
686 | 687 FontMap.SetAPType("D"); |
687 switch (nBorderStyle) | 688 |
688 { | 689 csAP = CPWL_Utils::GetRectFillAppStream( |
689 case PBS_BEVELED: | 690 rcWindow, CPWL_Utils::SubstractColor(crBackground, 0.25f)) + |
690 { | 691 CPWL_Utils::GetBorderAppStream(rcWindow, |
691 CPWL_Color crTemp = crLeftTop; | 692 fBorderWidth, |
692 crLeftTop = crRightBottom; | 693 crBorder, |
693 crRightBottom = crTemp; | 694 crLeftTop, |
694 } | 695 crRightBottom, |
695 break; | 696 nBorderStyle, |
696 case PBS_INSET: | 697 dsBorder) + |
697 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0); | 698 CPWL_Utils::GetPushButtonAppStream( |
698 crRightBottom = CPWL_Color(COLORTYPE_GRAY,1); | 699 iconFit.GetFittingBounds() ? rcWindow : rcClient, |
699 break; | 700 &FontMap, |
700 } | 701 pDownIcon, |
701 | 702 iconFit, |
702 FontMap.SetAPType("D"); | 703 csDownCaption, |
703 | 704 crText, |
704 csAP = CPWL_Utils::GetRectFillAppStream(rcWindow, CPWL_Utils::Su
bstractColor(crBackground,0.25f)) + | 705 fFontSize, |
705 CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, c
rBorder, crLeftTop, crRightBottom, nBorderStyle, dsBorder) + | 706 nLayout); |
706 CPWL_Utils::GetPushButtonAppStream(iconFit.GetFittingBou
nds() ? rcWindow : rcClient, &FontMap, pDownIcon, iconFit, csDownCaption, crText
, fFontSize, nLayout); | 707 |
707 | 708 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP); |
708 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP); | 709 if (pDownIcon) |
709 if (pDownIcon) | 710 AddImageToAppearance("D", pDownIcon); |
710 AddImageToAppearance("D", pDownIcon); | 711 } else { |
711 } | 712 RemoveAppearance("D"); |
712 else | 713 RemoveAppearance("R"); |
713 { | 714 } |
714 RemoveAppearance("D"); | 715 } |
715 RemoveAppearance("R"); | 716 |
716 } | 717 void CPDFSDK_Widget::ResetAppearance_CheckBox() { |
717 } | 718 CPDF_FormControl* pControl = GetFormControl(); |
718 | 719 ASSERT(pControl != NULL); |
719 void CPDFSDK_Widget::ResetAppearance_CheckBox() | 720 |
720 { | 721 CPWL_Color crBackground, crBorder, crText; |
721 CPDF_FormControl* pControl = GetFormControl(); | 722 |
722 ASSERT(pControl != NULL); | 723 int iColorType; |
723 | 724 FX_FLOAT fc[4]; |
724 | 725 |
725 | 726 pControl->GetOriginalBackgroundColor(iColorType, fc); |
726 CPWL_Color crBackground, crBorder, crText; | 727 if (iColorType > 0) |
727 | 728 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
728 int iColorType; | 729 |
729 FX_FLOAT fc[4]; | 730 pControl->GetOriginalBorderColor(iColorType, fc); |
730 | 731 if (iColorType > 0) |
731 pControl->GetOriginalBackgroundColor(iColorType, fc); | 732 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
732 if (iColorType > 0) | 733 |
733 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]
); | 734 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
734 | 735 FX_INT32 nBorderStyle = 0; |
735 pControl->GetOriginalBorderColor(iColorType, fc); | 736 CPWL_Dash dsBorder(3, 0, 0); |
736 if (iColorType > 0) | 737 CPWL_Color crLeftTop, crRightBottom; |
737 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 738 |
738 | 739 switch (GetBorderStyle()) { |
739 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 740 case BBS_DASH: |
740 FX_INT32 nBorderStyle = 0; | 741 nBorderStyle = PBS_DASH; |
741 CPWL_Dash dsBorder(3,0,0); | 742 dsBorder = CPWL_Dash(3, 3, 0); |
742 CPWL_Color crLeftTop,crRightBottom; | 743 break; |
743 | 744 case BBS_BEVELED: |
744 switch (GetBorderStyle()) | 745 nBorderStyle = PBS_BEVELED; |
745 { | 746 fBorderWidth *= 2; |
746 case BBS_DASH: | 747 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); |
747 nBorderStyle = PBS_DASH; | 748 crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); |
748 dsBorder = CPWL_Dash(3, 3, 0); | 749 break; |
749 break; | 750 case BBS_INSET: |
750 case BBS_BEVELED: | 751 nBorderStyle = PBS_INSET; |
751 nBorderStyle = PBS_BEVELED; | 752 fBorderWidth *= 2; |
752 fBorderWidth *= 2; | 753 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); |
753 crLeftTop = CPWL_Color(COLORTYPE_GRAY,1); | 754 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
754 crRightBottom = CPWL_Utils::DevideColor(crBackground,2); | 755 break; |
755 break; | 756 case BBS_UNDERLINE: |
756 case BBS_INSET: | 757 nBorderStyle = PBS_UNDERLINED; |
757 nBorderStyle = PBS_INSET; | 758 break; |
758 fBorderWidth *= 2; | 759 default: |
759 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5); | 760 nBorderStyle = PBS_SOLID; |
760 crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75); | 761 break; |
761 break; | 762 } |
762 case BBS_UNDERLINE: | 763 |
763 nBorderStyle = PBS_UNDERLINED; | 764 CPDF_Rect rcWindow = GetRotatedRect(); |
764 break; | 765 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
765 default: | 766 |
766 nBorderStyle = PBS_SOLID; | 767 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); |
767 break; | 768 if (da.HasColor()) { |
768 } | 769 da.GetColor(iColorType, fc); |
769 | 770 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
770 CPDF_Rect rcWindow = GetRotatedRect(); | 771 } |
771 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,fBorderWidth); | 772 |
772 | 773 FX_INT32 nStyle = 0; |
773 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); | 774 |
774 if (da.HasColor()) | 775 CFX_WideString csWCaption = pControl->GetNormalCaption(); |
775 { | 776 if (csWCaption.GetLength() > 0) { |
776 da.GetColor(iColorType, fc); | 777 switch (csWCaption[0]) { |
777 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 778 case L'l': |
778 } | 779 nStyle = PCS_CIRCLE; |
779 | 780 break; |
780 FX_INT32 nStyle = 0; | 781 case L'8': |
781 | 782 nStyle = PCS_CROSS; |
782 CFX_WideString csWCaption = pControl->GetNormalCaption(); | 783 break; |
783 if (csWCaption.GetLength() > 0) | 784 case L'u': |
784 { | 785 nStyle = PCS_DIAMOND; |
785 switch (csWCaption[0]) | 786 break; |
786 { | 787 case L'n': |
787 case L'l': | 788 nStyle = PCS_SQUARE; |
788 nStyle = PCS_CIRCLE; | 789 break; |
789 break; | 790 case L'H': |
790 case L'8': | 791 nStyle = PCS_STAR; |
791 nStyle = PCS_CROSS; | 792 break; |
792 break; | 793 default: // L'4' |
793 case L'u': | 794 nStyle = PCS_CHECK; |
794 nStyle = PCS_DIAMOND; | 795 break; |
795 break; | 796 } |
796 case L'n': | 797 } else { |
797 nStyle = PCS_SQUARE; | 798 nStyle = PCS_CHECK; |
798 break; | 799 } |
799 case L'H': | 800 |
800 nStyle = PCS_STAR; | 801 CFX_ByteString csAP_N_ON = |
801 break; | 802 CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
802 default: //L'4' | 803 CPWL_Utils::GetBorderAppStream(rcWindow, |
803 nStyle = PCS_CHECK; | 804 fBorderWidth, |
804 break; | 805 crBorder, |
805 } | 806 crLeftTop, |
806 } | 807 crRightBottom, |
807 else | 808 nBorderStyle, |
808 { | 809 dsBorder); |
809 nStyle = PCS_CHECK; | 810 |
810 } | 811 CFX_ByteString csAP_N_OFF = csAP_N_ON; |
811 | 812 |
812 CFX_ByteString csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crB
ackground) + | 813 switch (nBorderStyle) { |
813 CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,cr
LeftTop,crRightBottom,nBorderStyle,dsBorder); | 814 case PBS_BEVELED: { |
814 | 815 CPWL_Color crTemp = crLeftTop; |
815 CFX_ByteString csAP_N_OFF = csAP_N_ON; | 816 crLeftTop = crRightBottom; |
816 | 817 crRightBottom = crTemp; |
817 switch (nBorderStyle) | 818 } break; |
818 { | 819 case PBS_INSET: |
819 case PBS_BEVELED: | 820 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); |
820 { | 821 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); |
821 CPWL_Color crTemp = crLeftTop; | 822 break; |
822 crLeftTop = crRightBottom; | 823 } |
823 crRightBottom = crTemp; | 824 |
824 } | 825 CFX_ByteString csAP_D_ON = |
825 break; | 826 CPWL_Utils::GetRectFillAppStream( |
826 case PBS_INSET: | 827 rcWindow, CPWL_Utils::SubstractColor(crBackground, 0.25f)) + |
827 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0); | 828 CPWL_Utils::GetBorderAppStream(rcWindow, |
828 crRightBottom = CPWL_Color(COLORTYPE_GRAY,1); | 829 fBorderWidth, |
829 break; | 830 crBorder, |
830 } | 831 crLeftTop, |
831 | 832 crRightBottom, |
832 CFX_ByteString csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPW
L_Utils::SubstractColor(crBackground,0.25f)) + | 833 nBorderStyle, |
833 CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crBorder,cr
LeftTop,crRightBottom,nBorderStyle,dsBorder); | 834 dsBorder); |
834 | 835 |
835 CFX_ByteString csAP_D_OFF = csAP_D_ON; | 836 CFX_ByteString csAP_D_OFF = csAP_D_ON; |
836 | 837 |
837 csAP_N_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient,nStyle,crText); | 838 csAP_N_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient, nStyle, crText); |
838 csAP_D_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient,nStyle,crText); | 839 csAP_D_ON += CPWL_Utils::GetCheckBoxAppStream(rcClient, nStyle, crText); |
839 | 840 |
840 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_ON, pControl-
>GetCheckedAPState()); | 841 WriteAppearance("N", |
841 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off"); | 842 GetRotatedRect(), |
842 | 843 GetMatrix(), |
843 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl-
>GetCheckedAPState()); | 844 csAP_N_ON, |
844 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 845 pControl->GetCheckedAPState()); |
845 | 846 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off"); |
846 CFX_ByteString csAS = GetAppState(); | 847 |
847 if (csAS.IsEmpty()) | 848 WriteAppearance("D", |
848 SetAppState("Off"); | 849 GetRotatedRect(), |
849 } | 850 GetMatrix(), |
850 | 851 csAP_D_ON, |
851 void CPDFSDK_Widget::ResetAppearance_RadioButton() | 852 pControl->GetCheckedAPState()); |
852 { | 853 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
853 CPDF_FormControl* pControl = GetFormControl(); | 854 |
854 ASSERT(pControl != NULL); | 855 CFX_ByteString csAS = GetAppState(); |
855 | 856 if (csAS.IsEmpty()) |
856 | 857 SetAppState("Off"); |
857 | 858 } |
858 CPWL_Color crBackground, crBorder, crText; | 859 |
859 | 860 void CPDFSDK_Widget::ResetAppearance_RadioButton() { |
860 int iColorType; | 861 CPDF_FormControl* pControl = GetFormControl(); |
861 FX_FLOAT fc[4]; | 862 ASSERT(pControl != NULL); |
862 | 863 |
863 pControl->GetOriginalBackgroundColor(iColorType, fc); | 864 CPWL_Color crBackground, crBorder, crText; |
864 if (iColorType > 0) | 865 |
865 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]
); | 866 int iColorType; |
866 | 867 FX_FLOAT fc[4]; |
867 pControl->GetOriginalBorderColor(iColorType, fc); | 868 |
868 if (iColorType > 0) | 869 pControl->GetOriginalBackgroundColor(iColorType, fc); |
869 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 870 if (iColorType > 0) |
870 | 871 crBackground = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
871 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 872 |
872 FX_INT32 nBorderStyle = 0; | 873 pControl->GetOriginalBorderColor(iColorType, fc); |
873 CPWL_Dash dsBorder(3,0,0); | 874 if (iColorType > 0) |
874 CPWL_Color crLeftTop,crRightBottom; | 875 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
875 | 876 |
876 switch (GetBorderStyle()) | 877 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
877 { | 878 FX_INT32 nBorderStyle = 0; |
878 case BBS_DASH: | 879 CPWL_Dash dsBorder(3, 0, 0); |
879 nBorderStyle = PBS_DASH; | 880 CPWL_Color crLeftTop, crRightBottom; |
880 dsBorder = CPWL_Dash(3, 3, 0); | 881 |
881 break; | 882 switch (GetBorderStyle()) { |
882 case BBS_BEVELED: | 883 case BBS_DASH: |
883 nBorderStyle = PBS_BEVELED; | 884 nBorderStyle = PBS_DASH; |
884 fBorderWidth *= 2; | 885 dsBorder = CPWL_Dash(3, 3, 0); |
885 crLeftTop = CPWL_Color(COLORTYPE_GRAY,1); | 886 break; |
886 crRightBottom = CPWL_Utils::DevideColor(crBackground,2); | 887 case BBS_BEVELED: |
887 break; | 888 nBorderStyle = PBS_BEVELED; |
888 case BBS_INSET: | 889 fBorderWidth *= 2; |
889 nBorderStyle = PBS_INSET; | 890 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); |
890 fBorderWidth *= 2; | 891 crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); |
891 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5); | 892 break; |
892 crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75); | 893 case BBS_INSET: |
893 break; | 894 nBorderStyle = PBS_INSET; |
894 case BBS_UNDERLINE: | 895 fBorderWidth *= 2; |
895 nBorderStyle = PBS_UNDERLINED; | 896 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); |
896 break; | 897 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
897 default: | 898 break; |
898 nBorderStyle = PBS_SOLID; | 899 case BBS_UNDERLINE: |
899 break; | 900 nBorderStyle = PBS_UNDERLINED; |
900 } | 901 break; |
901 | 902 default: |
902 CPDF_Rect rcWindow = GetRotatedRect(); | 903 nBorderStyle = PBS_SOLID; |
903 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); | 904 break; |
904 | 905 } |
905 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); | 906 |
906 if (da.HasColor()) | 907 CPDF_Rect rcWindow = GetRotatedRect(); |
907 { | 908 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
908 da.GetColor(iColorType, fc); | 909 |
909 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 910 CPDF_DefaultAppearance da = pControl->GetDefaultAppearance(); |
910 } | 911 if (da.HasColor()) { |
911 | 912 da.GetColor(iColorType, fc); |
912 FX_INT32 nStyle = 0; | 913 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
913 | 914 } |
914 CFX_WideString csWCaption = pControl->GetNormalCaption(); | 915 |
915 if (csWCaption.GetLength() > 0) | 916 FX_INT32 nStyle = 0; |
916 { | 917 |
917 switch (csWCaption[0]) | 918 CFX_WideString csWCaption = pControl->GetNormalCaption(); |
918 { | 919 if (csWCaption.GetLength() > 0) { |
919 default: //L'l': | 920 switch (csWCaption[0]) { |
920 nStyle = PCS_CIRCLE; | 921 default: // L'l': |
921 break; | 922 nStyle = PCS_CIRCLE; |
922 case L'8': | 923 break; |
923 nStyle = PCS_CROSS; | 924 case L'8': |
924 break; | 925 nStyle = PCS_CROSS; |
925 case L'u': | 926 break; |
926 nStyle = PCS_DIAMOND; | 927 case L'u': |
927 break; | 928 nStyle = PCS_DIAMOND; |
928 case L'n': | 929 break; |
929 nStyle = PCS_SQUARE; | 930 case L'n': |
930 break; | 931 nStyle = PCS_SQUARE; |
931 case L'H': | 932 break; |
932 nStyle = PCS_STAR; | 933 case L'H': |
933 break; | 934 nStyle = PCS_STAR; |
934 case L'4': | 935 break; |
935 nStyle = PCS_CHECK; | 936 case L'4': |
936 break; | 937 nStyle = PCS_CHECK; |
937 } | 938 break; |
938 } | 939 } |
939 else | 940 } else { |
940 { | 941 nStyle = PCS_CIRCLE; |
941 nStyle = PCS_CIRCLE; | 942 } |
942 } | 943 |
943 | 944 CFX_ByteString csAP_N_ON; |
944 CFX_ByteString csAP_N_ON; | 945 |
945 | 946 CPDF_Rect rcCenter = |
946 CPDF_Rect rcCenter = CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare
(rcWindow), 1.0f); | 947 CPWL_Utils::DeflateRect(CPWL_Utils::GetCenterSquare(rcWindow), 1.0f); |
947 | 948 |
948 if (nStyle == PCS_CIRCLE) | 949 if (nStyle == PCS_CIRCLE) { |
949 { | 950 if (nBorderStyle == PBS_BEVELED) { |
950 if (nBorderStyle == PBS_BEVELED) | 951 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); |
951 { | 952 crRightBottom = CPWL_Utils::SubstractColor(crBackground, 0.25f); |
952 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); | 953 } else if (nBorderStyle == PBS_INSET) { |
953 crRightBottom = CPWL_Utils::SubstractColor(crBackground,
0.25f); | 954 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5f); |
954 } | 955 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75f); |
955 else if (nBorderStyle == PBS_INSET) | 956 } |
956 { | 957 |
957 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0.5f); | 958 csAP_N_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter, crBackground) + |
958 crRightBottom = CPWL_Color(COLORTYPE_GRAY,0.75f); | 959 CPWL_Utils::GetCircleBorderAppStream(rcCenter, |
959 } | 960 fBorderWidth, |
960 | 961 crBorder, |
961 csAP_N_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBackgr
ound) + | 962 crLeftTop, |
962 CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderWid
th,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); | 963 crRightBottom, |
963 } | 964 nBorderStyle, |
964 else | 965 dsBorder); |
965 { | 966 } else { |
966 csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,crBackgrou
nd) + | 967 csAP_N_ON = CPWL_Utils::GetRectFillAppStream(rcWindow, crBackground) + |
967 CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crB
order,crLeftTop,crRightBottom,nBorderStyle,dsBorder); | 968 CPWL_Utils::GetBorderAppStream(rcWindow, |
968 } | 969 fBorderWidth, |
969 | 970 crBorder, |
970 CFX_ByteString csAP_N_OFF = csAP_N_ON; | 971 crLeftTop, |
971 | 972 crRightBottom, |
972 switch (nBorderStyle) | 973 nBorderStyle, |
973 { | 974 dsBorder); |
974 case PBS_BEVELED: | 975 } |
975 { | 976 |
976 CPWL_Color crTemp = crLeftTop; | 977 CFX_ByteString csAP_N_OFF = csAP_N_ON; |
977 crLeftTop = crRightBottom; | 978 |
978 crRightBottom = crTemp; | 979 switch (nBorderStyle) { |
979 } | 980 case PBS_BEVELED: { |
980 break; | 981 CPWL_Color crTemp = crLeftTop; |
981 case PBS_INSET: | 982 crLeftTop = crRightBottom; |
982 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0); | 983 crRightBottom = crTemp; |
983 crRightBottom = CPWL_Color(COLORTYPE_GRAY,1); | 984 } break; |
984 break; | 985 case PBS_INSET: |
985 } | 986 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); |
986 | 987 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); |
987 CFX_ByteString csAP_D_ON; | 988 break; |
988 | 989 } |
989 if (nStyle == PCS_CIRCLE) | 990 |
990 { | 991 CFX_ByteString csAP_D_ON; |
991 CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground,0.25f)
; | 992 |
992 if (nBorderStyle == PBS_BEVELED) | 993 if (nStyle == PCS_CIRCLE) { |
993 { | 994 CPWL_Color crBK = CPWL_Utils::SubstractColor(crBackground, 0.25f); |
994 crLeftTop = CPWL_Utils::SubstractColor(crBackground,0.25
f); | 995 if (nBorderStyle == PBS_BEVELED) { |
995 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); | 996 crLeftTop = CPWL_Utils::SubstractColor(crBackground, 0.25f); |
996 crBK = crBackground; | 997 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); |
997 } | 998 crBK = crBackground; |
998 else if (nBorderStyle == PBS_INSET) | 999 } else if (nBorderStyle == PBS_INSET) { |
999 { | 1000 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0); |
1000 crLeftTop = CPWL_Color(COLORTYPE_GRAY,0); | 1001 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 1); |
1001 crRightBottom = CPWL_Color(COLORTYPE_GRAY,1); | 1002 } |
1002 } | 1003 |
1003 | 1004 csAP_D_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter, crBK) + |
1004 csAP_D_ON = CPWL_Utils::GetCircleFillAppStream(rcCenter,crBK) | 1005 CPWL_Utils::GetCircleBorderAppStream(rcCenter, |
1005 + CPWL_Utils::GetCircleBorderAppStream(rcCenter,fBorderW
idth,crBorder,crLeftTop,crRightBottom,nBorderStyle,dsBorder); | 1006 fBorderWidth, |
1006 } | 1007 crBorder, |
1007 else | 1008 crLeftTop, |
1008 { | 1009 crRightBottom, |
1009 csAP_D_ON = CPWL_Utils::GetRectFillAppStream(rcWindow,CPWL_Utils
::SubstractColor(crBackground,0.25f)) + | 1010 nBorderStyle, |
1010 CPWL_Utils::GetBorderAppStream(rcWindow,fBorderWidth,crB
order,crLeftTop,crRightBottom,nBorderStyle,dsBorder); | 1011 dsBorder); |
1011 } | 1012 } else { |
1012 | 1013 csAP_D_ON = CPWL_Utils::GetRectFillAppStream( |
1013 CFX_ByteString csAP_D_OFF = csAP_D_ON; | 1014 rcWindow, CPWL_Utils::SubstractColor(crBackground, 0.25f)) + |
1014 | 1015 CPWL_Utils::GetBorderAppStream(rcWindow, |
1015 csAP_N_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient,nStyle,crText)
; | 1016 fBorderWidth, |
1016 csAP_D_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient,nStyle,crText)
; | 1017 crBorder, |
1017 | 1018 crLeftTop, |
1018 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_ON, pControl-
>GetCheckedAPState()); | 1019 crRightBottom, |
1019 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off"); | 1020 nBorderStyle, |
1020 | 1021 dsBorder); |
1021 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl-
>GetCheckedAPState()); | 1022 } |
1022 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 1023 |
1023 | 1024 CFX_ByteString csAP_D_OFF = csAP_D_ON; |
1024 CFX_ByteString csAS = GetAppState(); | 1025 |
1025 if (csAS.IsEmpty()) | 1026 csAP_N_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient, nStyle, crText); |
1026 SetAppState("Off"); | 1027 csAP_D_ON += CPWL_Utils::GetRadioButtonAppStream(rcClient, nStyle, crText); |
1027 } | 1028 |
1028 | 1029 WriteAppearance("N", |
1029 void CPDFSDK_Widget::ResetAppearance_ComboBox(FX_LPCWSTR sValue) | 1030 GetRotatedRect(), |
1030 { | 1031 GetMatrix(), |
1031 CPDF_FormControl* pControl = GetFormControl(); | 1032 csAP_N_ON, |
1032 ASSERT(pControl != NULL); | 1033 pControl->GetCheckedAPState()); |
1033 CPDF_FormField* pField = pControl->GetField(); | 1034 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off"); |
1034 ASSERT(pField != NULL); | 1035 |
1035 | 1036 WriteAppearance("D", |
1036 CFX_ByteTextBuf sBody, sLines; | 1037 GetRotatedRect(), |
1037 | 1038 GetMatrix(), |
1038 CPDF_Rect rcClient = GetClientRect(); | 1039 csAP_D_ON, |
1039 CPDF_Rect rcButton = rcClient; | 1040 pControl->GetCheckedAPState()); |
1040 rcButton.left = rcButton.right - 13; | 1041 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
1041 rcButton.Normalize(); | 1042 |
1042 | 1043 CFX_ByteString csAS = GetAppState(); |
1043 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1044 if (csAS.IsEmpty()) |
1044 { | 1045 SetAppState("Off"); |
1045 pEdit->EnableRefresh(FALSE); | 1046 } |
1046 | 1047 |
1047 ASSERT(this->m_pInterForm != NULL); | 1048 void CPDFSDK_Widget::ResetAppearance_ComboBox(FX_LPCWSTR sValue) { |
1048 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1049 CPDF_FormControl* pControl = GetFormControl(); |
1049 ASSERT(pDoc != NULL); | 1050 ASSERT(pControl != NULL); |
1050 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1051 CPDF_FormField* pField = pControl->GetField(); |
1051 CBA_FontMap FontMap(this,pEnv->GetSysHandler()); | 1052 ASSERT(pField != NULL); |
1052 FontMap.Initial(); | 1053 |
1053 pEdit->SetFontMap(&FontMap); | 1054 CFX_ByteTextBuf sBody, sLines; |
1054 | 1055 |
1055 CPDF_Rect rcEdit = rcClient; | 1056 CPDF_Rect rcClient = GetClientRect(); |
1056 rcEdit.right = rcButton.left; | 1057 CPDF_Rect rcButton = rcClient; |
1057 rcEdit.Normalize(); | 1058 rcButton.left = rcButton.right - 13; |
1058 | 1059 rcButton.Normalize(); |
1059 pEdit->SetPlateRect(rcEdit); | 1060 |
1060 pEdit->SetAlignmentV(1); | 1061 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
1061 | 1062 pEdit->EnableRefresh(FALSE); |
1062 FX_FLOAT fFontSize = this->GetFontSize(); | 1063 |
1063 if (IsFloatZero(fFontSize)) | 1064 ASSERT(this->m_pInterForm != NULL); |
1064 pEdit->SetAutoFontSize(TRUE); | 1065 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1065 else | 1066 ASSERT(pDoc != NULL); |
1066 pEdit->SetFontSize(fFontSize); | 1067 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1067 | 1068 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
1068 pEdit->Initialize(); | 1069 FontMap.Initial(); |
1069 | 1070 pEdit->SetFontMap(&FontMap); |
1070 if (sValue) | 1071 |
1071 pEdit->SetText(sValue); | 1072 CPDF_Rect rcEdit = rcClient; |
1072 else | 1073 rcEdit.right = rcButton.left; |
1073 { | 1074 rcEdit.Normalize(); |
1074 FX_INT32 nCurSel = pField->GetSelectedIndex(0); | 1075 |
1075 | 1076 pEdit->SetPlateRect(rcEdit); |
1076 if (nCurSel < 0) | 1077 pEdit->SetAlignmentV(1); |
1077 pEdit->SetText((FX_LPCWSTR)pField->GetValue()); | 1078 |
1078 else | 1079 FX_FLOAT fFontSize = this->GetFontSize(); |
1079 pEdit->SetText((FX_LPCWSTR)pField->GetOptionLabe
l(nCurSel)); | 1080 if (IsFloatZero(fFontSize)) |
1080 } | 1081 pEdit->SetAutoFontSize(TRUE); |
1081 | 1082 else |
1082 CPDF_Rect rcContent = pEdit->GetContentRect(); | 1083 pEdit->SetFontSize(fFontSize); |
1083 | 1084 |
1084 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_P
oint(0.0f,0.0f)); | 1085 pEdit->Initialize(); |
1085 if (sEdit.GetLength() > 0) | 1086 |
1086 { | 1087 if (sValue) |
1087 sBody << "/Tx BMC\n" << "q\n"; | 1088 pEdit->SetText(sValue); |
1088 if (rcContent.Width() > rcEdit.Width() || | 1089 else { |
1089 rcContent.Height() > rcEdit.Height()) | 1090 FX_INT32 nCurSel = pField->GetSelectedIndex(0); |
1090 { | 1091 |
1091 sBody << rcEdit.left << " " << rcEdit.bottom <<
" " | 1092 if (nCurSel < 0) |
1092 << rcEdit.Width() << " " << rcEdit.Heigh
t() << " re\nW\nn\n"; | 1093 pEdit->SetText((FX_LPCWSTR)pField->GetValue()); |
1093 } | 1094 else |
1094 | 1095 pEdit->SetText((FX_LPCWSTR)pField->GetOptionLabel(nCurSel)); |
1095 CPWL_Color crText = GetTextPWLColor(); | 1096 } |
1096 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText)
<< sEdit << "ET\n" << "Q\nEMC\n"; | 1097 |
1097 } | 1098 CPDF_Rect rcContent = pEdit->GetContentRect(); |
1098 | 1099 |
1099 IFX_Edit::DelEdit(pEdit); | 1100 CFX_ByteString sEdit = |
1100 } | 1101 CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, 0.0f)); |
1101 | 1102 if (sEdit.GetLength() > 0) { |
1102 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); | 1103 sBody << "/Tx BMC\n" |
1103 | 1104 << "q\n"; |
1104 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + s
Lines.GetByteString() + sBody.GetByteString(); | 1105 if (rcContent.Width() > rcEdit.Width() || |
1105 | 1106 rcContent.Height() > rcEdit.Height()) { |
1106 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1107 sBody << rcEdit.left << " " << rcEdit.bottom << " " << rcEdit.Width() |
1107 } | 1108 << " " << rcEdit.Height() << " re\nW\nn\n"; |
1108 | 1109 } |
1109 void CPDFSDK_Widget::ResetAppearance_ListBox() | 1110 |
1110 { | 1111 CPWL_Color crText = GetTextPWLColor(); |
1111 CPDF_FormControl* pControl = GetFormControl(); | 1112 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit |
1112 ASSERT(pControl != NULL); | 1113 << "ET\n" |
1113 CPDF_FormField* pField = pControl->GetField(); | 1114 << "Q\nEMC\n"; |
1114 ASSERT(pField != NULL); | 1115 } |
1115 | 1116 |
1116 CPDF_Rect rcClient = GetClientRect(); | 1117 IFX_Edit::DelEdit(pEdit); |
1117 | 1118 } |
1118 CFX_ByteTextBuf sBody, sLines; | 1119 |
1119 | 1120 sBody << CPWL_Utils::GetDropButtonAppStream(rcButton); |
1120 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1121 |
1121 { | 1122 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
1122 pEdit->EnableRefresh(FALSE); | 1123 sLines.GetByteString() + sBody.GetByteString(); |
1123 | 1124 |
1124 // ASSERT(this->m_pBaseForm != NULL); | 1125 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
1125 ASSERT(this->m_pInterForm != NULL); | 1126 } |
1126 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1127 |
1127 ASSERT(pDoc != NULL); | 1128 void CPDFSDK_Widget::ResetAppearance_ListBox() { |
1128 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1129 CPDF_FormControl* pControl = GetFormControl(); |
1129 | 1130 ASSERT(pControl != NULL); |
1130 CBA_FontMap FontMap(this,pEnv->GetSysHandler()); | 1131 CPDF_FormField* pField = pControl->GetField(); |
1131 FontMap.Initial(); | 1132 ASSERT(pField != NULL); |
1132 pEdit->SetFontMap(&FontMap); | 1133 |
1133 | 1134 CPDF_Rect rcClient = GetClientRect(); |
1134 pEdit->SetPlateRect(CPDF_Rect(rcClient.left,0.0f,rcClient.right,
0.0f)); | 1135 |
1135 | 1136 CFX_ByteTextBuf sBody, sLines; |
1136 FX_FLOAT fFontSize = GetFontSize(); | 1137 |
1137 | 1138 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
1138 if (IsFloatZero(fFontSize)) | 1139 pEdit->EnableRefresh(FALSE); |
1139 pEdit->SetFontSize(12.0f); | 1140 |
1140 else | 1141 // ASSERT(this->m_pBaseForm != NULL); |
1141 pEdit->SetFontSize(fFontSize); | 1142 ASSERT(this->m_pInterForm != NULL); |
1142 | 1143 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1143 pEdit->Initialize(); | 1144 ASSERT(pDoc != NULL); |
1144 | 1145 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1145 CFX_ByteTextBuf sList; | 1146 |
1146 FX_FLOAT fy = rcClient.top; | 1147 CBA_FontMap FontMap(this, pEnv->GetSysHandler()); |
1147 | 1148 FontMap.Initial(); |
1148 FX_INT32 nTop = pField->GetTopVisibleIndex(); | 1149 pEdit->SetFontMap(&FontMap); |
1149 FX_INT32 nCount = pField->CountOptions(); | 1150 |
1150 FX_INT32 nSelCount = pField->CountSelectedItems(); | 1151 pEdit->SetPlateRect(CPDF_Rect(rcClient.left, 0.0f, rcClient.right, 0.0f)); |
1151 | 1152 |
1152 for (FX_INT32 i=nTop; i<nCount; i++) | 1153 FX_FLOAT fFontSize = GetFontSize(); |
1153 { | 1154 |
1154 FX_BOOL bSelected = FALSE; | 1155 if (IsFloatZero(fFontSize)) |
1155 for (FX_INT32 j=0; j<nSelCount; j++) | 1156 pEdit->SetFontSize(12.0f); |
1156 { | 1157 else |
1157 if (pField->GetSelectedIndex(j) == i) | 1158 pEdit->SetFontSize(fFontSize); |
1158 { | 1159 |
1159 bSelected = TRUE; | 1160 pEdit->Initialize(); |
1160 break; | 1161 |
1161 } | 1162 CFX_ByteTextBuf sList; |
1162 } | 1163 FX_FLOAT fy = rcClient.top; |
1163 | 1164 |
1164 pEdit->SetText((FX_LPCWSTR)pField->GetOptionLabel(i)); | 1165 FX_INT32 nTop = pField->GetTopVisibleIndex(); |
1165 | 1166 FX_INT32 nCount = pField->CountOptions(); |
1166 CPDF_Rect rcContent = pEdit->GetContentRect(); | 1167 FX_INT32 nSelCount = pField->CountSelectedItems(); |
1167 FX_FLOAT fItemHeight = rcContent.Height(); | 1168 |
1168 | 1169 for (FX_INT32 i = nTop; i < nCount; i++) { |
1169 if (bSelected) | 1170 FX_BOOL bSelected = FALSE; |
1170 { | 1171 for (FX_INT32 j = 0; j < nSelCount; j++) { |
1171 CPDF_Rect rcItem = CPDF_Rect(rcClient.left,fy-fI
temHeight,rcClient.right,fy); | 1172 if (pField->GetSelectedIndex(j) == i) { |
1172 sList << "q\n" << CPWL_Utils::GetColorAppStream(
CPWL_Color(COLORTYPE_RGB,0,51.0f/255.0f,113.0f/255.0f),TRUE) | 1173 bSelected = TRUE; |
1173 << rcItem.left << " " << rcItem.bottom <
< " " << rcItem.Width() << " " << rcItem.Height() << " re f\n" << "Q\n"; | 1174 break; |
1174 | 1175 } |
1175 sList << "BT\n" << CPWL_Utils::GetColorAppStream
(CPWL_Color(COLORTYPE_GRAY,1),TRUE) << | 1176 } |
1176 CPWL_Utils::GetEditAppStream(pEdit,CPDF_
Point(0.0f,fy)) << "ET\n"; | 1177 |
1177 } | 1178 pEdit->SetText((FX_LPCWSTR)pField->GetOptionLabel(i)); |
1178 else | 1179 |
1179 { | 1180 CPDF_Rect rcContent = pEdit->GetContentRect(); |
1180 CPWL_Color crText = GetTextPWLColor(); | 1181 FX_FLOAT fItemHeight = rcContent.Height(); |
1181 sList << "BT\n" << CPWL_Utils::GetColorAppStream
(crText,TRUE) << | 1182 |
1182 CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.
0f,fy)) << "ET\n"; | 1183 if (bSelected) { |
1183 } | 1184 CPDF_Rect rcItem = |
1184 | 1185 CPDF_Rect(rcClient.left, fy - fItemHeight, rcClient.right, fy); |
1185 fy -= fItemHeight; | 1186 sList << "q\n" |
1186 } | 1187 << CPWL_Utils::GetColorAppStream( |
1187 | 1188 CPWL_Color( |
1188 if (sList.GetSize() > 0) | 1189 COLORTYPE_RGB, 0, 51.0f / 255.0f, 113.0f / 255.0f), |
1189 { | 1190 TRUE) << rcItem.left << " " << rcItem.bottom << " " |
1190 sBody << "/Tx BMC\n" << "q\n" << rcClient.left << " " <<
rcClient.bottom << " " | 1191 << rcItem.Width() << " " << rcItem.Height() << " re f\n" |
1191 << rcClient.Width() << " " << rcClient.H
eight() << " re\nW\nn\n"; | 1192 << "Q\n"; |
1192 sBody << sList << "Q\nEMC\n"; | 1193 |
1193 } | 1194 sList << "BT\n" << CPWL_Utils::GetColorAppStream( |
1194 | 1195 CPWL_Color(COLORTYPE_GRAY, 1), TRUE) |
1195 IFX_Edit::DelEdit(pEdit); | 1196 << CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, fy)) |
1196 } | 1197 << "ET\n"; |
1197 | 1198 } else { |
1198 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + s
Lines.GetByteString() + sBody.GetByteString(); | 1199 CPWL_Color crText = GetTextPWLColor(); |
1199 | 1200 sList << "BT\n" << CPWL_Utils::GetColorAppStream(crText, TRUE) |
1200 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1201 << CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f, fy)) |
1201 } | 1202 << "ET\n"; |
1202 | 1203 } |
1203 void CPDFSDK_Widget::ResetAppearance_TextField(FX_LPCWSTR sValue) | 1204 |
1204 { | 1205 fy -= fItemHeight; |
1205 CPDF_FormControl* pControl = GetFormControl(); | 1206 } |
1206 ASSERT(pControl != NULL); | 1207 |
1207 CPDF_FormField* pField = pControl->GetField(); | 1208 if (sList.GetSize() > 0) { |
1208 ASSERT(pField != NULL); | 1209 sBody << "/Tx BMC\n" |
1209 | 1210 << "q\n" << rcClient.left << " " << rcClient.bottom << " " |
1210 CFX_ByteTextBuf sBody, sLines; | 1211 << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; |
1211 | 1212 sBody << sList << "Q\nEMC\n"; |
1212 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1213 } |
1213 { | 1214 |
1214 pEdit->EnableRefresh(FALSE); | 1215 IFX_Edit::DelEdit(pEdit); |
1215 | 1216 } |
1216 // ASSERT(this->m_pBaseForm != NULL); | 1217 |
1217 ASSERT(this->m_pInterForm != NULL); | 1218 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
1218 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); | 1219 sLines.GetByteString() + sBody.GetByteString(); |
1219 ASSERT(pDoc != NULL); | 1220 |
1220 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); | 1221 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
1221 | 1222 } |
1222 CBA_FontMap FontMap(this,pEnv->GetSysHandler());//, ISystemHandl
e::GetSystemHandler(m_pBaseForm->GetEnv())); | 1223 |
1223 FontMap.Initial(); | 1224 void CPDFSDK_Widget::ResetAppearance_TextField(FX_LPCWSTR sValue) { |
1224 pEdit->SetFontMap(&FontMap); | 1225 CPDF_FormControl* pControl = GetFormControl(); |
1225 | 1226 ASSERT(pControl != NULL); |
1226 CPDF_Rect rcClient = GetClientRect(); | 1227 CPDF_FormField* pField = pControl->GetField(); |
1227 pEdit->SetPlateRect(rcClient); | 1228 ASSERT(pField != NULL); |
1228 pEdit->SetAlignmentH(pControl->GetControlAlignment()); | 1229 |
1229 | 1230 CFX_ByteTextBuf sBody, sLines; |
1230 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); | 1231 |
1231 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; | 1232 if (IFX_Edit* pEdit = IFX_Edit::NewEdit()) { |
1232 | 1233 pEdit->EnableRefresh(FALSE); |
1233 if (bMultiLine) | 1234 |
1234 { | 1235 // ASSERT(this->m_pBaseForm != NULL); |
1235 pEdit->SetMultiLine(TRUE); | 1236 ASSERT(this->m_pInterForm != NULL); |
1236 pEdit->SetAutoReturn(TRUE); | 1237 CPDFSDK_Document* pDoc = m_pInterForm->GetDocument(); |
1237 } | 1238 ASSERT(pDoc != NULL); |
1238 else | 1239 CPDFDoc_Environment* pEnv = pDoc->GetEnv(); |
1239 { | 1240 |
1240 pEdit->SetAlignmentV(1); | 1241 CBA_FontMap FontMap( |
1241 } | 1242 this, |
1242 | 1243 pEnv->GetSysHandler()); //, |
1243 FX_WORD subWord = 0; | 1244 //ISystemHandle::GetSystemHandler(m_pBaseForm->
GetEnv())); |
1244 if ((dwFieldFlags >> 13) & 1) | 1245 FontMap.Initial(); |
1245 { | 1246 pEdit->SetFontMap(&FontMap); |
1246 subWord = '*'; | 1247 |
1247 pEdit->SetPasswordChar(subWord); | 1248 CPDF_Rect rcClient = GetClientRect(); |
1248 } | 1249 pEdit->SetPlateRect(rcClient); |
1249 | 1250 pEdit->SetAlignmentH(pControl->GetControlAlignment()); |
1250 int nMaxLen = pField->GetMaxLen(); | 1251 |
1251 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; | 1252 FX_DWORD dwFieldFlags = pField->GetFieldFlags(); |
1252 FX_FLOAT fFontSize = GetFontSize(); | 1253 FX_BOOL bMultiLine = (dwFieldFlags >> 12) & 1; |
1253 | 1254 |
1254 if (nMaxLen > 0) | 1255 if (bMultiLine) { |
1255 { | 1256 pEdit->SetMultiLine(TRUE); |
1256 if (bCharArray) | 1257 pEdit->SetAutoReturn(TRUE); |
1257 { | 1258 } else { |
1258 pEdit->SetCharArray(nMaxLen); | 1259 pEdit->SetAlignmentV(1); |
1259 | 1260 } |
1260 if (IsFloatZero(fFontSize)) | 1261 |
1261 { | 1262 FX_WORD subWord = 0; |
1262 fFontSize = CPWL_Edit::GetCharArrayAutoF
ontSize(FontMap.GetPDFFont(0),rcClient,nMaxLen); | 1263 if ((dwFieldFlags >> 13) & 1) { |
1263 } | 1264 subWord = '*'; |
1264 } | 1265 pEdit->SetPasswordChar(subWord); |
1265 else | 1266 } |
1266 { | 1267 |
1267 if (sValue) | 1268 int nMaxLen = pField->GetMaxLen(); |
1268 nMaxLen = wcslen((const wchar_t*)sValue)
; | 1269 FX_BOOL bCharArray = (dwFieldFlags >> 24) & 1; |
1269 pEdit->SetLimitChar(nMaxLen); | 1270 FX_FLOAT fFontSize = GetFontSize(); |
1270 } | 1271 |
1271 } | 1272 if (nMaxLen > 0) { |
1272 | 1273 if (bCharArray) { |
1273 if (IsFloatZero(fFontSize)) | 1274 pEdit->SetCharArray(nMaxLen); |
1274 pEdit->SetAutoFontSize(TRUE); | 1275 |
1275 else | 1276 if (IsFloatZero(fFontSize)) { |
1276 pEdit->SetFontSize(fFontSize); | 1277 fFontSize = CPWL_Edit::GetCharArrayAutoFontSize( |
1277 | 1278 FontMap.GetPDFFont(0), rcClient, nMaxLen); |
1278 pEdit->Initialize(); | 1279 } |
1279 | 1280 } else { |
1280 if (sValue) | 1281 if (sValue) |
1281 pEdit->SetText(sValue); | 1282 nMaxLen = wcslen((const wchar_t*)sValue); |
1282 else | 1283 pEdit->SetLimitChar(nMaxLen); |
1283 pEdit->SetText((FX_LPCWSTR)pField->GetValue()); | 1284 } |
1284 | 1285 } |
1285 CPDF_Rect rcContent = pEdit->GetContentRect(); | 1286 |
1286 | 1287 if (IsFloatZero(fFontSize)) |
1287 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_P
oint(0.0f,0.0f), | 1288 pEdit->SetAutoFontSize(TRUE); |
1288
NULL,!bCharArray,subWord
); | 1289 else |
1289 | 1290 pEdit->SetFontSize(fFontSize); |
1290 if (sEdit.GetLength() > 0) | 1291 |
1291 { | 1292 pEdit->Initialize(); |
1292 sBody << "/Tx BMC\n" << "q\n"; | 1293 |
1293 if (rcContent.Width() > rcClient.Width() || | 1294 if (sValue) |
1294 rcContent.Height() > rcClient.Height()) | 1295 pEdit->SetText(sValue); |
1295 { | 1296 else |
1296 sBody << rcClient.left << " " << rcClient.bottom
<< " " | 1297 pEdit->SetText((FX_LPCWSTR)pField->GetValue()); |
1297 << rcClient.Width() << " " << rcClient.H
eight() << " re\nW\nn\n"; | 1298 |
1298 } | 1299 CPDF_Rect rcContent = pEdit->GetContentRect(); |
1299 CPWL_Color crText = GetTextPWLColor(); | 1300 |
1300 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText)
<< sEdit << "ET\n" << "Q\nEMC\n"; | 1301 CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream( |
1301 } | 1302 pEdit, CPDF_Point(0.0f, 0.0f), NULL, !bCharArray, subWord); |
1302 | 1303 |
1303 if (bCharArray) | 1304 if (sEdit.GetLength() > 0) { |
1304 { | 1305 sBody << "/Tx BMC\n" |
1305 switch (GetBorderStyle()) | 1306 << "q\n"; |
1306 { | 1307 if (rcContent.Width() > rcClient.Width() || |
1307 case BBS_SOLID: | 1308 rcContent.Height() > rcClient.Height()) { |
1308 { | 1309 sBody << rcClient.left << " " << rcClient.bottom << " " |
1309 CFX_ByteString sColor = CPWL_Utils::GetC
olorAppStream(GetBorderPWLColor(),FALSE); | 1310 << rcClient.Width() << " " << rcClient.Height() << " re\nW\nn\n"; |
1310 if (sColor.GetLength() > 0) | 1311 } |
1311 { | 1312 CPWL_Color crText = GetTextPWLColor(); |
1312 sLines << "q\n" << GetBorderWidt
h() << " w\n" | 1313 sBody << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit |
1313 << CPWL_Utils::GetColorA
ppStream(GetBorderPWLColor(),FALSE) << " 2 J 0 j\n";
| 1314 << "ET\n" |
1314 | 1315 << "Q\nEMC\n"; |
1315 for (FX_INT32 i=1;i<nMaxLen;i++) | 1316 } |
1316 { | 1317 |
1317 sLines << rcClient.left
+ ((rcClient.right - rcClient.left)/nMaxLen)*i << " " | 1318 if (bCharArray) { |
1318 << rcClient.bott
om << " m\n" | 1319 switch (GetBorderStyle()) { |
1319 << rcClient.left
+ ((rcClient.right - rcClient.left)/nMaxLen)*i << " " | 1320 case BBS_SOLID: { |
1320 << rcClient.top
<< " l S\n"; | 1321 CFX_ByteString sColor = |
1321 } | 1322 CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE); |
1322 | 1323 if (sColor.GetLength() > 0) { |
1323 sLines << "Q\n"; | 1324 sLines << "q\n" << GetBorderWidth() << " w\n" |
1324 } | 1325 << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE) |
1325 } | 1326 << " 2 J 0 j\n"; |
1326 break; | 1327 |
1327 case BBS_DASH: | 1328 for (FX_INT32 i = 1; i < nMaxLen; i++) { |
1328 { | 1329 sLines << rcClient.left + |
1329 CFX_ByteString sColor = CPWL_Utils::GetC
olorAppStream(GetBorderPWLColor(),FALSE); | 1330 ((rcClient.right - rcClient.left) / nMaxLen) * i |
1330 if (sColor.GetLength() > 0) | 1331 << " " << rcClient.bottom << " m\n" |
1331 { | 1332 << rcClient.left + |
1332 CPWL_Dash dsBorder = CPWL_Dash(3
, 3, 0); | 1333 ((rcClient.right - rcClient.left) / nMaxLen) * i |
1333 | 1334 << " " << rcClient.top << " l S\n"; |
1334 sLines << "q\n" << GetBorderWidt
h() << " w\n" | 1335 } |
1335 << CPWL_Utils::GetColorA
ppStream(GetBorderPWLColor(),FALSE) | 1336 |
1336 << "[" << dsBorder.nDash
<< " " | 1337 sLines << "Q\n"; |
1337 << dsBorder.nGap << "] "
| 1338 } |
1338 << dsBorder.nPhase << "
d\n"; | 1339 } break; |
1339 | 1340 case BBS_DASH: { |
1340 for (FX_INT32 i=1;i<nMaxLen;i++)
| 1341 CFX_ByteString sColor = |
1341 { | 1342 CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE); |
1342 sLines << rcClient.left
+ ((rcClient.right - rcClient.left)/nMaxLen)*i << " " | 1343 if (sColor.GetLength() > 0) { |
1343 << rcClient.bott
om << " m\n" | 1344 CPWL_Dash dsBorder = CPWL_Dash(3, 3, 0); |
1344 << rcClient.left
+ ((rcClient.right - rcClient.left)/nMaxLen)*i << " " | 1345 |
1345 << rcClient.top
<< " l S\n"; | 1346 sLines << "q\n" << GetBorderWidth() << " w\n" |
1346 } | 1347 << CPWL_Utils::GetColorAppStream(GetBorderPWLColor(), FALSE) |
1347 | 1348 << "[" << dsBorder.nDash << " " << dsBorder.nGap << "] " |
1348 sLines << "Q\n"; | 1349 << dsBorder.nPhase << " d\n"; |
1349 } | 1350 |
1350 } | 1351 for (FX_INT32 i = 1; i < nMaxLen; i++) { |
1351 break; | 1352 sLines << rcClient.left + |
1352 } | 1353 ((rcClient.right - rcClient.left) / nMaxLen) * i |
1353 } | 1354 << " " << rcClient.bottom << " m\n" |
1354 | 1355 << rcClient.left + |
1355 IFX_Edit::DelEdit(pEdit); | 1356 ((rcClient.right - rcClient.left) / nMaxLen) * i |
1356 } | 1357 << " " << rcClient.top << " l S\n"; |
1357 | 1358 } |
1358 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + s
Lines.GetByteString() + sBody.GetByteString(); | 1359 |
1359 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1360 sLines << "Q\n"; |
1360 } | 1361 } |
1361 | 1362 } break; |
1362 CPDF_Rect CPDFSDK_Widget::GetClientRect() const | 1363 } |
1363 { | 1364 } |
1364 CPDF_Rect rcWindow = GetRotatedRect(); | 1365 |
1365 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 1366 IFX_Edit::DelEdit(pEdit); |
1366 switch (GetBorderStyle()) | 1367 } |
1367 { | 1368 |
1368 case BBS_BEVELED: | 1369 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + |
1369 case BBS_INSET: | 1370 sLines.GetByteString() + sBody.GetByteString(); |
1370 fBorderWidth *= 2.0f; | 1371 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
1371 break; | 1372 } |
1372 } | 1373 |
1373 | 1374 CPDF_Rect CPDFSDK_Widget::GetClientRect() const { |
1374 return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); | 1375 CPDF_Rect rcWindow = GetRotatedRect(); |
1375 } | 1376 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
1376 | 1377 switch (GetBorderStyle()) { |
1377 CPDF_Rect CPDFSDK_Widget::GetRotatedRect() const | 1378 case BBS_BEVELED: |
1378 { | 1379 case BBS_INSET: |
1379 CPDF_Rect rectAnnot = GetRect(); | 1380 fBorderWidth *= 2.0f; |
1380 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; | 1381 break; |
1381 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; | 1382 } |
1382 | 1383 |
1383 CPDF_FormControl* pControl = GetFormControl(); | 1384 return CPWL_Utils::DeflateRect(rcWindow, fBorderWidth); |
1384 ASSERT(pControl != NULL); | 1385 } |
1385 | 1386 |
1386 CPDF_Rect rcPDFWindow; | 1387 CPDF_Rect CPDFSDK_Widget::GetRotatedRect() const { |
1387 switch(abs(pControl->GetRotation() % 360)) | 1388 CPDF_Rect rectAnnot = GetRect(); |
1388 { | 1389 FX_FLOAT fWidth = rectAnnot.right - rectAnnot.left; |
1389 case 0: | 1390 FX_FLOAT fHeight = rectAnnot.top - rectAnnot.bottom; |
1390 case 180: | 1391 |
1391 default: | 1392 CPDF_FormControl* pControl = GetFormControl(); |
1392 rcPDFWindow = CPDF_Rect(0, 0, fWidth, fHeight); | 1393 ASSERT(pControl != NULL); |
1393 break; | 1394 |
1394 case 90: | 1395 CPDF_Rect rcPDFWindow; |
1395 case 270: | 1396 switch (abs(pControl->GetRotation() % 360)) { |
1396 rcPDFWindow = CPDF_Rect(0, 0, fHeight, fWidth); | 1397 case 0: |
1397 break; | 1398 case 180: |
1398 } | 1399 default: |
1399 | 1400 rcPDFWindow = CPDF_Rect(0, 0, fWidth, fHeight); |
1400 return rcPDFWindow; | 1401 break; |
1401 } | 1402 case 90: |
1402 | 1403 case 270: |
1403 CFX_ByteString CPDFSDK_Widget::GetBackgroundAppStream() const | 1404 rcPDFWindow = CPDF_Rect(0, 0, fHeight, fWidth); |
1404 { | 1405 break; |
1405 CPWL_Color crBackground = GetFillPWLColor(); | 1406 } |
1406 if (crBackground.nColorType != COLORTYPE_TRANSPARENT) | 1407 |
1407 return CPWL_Utils::GetRectFillAppStream(GetRotatedRect(), crBack
ground); | 1408 return rcPDFWindow; |
1408 else | 1409 } |
1409 return ""; | 1410 |
1410 } | 1411 CFX_ByteString CPDFSDK_Widget::GetBackgroundAppStream() const { |
1411 | 1412 CPWL_Color crBackground = GetFillPWLColor(); |
1412 CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const | 1413 if (crBackground.nColorType != COLORTYPE_TRANSPARENT) |
1413 { | 1414 return CPWL_Utils::GetRectFillAppStream(GetRotatedRect(), crBackground); |
1414 CPDF_Rect rcWindow = GetRotatedRect(); | 1415 else |
1415 CPWL_Color crBorder = GetBorderPWLColor(); | 1416 return ""; |
1416 CPWL_Color crBackground = GetFillPWLColor(); | 1417 } |
1417 CPWL_Color crLeftTop, crRightBottom; | 1418 |
1418 | 1419 CFX_ByteString CPDFSDK_Widget::GetBorderAppStream() const { |
1419 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); | 1420 CPDF_Rect rcWindow = GetRotatedRect(); |
1420 FX_INT32 nBorderStyle = 0; | 1421 CPWL_Color crBorder = GetBorderPWLColor(); |
1421 CPWL_Dash dsBorder(3,0,0); | 1422 CPWL_Color crBackground = GetFillPWLColor(); |
1422 | 1423 CPWL_Color crLeftTop, crRightBottom; |
1423 switch (GetBorderStyle()) | 1424 |
1424 { | 1425 FX_FLOAT fBorderWidth = (FX_FLOAT)GetBorderWidth(); |
1425 case BBS_DASH: | 1426 FX_INT32 nBorderStyle = 0; |
1426 nBorderStyle = PBS_DASH; | 1427 CPWL_Dash dsBorder(3, 0, 0); |
1427 dsBorder = CPWL_Dash(3, 3, 0); | 1428 |
1428 break; | 1429 switch (GetBorderStyle()) { |
1429 case BBS_BEVELED: | 1430 case BBS_DASH: |
1430 nBorderStyle = PBS_BEVELED; | 1431 nBorderStyle = PBS_DASH; |
1431 fBorderWidth *= 2; | 1432 dsBorder = CPWL_Dash(3, 3, 0); |
1432 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); | 1433 break; |
1433 crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); | 1434 case BBS_BEVELED: |
1434 break; | 1435 nBorderStyle = PBS_BEVELED; |
1435 case BBS_INSET: | 1436 fBorderWidth *= 2; |
1436 nBorderStyle = PBS_INSET; | 1437 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 1); |
1437 fBorderWidth *= 2; | 1438 crRightBottom = CPWL_Utils::DevideColor(crBackground, 2); |
1438 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); | 1439 break; |
1439 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); | 1440 case BBS_INSET: |
1440 break; | 1441 nBorderStyle = PBS_INSET; |
1441 case BBS_UNDERLINE: | 1442 fBorderWidth *= 2; |
1442 nBorderStyle = PBS_UNDERLINED; | 1443 crLeftTop = CPWL_Color(COLORTYPE_GRAY, 0.5); |
1443 break; | 1444 crRightBottom = CPWL_Color(COLORTYPE_GRAY, 0.75); |
1444 default: | 1445 break; |
1445 nBorderStyle = PBS_SOLID; | 1446 case BBS_UNDERLINE: |
1446 break; | 1447 nBorderStyle = PBS_UNDERLINED; |
1447 } | 1448 break; |
1448 | 1449 default: |
1449 return CPWL_Utils::GetBorderAppStream(rcWindow, fBorderWidth, crBorder,
crLeftTop, | 1450 nBorderStyle = PBS_SOLID; |
1450 crRightBottom, nBorderStyle, dsBorder); | 1451 break; |
1451 } | 1452 } |
1452 | 1453 |
1453 CPDF_Matrix CPDFSDK_Widget::GetMatrix() const | 1454 return CPWL_Utils::GetBorderAppStream(rcWindow, |
1454 { | 1455 fBorderWidth, |
1455 CPDF_Matrix mt; | 1456 crBorder, |
1456 CPDF_FormControl* pControl = GetFormControl(); | 1457 crLeftTop, |
1457 ASSERT(pControl != NULL); | 1458 crRightBottom, |
1458 | 1459 nBorderStyle, |
1459 CPDF_Rect rcAnnot = GetRect(); | 1460 dsBorder); |
1460 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; | 1461 } |
1461 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; | 1462 |
1462 | 1463 CPDF_Matrix CPDFSDK_Widget::GetMatrix() const { |
1463 | 1464 CPDF_Matrix mt; |
1464 | 1465 CPDF_FormControl* pControl = GetFormControl(); |
1465 switch (abs(pControl->GetRotation() % 360)) | 1466 ASSERT(pControl != NULL); |
1466 { | 1467 |
1467 case 0: | 1468 CPDF_Rect rcAnnot = GetRect(); |
1468 default: | 1469 FX_FLOAT fWidth = rcAnnot.right - rcAnnot.left; |
1469 mt = CPDF_Matrix(1, 0, 0, 1, 0, 0); | 1470 FX_FLOAT fHeight = rcAnnot.top - rcAnnot.bottom; |
1470 break; | 1471 |
1471 case 90: | 1472 switch (abs(pControl->GetRotation() % 360)) { |
1472 mt = CPDF_Matrix(0, 1, -1, 0, fWidth, 0); | 1473 case 0: |
1473 break; | 1474 default: |
1474 case 180: | 1475 mt = CPDF_Matrix(1, 0, 0, 1, 0, 0); |
1475 mt = CPDF_Matrix(-1, 0, 0, -1, fWidth, fHeight); | 1476 break; |
1476 break; | 1477 case 90: |
1477 case 270: | 1478 mt = CPDF_Matrix(0, 1, -1, 0, fWidth, 0); |
1478 mt = CPDF_Matrix(0, -1, 1, 0, 0, fHeight); | 1479 break; |
1479 break; | 1480 case 180: |
1480 } | 1481 mt = CPDF_Matrix(-1, 0, 0, -1, fWidth, fHeight); |
1481 | 1482 break; |
1482 return mt; | 1483 case 270: |
1483 } | 1484 mt = CPDF_Matrix(0, -1, 1, 0, 0, fHeight); |
1484 | 1485 break; |
1485 CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const | 1486 } |
1486 { | 1487 |
1487 CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0); | 1488 return mt; |
1488 | 1489 } |
1489 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1490 |
1490 ASSERT(pFormCtrl != NULL); | 1491 CPWL_Color CPDFSDK_Widget::GetTextPWLColor() const { |
1491 | 1492 CPWL_Color crText = CPWL_Color(COLORTYPE_GRAY, 0); |
1492 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); | 1493 |
1493 if (da.HasColor()) | 1494 CPDF_FormControl* pFormCtrl = GetFormControl(); |
1494 { | 1495 ASSERT(pFormCtrl != NULL); |
1495 FX_INT32 iColorType; | 1496 |
1496 FX_FLOAT fc[4]; | 1497 CPDF_DefaultAppearance da = pFormCtrl->GetDefaultAppearance(); |
1497 da.GetColor(iColorType, fc); | 1498 if (da.HasColor()) { |
1498 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1499 FX_INT32 iColorType; |
1499 } | 1500 FX_FLOAT fc[4]; |
1500 | 1501 da.GetColor(iColorType, fc); |
1501 return crText; | 1502 crText = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1502 } | 1503 } |
1503 | 1504 |
1504 CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const | 1505 return crText; |
1505 { | 1506 } |
1506 CPWL_Color crBorder; | 1507 |
1507 | 1508 CPWL_Color CPDFSDK_Widget::GetBorderPWLColor() const { |
1508 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1509 CPWL_Color crBorder; |
1509 ASSERT(pFormCtrl != NULL); | 1510 |
1510 | 1511 CPDF_FormControl* pFormCtrl = GetFormControl(); |
1511 FX_INT32 iColorType; | 1512 ASSERT(pFormCtrl != NULL); |
1512 FX_FLOAT fc[4]; | 1513 |
1513 pFormCtrl->GetOriginalBorderColor(iColorType, fc); | 1514 FX_INT32 iColorType; |
1514 if (iColorType > 0) | 1515 FX_FLOAT fc[4]; |
1515 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1516 pFormCtrl->GetOriginalBorderColor(iColorType, fc); |
1516 | 1517 if (iColorType > 0) |
1517 return crBorder; | 1518 crBorder = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1518 } | 1519 |
1519 | 1520 return crBorder; |
1520 CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const | 1521 } |
1521 { | 1522 |
1522 CPWL_Color crFill; | 1523 CPWL_Color CPDFSDK_Widget::GetFillPWLColor() const { |
1523 | 1524 CPWL_Color crFill; |
1524 CPDF_FormControl* pFormCtrl = GetFormControl(); | 1525 |
1525 ASSERT(pFormCtrl != NULL); | 1526 CPDF_FormControl* pFormCtrl = GetFormControl(); |
1526 | 1527 ASSERT(pFormCtrl != NULL); |
1527 FX_INT32 iColorType; | 1528 |
1528 FX_FLOAT fc[4]; | 1529 FX_INT32 iColorType; |
1529 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); | 1530 FX_FLOAT fc[4]; |
1530 if (iColorType > 0) | 1531 pFormCtrl->GetOriginalBackgroundColor(iColorType, fc); |
1531 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); | 1532 if (iColorType > 0) |
1532 | 1533 crFill = CPWL_Color(iColorType, fc[0], fc[1], fc[2], fc[3]); |
1533 return crFill; | 1534 |
1534 } | 1535 return crFill; |
1535 | 1536 } |
1536 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, CPDF_St
ream* pImage) | 1537 |
1537 { | 1538 void CPDFSDK_Widget::AddImageToAppearance(const CFX_ByteString& sAPType, |
1538 ASSERT(pImage != NULL); | 1539 CPDF_Stream* pImage) { |
1539 | 1540 ASSERT(pImage != NULL); |
1540 ASSERT(m_pAnnot != NULL); | 1541 |
1541 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 1542 ASSERT(m_pAnnot != NULL); |
1542 | 1543 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
1543 CPDF_Document* pDoc = m_pPageView->GetPDFDocument();//pDocument->GetDocu
ment(); | 1544 |
1544 ASSERT(pDoc != NULL); | 1545 CPDF_Document* pDoc = |
1545 | 1546 m_pPageView->GetPDFDocument(); // pDocument->GetDocument(); |
1546 CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP"); | 1547 ASSERT(pDoc != NULL); |
1547 ASSERT(pAPDict != NULL); | 1548 |
1548 | 1549 CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP"); |
1549 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); | 1550 ASSERT(pAPDict != NULL); |
1550 ASSERT(pStream != NULL); | 1551 |
1551 | 1552 CPDF_Stream* pStream = pAPDict->GetStream(sAPType); |
1552 CPDF_Dictionary* pStreamDict = pStream->GetDict(); | 1553 ASSERT(pStream != NULL); |
1553 ASSERT(pStreamDict != NULL); | 1554 |
1554 | 1555 CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
1555 CFX_ByteString sImageAlias = "IMG"; | 1556 ASSERT(pStreamDict != NULL); |
1556 | 1557 |
1557 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) | 1558 CFX_ByteString sImageAlias = "IMG"; |
1558 { | 1559 |
1559 sImageAlias = pImageDict->GetString("Name"); | 1560 if (CPDF_Dictionary* pImageDict = pImage->GetDict()) { |
1560 if (sImageAlias.IsEmpty()) | 1561 sImageAlias = pImageDict->GetString("Name"); |
1561 sImageAlias = "IMG"; | 1562 if (sImageAlias.IsEmpty()) |
1562 } | 1563 sImageAlias = "IMG"; |
1563 | 1564 } |
1564 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); | 1565 |
1565 if (!pStreamResList) | 1566 CPDF_Dictionary* pStreamResList = pStreamDict->GetDict("Resources"); |
1566 { | 1567 if (!pStreamResList) { |
1567 pStreamResList = FX_NEW CPDF_Dictionary(); | 1568 pStreamResList = FX_NEW CPDF_Dictionary(); |
1568 pStreamDict->SetAt("Resources", pStreamResList); | 1569 pStreamDict->SetAt("Resources", pStreamResList); |
1569 } | 1570 } |
1570 | 1571 |
1571 if (pStreamResList) | 1572 if (pStreamResList) { |
1572 { | 1573 CPDF_Dictionary* pXObject = FX_NEW CPDF_Dictionary; |
1573 CPDF_Dictionary* pXObject = FX_NEW CPDF_Dictionary;
| 1574 pXObject->SetAtReference(sImageAlias, pDoc, pImage); |
1574 pXObject->SetAtReference(sImageAlias, pDoc, pImage); | 1575 pStreamResList->SetAt("XObject", pXObject); |
1575 pStreamResList->SetAt("XObject", pXObject); | 1576 } |
1576 } | 1577 } |
1577 } | 1578 |
1578 | 1579 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) { |
1579 void CPDFSDK_Widget::RemoveAppearance(const CFX_ByteString& sAPType) | 1580 ASSERT(m_pAnnot != NULL); |
1580 { | 1581 ASSERT(m_pAnnot->m_pAnnotDict != NULL); |
1581 ASSERT(m_pAnnot != NULL); | 1582 |
1582 ASSERT(m_pAnnot->m_pAnnotDict != NULL); | 1583 if (CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP")) { |
1583 | 1584 pAPDict->RemoveAt(sAPType); |
1584 if (CPDF_Dictionary* pAPDict = m_pAnnot->m_pAnnotDict->GetDict("AP")) | 1585 } |
1585 { | 1586 } |
1586 pAPDict->RemoveAt(sAPType); | 1587 |
1587 } | 1588 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, |
1588 } | 1589 PDFSDK_FieldAction& data, |
1589 | 1590 CPDFSDK_PageView* pPageView) { |
1590 FX_BOOL CPDFSDK_Widget::OnAAction(CPDF_AAction::AActionType type, PDFSDK_FieldAc
tion& data, CPDFSDK_PageView* pPageView) | 1591 CPDF_Action action = GetAAction(type); |
1591 { | 1592 |
1592 CPDF_Action action = GetAAction(type); | 1593 if (action && action.GetType() != CPDF_Action::Unknown) { |
1593 | 1594 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); |
1594 if (action && action.GetType() != CPDF_Action::Unknown) | 1595 ASSERT(pDocument != NULL); |
1595 { | 1596 |
1596 CPDFSDK_Document* pDocument = pPageView->GetSDKDocument(); | 1597 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); |
1597 ASSERT(pDocument != NULL); | 1598 ASSERT(pEnv != NULL); |
1598 | 1599 |
1599 CPDFDoc_Environment* pEnv = pDocument->GetEnv(); | 1600 CPDFSDK_ActionHandler* pActionHandler = |
1600 ASSERT(pEnv != NULL); | 1601 pEnv->GetActionHander(); /*(CPDFSDK_ActionHandler*)pApp->GetActionHandle
r();*/ |
1601 | 1602 ASSERT(pActionHandler != NULL); |
1602 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander();
/*(CPDFSDK_ActionHandler*)pApp->GetActionHandler();*/ | 1603 |
1603 ASSERT(pActionHandler != NULL); | 1604 return pActionHandler->DoAction_Field( |
1604 | 1605 action, type, pDocument, GetFormField(), data); |
1605 return pActionHandler->DoAction_Field(action, type, pDocument, G
etFormField(), data); | 1606 } |
1606 } | 1607 |
1607 | 1608 return FALSE; |
1608 return FALSE; | 1609 } |
1609 } | 1610 |
1610 | 1611 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) { |
1611 CPDF_Action CPDFSDK_Widget::GetAAction(CPDF_AAction::AActionType eAAT) | 1612 switch (eAAT) { |
1612 { | 1613 case CPDF_AAction::CursorEnter: |
1613 switch (eAAT) | 1614 case CPDF_AAction::CursorExit: |
1614 { | 1615 case CPDF_AAction::ButtonDown: |
1615 case CPDF_AAction::CursorEnter: | 1616 case CPDF_AAction::ButtonUp: |
1616 case CPDF_AAction::CursorExit: | 1617 case CPDF_AAction::GetFocus: |
1617 case CPDF_AAction::ButtonDown: | 1618 case CPDF_AAction::LoseFocus: |
1618 case CPDF_AAction::ButtonUp: | 1619 case CPDF_AAction::PageOpen: |
1619 case CPDF_AAction::GetFocus: | 1620 case CPDF_AAction::PageClose: |
1620 case CPDF_AAction::LoseFocus: | 1621 case CPDF_AAction::PageVisible: |
1621 case CPDF_AAction::PageOpen: | 1622 case CPDF_AAction::PageInvisible: |
1622 case CPDF_AAction::PageClose: | 1623 return CPDFSDK_Annot::GetAAction(eAAT); |
1623 case CPDF_AAction::PageVisible: | 1624 case CPDF_AAction::KeyStroke: |
1624 case CPDF_AAction::PageInvisible: | 1625 case CPDF_AAction::Format: |
1625 return CPDFSDK_Annot::GetAAction(eAAT); | 1626 case CPDF_AAction::Validate: |
1626 case CPDF_AAction::KeyStroke: | 1627 case CPDF_AAction::Calculate: { |
1627 case CPDF_AAction::Format: | 1628 CPDF_FormField* pField = this->GetFormField(); |
1628 case CPDF_AAction::Validate: | 1629 ASSERT(pField != NULL); |
1629 case CPDF_AAction::Calculate: | 1630 |
1630 { | 1631 if (CPDF_AAction aa = pField->GetAdditionalAction()) |
1631 CPDF_FormField* pField = this->GetFormField(); | 1632 return aa.GetAction(eAAT); |
1632 ASSERT(pField != NULL); | 1633 else |
1633 | 1634 return CPDFSDK_Annot::GetAAction(eAAT); |
1634 if (CPDF_AAction aa = pField->GetAdditionalAction()) | 1635 } |
1635 return aa.GetAction(eAAT); | 1636 default: |
1636 else | 1637 return NULL; |
1637 return CPDFSDK_Annot::GetAAction(eAAT); | 1638 } |
1638 } | 1639 |
1639 default: | 1640 return NULL; |
1640 return NULL; | 1641 } |
1641 } | 1642 |
1642 | 1643 CFX_WideString CPDFSDK_Widget::GetAlternateName() const { |
1643 return NULL; | 1644 CPDF_FormField* pFormField = GetFormField(); |
1644 } | 1645 ASSERT(pFormField != NULL); |
1645 | 1646 |
1646 | 1647 return pFormField->GetAlternateName(); |
1647 CFX_WideString CPDFSDK_Widget::GetAlternateName() const | 1648 } |
1648 { | 1649 |
1649 CPDF_FormField* pFormField = GetFormField(); | 1650 FX_INT32 CPDFSDK_Widget::GetAppearanceAge() const { |
1650 ASSERT(pFormField != NULL); | 1651 return m_nAppAge; |
1651 | 1652 } |
1652 return pFormField->GetAlternateName(); | 1653 |
1653 } | 1654 FX_INT32 CPDFSDK_Widget::GetValueAge() const { |
1654 | 1655 return m_nValueAge; |
1655 FX_INT32 CPDFSDK_Widget::GetAppearanceAge() const | 1656 } |
1656 { | 1657 |
1657 return m_nAppAge; | 1658 FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) { |
1658 } | 1659 CPDF_Annot* pAnnot = GetPDFAnnot(); |
1659 | 1660 CFX_FloatRect annotRect; |
1660 FX_INT32 CPDFSDK_Widget::GetValueAge() const | 1661 pAnnot->GetRect(annotRect); |
1661 { | 1662 if (annotRect.Contains(pageX, pageY)) { |
1662 return m_nValueAge; | 1663 if (!IsVisible()) |
1663 } | 1664 return FALSE; |
1664 | 1665 |
1665 | 1666 int nFieldFlags = GetFieldFlags(); |
1666 FX_BOOL CPDFSDK_Widget::HitTest(FX_FLOAT pageX, FX_FLOAT pageY) | 1667 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) |
1667 { | 1668 return FALSE; |
1668 CPDF_Annot* pAnnot = GetPDFAnnot(); | 1669 |
1669 CFX_FloatRect annotRect; | 1670 return TRUE; |
1670 pAnnot->GetRect(annotRect); | 1671 } |
1671 if(annotRect.Contains(pageX, pageY)) | 1672 return FALSE; |
1672 { | |
1673 if (!IsVisible()) return FALSE; | |
1674 | |
1675 int nFieldFlags = GetFieldFlags(); | |
1676 if ((nFieldFlags & FIELDFLAG_READONLY) == FIELDFLAG_READONLY) | |
1677 return FALSE; | |
1678 | |
1679 return TRUE; | |
1680 } | |
1681 return FALSE; | |
1682 } | 1673 } |
1683 | 1674 |
1684 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) | 1675 CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_Document* pDocument) |
1685 » :m_pDocument(pDocument), | 1676 : m_pDocument(pDocument), |
1686 » m_pInterForm(NULL), | 1677 m_pInterForm(NULL), |
1687 » m_bCalculate(TRUE), | 1678 m_bCalculate(TRUE), |
1688 » m_bBusy(FALSE) | 1679 m_bBusy(FALSE) { |
1689 { | 1680 ASSERT(m_pDocument != NULL); |
1690 » ASSERT(m_pDocument != NULL); | 1681 m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), FALSE); |
1691 » m_pInterForm = new CPDF_InterForm(m_pDocument->GetDocument(), FALSE); | 1682 ASSERT(m_pInterForm != NULL); |
1692 » ASSERT(m_pInterForm != NULL); | 1683 m_pInterForm->SetFormNotify(this); |
1693 » m_pInterForm->SetFormNotify(this); | 1684 |
1694 | 1685 for (int i = 0; i < 6; i++) |
1695 » for(int i=0; i<6; i++) | 1686 m_bNeedHightlight[i] = FALSE; |
1696 » » m_bNeedHightlight[i] = FALSE; | 1687 m_iHighlightAlpha = 0; |
1697 » m_iHighlightAlpha = 0; | 1688 } |
1698 } | 1689 |
1699 | 1690 CPDFSDK_InterForm::~CPDFSDK_InterForm() { |
1700 CPDFSDK_InterForm::~CPDFSDK_InterForm() | 1691 ASSERT(m_pInterForm != NULL); |
1701 { | 1692 delete m_pInterForm; |
1702 » ASSERT(m_pInterForm != NULL); | 1693 m_pInterForm = NULL; |
1703 » delete m_pInterForm; | 1694 |
1704 » m_pInterForm = NULL; | 1695 m_Map.RemoveAll(); |
1705 | 1696 } |
1706 » m_Map.RemoveAll(); | 1697 |
1707 } | 1698 void CPDFSDK_InterForm::Destroy() { |
1708 | 1699 delete this; |
1709 void CPDFSDK_InterForm::Destroy() | 1700 } |
1710 { | 1701 |
1711 » delete this; | 1702 CPDF_InterForm* CPDFSDK_InterForm::GetInterForm() { |
1712 } | 1703 return m_pInterForm; |
1713 | 1704 } |
1714 CPDF_InterForm* CPDFSDK_InterForm::GetInterForm() | 1705 |
1715 { | 1706 CPDFSDK_Document* CPDFSDK_InterForm::GetDocument() { |
1716 » return m_pInterForm; | 1707 return m_pDocument; |
1717 } | 1708 } |
1718 | 1709 |
1719 CPDFSDK_Document* CPDFSDK_InterForm::GetDocument() | 1710 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() { |
1720 { | 1711 return FALSE; |
1721 » return m_pDocument; | 1712 } |
1722 } | 1713 |
1723 | 1714 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, |
1724 FX_BOOL CPDFSDK_InterForm::HighlightWidgets() | 1715 FX_BOOL bNext) const { |
1725 { | 1716 ASSERT(pWidget != NULL); |
1726 » return FALSE; | 1717 |
1727 } | 1718 CBA_AnnotIterator* pIterator = |
1728 | 1719 new CBA_AnnotIterator(pWidget->GetPageView(), "Widget", ""); |
1729 CPDFSDK_Widget* CPDFSDK_InterForm::GetSibling(CPDFSDK_Widget* pWidget, FX_BOOL b
Next) const | 1720 ASSERT(pIterator != NULL); |
1730 { | 1721 |
1731 » ASSERT(pWidget != NULL); | 1722 CPDFSDK_Widget* pRet = NULL; |
1732 | 1723 |
1733 » CBA_AnnotIterator* pIterator = new CBA_AnnotIterator(pWidget->GetPageVie
w(), "Widget", ""); | 1724 if (bNext) |
1734 » ASSERT(pIterator != NULL); | 1725 pRet = (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget); |
1735 | 1726 else |
1736 » CPDFSDK_Widget* pRet = NULL; | 1727 pRet = (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget); |
1737 | 1728 |
1738 » if (bNext) | 1729 pIterator->Release(); |
1739 » » pRet = (CPDFSDK_Widget*)pIterator->GetNextAnnot(pWidget); | 1730 |
1740 » else | 1731 return pRet; |
1741 » » pRet = (CPDFSDK_Widget*)pIterator->GetPrevAnnot(pWidget); | 1732 } |
1742 | 1733 |
1743 » pIterator->Release(); | 1734 CPDFSDK_Widget* CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const { |
1744 » | 1735 if (!pControl || !m_pInterForm) |
1745 » return pRet; | 1736 return NULL; |
1746 | 1737 |
1747 } | 1738 CPDFSDK_Widget* pWidget = NULL; |
1748 | 1739 m_Map.Lookup(pControl, pWidget); |
1749 CPDFSDK_Widget*»CPDFSDK_InterForm::GetWidget(CPDF_FormControl* pControl) const | 1740 |
1750 { | 1741 if (pWidget) |
1751 » if(!pControl || !m_pInterForm) return NULL; | 1742 return pWidget; |
1752 » | 1743 |
1753 » CPDFSDK_Widget* pWidget = NULL; | 1744 CPDF_Dictionary* pControlDict = pControl->GetWidget(); |
1754 » m_Map.Lookup(pControl, pWidget); | 1745 ASSERT(pControlDict != NULL); |
1755 | 1746 |
1756 » if (pWidget) return pWidget; | 1747 ASSERT(m_pDocument != NULL); |
1757 | 1748 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1758 » CPDF_Dictionary* pControlDict = pControl->GetWidget(); | 1749 |
1759 » ASSERT(pControlDict != NULL); | 1750 CPDFSDK_PageView* pPage = NULL; |
1760 | 1751 |
1761 » ASSERT(m_pDocument != NULL); | 1752 if (CPDF_Dictionary* pPageDict = pControlDict->GetDict("P")) { |
1762 » CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1753 int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum()); |
1763 | 1754 if (nPageIndex >= 0) { |
1764 » CPDFSDK_PageView* pPage = NULL; | 1755 pPage = m_pDocument->GetPageView(nPageIndex); |
1765 | 1756 } |
1766 » if (CPDF_Dictionary* pPageDict = pControlDict->GetDict("P")) | 1757 } |
1767 » { | 1758 |
1768 » » int nPageIndex = pDocument->GetPageIndex(pPageDict->GetObjNum())
; | 1759 if (!pPage) { |
1769 » » if (nPageIndex >= 0) | 1760 int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict); |
1770 » » { | 1761 if (nPageIndex >= 0) { |
1771 » » » pPage = m_pDocument->GetPageView(nPageIndex); | 1762 pPage = m_pDocument->GetPageView(nPageIndex); |
1772 » » } | 1763 } |
1773 » } | 1764 } |
1774 | 1765 |
1775 » if (!pPage) | 1766 if (pPage) |
1776 » { | 1767 return (CPDFSDK_Widget*)pPage->GetAnnotByDict(pControlDict); |
1777 » » int nPageIndex = GetPageIndexByAnnotDict(pDocument, pControlDict
); | 1768 |
1778 » » if (nPageIndex >= 0) | 1769 return NULL; |
1779 » » { | 1770 } |
1780 » » » pPage = m_pDocument->GetPageView(nPageIndex); | 1771 |
1781 » » } | 1772 void CPDFSDK_InterForm::GetWidgets(const CFX_WideString& sFieldName, |
1782 » } | 1773 CFX_PtrArray& widgets) { |
1783 | 1774 ASSERT(m_pInterForm != NULL); |
1784 » if (pPage) | 1775 |
1785 » » return (CPDFSDK_Widget*)pPage->GetAnnotByDict(pControlDict); | 1776 for (int i = 0, sz = m_pInterForm->CountFields(sFieldName); i < sz; i++) { |
1786 | 1777 CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldName); |
1787 » return NULL; | 1778 ASSERT(pFormField != NULL); |
1788 } | 1779 |
1789 | 1780 GetWidgets(pFormField, widgets); |
1790 void CPDFSDK_InterForm::GetWidgets(const CFX_WideString& sFieldName, CFX_PtrArra
y& widgets) | 1781 } |
1791 { | 1782 } |
1792 » ASSERT(m_pInterForm != NULL); | 1783 |
1793 | 1784 void CPDFSDK_InterForm::GetWidgets(CPDF_FormField* pField, |
1794 » for (int i=0,sz=m_pInterForm->CountFields(sFieldName); i<sz; i++) | 1785 CFX_PtrArray& widgets) { |
1795 » { | 1786 ASSERT(pField != NULL); |
1796 » » CPDF_FormField* pFormField = m_pInterForm->GetField(i, sFieldNam
e); | 1787 |
1797 » » ASSERT(pFormField != NULL); | 1788 for (int i = 0, isz = pField->CountControls(); i < isz; i++) { |
1798 | 1789 CPDF_FormControl* pFormCtrl = pField->GetControl(i); |
1799 » » GetWidgets(pFormField, widgets);» | 1790 ASSERT(pFormCtrl != NULL); |
1800 » } | 1791 |
1801 } | 1792 CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); |
1802 | 1793 |
1803 void CPDFSDK_InterForm::GetWidgets(CPDF_FormField* pField, CFX_PtrArray& widgets
) | 1794 if (pWidget) |
1804 { | 1795 widgets.Add(pWidget); |
1805 » ASSERT(pField != NULL); | 1796 } |
1806 | 1797 } |
1807 » for (int i=0,isz=pField->CountControls(); i<isz; i++) | 1798 |
1808 » { | 1799 int CPDFSDK_InterForm::GetPageIndexByAnnotDict( |
1809 » » CPDF_FormControl* pFormCtrl = pField->GetControl(i); | 1800 CPDF_Document* pDocument, |
1810 » » ASSERT(pFormCtrl != NULL); | 1801 CPDF_Dictionary* pAnnotDict) const { |
1811 | 1802 ASSERT(pDocument != NULL); |
1812 » » CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl); | 1803 ASSERT(pAnnotDict != NULL); |
1813 | 1804 |
1814 » » if (pWidget) | 1805 for (int i = 0, sz = pDocument->GetPageCount(); i < sz; i++) { |
1815 » » » widgets.Add(pWidget); | 1806 if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) { |
1816 » } | 1807 if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) { |
1817 } | 1808 for (int j = 0, jsz = pAnnots->GetCount(); j < jsz; j++) { |
1818 | 1809 CPDF_Object* pDict = pAnnots->GetElementValue(j); |
1819 int CPDFSDK_InterForm::GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Di
ctionary* pAnnotDict) const | 1810 if (pAnnotDict == pDict) { |
1820 { | 1811 return i; |
1821 » ASSERT(pDocument != NULL); | 1812 } |
1822 » ASSERT(pAnnotDict != NULL); | 1813 } |
1823 | 1814 } |
1824 » for (int i=0,sz=pDocument->GetPageCount(); i<sz; i++) | 1815 } |
1825 » { | 1816 } |
1826 » » if (CPDF_Dictionary* pPageDict = pDocument->GetPage(i)) | 1817 |
1827 » » {» » » | 1818 return -1; |
1828 » » » if (CPDF_Array* pAnnots = pPageDict->GetArray("Annots")) | 1819 } |
1829 » » » { | 1820 |
1830 » » » » for (int j=0,jsz=pAnnots->GetCount(); j<jsz; j++
) | 1821 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, |
1831 » » » » { | 1822 CPDFSDK_Widget* pWidget) { |
1832 » » » » » CPDF_Object* pDict = pAnnots->GetElement
Value(j); | 1823 m_Map.SetAt(pControl, pWidget); |
1833 » » » » » if (pAnnotDict == pDict) | 1824 } |
1834 » » » » » { | 1825 |
1835 » » » » » » return i; | 1826 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) { |
1836 » » » » » } | 1827 m_Map.RemoveKey(pControl); |
1837 » » » » } | 1828 } |
1838 » » » } | 1829 |
1839 » » } | 1830 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) { |
1840 » } | 1831 m_bCalculate = bEnabled; |
1841 | 1832 } |
1842 » return -1; | 1833 |
1843 } | 1834 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const { |
1844 | 1835 return m_bCalculate; |
1845 void CPDFSDK_InterForm::AddMap(CPDF_FormControl* pControl, CPDFSDK_Widget* pWidg
et) | |
1846 { | |
1847 » m_Map.SetAt(pControl, pWidget); | |
1848 } | |
1849 | |
1850 void CPDFSDK_InterForm::RemoveMap(CPDF_FormControl* pControl) | |
1851 { | |
1852 » m_Map.RemoveKey(pControl); | |
1853 } | |
1854 | |
1855 void CPDFSDK_InterForm::EnableCalculate(FX_BOOL bEnabled) | |
1856 { | |
1857 » m_bCalculate = bEnabled; | |
1858 } | |
1859 | |
1860 FX_BOOL CPDFSDK_InterForm::IsCalculateEnabled() const | |
1861 { | |
1862 » return m_bCalculate; | |
1863 } | 1836 } |
1864 | 1837 |
1865 #ifdef _WIN32 | 1838 #ifdef _WIN32 |
1866 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) | 1839 CPDF_Stream* CPDFSDK_InterForm::LoadImageFromFile(const CFX_WideString& sFile) { |
1867 { | 1840 ASSERT(m_pDocument != NULL); |
1868 » ASSERT(m_pDocument != NULL); | 1841 CPDF_Document* pDocument = m_pDocument->GetDocument(); |
1869 » CPDF_Document* pDocument = m_pDocument->GetDocument(); | 1842 ASSERT(pDocument != NULL); |
1870 » ASSERT(pDocument != NULL); | 1843 |
1871 | 1844 CPDF_Stream* pRetStream = NULL; |
1872 » CPDF_Stream* pRetStream = NULL; | 1845 |
1873 | 1846 if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile)) { |
1874 » if (CFX_DIBitmap* pBmp = CFX_WindowsDIB::LoadFromFile(sFile)) | 1847 int nWidth = pBmp->GetWidth(); |
1875 » { | 1848 int nHeight = pBmp->GetHeight(); |
1876 » » int nWidth = pBmp->GetWidth(); | 1849 |
1877 » » int nHeight = pBmp->GetHeight(); | 1850 CPDF_Image Image(pDocument); |
1878 | 1851 Image.SetImage(pBmp, FALSE); |
1879 » » CPDF_Image Image(pDocument); | 1852 CPDF_Stream* pImageStream = Image.GetStream(); |
1880 » » Image.SetImage(pBmp, FALSE); | 1853 if (pImageStream) { |
1881 » » CPDF_Stream* pImageStream = Image.GetStream(); | 1854 if (pImageStream->GetObjNum() == 0) |
1882 » » if (pImageStream) | 1855 pDocument->AddIndirectObject(pImageStream); |
1883 » » { | 1856 |
1884 » » » if (pImageStream->GetObjNum() == 0) | 1857 CPDF_Dictionary* pStreamDict = new CPDF_Dictionary(); |
1885 » » » » pDocument->AddIndirectObject(pImageStream); | 1858 pStreamDict->SetAtName("Subtype", "Form"); |
1886 | 1859 pStreamDict->SetAtName("Name", "IMG"); |
1887 » » » CPDF_Dictionary* pStreamDict = new CPDF_Dictionary(); | 1860 CPDF_Array* pMatrix = new CPDF_Array(); |
1888 » » » pStreamDict->SetAtName("Subtype", "Form"); | 1861 pStreamDict->SetAt("Matrix", pMatrix); |
1889 » » » pStreamDict->SetAtName("Name", "IMG"); | 1862 pMatrix->AddInteger(1); |
1890 » » » CPDF_Array* pMatrix = new CPDF_Array(); | 1863 pMatrix->AddInteger(0); |
1891 » » » pStreamDict->SetAt("Matrix", pMatrix); | 1864 pMatrix->AddInteger(0); |
1892 » » » pMatrix->AddInteger(1); | 1865 pMatrix->AddInteger(1); |
1893 » » » pMatrix->AddInteger(0); | 1866 pMatrix->AddInteger(-nWidth / 2); |
1894 » » » pMatrix->AddInteger(0); | 1867 pMatrix->AddInteger(-nHeight / 2); |
1895 » » » pMatrix->AddInteger(1); | 1868 CPDF_Dictionary* pResource = new CPDF_Dictionary(); |
1896 » » » pMatrix->AddInteger(-nWidth / 2); | 1869 pStreamDict->SetAt("Resources", pResource); |
1897 » » » pMatrix->AddInteger(-nHeight / 2); | 1870 CPDF_Dictionary* pXObject = new CPDF_Dictionary(); |
1898 » » » CPDF_Dictionary* pResource = new CPDF_Dictionary(); | 1871 pResource->SetAt("XObject", pXObject); |
1899 » » » pStreamDict->SetAt("Resources", pResource); | 1872 pXObject->SetAtReference("Img", pDocument, pImageStream); |
1900 » » » CPDF_Dictionary* pXObject = new CPDF_Dictionary(); | 1873 CPDF_Array* pProcSet = new CPDF_Array(); |
1901 » » » pResource->SetAt("XObject", pXObject); | 1874 pResource->SetAt("ProcSet", pProcSet); |
1902 » » » pXObject->SetAtReference("Img", pDocument, pImageStream)
; | 1875 pProcSet->AddName("PDF"); |
1903 » » » CPDF_Array* pProcSet = new CPDF_Array(); | 1876 pProcSet->AddName("ImageC"); |
1904 » » » pResource->SetAt("ProcSet", pProcSet); | 1877 pStreamDict->SetAtName("Type", "XObject"); |
1905 » » » pProcSet->AddName("PDF"); | 1878 CPDF_Array* pBBox = new CPDF_Array(); |
1906 » » » pProcSet->AddName("ImageC"); | 1879 pStreamDict->SetAt("BBox", pBBox); |
1907 » » » pStreamDict->SetAtName("Type", "XObject"); | 1880 pBBox->AddInteger(0); |
1908 » » » CPDF_Array* pBBox = new CPDF_Array(); | 1881 pBBox->AddInteger(0); |
1909 » » » pStreamDict->SetAt("BBox", pBBox); | 1882 pBBox->AddInteger(nWidth); |
1910 » » » pBBox->AddInteger(0); | 1883 pBBox->AddInteger(nHeight); |
1911 » » » pBBox->AddInteger(0); | 1884 pStreamDict->SetAtInteger("FormType", 1); |
1912 » » » pBBox->AddInteger(nWidth); | 1885 |
1913 » » » pBBox->AddInteger(nHeight); | 1886 pRetStream = new CPDF_Stream(NULL, 0, NULL); |
1914 » » » pStreamDict->SetAtInteger("FormType", 1); | 1887 CFX_ByteString csStream; |
1915 | 1888 csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidth, nHeight); |
1916 » » » pRetStream = new CPDF_Stream(NULL, 0, NULL); | 1889 pRetStream->InitStream( |
1917 » » » CFX_ByteString csStream; | 1890 (FX_BYTE*)(FX_LPCSTR) csStream, csStream.GetLength(), pStreamDict); |
1918 » » » csStream.Format("q\n%d 0 0 %d 0 0 cm\n/Img Do\nQ", nWidt
h, nHeight); | 1891 pDocument->AddIndirectObject(pRetStream); |
1919 » » » pRetStream->InitStream((FX_BYTE*)(FX_LPCSTR)csStream, cs
Stream.GetLength(), pStreamDict); | 1892 } |
1920 » » » pDocument->AddIndirectObject(pRetStream); | 1893 |
1921 » » } | 1894 delete pBmp; |
1922 | 1895 } |
1923 » » delete pBmp; | 1896 |
1924 » } | 1897 return pRetStream; |
1925 | |
1926 » return pRetStream; | |
1927 } | 1898 } |
1928 #endif | 1899 #endif |
1929 | 1900 |
1930 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) | 1901 void CPDFSDK_InterForm::OnCalculate(CPDF_FormField* pFormField) { |
1931 { | 1902 ASSERT(m_pDocument != NULL); |
1932 ASSERT(m_pDocument != NULL); | 1903 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1933 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1904 ASSERT(pEnv); |
1934 ASSERT(pEnv); | 1905 if (!pEnv->IsJSInitiated()) |
1935 if(!pEnv->IsJSInitiated()) | 1906 return; |
1936 return; | 1907 |
1937 | 1908 if (m_bBusy) |
1938 if (m_bBusy) return; | 1909 return; |
1939 | 1910 |
1940 m_bBusy = TRUE; | 1911 m_bBusy = TRUE; |
1941 | 1912 |
1942 if (this->IsCalculateEnabled()) | 1913 if (this->IsCalculateEnabled()) { |
1943 { | 1914 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
1944 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1915 ASSERT(pRuntime != NULL); |
1945 ASSERT(pRuntime != NULL); | 1916 |
1946 | 1917 pRuntime->SetReaderDocument(m_pDocument); |
1947 pRuntime->SetReaderDocument(m_pDocument); | 1918 |
1948 | 1919 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); |
1949 int nSize = m_pInterForm->CountFieldsInCalculationOrder(); | 1920 for (int i = 0; i < nSize; i++) { |
1950 for (int i=0; i<nSize; i++) | 1921 if (CPDF_FormField* pField = |
1951 { | 1922 m_pInterForm->GetFieldInCalculationOrder(i)) { |
1952 if(CPDF_FormField* pField = m_pInterForm->GetFieldInCalc
ulationOrder(i)) | 1923 // ASSERT(pField != NULL); |
1953 { | 1924 int nType = pField->GetFieldType(); |
1954 // ASSERT(pField != NULL); | 1925 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
1955 int nType = pField->GetFieldType(); | 1926 CPDF_AAction aAction = pField->GetAdditionalAction(); |
1956 if (nType == FIELDTYPE_COMBOBOX || nType == FIEL
DTYPE_TEXTFIELD) | 1927 if (aAction && aAction.ActionExist(CPDF_AAction::Calculate)) { |
1957 { | 1928 CPDF_Action action = aAction.GetAction(CPDF_AAction::Calculate); |
1958 CPDF_AAction aAction = pField->GetAdditi
onalAction(); | 1929 if (action) { |
1959 if (aAction && aAction.ActionExist(CPDF_
AAction::Calculate)) | 1930 CFX_WideString csJS = action.GetJavaScript(); |
1960 { | 1931 if (!csJS.IsEmpty()) { |
1961 CPDF_Action action = aAction.Get
Action(CPDF_AAction::Calculate); | 1932 IFXJS_Context* pContext = pRuntime->NewContext(); |
1962 if (action) | 1933 ASSERT(pContext != NULL); |
1963 { | 1934 |
1964 CFX_WideString csJS = ac
tion.GetJavaScript(); | 1935 CFX_WideString sOldValue = pField->GetValue(); |
1965 if (!csJS.IsEmpty()) | 1936 CFX_WideString sValue = sOldValue; |
1966 { | 1937 FX_BOOL bRC = TRUE; |
1967 IFXJS_Context* p
Context = pRuntime->NewContext(); | 1938 pContext->OnField_Calculate(pFormField, pField, sValue, bRC); |
1968 ASSERT(pContext
!= NULL); | 1939 |
1969 | 1940 CFX_WideString sInfo; |
1970 CFX_WideString s
OldValue = pField->GetValue(); | 1941 FX_BOOL bRet = pContext->RunScript(csJS, sInfo); |
1971 CFX_WideString s
Value = sOldValue; | 1942 pRuntime->ReleaseContext(pContext); |
1972 FX_BOOL bRC = TR
UE; | 1943 |
1973 pContext->OnFiel
d_Calculate(pFormField, pField, sValue, bRC); | 1944 if (bRet) { |
1974 | 1945 if (bRC) { |
1975 CFX_WideString s
Info; | 1946 if (sValue.Compare(sOldValue) != 0) |
1976 FX_BOOL bRet = p
Context->RunScript(csJS, sInfo); | 1947 pField->SetValue(sValue, TRUE); |
1977 pRuntime->Releas
eContext(pContext); | 1948 } |
1978 | 1949 } |
1979 if (bRet) | 1950 } |
1980 { | 1951 } |
1981 if (bRC) | 1952 } |
1982 { | 1953 } |
1983
if (sValue.Compare(sOldValue) != 0) | 1954 } |
1984
pField->SetValue(sValue, TRUE); | 1955 } |
1985 } | 1956 } |
1986 } | 1957 |
1987 } | 1958 m_bBusy = FALSE; |
1988 } | 1959 } |
1989 } | 1960 |
1990 } | 1961 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, |
1991 } | 1962 int nCommitKey, |
1992 } | 1963 FX_BOOL& bFormated) { |
1993 | 1964 ASSERT(m_pDocument != NULL); |
1994 | 1965 ASSERT(pFormField != NULL); |
1995 } | 1966 |
1996 | 1967 CFX_WideString sValue = pFormField->GetValue(); |
1997 m_bBusy = FALSE; | 1968 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
1998 } | 1969 ASSERT(pEnv); |
1999 | 1970 if (!pEnv->IsJSInitiated()) { |
2000 CFX_WideString CPDFSDK_InterForm::OnFormat(CPDF_FormField* pFormField, int nComm
itKey, FX_BOOL& bFormated) | 1971 bFormated = FALSE; |
2001 { | 1972 return sValue; |
2002 ASSERT(m_pDocument != NULL); | 1973 } |
2003 ASSERT(pFormField != NULL); | 1974 |
2004 | 1975 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); |
2005 CFX_WideString sValue = pFormField->GetValue(); | 1976 ASSERT(pRuntime != NULL); |
2006 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 1977 |
2007 ASSERT(pEnv); | 1978 pRuntime->SetReaderDocument(m_pDocument); |
2008 if(!pEnv->IsJSInitiated()) | 1979 |
2009 { | 1980 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) { |
2010 bFormated = FALSE; | 1981 if (pFormField->CountSelectedItems() > 0) { |
2011 return sValue; | 1982 int index = pFormField->GetSelectedIndex(0); |
2012 } | 1983 if (index >= 0) |
2013 | 1984 sValue = pFormField->GetOptionLabel(index); |
2014 IFXJS_Runtime* pRuntime = m_pDocument->GetJsRuntime(); | 1985 } |
2015 ASSERT(pRuntime != NULL); | 1986 } |
2016 | 1987 |
2017 pRuntime->SetReaderDocument(m_pDocument); | 1988 bFormated = FALSE; |
2018 | 1989 |
2019 if (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX) | 1990 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
2020 { | 1991 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) { |
2021 if (pFormField->CountSelectedItems() > 0) | 1992 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); |
2022 { | 1993 if (action) { |
2023 int index = pFormField->GetSelectedIndex(0); | 1994 CFX_WideString script = action.GetJavaScript(); |
2024 if (index >= 0) | 1995 if (!script.IsEmpty()) { |
2025 sValue = pFormField->GetOptionLabel(index); | 1996 CFX_WideString Value = sValue; |
2026 } | 1997 |
2027 } | 1998 IFXJS_Context* pContext = pRuntime->NewContext(); |
2028 | 1999 ASSERT(pContext != NULL); |
2029 bFormated = FALSE; | 2000 |
2030 | 2001 pContext->OnField_Format(nCommitKey, pFormField, Value, TRUE); |
2031 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2002 |
2032 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Format)) | 2003 CFX_WideString sInfo; |
2033 { | 2004 FX_BOOL bRet = pContext->RunScript(script, sInfo); |
2034 CPDF_Action action = aAction.GetAction(CPDF_AAction::Format); | 2005 pRuntime->ReleaseContext(pContext); |
2035 if (action) | 2006 |
2036 { | 2007 if (bRet) { |
2037 CFX_WideString script = action.GetJavaScript(); | 2008 sValue = Value; |
2038 if (!script.IsEmpty()) | 2009 bFormated = TRUE; |
2039 { | 2010 } |
2040 CFX_WideString Value = sValue; | 2011 } |
2041 | 2012 } |
2042 IFXJS_Context* pContext = pRuntime->NewContext()
; | 2013 } |
2043 ASSERT(pContext != NULL); | 2014 |
2044 | 2015 return sValue; |
2045 pContext->OnField_Format(nCommitKey, pFormField,
Value, TRUE); | 2016 } |
2046 | 2017 |
2047 CFX_WideString sInfo; | 2018 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, |
2048 FX_BOOL bRet = pContext->RunScript(script, sInfo
); | 2019 FX_LPCWSTR sValue, |
2049 pRuntime->ReleaseContext(pContext); | 2020 FX_BOOL bValueChanged) { |
2050 | 2021 ASSERT(pFormField != NULL); |
2051 if (bRet) | 2022 |
2052 { | 2023 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2053 sValue = Value; | 2024 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2054 bFormated = TRUE; | 2025 ASSERT(pFormCtrl != NULL); |
2055 } | 2026 |
2056 } | 2027 ASSERT(m_pInterForm != NULL); |
2057 } | 2028 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
2058 } | 2029 pWidget->ResetAppearance(sValue, bValueChanged); |
2059 | 2030 } |
2060 return sValue; | 2031 } |
2061 } | 2032 |
2062 | 2033 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) { |
2063 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, FX_LPCW
STR sValue, FX_BOOL bValueChanged) | 2034 ASSERT(pFormField != NULL); |
2064 { | 2035 |
2065 ASSERT(pFormField != NULL); | 2036 for (int i = 0, sz = pFormField->CountControls(); i < sz; i++) { |
2066 | 2037 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2067 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | 2038 ASSERT(pFormCtrl != NULL); |
2068 { | 2039 |
2069 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2040 if (CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) { |
2070 ASSERT(pFormCtrl != NULL); | 2041 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2071 | 2042 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); |
2072 ASSERT(m_pInterForm != NULL); | 2043 |
2073 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2044 CPDF_Page* pPage = pWidget->GetPDFPage(); |
2074 pWidget->ResetAppearance(sValue, bValueChanged); | 2045 CPDFSDK_PageView* pPageView = m_pDocument->GetPageView(pPage, FALSE); |
2075 } | 2046 |
2076 } | 2047 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pWidget); |
2077 | 2048 |
2078 void CPDFSDK_InterForm::UpdateField(CPDF_FormField* pFormField) | 2049 pEnv->FFI_Invalidate( |
2079 { | 2050 pPage, rcBBox.left, rcBBox.top, rcBBox.right, rcBBox.bottom); |
2080 ASSERT(pFormField != NULL); | 2051 } |
2081 | 2052 } |
2082 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | 2053 } |
2083 { | 2054 |
2084 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2055 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, |
2085 ASSERT(pFormCtrl != NULL); | 2056 CFX_WideString& csValue, |
2086 | 2057 FX_BOOL& bRC) { |
2087 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2058 ASSERT(pFormField != NULL); |
2088 { | 2059 |
2089 CPDFDoc_Environment * pEnv = m_pDocument->GetEnv(); | 2060 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
2090 CFFL_IFormFiller* pIFormFiller = pEnv->GetIFormFiller(); | 2061 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke)) { |
2091 | 2062 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); |
2092 CPDF_Page * pPage = pWidget->GetPDFPage(); | 2063 if (action) { |
2093 CPDFSDK_PageView * pPageView = m_pDocument->GetPageView(
pPage,FALSE); | 2064 ASSERT(m_pDocument != NULL); |
2094 | 2065 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2095 FX_RECT rcBBox = pIFormFiller->GetViewBBox(pPageView, pW
idget); | 2066 ASSERT(pEnv != NULL); |
2096 | 2067 |
2097 pEnv->FFI_Invalidate(pPage,rcBBox.left, rcBBox.top, rcBB
ox.right, rcBBox.bottom); | 2068 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
2098 } | 2069 ASSERT(pActionHandler != NULL); |
2099 } | 2070 |
2100 } | 2071 PDFSDK_FieldAction fa; |
2101 | 2072 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
2102 void CPDFSDK_InterForm::OnKeyStrokeCommit(CPDF_FormField* pFormField, CFX_WideSt
ring& csValue, FX_BOOL& bRC) | 2073 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
2103 { | 2074 fa.sValue = csValue; |
2104 ASSERT(pFormField != NULL); | 2075 |
2105 | 2076 pActionHandler->DoAction_FieldJavaScript( |
2106 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2077 action, CPDF_AAction::KeyStroke, m_pDocument, pFormField, fa); |
2107 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::KeyStroke)) | 2078 bRC = fa.bRC; |
2108 { | 2079 } |
2109 CPDF_Action action = aAction.GetAction(CPDF_AAction::KeyStroke); | 2080 } |
2110 if (action) | 2081 } |
2111 { | 2082 |
2112 ASSERT(m_pDocument != NULL); | 2083 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, |
2113 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2084 CFX_WideString& csValue, |
2114 ASSERT(pEnv != NULL); | 2085 FX_BOOL& bRC) { |
2115 | 2086 ASSERT(pFormField != NULL); |
2116 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionH
ander(); | 2087 |
2117 ASSERT(pActionHandler != NULL); | 2088 CPDF_AAction aAction = pFormField->GetAdditionalAction(); |
2118 | 2089 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate)) { |
2119 PDFSDK_FieldAction fa; | 2090 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); |
2120 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | 2091 if (action) { |
2121 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | 2092 ASSERT(m_pDocument != NULL); |
2122 fa.sValue = csValue; | 2093 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2123 | 2094 ASSERT(pEnv != NULL); |
2124 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AA
ction::KeyStroke, | 2095 |
2125 m_pDocument, pFormField, fa); | 2096 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionHander(); |
2126 bRC = fa.bRC; | 2097 ASSERT(pActionHandler != NULL); |
2127 } | 2098 |
2128 } | 2099 PDFSDK_FieldAction fa; |
2129 } | 2100 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); |
2130 | 2101 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); |
2131 void CPDFSDK_InterForm::OnValidate(CPDF_FormField* pFormField, CFX_WideString& c
sValue, FX_BOOL& bRC) | 2102 fa.sValue = csValue; |
2132 { | 2103 |
2133 ASSERT(pFormField != NULL); | 2104 pActionHandler->DoAction_FieldJavaScript( |
2134 | 2105 action, CPDF_AAction::Validate, m_pDocument, pFormField, fa); |
2135 CPDF_AAction aAction = pFormField->GetAdditionalAction(); | 2106 bRC = fa.bRC; |
2136 if (aAction != NULL && aAction.ActionExist(CPDF_AAction::Validate)) | 2107 } |
2137 { | 2108 } |
2138 CPDF_Action action = aAction.GetAction(CPDF_AAction::Validate); | |
2139 if (action) | |
2140 { | |
2141 ASSERT(m_pDocument != NULL); | |
2142 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | |
2143 ASSERT(pEnv != NULL); | |
2144 | |
2145 CPDFSDK_ActionHandler* pActionHandler = pEnv->GetActionH
ander(); | |
2146 ASSERT(pActionHandler != NULL); | |
2147 | |
2148 PDFSDK_FieldAction fa; | |
2149 fa.bModifier = pEnv->FFI_IsCTRLKeyDown(0); | |
2150 fa.bShift = pEnv->FFI_IsSHIFTKeyDown(0); | |
2151 fa.sValue = csValue; | |
2152 | |
2153 pActionHandler->DoAction_FieldJavaScript(action, CPDF_AA
ction::Validate, m_pDocument, pFormField, fa); | |
2154 bRC = fa.bRC; | |
2155 | |
2156 } | |
2157 } | |
2158 } | 2109 } |
2159 | 2110 |
2160 /* ----------------------------- action ----------------------------- */ | 2111 /* ----------------------------- action ----------------------------- */ |
2161 | 2112 |
2162 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) | 2113 FX_BOOL CPDFSDK_InterForm::DoAction_Hide(const CPDF_Action& action) { |
2163 { | 2114 ASSERT(action != NULL); |
2164 ASSERT(action != NULL); | 2115 |
2165 | 2116 CPDF_ActionFields af = action.GetWidgets(); |
2166 CPDF_ActionFields af = action.GetWidgets(); | 2117 CFX_PtrArray fieldObjects; |
2167 CFX_PtrArray fieldObjects; | 2118 af.GetAllFields(fieldObjects); |
2168 af.GetAllFields(fieldObjects); | 2119 CFX_PtrArray widgetArray; |
2169 CFX_PtrArray widgetArray; | 2120 CFX_PtrArray fields; |
2170 CFX_PtrArray fields; | 2121 GetFieldFromObjects(fieldObjects, fields); |
2171 GetFieldFromObjects(fieldObjects, fields); | 2122 |
2172 | 2123 FX_BOOL bHide = action.GetHideStatus(); |
2173 FX_BOOL bHide = action.GetHideStatus(); | 2124 |
2174 | 2125 FX_BOOL bChanged = FALSE; |
2175 FX_BOOL bChanged = FALSE; | 2126 |
2176 | 2127 for (int i = 0, sz = fields.GetSize(); i < sz; i++) { |
2177 for (int i=0, sz=fields.GetSize(); i<sz; i++) | 2128 CPDF_FormField* pField = (CPDF_FormField*)fields[i]; |
2178 { | 2129 ASSERT(pField != NULL); |
2179 CPDF_FormField* pField = (CPDF_FormField*)fields[i]; | 2130 |
2180 ASSERT(pField != NULL); | 2131 for (int j = 0, jsz = pField->CountControls(); j < jsz; j++) { |
2181 | 2132 CPDF_FormControl* pControl = pField->GetControl(j); |
2182 | 2133 ASSERT(pControl != NULL); |
2183 for (int j=0,jsz=pField->CountControls(); j<jsz; j++) | 2134 |
2184 { | 2135 if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) { |
2185 CPDF_FormControl* pControl = pField->GetControl(j); | 2136 int nFlags = pWidget->GetFlags(); |
2186 ASSERT(pControl != NULL); | 2137 if (bHide) { |
2187 | 2138 nFlags &= (~ANNOTFLAG_INVISIBLE); |
2188 if (CPDFSDK_Widget* pWidget = GetWidget(pControl)) | 2139 nFlags &= (~ANNOTFLAG_NOVIEW); |
2189 { | 2140 nFlags |= (ANNOTFLAG_HIDDEN); |
2190 int nFlags = pWidget->GetFlags(); | 2141 } else { |
2191 if (bHide) | 2142 nFlags &= (~ANNOTFLAG_INVISIBLE); |
2192 { | 2143 nFlags &= (~ANNOTFLAG_HIDDEN); |
2193 nFlags &= (~ANNOTFLAG_INVISIBLE); | 2144 nFlags &= (~ANNOTFLAG_NOVIEW); |
2194 nFlags &= (~ANNOTFLAG_NOVIEW); | 2145 } |
2195 nFlags |= (ANNOTFLAG_HIDDEN); | 2146 pWidget->SetFlags(nFlags); |
2196 } | 2147 |
2197 else | 2148 CPDFSDK_PageView* pPageView = pWidget->GetPageView(); |
2198 { | 2149 ASSERT(pPageView != NULL); |
2199 nFlags &= (~ANNOTFLAG_INVISIBLE); | 2150 |
2200 nFlags &= (~ANNOTFLAG_HIDDEN); | 2151 pPageView->UpdateView(pWidget); |
2201 nFlags &= (~ANNOTFLAG_NOVIEW); | 2152 |
2202 } | 2153 bChanged = TRUE; |
2203 pWidget->SetFlags(nFlags); | 2154 } |
2204 | 2155 } |
2205 CPDFSDK_PageView* pPageView = pWidget->GetPageVi
ew(); | 2156 } |
2206 ASSERT(pPageView != NULL); | 2157 |
2207 | 2158 return bChanged; |
2208 pPageView->UpdateView(pWidget); | 2159 } |
2209 | 2160 |
2210 bChanged = TRUE; | 2161 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) { |
2211 } | 2162 ASSERT(action != NULL); |
2212 } | 2163 ASSERT(m_pInterForm != NULL); |
2213 } | 2164 |
2214 | 2165 CFX_WideString sDestination = action.GetFilePath(); |
2215 return bChanged; | 2166 if (sDestination.IsEmpty()) |
2216 } | 2167 return FALSE; |
2217 | 2168 |
2218 FX_BOOL CPDFSDK_InterForm::DoAction_SubmitForm(const CPDF_Action& action) | 2169 CPDF_Dictionary* pActionDict = action; |
2219 { | 2170 if (pActionDict->KeyExist("Fields")) { |
2220 ASSERT(action != NULL); | 2171 CPDF_ActionFields af = action.GetWidgets(); |
2221 ASSERT(m_pInterForm != NULL); | 2172 FX_DWORD dwFlags = action.GetFlags(); |
2222 | 2173 |
2223 CFX_WideString sDestination = action.GetFilePath(); | 2174 CFX_PtrArray fieldObjects; |
2224 if (sDestination.IsEmpty()) return FALSE; | 2175 af.GetAllFields(fieldObjects); |
2225 | 2176 CFX_PtrArray fields; |
2226 CPDF_Dictionary* pActionDict = action; | 2177 GetFieldFromObjects(fieldObjects, fields); |
2227 if (pActionDict->KeyExist("Fields")) | 2178 |
2228 { | 2179 if (fields.GetSize() != 0) { |
2229 CPDF_ActionFields af = action.GetWidgets(); | 2180 FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01); |
2230 FX_DWORD dwFlags = action.GetFlags(); | 2181 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeOrExclude)) { |
2231 | 2182 return FALSE; |
2232 CFX_PtrArray fieldObjects; | 2183 } |
2233 af.GetAllFields(fieldObjects); | 2184 return SubmitFields(sDestination, fields, bIncludeOrExclude, FALSE); |
2234 CFX_PtrArray fields; | 2185 } else { |
2235 GetFieldFromObjects(fieldObjects, fields); | 2186 if (m_pInterForm->CheckRequiredFields()) { |
2236 | 2187 return FALSE; |
2237 if (fields.GetSize() != 0) | 2188 } |
2238 { | 2189 |
2239 FX_BOOL bIncludeOrExclude = !(dwFlags & 0x01); | 2190 return SubmitForm(sDestination, FALSE); |
2240 if (m_pInterForm->CheckRequiredFields(&fields, bIncludeO
rExclude)) | 2191 } |
2241 { | 2192 } else { |
2242 return FALSE; | 2193 if (m_pInterForm->CheckRequiredFields()) { |
2243 } | 2194 return FALSE; |
2244 return SubmitFields(sDestination, fields, bIncludeOrExcl
ude, FALSE); | 2195 } |
2245 } | 2196 |
2246 else | 2197 return SubmitForm(sDestination, FALSE); |
2247 { | 2198 } |
2248 if ( m_pInterForm->CheckRequiredFields()) | 2199 } |
2249 { | 2200 |
2250 return FALSE; | 2201 FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, |
2251 } | 2202 const CFX_PtrArray& fields, |
2252 | 2203 FX_BOOL bIncludeOrExclude, |
2253 return SubmitForm(sDestination, FALSE); | 2204 FX_BOOL bUrlEncoded) { |
2254 } | 2205 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2255 } | 2206 ASSERT(pEnv != NULL); |
2256 else | 2207 |
2257 { | 2208 CFX_ByteTextBuf textBuf; |
2258 if ( m_pInterForm->CheckRequiredFields()) | 2209 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); |
2259 { | 2210 |
2260 return FALSE; | 2211 FX_LPBYTE pBuffer = textBuf.GetBuffer(); |
2261 } | 2212 FX_STRSIZE nBufSize = textBuf.GetLength(); |
2262 | 2213 |
2263 return SubmitForm(sDestination, FALSE); | 2214 if (bUrlEncoded) { |
2264 } | 2215 if (!FDFToURLEncodedData(pBuffer, nBufSize)) |
2265 } | 2216 return FALSE; |
2266 | 2217 } |
2267 FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, con
st CFX_PtrArray& fields, | 2218 |
2268 FX_BOOL
bIncludeOrExclude, FX_BOOL bUrlEncoded) | 2219 pEnv->JS_docSubmitForm(pBuffer, nBufSize, (FX_LPCWSTR)csDestination); |
2269 { | 2220 |
2270 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2221 if (bUrlEncoded && pBuffer) { |
2271 ASSERT(pEnv != NULL); | 2222 FX_Free(pBuffer); |
2272 | 2223 pBuffer = NULL; |
2273 CFX_ByteTextBuf textBuf; | 2224 } |
2274 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 2225 |
2275 | 2226 return TRUE; |
2276 FX_LPBYTE pBuffer = textBuf.GetBuffer(); | 2227 } |
2277 FX_STRSIZE nBufSize = textBuf.GetLength(); | 2228 |
2278 | 2229 void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer) { |
2279 if (bUrlEncoded) | 2230 ASSERT(m_pDocument != NULL); |
2280 { | 2231 |
2281 if(!FDFToURLEncodedData(pBuffer, nBufSize)) | 2232 if (CFDF_Document* pFDFDocument = CFDF_Document::ParseMemory( |
2282 return FALSE; | 2233 (const unsigned char*)sBuffer.GetBuffer(sBuffer.GetLength()), |
2283 } | 2234 sBuffer.GetLength())) { |
2284 | 2235 CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot(); |
2285 pEnv->JS_docSubmitForm(pBuffer, nBufSize, (FX_LPCWSTR)csDestination); | 2236 if (pRootDic) { |
2286 | 2237 CPDF_Dictionary* pFDFDict = pRootDic->GetDict("FDF"); |
2287 if (bUrlEncoded && pBuffer) | 2238 if (pFDFDict) { |
2288 { | 2239 CPDF_Dictionary* pJSDict = pFDFDict->GetDict("JavaScript"); |
2289 FX_Free(pBuffer); | 2240 if (pJSDict) { |
2290 pBuffer = NULL; | 2241 CFX_WideString csJS; |
2291 } | 2242 |
2292 | 2243 CPDF_Object* pJS = pJSDict->GetElementValue("Before"); |
2293 return TRUE; | 2244 if (pJS != NULL) { |
2294 } | 2245 int iType = pJS->GetType(); |
2295 | 2246 if (iType == PDFOBJ_STRING) |
2296 void CPDFSDK_InterForm::DoFDFBuffer(CFX_ByteString sBuffer) | 2247 csJS = pJSDict->GetUnicodeText("Before"); |
2297 { | 2248 else if (iType == PDFOBJ_STREAM) |
2298 ASSERT(m_pDocument != NULL); | 2249 csJS = pJS->GetUnicodeText(); |
2299 | 2250 } |
2300 if (CFDF_Document *pFDFDocument = CFDF_Document::ParseMemory((const unsi
gned char *)sBuffer.GetBuffer(sBuffer.GetLength()), sBuffer.GetLength())) | 2251 } |
2301 { | 2252 } |
2302 CPDF_Dictionary* pRootDic = pFDFDocument->GetRoot(); | 2253 } |
2303 if(pRootDic) | 2254 delete pFDFDocument; |
2304 { | 2255 } |
2305 CPDF_Dictionary * pFDFDict=pRootDic->GetDict("FDF"); | 2256 |
2306 if(pFDFDict) | 2257 sBuffer.ReleaseBuffer(); |
2307 { | 2258 } |
2308 CPDF_Dictionary * pJSDict = pFDFDict->GetDict("J
avaScript"); | 2259 |
2309 if(pJSDict) | 2260 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, |
2310 { | 2261 CFX_WideString csTxtFile) { |
2311 CFX_WideString csJS; | 2262 return TRUE; |
2312 | 2263 } |
2313 CPDF_Object* pJS = pJSDict->GetElementVa
lue("Before"); | 2264 |
2314 if (pJS != NULL) | 2265 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(FX_LPBYTE& pBuf, |
2315 { | 2266 FX_STRSIZE& nBufSize) { |
2316 int iType = pJS->GetType(); | 2267 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); |
2317 if (iType == PDFOBJ_STRING) | 2268 if (pFDF) { |
2318 csJS = pJSDict->GetUnico
deText("Before"); | 2269 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); |
2319 else if (iType == PDFOBJ_STREAM) | 2270 if (pMainDict == NULL) |
2320 csJS = pJS->GetUnicodeTe
xt(); | 2271 return FALSE; |
2321 } | 2272 |
2322 | 2273 // Get fields |
2323 } | 2274 CPDF_Array* pFields = pMainDict->GetArray("Fields"); |
2324 } | 2275 if (pFields == NULL) |
2325 } | 2276 return FALSE; |
2326 delete pFDFDocument; | 2277 |
2327 } | 2278 CFX_ByteTextBuf fdfEncodedData; |
2328 | 2279 |
2329 sBuffer.ReleaseBuffer(); | 2280 for (FX_DWORD i = 0; i < pFields->GetCount(); i++) { |
2330 } | 2281 CPDF_Dictionary* pField = pFields->GetDict(i); |
2331 | 2282 if (pField == NULL) |
2332 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_Wid
eString csTxtFile) | 2283 continue; |
2333 { | 2284 CFX_WideString name; |
2334 return TRUE; | 2285 name = pField->GetUnicodeText("T"); |
2335 } | 2286 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name); |
2336 | 2287 CFX_ByteString csBValue = pField->GetString("V"); |
2337 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(FX_LPBYTE& pBuf, FX_STRSIZE& nBuf
Size) | 2288 CFX_WideString csWValue = PDF_DecodeText(csBValue); |
2338 { | 2289 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(csWValue); |
2339 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); | 2290 |
2340 if (pFDF) | 2291 fdfEncodedData = fdfEncodedData << name_b.GetBuffer(name_b.GetLength()); |
2341 { | 2292 name_b.ReleaseBuffer(); |
2342 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); | 2293 fdfEncodedData = fdfEncodedData << "="; |
2343 if (pMainDict == NULL) return FALSE; | 2294 fdfEncodedData = fdfEncodedData |
2344 | 2295 << csValue_b.GetBuffer(csValue_b.GetLength()); |
2345 // Get fields | 2296 csValue_b.ReleaseBuffer(); |
2346 CPDF_Array* pFields = pMainDict->GetArray("Fields"); | 2297 if (i != pFields->GetCount() - 1) |
2347 if (pFields == NULL) return FALSE; | 2298 fdfEncodedData = fdfEncodedData << "&"; |
2348 | 2299 } |
2349 CFX_ByteTextBuf fdfEncodedData; | 2300 |
2350 | 2301 nBufSize = fdfEncodedData.GetLength(); |
2351 for (FX_DWORD i = 0; i < pFields->GetCount(); i ++) | 2302 pBuf = FX_Alloc(FX_BYTE, nBufSize); |
2352 { | 2303 if (!pBuf) |
2353 CPDF_Dictionary* pField = pFields->GetDict(i); | 2304 return FALSE; |
2354 if (pField == NULL) continue; | 2305 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); |
2355 CFX_WideString name; | 2306 } |
2356 name = pField->GetUnicodeText("T"); | 2307 return TRUE; |
2357 CFX_ByteString name_b = CFX_ByteString::FromUnicode(name
); | 2308 } |
2358 CFX_ByteString csBValue = pField->GetString("V"); | 2309 |
2359 CFX_WideString csWValue = PDF_DecodeText(csBValue); | 2310 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFFile( |
2360 CFX_ByteString csValue_b = CFX_ByteString::FromUnicode(c
sWValue); | 2311 const CFX_WideString& sFDFFileName, |
2361 | 2312 const CFX_PtrArray& fields, |
2362 fdfEncodedData = fdfEncodedData<<name_b.GetBuffer(name_b
.GetLength()); | 2313 FX_BOOL bIncludeOrExclude) { |
2363 name_b.ReleaseBuffer(); | 2314 if (sFDFFileName.IsEmpty()) |
2364 fdfEncodedData = fdfEncodedData<<"="; | 2315 return FALSE; |
2365 fdfEncodedData = fdfEncodedData<<csValue_b.GetBuffer(csV
alue_b.GetLength()); | 2316 ASSERT(m_pDocument != NULL); |
2366 csValue_b.ReleaseBuffer(); | 2317 ASSERT(m_pInterForm != NULL); |
2367 if(i != pFields->GetCount()-1) | 2318 |
2368 fdfEncodedData = fdfEncodedData<<"&"; | 2319 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( |
2369 } | 2320 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); |
2370 | 2321 if (!pFDF) |
2371 nBufSize = fdfEncodedData.GetLength(); | 2322 return FALSE; |
2372 pBuf = FX_Alloc(FX_BYTE, nBufSize); | 2323 FX_BOOL bRet = pFDF->WriteFile(sFDFFileName.UTF8Encode()); // = FALSE;// |
2373 if(!pBuf) | 2324 delete pFDF; |
2374 return FALSE; | 2325 |
2375 FXSYS_memcpy(pBuf, fdfEncodedData.GetBuffer(), nBufSize); | 2326 return bRet; |
2376 | 2327 } |
2377 } | 2328 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields, |
2378 return TRUE; | 2329 FX_BOOL bIncludeOrExclude, |
2379 } | 2330 CFX_ByteTextBuf& textBuf) { |
2380 | 2331 ASSERT(m_pDocument != NULL); |
2381 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFFile(const CFX_WideString& sFDFFileN
ame, | 2332 ASSERT(m_pInterForm != NULL); |
2382
const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude) | 2333 |
2383 { | 2334 CFDF_Document* pFDF = m_pInterForm->ExportToFDF( |
2384 if (sFDFFileName.IsEmpty()) return FALSE; | 2335 m_pDocument->GetPath(), (CFX_PtrArray&)fields, bIncludeOrExclude); |
2385 ASSERT(m_pDocument != NULL); | 2336 if (!pFDF) |
2386 ASSERT(m_pInterForm != NULL); | 2337 return FALSE; |
2387 | 2338 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// |
2388 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(
CFX_PtrArray&)fields, bIncludeOrExclude); | 2339 delete pFDF; |
2389 if (!pFDF) return FALSE; | 2340 |
2390 FX_BOOL bRet = pFDF->WriteFile(sFDFFileName.UTF8Encode()); // = FALSE;// | 2341 return bRet; |
2391 delete pFDF; | 2342 } |
2392 | 2343 |
2393 return bRet; | 2344 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName( |
2394 } | 2345 const CFX_WideString& sFileExt) { |
2395 FX_BOOL CPDFSDK_InterForm::ExportFieldsToFDFTextBuf(const CFX_PtrArray& fields,F
X_BOOL bIncludeOrExclude, CFX_ByteTextBuf& textBuf) | 2346 CFX_WideString sFileName; |
2396 { | 2347 return L""; |
2397 ASSERT(m_pDocument != NULL); | 2348 } |
2398 ASSERT(m_pInterForm != NULL); | 2349 |
2399 | 2350 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, |
2400 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath(),(
CFX_PtrArray&)fields, bIncludeOrExclude); | 2351 FX_BOOL bUrlEncoded) { |
2401 if (!pFDF) return FALSE; | 2352 if (sDestination.IsEmpty()) |
2402 FX_BOOL bRet = pFDF->WriteBuf(textBuf); // = FALSE;// | 2353 return FALSE; |
2403 delete pFDF; | 2354 |
2404 | 2355 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2405 return bRet; | 2356 ASSERT(pEnv != NULL); |
2406 } | 2357 |
2407 | 2358 if (NULL == m_pDocument) |
2408 CFX_WideString CPDFSDK_InterForm::GetTemporaryFileName(const CFX_WideString& sFi
leExt) | 2359 return FALSE; |
2409 { | 2360 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); |
2410 CFX_WideString sFileName; | 2361 |
2411 return L""; | 2362 if (NULL == m_pInterForm) |
2412 } | 2363 return FALSE; |
2413 | 2364 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); |
2414 FX_BOOL CPDFSDK_InterForm::SubmitForm(const CFX_WideString& sDestination, FX_BOO
L bUrlEncoded) | 2365 if (NULL == pFDFDoc) |
2415 { | 2366 return FALSE; |
2416 if (sDestination.IsEmpty()) return FALSE; | 2367 |
2417 | 2368 CFX_ByteTextBuf FdfBuffer; |
2418 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2369 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); |
2419 ASSERT(pEnv != NULL); | 2370 delete pFDFDoc; |
2420 | 2371 if (!bRet) |
2421 if(NULL == m_pDocument) return FALSE; | 2372 return FALSE; |
2422 CFX_WideString wsPDFFilePath = m_pDocument->GetPath(); | 2373 |
2423 | 2374 FX_LPBYTE pBuffer = FdfBuffer.GetBuffer(); |
2424 if(NULL == m_pInterForm) return FALSE; | 2375 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
2425 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); | 2376 |
2426 if (NULL == pFDFDoc) return FALSE; | 2377 if (bUrlEncoded) { |
2427 | 2378 if (!FDFToURLEncodedData(pBuffer, nBufSize)) |
2428 CFX_ByteTextBuf FdfBuffer; | 2379 return FALSE; |
2429 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 2380 } |
2430 delete pFDFDoc; | 2381 |
2431 if (!bRet) return FALSE; | 2382 pEnv->JS_docSubmitForm(pBuffer, nBufSize, (FX_LPCWSTR)sDestination); |
2432 | 2383 |
2433 FX_LPBYTE pBuffer = FdfBuffer.GetBuffer(); | 2384 if (bUrlEncoded && pBuffer) { |
2434 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 2385 FX_Free(pBuffer); |
2435 | 2386 pBuffer = NULL; |
2436 if (bUrlEncoded) | 2387 } |
2437 { | 2388 |
2438 if(!FDFToURLEncodedData(pBuffer, nBufSize)) | 2389 return TRUE; |
2439 return FALSE; | 2390 } |
2440 } | 2391 |
2441 | 2392 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFFile( |
2442 pEnv->JS_docSubmitForm(pBuffer, nBufSize, (FX_LPCWSTR)sDestination); | 2393 const CFX_WideString& sFDFFileName) { |
2443 | 2394 if (sFDFFileName.IsEmpty()) |
2444 if (bUrlEncoded && pBuffer) | 2395 return FALSE; |
2445 { | 2396 |
2446 FX_Free(pBuffer); | 2397 ASSERT(m_pInterForm != NULL); |
2447 pBuffer = NULL; | 2398 ASSERT(m_pDocument != NULL); |
2448 } | 2399 |
2449 | 2400 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); |
2450 return TRUE; | 2401 if (!pFDF) |
2451 } | 2402 return FALSE; |
2452 | 2403 |
2453 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFFile(const CFX_WideString& sFDFFileNam
e) | 2404 FX_BOOL bRet = pFDF->WriteFile(sFDFFileName.UTF8Encode()); |
2454 { | 2405 delete pFDF; |
2455 if (sFDFFileName.IsEmpty()) return FALSE; | 2406 |
2456 | 2407 return bRet; |
2457 ASSERT(m_pInterForm != NULL); | 2408 } |
2458 ASSERT(m_pDocument != NULL); | 2409 |
2459 | 2410 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) { |
2460 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); | 2411 ASSERT(m_pInterForm != NULL); |
2461 if (!pFDF) return FALSE; | 2412 ASSERT(m_pDocument != NULL); |
2462 | 2413 |
2463 FX_BOOL bRet = pFDF->WriteFile(sFDFFileName.UTF8Encode()); | 2414 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); |
2464 delete pFDF; | 2415 if (!pFDF) |
2465 | 2416 return FALSE; |
2466 return bRet; | 2417 |
2467 } | 2418 FX_BOOL bRet = pFDF->WriteBuf(textBuf); |
2468 | 2419 delete pFDF; |
2469 FX_BOOL CPDFSDK_InterForm::ExportFormToFDFTextBuf(CFX_ByteTextBuf& textBuf) | 2420 |
2470 { | 2421 return bRet; |
2471 | 2422 } |
2472 ASSERT(m_pInterForm != NULL); | 2423 |
2473 ASSERT(m_pDocument != NULL); | 2424 FX_BOOL CPDFSDK_InterForm::ExportFormToTxtFile( |
2474 | 2425 const CFX_WideString& sTxtFileName) { |
2475 CFDF_Document* pFDF = m_pInterForm->ExportToFDF(m_pDocument->GetPath()); | 2426 ASSERT(m_pInterForm != NULL); |
2476 if (!pFDF) return FALSE; | 2427 |
2477 | 2428 CFX_WideString sFieldNames; |
2478 FX_BOOL bRet = pFDF->WriteBuf(textBuf); | 2429 CFX_WideString sFieldValues; |
2479 delete pFDF; | 2430 |
2480 | 2431 int nSize = m_pInterForm->CountFields(); |
2481 return bRet; | 2432 |
2482 } | 2433 if (nSize > 0) { |
2483 | 2434 for (int i = 0; i < nSize; i++) { |
2484 FX_BOOL CPDFSDK_InterForm::ExportFormToTxtFile(const CFX_WideString& sTxtFileNam
e) | 2435 CPDF_FormField* pField = m_pInterForm->GetField(i); |
2485 { | 2436 ASSERT(pField != NULL); |
2486 ASSERT(m_pInterForm != NULL); | 2437 |
2487 | 2438 if (i != 0) { |
2488 CFX_WideString sFieldNames; | 2439 sFieldNames += L"\t"; |
2489 CFX_WideString sFieldValues; | 2440 sFieldValues += L"\t"; |
2490 | 2441 } |
2491 int nSize = m_pInterForm->CountFields(); | 2442 sFieldNames += pField->GetFullName(); |
2492 | 2443 sFieldValues += pField->GetValue(); |
2493 if (nSize > 0) | 2444 } |
2494 { | 2445 |
2495 for (int i=0; i<nSize; i++) | 2446 return TRUE; |
2496 { | 2447 } |
2497 CPDF_FormField* pField = m_pInterForm->GetField(i); | 2448 |
2498 ASSERT(pField != NULL); | 2449 return FALSE; |
2499 | 2450 } |
2500 if (i != 0) | 2451 |
2501 { | 2452 FX_BOOL CPDFSDK_InterForm::ImportFormFromTxtFile( |
2502 sFieldNames += L"\t"; | 2453 const CFX_WideString& sTxtFileName) { |
2503 sFieldValues += L"\t"; | 2454 ASSERT(m_pInterForm != NULL); |
2504 } | 2455 |
2505 sFieldNames += pField->GetFullName(); | 2456 return TRUE; |
2506 sFieldValues += pField->GetValue(); | 2457 } |
2507 } | 2458 |
2508 | 2459 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) { |
2509 return TRUE; | 2460 ASSERT(action != NULL); |
2510 } | 2461 |
2511 | 2462 CPDF_Dictionary* pActionDict = action; |
2512 return FALSE; | 2463 |
2513 } | 2464 if (pActionDict->KeyExist("Fields")) { |
2514 | 2465 CPDF_ActionFields af = action.GetWidgets(); |
2515 FX_BOOL CPDFSDK_InterForm::ImportFormFromTxtFile(const CFX_WideString& sTxtFileN
ame) | 2466 FX_DWORD dwFlags = action.GetFlags(); |
2516 { | 2467 |
2517 ASSERT(m_pInterForm != NULL); | 2468 CFX_PtrArray fieldObjects; |
2518 | 2469 af.GetAllFields(fieldObjects); |
2519 return TRUE; | 2470 CFX_PtrArray fields; |
2520 } | 2471 GetFieldFromObjects(fieldObjects, fields); |
2521 | 2472 |
2522 FX_BOOL CPDFSDK_InterForm::DoAction_ResetForm(const CPDF_Action& action) | 2473 ASSERT(m_pInterForm != NULL); |
2523 { | 2474 |
2524 ASSERT(action != NULL); | 2475 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE); |
2525 | 2476 } else { |
2526 CPDF_Dictionary* pActionDict = action; | 2477 ASSERT(m_pInterForm != NULL); |
2527 | 2478 return m_pInterForm->ResetForm(TRUE); |
2528 if (pActionDict->KeyExist("Fields")) | 2479 } |
2529 { | 2480 } |
2530 CPDF_ActionFields af = action.GetWidgets(); | 2481 |
2531 FX_DWORD dwFlags = action.GetFlags(); | 2482 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) { |
2532 | 2483 ASSERT(action != NULL); |
2533 CFX_PtrArray fieldObjects; | 2484 |
2534 af.GetAllFields(fieldObjects); | 2485 CFX_WideString sFilePath = action.GetFilePath(); |
2535 CFX_PtrArray fields; | 2486 if (sFilePath.IsEmpty()) |
2536 GetFieldFromObjects(fieldObjects, fields); | 2487 return FALSE; |
2537 | 2488 |
2538 ASSERT(m_pInterForm != NULL); | 2489 if (!ImportFormFromFDFFile(sFilePath, TRUE)) { |
2539 | 2490 return FALSE; |
2540 return m_pInterForm->ResetForm(fields, !(dwFlags & 0x01), TRUE); | 2491 } |
2541 } | 2492 |
2542 else | 2493 return TRUE; |
2543 { | 2494 } |
2544 ASSERT(m_pInterForm != NULL); | 2495 |
2545 return m_pInterForm->ResetForm(TRUE); | 2496 FX_BOOL CPDFSDK_InterForm::ImportFormFromFDFFile( |
2546 } | 2497 const CFX_WideString& csFDFFileName, |
2547 } | 2498 FX_BOOL bNotify) { |
2548 | 2499 return FALSE; |
2549 FX_BOOL CPDFSDK_InterForm::DoAction_ImportData(const CPDF_Action& action) | 2500 } |
2550 { | 2501 |
2551 ASSERT(action != NULL); | 2502 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, |
2552 | 2503 CFX_PtrArray& fields) { |
2553 CFX_WideString sFilePath = action.GetFilePath(); | 2504 ASSERT(m_pInterForm != NULL); |
2554 if (sFilePath.IsEmpty()) | 2505 |
2555 return FALSE; | 2506 int iCount = objects.GetSize(); |
2556 | 2507 for (int i = 0; i < iCount; i++) { |
2557 if (!ImportFormFromFDFFile(sFilePath, TRUE)) | 2508 CPDF_Object* pObject = (CPDF_Object*)objects[i]; |
2558 { | 2509 if (pObject == NULL) |
2559 return FALSE; | 2510 continue; |
2560 } | 2511 |
2561 | 2512 int iType = pObject->GetType(); |
2562 return TRUE; | 2513 if (iType == PDFOBJ_STRING) { |
2563 } | 2514 CFX_WideString csName = pObject->GetUnicodeText(); |
2564 | 2515 CPDF_FormField* pField = m_pInterForm->GetField(0, csName); |
2565 FX_BOOL CPDFSDK_InterForm::ImportFormFromFDFFile(const CFX_WideString& csFDFFile
Name, | 2516 if (pField != NULL) |
2566
FX_BOOL bNotify) | 2517 fields.Add(pField); |
2567 { | 2518 } else if (iType == PDFOBJ_DICTIONARY) { |
2568 return FALSE; | 2519 if (m_pInterForm->IsValidFormField(pObject)) |
2569 } | 2520 fields.Add(pObject); |
2570 | 2521 } |
2571 void CPDFSDK_InterForm::GetFieldFromObjects(const CFX_PtrArray& objects, CFX_Ptr
Array& fields) | 2522 } |
2572 { | 2523 } |
2573 ASSERT(m_pInterForm != NULL); | 2524 |
2574 | 2525 /* ----------------------------- CPDF_FormNotify ----------------------------- |
2575 int iCount = objects.GetSize(); | 2526 */ |
2576 for (int i = 0; i < iCount; i ++) | 2527 |
2577 { | 2528 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, |
2578 CPDF_Object* pObject = (CPDF_Object*)objects[i]; | 2529 CFX_WideString& csValue) { |
2579 if (pObject == NULL) continue; | 2530 ASSERT(pField != NULL); |
2580 | 2531 |
2581 int iType = pObject->GetType(); | 2532 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2582 if (iType == PDFOBJ_STRING) | 2533 |
2583 { | 2534 int nType = pFormField->GetFieldType(); |
2584 CFX_WideString csName = pObject->GetUnicodeText(); | 2535 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
2585 CPDF_FormField* pField = m_pInterForm->GetField(0, csNam
e); | 2536 FX_BOOL bRC = TRUE; |
2586 if (pField != NULL) | 2537 OnKeyStrokeCommit(pFormField, csValue, bRC); |
2587 fields.Add(pField); | 2538 if (bRC) { |
2588 } | 2539 OnValidate(pFormField, csValue, bRC); |
2589 else if (iType == PDFOBJ_DICTIONARY) | 2540 if (bRC) |
2590 { | 2541 return 1; |
2591 if (m_pInterForm->IsValidFormField(pObject)) | 2542 else |
2592 fields.Add(pObject); | 2543 return -1; |
2593 } | 2544 } else |
2594 } | 2545 return -1; |
2595 } | 2546 } else |
2596 | 2547 return 0; |
2597 /* ----------------------------- CPDF_FormNotify ----------------------------- *
/ | 2548 } |
2598 | 2549 |
2599 int CPDFSDK_InterForm::BeforeValueChange(const CPDF_FormField* pField, CFX_W
ideString& csValue) | 2550 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) { |
2600 { | 2551 ASSERT(pField != NULL); |
2601 ASSERT(pField != NULL); | 2552 |
2602 | 2553 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2603 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2554 int nType = pFormField->GetFieldType(); |
2604 | 2555 |
2605 int nType = pFormField->GetFieldType(); | 2556 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) { |
2606 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) | 2557 this->OnCalculate(pFormField); |
2607 { | 2558 FX_BOOL bFormated = FALSE; |
2608 FX_BOOL bRC = TRUE; | 2559 CFX_WideString sValue = this->OnFormat(pFormField, 0, bFormated); |
2609 OnKeyStrokeCommit(pFormField, csValue, bRC); | 2560 if (bFormated) |
2610 if (bRC) | 2561 this->ResetFieldAppearance(pFormField, sValue, TRUE); |
2611 { | 2562 else |
2612 OnValidate(pFormField, csValue, bRC); | 2563 this->ResetFieldAppearance(pFormField, NULL, TRUE); |
2613 if (bRC) | 2564 this->UpdateField(pFormField); |
2614 return 1; | 2565 } |
2615 else | 2566 |
2616 return -1; | 2567 return 0; |
2617 } | 2568 } |
2618 else | 2569 |
2619 return -1; | 2570 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, |
2620 } | 2571 CFX_WideString& csValue) { |
2621 else | 2572 ASSERT(pField != NULL); |
2622 return 0; | 2573 |
2623 } | 2574 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2624 | 2575 |
2625 int CPDFSDK_InterForm::AfterValueChange(const CPDF_FormField* pField) | 2576 int nType = pFormField->GetFieldType(); |
2626 { | 2577 if (nType == FIELDTYPE_LISTBOX) { |
2627 ASSERT(pField != NULL); | 2578 FX_BOOL bRC = TRUE; |
2628 | 2579 OnKeyStrokeCommit(pFormField, csValue, bRC); |
2629 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2580 if (bRC) { |
2630 int nType = pFormField->GetFieldType(); | 2581 OnValidate(pFormField, csValue, bRC); |
2631 | 2582 if (bRC) |
2632 if (nType == FIELDTYPE_COMBOBOX || nType == FIELDTYPE_TEXTFIELD) | 2583 return 1; |
2633 { | 2584 else |
2634 this->OnCalculate(pFormField); | 2585 return -1; |
2635 FX_BOOL bFormated = FALSE; | 2586 } else |
2636 CFX_WideString sValue = this->OnFormat(pFormField, 0, bFormated)
; | 2587 return -1; |
2637 if (bFormated) | 2588 } else |
2638 this->ResetFieldAppearance(pFormField, sValue, TRUE); | 2589 return 0; |
2639 else | 2590 } |
2640 this->ResetFieldAppearance(pFormField, NULL, TRUE); | 2591 |
2641 this->UpdateField(pFormField); | 2592 int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) { |
2642 } | 2593 ASSERT(pField != NULL); |
2643 | 2594 |
2644 return 0; | 2595 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2645 } | 2596 int nType = pFormField->GetFieldType(); |
2646 | 2597 |
2647 int CPDFSDK_InterForm::BeforeSelectionChange(const CPDF_FormField* pField, C
FX_WideString& csValue) | 2598 if (nType == FIELDTYPE_LISTBOX) { |
2648 { | 2599 this->OnCalculate(pFormField); |
2649 ASSERT(pField != NULL); | 2600 this->ResetFieldAppearance(pFormField, NULL, TRUE); |
2650 | 2601 this->UpdateField(pFormField); |
2651 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2602 } |
2652 | 2603 |
2653 int nType = pFormField->GetFieldType(); | 2604 return 0; |
2654 if (nType == FIELDTYPE_LISTBOX) | 2605 } |
2655 { | 2606 |
2656 FX_BOOL bRC = TRUE; | 2607 int CPDFSDK_InterForm::AfterCheckedStatusChange( |
2657 OnKeyStrokeCommit(pFormField, csValue, bRC); | 2608 const CPDF_FormField* pField, |
2658 if (bRC) | 2609 const CFX_ByteArray& statusArray) { |
2659 { | 2610 ASSERT(pField != NULL); |
2660 OnValidate(pFormField, csValue, bRC); | 2611 |
2661 if (bRC) | 2612 CPDF_FormField* pFormField = (CPDF_FormField*)pField; |
2662 return 1; | 2613 int nType = pFormField->GetFieldType(); |
2663 else | 2614 |
2664 return -1; | 2615 if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) { |
2665 } | 2616 this->OnCalculate(pFormField); |
2666 else | 2617 // this->ResetFieldAppearance(pFormField, NULL); |
2667 return -1; | 2618 this->UpdateField(pFormField); |
2668 } | 2619 } |
2669 else | 2620 |
2670 return 0; | 2621 return 0; |
2671 } | 2622 } |
2672 | 2623 |
2673 int CPDFSDK_InterForm::AfterSelectionChange(const CPDF_FormField* pField) | 2624 int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm) { |
2674 { | 2625 return 0; |
2675 ASSERT(pField != NULL); | 2626 } |
2676 | 2627 |
2677 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2628 int CPDFSDK_InterForm::AfterFormReset(const CPDF_InterForm* pForm) { |
2678 int nType = pFormField->GetFieldType(); | 2629 this->OnCalculate(NULL); |
2679 | 2630 |
2680 if (nType == FIELDTYPE_LISTBOX) | 2631 return 0; |
2681 { | 2632 } |
2682 this->OnCalculate(pFormField); | 2633 |
2683 this->ResetFieldAppearance(pFormField, NULL, TRUE); | 2634 int CPDFSDK_InterForm::BeforeFormImportData(const CPDF_InterForm* pForm) { |
2684 this->UpdateField(pFormField); | 2635 return 0; |
2685 } | 2636 } |
2686 | 2637 |
2687 return 0; | 2638 int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) { |
2688 } | 2639 this->OnCalculate(NULL); |
2689 | 2640 |
2690 int CPDFSDK_InterForm::AfterCheckedStatusChange(const CPDF_FormField* pField
, const CFX_ByteArray& statusArray) | 2641 return 0; |
2691 { | 2642 } |
2692 ASSERT(pField != NULL); | 2643 |
2693 | 2644 FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) { |
2694 CPDF_FormField* pFormField = (CPDF_FormField*)pField; | 2645 if (nFieldType < 1 || nFieldType > 6) |
2695 int nType = pFormField->GetFieldType(); | 2646 return FALSE; |
2696 | 2647 return m_bNeedHightlight[nFieldType - 1]; |
2697 if (nType == FIELDTYPE_CHECKBOX || nType == FIELDTYPE_RADIOBUTTON) | 2648 } |
2698 { | 2649 |
2699 this->OnCalculate(pFormField); | 2650 void CPDFSDK_InterForm::RemoveAllHighLight() { |
2700 //this->ResetFieldAppearance(pFormField, NULL); | 2651 memset((void*)m_bNeedHightlight, 0, 6 * sizeof(FX_BOOL)); |
2701 this->UpdateField(pFormField); | 2652 } |
2702 } | 2653 void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) { |
2703 | 2654 if (nFieldType < 0 || nFieldType > 6) |
2704 return 0; | 2655 return; |
2705 } | 2656 switch (nFieldType) { |
2706 | 2657 case 0: { |
2707 int CPDFSDK_InterForm::BeforeFormReset(const CPDF_InterForm* pForm) | 2658 for (int i = 0; i < 6; i++) { |
2708 { | 2659 m_aHighlightColor[i] = clr; |
2709 return 0; | 2660 m_bNeedHightlight[i] = TRUE; |
2710 } | 2661 } |
2711 | 2662 break; |
2712 int CPDFSDK_InterForm::AfterFormReset(const CPDF_InterForm* pForm) | 2663 } |
2713 { | 2664 default: { |
2714 this->OnCalculate(NULL); | 2665 m_aHighlightColor[nFieldType - 1] = clr; |
2715 | 2666 m_bNeedHightlight[nFieldType - 1] = TRUE; |
2716 return 0; | 2667 break; |
2717 } | 2668 } |
2718 | 2669 } |
2719 int CPDFSDK_InterForm::BeforeFormImportData(const CPDF_InterForm* pForm) | 2670 } |
2720 { | 2671 |
2721 return 0; | 2672 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) { |
2722 } | 2673 if (nFieldType < 0 || nFieldType > 6) |
2723 | 2674 return FXSYS_RGB(255, 255, 255); |
2724 int CPDFSDK_InterForm::AfterFormImportData(const CPDF_InterForm* pForm) | 2675 if (nFieldType == 0) |
2725 { | 2676 return m_aHighlightColor[0]; |
2726 this->OnCalculate(NULL); | 2677 else |
2727 | 2678 return m_aHighlightColor[nFieldType - 1]; |
2728 return 0; | |
2729 } | |
2730 | |
2731 FX_BOOL CPDFSDK_InterForm::IsNeedHighLight(int nFieldType) | |
2732 { | |
2733 if(nFieldType <1 || nFieldType > 6) | |
2734 return FALSE; | |
2735 return m_bNeedHightlight[nFieldType-1]; | |
2736 } | |
2737 | |
2738 void CPDFSDK_InterForm::RemoveAllHighLight() | |
2739 { | |
2740 memset((void*)m_bNeedHightlight, 0, 6*sizeof(FX_BOOL)); | |
2741 } | |
2742 void CPDFSDK_InterForm::SetHighlightColor(FX_COLORREF clr, int nFieldType) | |
2743 { | |
2744 if(nFieldType <0 || nFieldType > 6) return; | |
2745 switch(nFieldType) | |
2746 { | |
2747 case 0: | |
2748 { | |
2749 for(int i=0; i<6; i++) | |
2750 { | |
2751 m_aHighlightColor[i] = clr; | |
2752 m_bNeedHightlight[i] = TRUE; | |
2753 } | |
2754 break; | |
2755 } | |
2756 default: | |
2757 { | |
2758 m_aHighlightColor[nFieldType-1] = clr; | |
2759 m_bNeedHightlight[nFieldType-1] = TRUE; | |
2760 break; | |
2761 } | |
2762 } | |
2763 | |
2764 } | |
2765 | |
2766 FX_COLORREF CPDFSDK_InterForm::GetHighlightColor(int nFieldType) | |
2767 { | |
2768 if(nFieldType <0 || nFieldType >6) return FXSYS_RGB(255,255,255); | |
2769 if(nFieldType == 0) | |
2770 return m_aHighlightColor[0]; | |
2771 else | |
2772 return m_aHighlightColor[nFieldType-1]; | |
2773 } | 2679 } |
2774 | 2680 |
2775 /* ------------------------- CBA_AnnotIterator ------------------------- */ | 2681 /* ------------------------- CBA_AnnotIterator ------------------------- */ |
2776 | 2682 |
2777 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, const CFX_Byte
String& sType, const CFX_ByteString& sSubType) | 2683 CBA_AnnotIterator::CBA_AnnotIterator(CPDFSDK_PageView* pPageView, |
2778 :m_pPageView(pPageView), | 2684 const CFX_ByteString& sType, |
2779 m_sType(sType), | 2685 const CFX_ByteString& sSubType) |
2780 m_sSubType(sSubType), | 2686 : m_pPageView(pPageView), |
2781 m_nTabs(BAI_STRUCTURE) | 2687 m_sType(sType), |
2782 { | 2688 m_sSubType(sSubType), |
2783 ASSERT(m_pPageView != NULL); | 2689 m_nTabs(BAI_STRUCTURE) { |
2784 | 2690 ASSERT(m_pPageView != NULL); |
2785 CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); | 2691 |
2786 ASSERT(pPDFPage != NULL); | 2692 CPDF_Page* pPDFPage = m_pPageView->GetPDFPage(); |
2787 ASSERT(pPDFPage->m_pFormDict != NULL); | 2693 ASSERT(pPDFPage != NULL); |
2788 | 2694 ASSERT(pPDFPage->m_pFormDict != NULL); |
2789 CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs"); | 2695 |
2790 | 2696 CFX_ByteString sTabs = pPDFPage->m_pFormDict->GetString("Tabs"); |
2791 if (sTabs == "R") | 2697 |
2792 { | 2698 if (sTabs == "R") { |
2793 m_nTabs = BAI_ROW; | 2699 m_nTabs = BAI_ROW; |
2794 } | 2700 } else if (sTabs == "C") { |
2795 else if (sTabs == "C") | 2701 m_nTabs = BAI_COLUMN; |
2796 { | 2702 } else { |
2797 m_nTabs = BAI_COLUMN; | 2703 m_nTabs = BAI_STRUCTURE; |
2798 } | 2704 } |
2799 else | 2705 |
2800 { | 2706 GenerateResults(); |
2801 m_nTabs = BAI_STRUCTURE; | 2707 } |
2802 } | 2708 |
2803 | 2709 CBA_AnnotIterator::~CBA_AnnotIterator() { |
2804 GenerateResults(); | 2710 m_Annots.RemoveAll(); |
2805 } | 2711 } |
2806 | 2712 |
2807 CBA_AnnotIterator::~CBA_AnnotIterator() | 2713 CPDFSDK_Annot* CBA_AnnotIterator::GetFirstAnnot() { |
2808 { | 2714 if (m_Annots.GetSize() > 0) |
2809 m_Annots.RemoveAll(); | 2715 return m_Annots[0]; |
2810 } | 2716 |
2811 | 2717 return NULL; |
2812 CPDFSDK_Annot* CBA_AnnotIterator::GetFirstAnnot() | 2718 } |
2813 { | 2719 |
2814 if (m_Annots.GetSize() > 0) | 2720 CPDFSDK_Annot* CBA_AnnotIterator::GetLastAnnot() { |
2815 return m_Annots[0]; | 2721 if (m_Annots.GetSize() > 0) |
2816 | 2722 return m_Annots[m_Annots.GetSize() - 1]; |
2817 return NULL; | 2723 |
2818 } | 2724 return NULL; |
2819 | 2725 } |
2820 CPDFSDK_Annot* CBA_AnnotIterator::GetLastAnnot() | 2726 |
2821 { | 2727 CPDFSDK_Annot* CBA_AnnotIterator::GetNextAnnot(CPDFSDK_Annot* pAnnot) { |
2822 if (m_Annots.GetSize() > 0) | 2728 for (int i = 0, sz = m_Annots.GetSize(); i < sz; i++) { |
2823 return m_Annots[m_Annots.GetSize() - 1]; | 2729 if (m_Annots[i] == pAnnot) { |
2824 | 2730 if (i + 1 < sz) |
2825 return NULL; | 2731 return m_Annots[i + 1]; |
2826 } | 2732 else |
2827 | 2733 return m_Annots[0]; |
2828 CPDFSDK_Annot* CBA_AnnotIterator::GetNextAnnot(CPDFSDK_Annot* pAnnot) | 2734 } |
2829 { | 2735 } |
2830 for (int i=0,sz=m_Annots.GetSize(); i<sz; i++) | 2736 |
2831 { | 2737 return NULL; |
2832 if (m_Annots[i] == pAnnot) | 2738 } |
2833 { | 2739 |
2834 if (i+1 < sz) | 2740 CPDFSDK_Annot* CBA_AnnotIterator::GetPrevAnnot(CPDFSDK_Annot* pAnnot) { |
2835 return m_Annots[i+1]; | 2741 for (int i = 0, sz = m_Annots.GetSize(); i < sz; i++) { |
2836 else | 2742 if (m_Annots[i] == pAnnot) { |
2837 return m_Annots[0]; | 2743 if (i - 1 >= 0) |
2838 } | 2744 return m_Annots[i - 1]; |
2839 } | 2745 else |
2840 | 2746 return m_Annots[sz - 1]; |
2841 return NULL; | 2747 } |
2842 } | 2748 } |
2843 | 2749 |
2844 CPDFSDK_Annot* CBA_AnnotIterator::GetPrevAnnot(CPDFSDK_Annot* pAnnot) | 2750 return NULL; |
2845 { | 2751 } |
2846 for (int i=0,sz=m_Annots.GetSize(); i<sz; i++) | 2752 |
2847 { | 2753 int CBA_AnnotIterator::CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
2848 if (m_Annots[i] == pAnnot) | 2754 ASSERT(p1 != NULL); |
2849 { | 2755 ASSERT(p2 != NULL); |
2850 if (i-1 >= 0) | 2756 |
2851 return m_Annots[i-1]; | 2757 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); |
2852 else | 2758 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); |
2853 return m_Annots[sz-1]; | 2759 |
2854 } | 2760 if (rcAnnot1.left < rcAnnot2.left) |
2855 } | 2761 return -1; |
2856 | 2762 if (rcAnnot1.left > rcAnnot2.left) |
2857 return NULL; | 2763 return 1; |
2858 } | 2764 return 0; |
2859 | 2765 } |
2860 int CBA_AnnotIterator::CompareByLeft(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) | 2766 |
2861 { | 2767 int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) { |
2862 ASSERT(p1 != NULL); | 2768 ASSERT(p1 != NULL); |
2863 ASSERT(p2 != NULL); | 2769 ASSERT(p2 != NULL); |
2864 | 2770 |
2865 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); | 2771 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); |
2866 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); | 2772 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); |
2867 | 2773 |
2868 if (rcAnnot1.left < rcAnnot2.left) | 2774 if (rcAnnot1.top < rcAnnot2.top) |
2869 return -1; | 2775 return -1; |
2870 if (rcAnnot1.left > rcAnnot2.left) | 2776 if (rcAnnot1.top > rcAnnot2.top) |
2871 return 1; | 2777 return 1; |
2872 return 0; | 2778 return 0; |
2873 } | 2779 } |
2874 | 2780 |
2875 | 2781 void CBA_AnnotIterator::GenerateResults() { |
2876 int CBA_AnnotIterator::CompareByTop(CPDFSDK_Annot* p1, CPDFSDK_Annot* p2) | 2782 ASSERT(m_pPageView != NULL); |
2877 { | 2783 |
2878 ASSERT(p1 != NULL); | 2784 switch (m_nTabs) { |
2879 ASSERT(p2 != NULL); | 2785 case BAI_STRUCTURE: { |
2880 | 2786 for (int i = 0, sz = m_pPageView->CountAnnots(); i < sz; i++) { |
2881 CPDF_Rect rcAnnot1 = GetAnnotRect(p1); | 2787 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); |
2882 CPDF_Rect rcAnnot2 = GetAnnotRect(p2); | 2788 ASSERT(pAnnot != NULL); |
2883 | 2789 |
2884 if (rcAnnot1.top < rcAnnot2.top) | 2790 if (pAnnot->GetType() == m_sType && pAnnot->GetSubType() == m_sSubType) |
2885 return -1; | 2791 m_Annots.Add(pAnnot); |
2886 if (rcAnnot1.top > rcAnnot2.top) | 2792 } |
2887 return 1; | 2793 } break; |
2888 return 0; | 2794 case BAI_ROW: { |
2889 } | 2795 CPDFSDK_SortAnnots sa; |
2890 | 2796 |
2891 void CBA_AnnotIterator::GenerateResults() | 2797 { |
2892 { | 2798 for (int i = 0, sz = m_pPageView->CountAnnots(); i < sz; i++) { |
2893 ASSERT(m_pPageView != NULL); | 2799 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); |
2894 | 2800 ASSERT(pAnnot != NULL); |
2895 switch (m_nTabs) | 2801 |
2896 { | 2802 if (pAnnot->GetType() == m_sType && |
2897 case BAI_STRUCTURE: | 2803 pAnnot->GetSubType() == m_sSubType) |
2898 { | 2804 sa.Add(pAnnot); |
2899 for (int i=0,sz=m_pPageView->CountAnnots(); i<sz; i++) | 2805 } |
2900 { | 2806 } |
2901 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i)
; | 2807 |
2902 ASSERT(pAnnot != NULL); | 2808 if (sa.GetSize() > 0) { |
2903 | 2809 sa.Sort(CBA_AnnotIterator::CompareByLeft); |
2904 if (pAnnot->GetType() == m_sType | 2810 } |
2905 && pAnnot->GetSubType() == m_sSubType) | 2811 |
2906 m_Annots.Add(pAnnot); | 2812 while (sa.GetSize() > 0) { |
2907 } | 2813 int nLeftTopIndex = -1; |
2908 } | 2814 |
2909 break; | 2815 { |
2910 case BAI_ROW: | 2816 FX_FLOAT fTop = 0.0f; |
2911 { | 2817 |
2912 CPDFSDK_SortAnnots sa; | 2818 for (int i = sa.GetSize() - 1; i >= 0; i--) { |
2913 | 2819 CPDFSDK_Annot* pAnnot = sa.GetAt(i); |
2914 { | 2820 ASSERT(pAnnot != NULL); |
2915 | 2821 |
2916 for (int i=0,sz=m_pPageView->CountAnnots(); i<sz
; i++) | 2822 CPDF_Rect rcAnnot = GetAnnotRect(pAnnot); |
2917 { | 2823 |
2918 CPDFSDK_Annot* pAnnot = m_pPageView->Get
Annot(i); | 2824 if (rcAnnot.top > fTop) { |
2919 ASSERT(pAnnot != NULL); | 2825 nLeftTopIndex = i; |
2920 | 2826 fTop = rcAnnot.top; |
2921 if (pAnnot->GetType() == m_sType | 2827 } |
2922 && pAnnot->GetSubType() == m_sSu
bType) | 2828 } |
2923 sa.Add(pAnnot); | 2829 } |
2924 } | 2830 |
2925 } | 2831 if (nLeftTopIndex >= 0) { |
2926 | 2832 CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(nLeftTopIndex); |
2927 if (sa.GetSize() > 0) | 2833 ASSERT(pLeftTopAnnot != NULL); |
2928 { | 2834 |
2929 sa.Sort(CBA_AnnotIterator::CompareByLeft); | 2835 CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot); |
2930 } | 2836 |
2931 | 2837 m_Annots.Add(pLeftTopAnnot); |
2932 while (sa.GetSize() > 0) | 2838 sa.RemoveAt(nLeftTopIndex); |
2933 { | 2839 |
2934 int nLeftTopIndex = -1; | 2840 CFX_ArrayTemplate<int> aSelect; |
2935 | 2841 |
2936 { | 2842 { |
2937 FX_FLOAT fTop = 0.0f; | 2843 for (int i = 0, sz = sa.GetSize(); i < sz; i++) { |
2938 | 2844 CPDFSDK_Annot* pAnnot = sa.GetAt(i); |
2939 for (int i=sa.GetSize()-1; i>=0; i--) | 2845 ASSERT(pAnnot != NULL); |
2940 { | 2846 |
2941 CPDFSDK_Annot* pAnnot = sa.GetAt
(i); | 2847 CPDF_Rect rcAnnot = GetAnnotRect(pAnnot); |
2942 ASSERT(pAnnot != NULL); | 2848 |
2943 | 2849 FX_FLOAT fCenterY = (rcAnnot.top + rcAnnot.bottom) / 2.0f; |
2944 CPDF_Rect rcAnnot = GetAnnotRect
(pAnnot); | 2850 |
2945 | 2851 if (fCenterY > rcLeftTop.bottom && fCenterY < rcLeftTop.top) |
2946 if (rcAnnot.top > fTop) | 2852 aSelect.Add(i); |
2947 { | 2853 } |
2948 nLeftTopIndex = i; | 2854 } |
2949 fTop = rcAnnot.top; | 2855 |
2950 } | 2856 { |
2951 } | 2857 for (int i = 0, sz = aSelect.GetSize(); i < sz; i++) { |
2952 } | 2858 m_Annots.Add(sa[aSelect[i]]); |
2953 | 2859 } |
2954 if (nLeftTopIndex >= 0) | 2860 } |
2955 { | 2861 |
2956 CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(
nLeftTopIndex); | 2862 { |
2957 ASSERT(pLeftTopAnnot != NULL); | 2863 for (int i = aSelect.GetSize() - 1; i >= 0; i--) { |
2958 | 2864 sa.RemoveAt(aSelect[i]); |
2959 CPDF_Rect rcLeftTop = GetAnnotRect(pLeft
TopAnnot); | 2865 } |
2960 | 2866 } |
2961 m_Annots.Add(pLeftTopAnnot); | 2867 |
2962 sa.RemoveAt(nLeftTopIndex); | 2868 aSelect.RemoveAll(); |
2963 | 2869 } |
2964 CFX_ArrayTemplate<int> aSelect; | 2870 } |
2965 | 2871 sa.RemoveAll(); |
2966 { | 2872 } break; |
2967 for (int i=0,sz=sa.GetSize(); i<
sz; i++) | 2873 case BAI_COLUMN: { |
2968 { | 2874 CPDFSDK_SortAnnots sa; |
2969 CPDFSDK_Annot* pAnnot =
sa.GetAt(i); | 2875 |
2970 ASSERT(pAnnot != NULL); | 2876 { |
2971 | 2877 for (int i = 0, sz = m_pPageView->CountAnnots(); i < sz; i++) { |
2972 CPDF_Rect rcAnnot = GetA
nnotRect(pAnnot); | 2878 CPDFSDK_Annot* pAnnot = m_pPageView->GetAnnot(i); |
2973 | 2879 ASSERT(pAnnot != NULL); |
2974 FX_FLOAT fCenterY = (rcA
nnot.top + rcAnnot.bottom) / 2.0f; | 2880 |
2975 | 2881 if (pAnnot->GetType() == m_sType && |
2976 if (fCenterY > rcLeftTop
.bottom && fCenterY < rcLeftTop.top) | 2882 pAnnot->GetSubType() == m_sSubType) |
2977 aSelect.Add(i); | 2883 sa.Add(pAnnot); |
2978 } | 2884 } |
2979 } | 2885 } |
2980 | 2886 |
2981 { | 2887 if (sa.GetSize() > 0) { |
2982 for (int i=0,sz=aSelect.GetSize(
); i<sz; i++) | 2888 sa.Sort(CBA_AnnotIterator::CompareByTop, FALSE); |
2983 { | 2889 } |
2984 m_Annots.Add(sa[aSelect[
i]]); | 2890 |
2985 } | 2891 while (sa.GetSize() > 0) { |
2986 } | 2892 int nLeftTopIndex = -1; |
2987 | 2893 |
2988 { | 2894 { |
2989 for (int i=aSelect.GetSize()-1;
i>=0; i--) | 2895 FX_FLOAT fLeft = -1.0f; |
2990 { | 2896 |
2991 sa.RemoveAt(aSelect[i]); | 2897 for (int i = sa.GetSize() - 1; i >= 0; i--) { |
2992 } | 2898 CPDFSDK_Annot* pAnnot = sa.GetAt(i); |
2993 } | 2899 ASSERT(pAnnot != NULL); |
2994 | 2900 |
2995 aSelect.RemoveAll(); | 2901 CPDF_Rect rcAnnot = GetAnnotRect(pAnnot); |
2996 } | 2902 |
2997 } | 2903 if (fLeft < 0) { |
2998 sa.RemoveAll(); | 2904 nLeftTopIndex = 0; |
2999 } | 2905 fLeft = rcAnnot.left; |
3000 break; | 2906 } else if (rcAnnot.left < fLeft) { |
3001 case BAI_COLUMN: | 2907 nLeftTopIndex = i; |
3002 { | 2908 fLeft = rcAnnot.left; |
3003 CPDFSDK_SortAnnots sa; | 2909 } |
3004 | 2910 } |
3005 { | 2911 } |
3006 for (int i=0,sz=m_pPageView->CountAnnots(); i<sz
; i++) | 2912 |
3007 { | 2913 if (nLeftTopIndex >= 0) { |
3008 CPDFSDK_Annot* pAnnot = m_pPageView->Get
Annot(i); | 2914 CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(nLeftTopIndex); |
3009 ASSERT(pAnnot != NULL); | 2915 ASSERT(pLeftTopAnnot != NULL); |
3010 | 2916 |
3011 if (pAnnot->GetType() == m_sType | 2917 CPDF_Rect rcLeftTop = GetAnnotRect(pLeftTopAnnot); |
3012 && pAnnot->GetSubType() == m_sSu
bType) | 2918 |
3013 sa.Add(pAnnot); | 2919 m_Annots.Add(pLeftTopAnnot); |
3014 } | 2920 sa.RemoveAt(nLeftTopIndex); |
3015 } | 2921 |
3016 | 2922 CFX_ArrayTemplate<int> aSelect; |
3017 if (sa.GetSize() > 0) | 2923 |
3018 { | 2924 { |
3019 sa.Sort(CBA_AnnotIterator::CompareByTop, FALSE); | 2925 for (int i = 0, sz = sa.GetSize(); i < sz; i++) { |
3020 } | 2926 CPDFSDK_Annot* pAnnot = sa.GetAt(i); |
3021 | 2927 ASSERT(pAnnot != NULL); |
3022 while (sa.GetSize() > 0) | 2928 |
3023 { | 2929 CPDF_Rect rcAnnot = GetAnnotRect(pAnnot); |
3024 int nLeftTopIndex = -1; | 2930 |
3025 | 2931 FX_FLOAT fCenterX = (rcAnnot.left + rcAnnot.right) / 2.0f; |
3026 { | 2932 |
3027 FX_FLOAT fLeft = -1.0f; | 2933 if (fCenterX > rcLeftTop.left && fCenterX < rcLeftTop.right) |
3028 | 2934 aSelect.Add(i); |
3029 for (int i=sa.GetSize()-1; i>=0; i--) | 2935 } |
3030 { | 2936 } |
3031 CPDFSDK_Annot* pAnnot = sa.GetAt
(i); | 2937 |
3032 ASSERT(pAnnot != NULL); | 2938 { |
3033 | 2939 for (int i = 0, sz = aSelect.GetSize(); i < sz; i++) { |
3034 CPDF_Rect rcAnnot = GetAnnotRect
(pAnnot); | 2940 m_Annots.Add(sa[aSelect[i]]); |
3035 | 2941 } |
3036 if (fLeft < 0) | 2942 } |
3037 { | 2943 |
3038 nLeftTopIndex = 0; | 2944 { |
3039 fLeft = rcAnnot.left; | 2945 for (int i = aSelect.GetSize() - 1; i >= 0; i--) { |
3040 } | 2946 sa.RemoveAt(aSelect[i]); |
3041 else if (rcAnnot.left < fLeft) | 2947 } |
3042 { | 2948 } |
3043 nLeftTopIndex = i; | 2949 |
3044 fLeft = rcAnnot.left; | 2950 aSelect.RemoveAll(); |
3045 } | 2951 } |
3046 } | 2952 } |
3047 } | 2953 sa.RemoveAll(); |
3048 | 2954 } break; |
3049 if (nLeftTopIndex >= 0) | 2955 } |
3050 { | 2956 } |
3051 CPDFSDK_Annot* pLeftTopAnnot = sa.GetAt(
nLeftTopIndex); | 2957 |
3052 ASSERT(pLeftTopAnnot != NULL); | 2958 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) { |
3053 | 2959 ASSERT(pAnnot != NULL); |
3054 CPDF_Rect rcLeftTop = GetAnnotRect(pLeft
TopAnnot); | 2960 |
3055 | 2961 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
3056 m_Annots.Add(pLeftTopAnnot); | 2962 ASSERT(pPDFAnnot != NULL); |
3057 sa.RemoveAt(nLeftTopIndex); | 2963 |
3058 | 2964 CPDF_Rect rcAnnot; |
3059 CFX_ArrayTemplate<int> aSelect; | 2965 pPDFAnnot->GetRect(rcAnnot); |
3060 | 2966 |
3061 { | 2967 return rcAnnot; |
3062 for (int i=0,sz=sa.GetSize(); i<
sz; i++) | 2968 } |
3063 { | |
3064 CPDFSDK_Annot* pAnnot =
sa.GetAt(i); | |
3065 ASSERT(pAnnot != NULL); | |
3066 | |
3067 CPDF_Rect rcAnnot = GetA
nnotRect(pAnnot); | |
3068 | |
3069 FX_FLOAT fCenterX = (rcA
nnot.left + rcAnnot.right) / 2.0f; | |
3070 | |
3071 if (fCenterX > rcLeftTop
.left && fCenterX < rcLeftTop.right) | |
3072 aSelect.Add(i); | |
3073 } | |
3074 } | |
3075 | |
3076 { | |
3077 for (int i=0,sz=aSelect.GetSize(
); i<sz; i++) | |
3078 { | |
3079 m_Annots.Add(sa[aSelect[
i]]); | |
3080 } | |
3081 } | |
3082 | |
3083 { | |
3084 for (int i=aSelect.GetSize()-1;
i>=0; i--) | |
3085 { | |
3086 sa.RemoveAt(aSelect[i]); | |
3087 } | |
3088 } | |
3089 | |
3090 aSelect.RemoveAll(); | |
3091 } | |
3092 } | |
3093 sa.RemoveAll(); | |
3094 } | |
3095 break; | |
3096 } | |
3097 } | |
3098 | |
3099 CPDF_Rect CBA_AnnotIterator::GetAnnotRect(CPDFSDK_Annot* pAnnot) | |
3100 { | |
3101 ASSERT(pAnnot != NULL); | |
3102 | |
3103 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | |
3104 ASSERT(pPDFAnnot != NULL); | |
3105 | |
3106 CPDF_Rect rcAnnot; | |
3107 pPDFAnnot->GetRect(rcAnnot); | |
3108 | |
3109 return rcAnnot; | |
3110 } | |
3111 | |
OLD | NEW |