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

Side by Side Diff: fpdfsdk/src/javascript/Field.cpp

Issue 1108903002: Merge to XFA: Reduce usage of operator LPCWSTR from CFX_WideString(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 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/javascript/Document.cpp ('k') | fpdfsdk/src/javascript/JS_Context.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 "../../include/javascript/JavaScript.h" 7 #include "../../include/javascript/JavaScript.h"
8 #include "../../include/javascript/IJavaScript.h" 8 #include "../../include/javascript/IJavaScript.h"
9 #include "../../include/javascript/JS_Define.h" 9 #include "../../include/javascript/JS_Define.h"
10 #include "../../include/javascript/JS_Object.h" 10 #include "../../include/javascript/JS_Object.h"
11 #include "../../include/javascript/JS_Value.h" 11 #include "../../include/javascript/JS_Value.h"
12 #include "../../include/javascript/Field.h" 12 #include "../../include/javascript/Field.h"
13 #include "../../include/javascript/JS_EventHandler.h" 13 #include "../../include/javascript/JS_EventHandler.h"
14 //#include "../include/JS_ResMgr.h"
15 #include "../../include/javascript/JS_Context.h" 14 #include "../../include/javascript/JS_Context.h"
16 #include "../../include/javascript/JS_Runtime.h" 15 #include "../../include/javascript/JS_Runtime.h"
17 #include "../../include/javascript/Document.h" 16 #include "../../include/javascript/Document.h"
18 #include "../../include/javascript/color.h" 17 #include "../../include/javascript/color.h"
19 #include "../../include/javascript/PublicMethods.h" 18 #include "../../include/javascript/PublicMethods.h"
20 #include "../../include/javascript/Icon.h" 19 #include "../../include/javascript/Icon.h"
21 20
22 21
23 /* ---------------------- Field ---------------------- */ 22 /* ---------------------- Field ---------------------- */
24 23
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_ TEXTFIELD) 251 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FIELDTYPE_ TEXTFIELD)
253 { 252 {
254 for (int i=0,sz=widgets.GetSize(); i<sz; i++) 253 for (int i=0,sz=widgets.GetSize(); i<sz; i++)
255 { 254 {
256 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widge ts.GetAt(i); 255 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widge ts.GetAt(i);
257 ASSERT(pWidget != NULL); 256 ASSERT(pWidget != NULL);
258 257
259 FX_BOOL bFormated = FALSE; 258 FX_BOOL bFormated = FALSE;
260 CFX_WideString sValue = pWidget->OnFormat(0, bFo rmated); 259 CFX_WideString sValue = pWidget->OnFormat(0, bFo rmated);
261 if (bFormated) 260 if (bFormated)
262 » » » » » pWidget->ResetAppearance(sValue, FALSE); 261 » » » » » pWidget->ResetAppearance(sValue.c_str(), FALSE);
263 else 262 else
264 pWidget->ResetAppearance(NULL, FALSE); 263 pWidget->ResetAppearance(NULL, FALSE);
265 } 264 }
266 } 265 }
267 else 266 else
268 { 267 {
269 for (int i=0,sz=widgets.GetSize(); i<sz; i++) 268 for (int i=0,sz=widgets.GetSize(); i<sz; i++)
270 { 269 {
271 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widge ts.GetAt(i); 270 CPDFSDK_Widget* pWidget = (CPDFSDK_Widget*)widge ts.GetAt(i);
272 ASSERT(pWidget != NULL); 271 ASSERT(pWidget != NULL);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 if (pWidget) 308 if (pWidget)
310 { 309 {
311 if (bResetAP) 310 if (bResetAP)
312 { 311 {
313 int nFieldType = pWidget->GetFieldType(); 312 int nFieldType = pWidget->GetFieldType();
314 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FI ELDTYPE_TEXTFIELD) 313 if (nFieldType == FIELDTYPE_COMBOBOX || nFieldType == FI ELDTYPE_TEXTFIELD)
315 { 314 {
316 FX_BOOL bFormated = FALSE; 315 FX_BOOL bFormated = FALSE;
317 CFX_WideString sValue = pWidget->OnFormat(0, bFo rmated); 316 CFX_WideString sValue = pWidget->OnFormat(0, bFo rmated);
318 if (bFormated) 317 if (bFormated)
319 » » » » » pWidget->ResetAppearance(sValue, FALSE); 318 » » » » » pWidget->ResetAppearance(sValue.c_str(), FALSE);
320 else 319 else
321 pWidget->ResetAppearance(NULL, FALSE); 320 pWidget->ResetAppearance(NULL, FALSE);
322 } 321 }
323 else 322 else
324 { 323 {
325 pWidget->ResetAppearance(NULL, FALSE); 324 pWidget->ResetAppearance(NULL, FALSE);
326 } 325 }
327 } 326 }
328 327
329 if (bRefresh) 328 if (bRefresh)
(...skipping 2790 matching lines...) Expand 10 before | Expand all | Expand 10 after
3120 { 3119 {
3121 case FIELDTYPE_PUSHBUTTON: 3120 case FIELDTYPE_PUSHBUTTON:
3122 return FALSE; 3121 return FALSE;
3123 case FIELDTYPE_COMBOBOX: 3122 case FIELDTYPE_COMBOBOX:
3124 case FIELDTYPE_TEXTFIELD: 3123 case FIELDTYPE_TEXTFIELD:
3125 { 3124 {
3126 CFX_WideString swValue = pFormField->GetValue(); 3125 CFX_WideString swValue = pFormField->GetValue();
3127 3126
3128 double dRet; 3127 double dRet;
3129 FX_BOOL bDot; 3128 FX_BOOL bDot;
3130 » » » » if (CJS_PublicMethods::ConvertStringToNumber(swV alue,dRet,bDot)) 3129 » » » » if (CJS_PublicMethods::ConvertStringToNumber(swV alue.c_str(), dRet, bDot))
3131 { 3130 {
3132 if (bDot) 3131 if (bDot)
3133 vp << dRet; 3132 vp << dRet;
3134 else 3133 else
3135 vp << dRet; 3134 vp << dRet;
3136 } 3135 }
3137 else 3136 else
3138 vp << swValue; 3137 vp << swValue;
3139 } 3138 }
3140 break; 3139 break;
3141 case FIELDTYPE_LISTBOX: 3140 case FIELDTYPE_LISTBOX:
3142 { 3141 {
3143 if (pFormField->CountSelectedItems() > 1) 3142 if (pFormField->CountSelectedItems() > 1)
3144 { 3143 {
3145 CJS_Array ValueArray(m_isolate); 3144 CJS_Array ValueArray(m_isolate);
3146 CJS_Value ElementValue(m_isolate); 3145 CJS_Value ElementValue(m_isolate);
3147 int iIndex; 3146 int iIndex;
3148 for (int i = 0, sz = pFormField->CountSe lectedItems(); i < sz; i++) 3147 for (int i = 0, sz = pFormField->CountSe lectedItems(); i < sz; i++)
3149 { 3148 {
3150 iIndex = pFormField->GetSelected Index(i); 3149 iIndex = pFormField->GetSelected Index(i);
3151 » » » » » » ElementValue = pFormField->GetOp tionValue(iIndex); 3150 » » » » » » ElementValue = pFormField->GetOp tionValue(iIndex).c_str();
3152 if (FXSYS_wcslen(ElementValue.To CFXWideString().c_str()) == 0) 3151 if (FXSYS_wcslen(ElementValue.To CFXWideString().c_str()) == 0)
3153 » » » » » » » ElementValue = pFormFiel d->GetOptionLabel(iIndex); 3152 » » » » » » » ElementValue = pFormFiel d->GetOptionLabel(iIndex).c_str();
3154 ValueArray.SetElement(i, Element Value); 3153 ValueArray.SetElement(i, Element Value);
3155 } 3154 }
3156 vp << ValueArray; 3155 vp << ValueArray;
3157 } 3156 }
3158 else 3157 else
3159 { 3158 {
3160 CFX_WideString swValue = pFormField->Get Value(); 3159 CFX_WideString swValue = pFormField->Get Value();
3161 3160
3162 double dRet; 3161 double dRet;
3163 FX_BOOL bDot; 3162 FX_BOOL bDot;
3164 » » » » » if (CJS_PublicMethods::ConvertStringToNu mber(swValue,dRet,bDot)) 3163 » » » » » if (CJS_PublicMethods::ConvertStringToNu mber(swValue.c_str(), dRet, bDot))
3165 { 3164 {
3166 if (bDot) 3165 if (bDot)
3167 vp << dRet; 3166 vp << dRet;
3168 else 3167 else
3169 vp << dRet; 3168 vp << dRet;
3170 } 3169 }
3171 else 3170 else
3172 vp << swValue; 3171 vp << swValue;
3173 } 3172 }
3174 } 3173 }
3175 break; 3174 break;
3176 case FIELDTYPE_CHECKBOX: 3175 case FIELDTYPE_CHECKBOX:
3177 case FIELDTYPE_RADIOBUTTON: 3176 case FIELDTYPE_RADIOBUTTON:
3178 { 3177 {
3179 FX_BOOL bFind = FALSE; 3178 FX_BOOL bFind = FALSE;
3180 for (int i = 0 , sz = pFormField->CountControls( ); i < sz; i++) 3179 for (int i = 0 , sz = pFormField->CountControls( ); i < sz; i++)
3181 { 3180 {
3182 if (pFormField->GetControl(i)->IsChecked ()) 3181 if (pFormField->GetControl(i)->IsChecked ())
3183 { 3182 {
3184 CFX_WideString swValue = pFormFi eld->GetControl(i)->GetExportValue(); 3183 CFX_WideString swValue = pFormFi eld->GetControl(i)->GetExportValue();
3185
3186 double dRet; 3184 double dRet;
3187 FX_BOOL bDot; 3185 FX_BOOL bDot;
3188 » » » » » » if (CJS_PublicMethods::ConvertSt ringToNumber(swValue,dRet,bDot)) 3186 » » » » » » if (CJS_PublicMethods::ConvertSt ringToNumber(swValue.c_str(), dRet, bDot))
3189 { 3187 {
3190 if (bDot) 3188 if (bDot)
3191 vp << dRet; 3189 vp << dRet;
3192 else 3190 else
3193 vp << dRet; 3191 vp << dRet;
3194 } 3192 }
3195 else 3193 else
3196 vp << swValue; 3194 vp << swValue;
3197 3195
3198 bFind = TRUE; 3196 bFind = TRUE;
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
3384 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0); 3382 CPDF_FormField* pFormField = (CPDF_FormField*)FieldArray.ElementAt(0);
3385 ASSERT(pFormField != NULL); 3383 ASSERT(pFormField != NULL);
3386 3384
3387 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON) 3385 if (pFormField->GetFieldType() != FIELDTYPE_PUSHBUTTON)
3388 return FALSE; 3386 return FALSE;
3389 3387
3390 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField); 3388 CPDF_FormControl* pFormControl = GetSmartFieldControl(pFormField);
3391 if (!pFormControl)return FALSE; 3389 if (!pFormControl)return FALSE;
3392 3390
3393 if (nface == 0) 3391 if (nface == 0)
3394 » » vRet = pFormControl->GetNormalCaption(); 3392 » » vRet = pFormControl->GetNormalCaption().c_str();
3395 else if (nface == 1) 3393 else if (nface == 1)
3396 » » vRet = pFormControl->GetDownCaption(); 3394 » » vRet = pFormControl->GetDownCaption().c_str();
3397 else if (nface == 2) 3395 else if (nface == 2)
3398 » » vRet = pFormControl->GetRolloverCaption(); 3396 » » vRet = pFormControl->GetRolloverCaption().c_str();
3399 else 3397 else
3400 return FALSE; 3398 return FALSE;
3401 3399
3402 return TRUE; 3400 return TRUE;
3403 } 3401 }
3404 3402
3405 //#pragma warning(disable: 4800) 3403 //#pragma warning(disable: 4800)
3406 3404
3407 FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ S_Value& vRet, CFX_WideString& sError) 3405 FX_BOOL Field::buttonGetIcon(IFXJS_Context* cc, const CJS_Parameters& params, CJ S_Value& vRet, CFX_WideString& sError)
3408 { 3406 {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3678 3676
3679 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX) 3677 if ((pFormField->GetFieldType() == FIELDTYPE_LISTBOX)
3680 || (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX)) 3678 || (pFormField->GetFieldType() == FIELDTYPE_COMBOBOX))
3681 { 3679 {
3682 if (nIdx == -1 || nIdx > pFormField->CountOptions()) 3680 if (nIdx == -1 || nIdx > pFormField->CountOptions())
3683 nIdx = pFormField->CountOptions() -1; 3681 nIdx = pFormField->CountOptions() -1;
3684 if (bExport) 3682 if (bExport)
3685 { 3683 {
3686 CFX_WideString strval = pFormField->GetOptionValue(nIdx) ; 3684 CFX_WideString strval = pFormField->GetOptionValue(nIdx) ;
3687 if (strval.IsEmpty()) 3685 if (strval.IsEmpty())
3688 » » » » vRet = pFormField->GetOptionLabel(nIdx); 3686 » » » » vRet = pFormField->GetOptionLabel(nIdx).c_str();
3689 else 3687 else
3690 » » » » vRet = strval; 3688 » » » » vRet = strval.c_str();
3691 } 3689 }
3692 else 3690 else
3693 » » » vRet = pFormField->GetOptionLabel(nIdx); 3691 » » » vRet = pFormField->GetOptionLabel(nIdx).c_str();
3694 } 3692 }
3695 else 3693 else
3696 return FALSE; 3694 return FALSE;
3697 3695
3698 return TRUE; 3696 return TRUE;
3699 } 3697 }
3700 3698
3701 FX_BOOL Field::getLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, CFX_WideString& sError) 3699 FX_BOOL Field::getLock(IFXJS_Context* cc, const CJS_Parameters& params, CJS_Valu e& vRet, CFX_WideString& sError)
3702 { 3700 {
3703 return FALSE; 3701 return FALSE;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
4108 4106
4109 #define JS_FIELD_MINWIDTH 1 4107 #define JS_FIELD_MINWIDTH 1
4110 #define JS_FIELD_MINHEIGHT 1 4108 #define JS_FIELD_MINHEIGHT 1
4111 4109
4112 void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType , 4110 void Field::AddField(CPDFSDK_Document* pDocument, int nPageIndex, int nFieldType ,
4113 const CFX_WideString& sN ame, const CPDF_Rect& rcCoords) 4111 const CFX_WideString& sN ame, const CPDF_Rect& rcCoords)
4114 { 4112 {
4115 //Not supported. 4113 //Not supported.
4116 } 4114 }
4117 4115
OLDNEW
« no previous file with comments | « fpdfsdk/src/javascript/Document.cpp ('k') | fpdfsdk/src/javascript/JS_Context.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698