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

Side by Side Diff: fpdfsdk/src/fsdk_baseform.cpp

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

Powered by Google App Engine
This is Rietveld 408576698