OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../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" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 void CPDFSDK_Widget::ClearAppModified() | 342 void CPDFSDK_Widget::ClearAppModified() |
343 { | 343 { |
344 m_bAppModified = FALSE; | 344 m_bAppModified = FALSE; |
345 } | 345 } |
346 | 346 |
347 FX_BOOL CPDFSDK_Widget::IsAppModified() const | 347 FX_BOOL CPDFSDK_Widget::IsAppModified() const |
348 { | 348 { |
349 return m_bAppModified; | 349 return m_bAppModified; |
350 } | 350 } |
351 | 351 |
352 void CPDFSDK_Widget::ResetAppearance(FX_LPCWSTR sValue, FX_BOOL bValueChanged) | 352 void CPDFSDK_Widget::ResetAppearance(const FX_WCHAR* sValue, FX_BOOL bValueChang
ed) |
353 { | 353 { |
354 SetAppModified(); | 354 SetAppModified(); |
355 | 355 |
356 m_nAppAge++; | 356 m_nAppAge++; |
357 if (m_nAppAge > 999999) | 357 if (m_nAppAge > 999999) |
358 m_nAppAge = 0; | 358 m_nAppAge = 0; |
359 if (bValueChanged) | 359 if (bValueChanged) |
360 m_nValueAge++; | 360 m_nValueAge++; |
361 | 361 |
362 int nFieldType = GetFieldType(); | 362 int nFieldType = GetFieldType(); |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off"); | 1017 WriteAppearance("N", GetRotatedRect(), GetMatrix(), csAP_N_OFF, "Off"); |
1018 | 1018 |
1019 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl-
>GetCheckedAPState()); | 1019 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_ON, pControl-
>GetCheckedAPState()); |
1020 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); | 1020 WriteAppearance("D", GetRotatedRect(), GetMatrix(), csAP_D_OFF, "Off"); |
1021 | 1021 |
1022 CFX_ByteString csAS = GetAppState(); | 1022 CFX_ByteString csAS = GetAppState(); |
1023 if (csAS.IsEmpty()) | 1023 if (csAS.IsEmpty()) |
1024 SetAppState("Off"); | 1024 SetAppState("Off"); |
1025 } | 1025 } |
1026 | 1026 |
1027 void CPDFSDK_Widget::ResetAppearance_ComboBox(FX_LPCWSTR sValue) | 1027 void CPDFSDK_Widget::ResetAppearance_ComboBox(const FX_WCHAR* sValue) |
1028 { | 1028 { |
1029 CPDF_FormControl* pControl = GetFormControl(); | 1029 CPDF_FormControl* pControl = GetFormControl(); |
1030 ASSERT(pControl != NULL); | 1030 ASSERT(pControl != NULL); |
1031 CPDF_FormField* pField = pControl->GetField(); | 1031 CPDF_FormField* pField = pControl->GetField(); |
1032 ASSERT(pField != NULL); | 1032 ASSERT(pField != NULL); |
1033 | 1033 |
1034 CFX_ByteTextBuf sBody, sLines; | 1034 CFX_ByteTextBuf sBody, sLines; |
1035 | 1035 |
1036 CPDF_Rect rcClient = GetClientRect(); | 1036 CPDF_Rect rcClient = GetClientRect(); |
1037 CPDF_Rect rcButton = rcClient; | 1037 CPDF_Rect rcButton = rcClient; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 } | 1191 } |
1192 | 1192 |
1193 IFX_Edit::DelEdit(pEdit); | 1193 IFX_Edit::DelEdit(pEdit); |
1194 } | 1194 } |
1195 | 1195 |
1196 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + s
Lines.GetByteString() + sBody.GetByteString(); | 1196 CFX_ByteString sAP = GetBackgroundAppStream() + GetBorderAppStream() + s
Lines.GetByteString() + sBody.GetByteString(); |
1197 | 1197 |
1198 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); | 1198 WriteAppearance("N", GetRotatedRect(), GetMatrix(), sAP); |
1199 } | 1199 } |
1200 | 1200 |
1201 void CPDFSDK_Widget::ResetAppearance_TextField(FX_LPCWSTR sValue) | 1201 void CPDFSDK_Widget::ResetAppearance_TextField(const FX_WCHAR* sValue) |
1202 { | 1202 { |
1203 CPDF_FormControl* pControl = GetFormControl(); | 1203 CPDF_FormControl* pControl = GetFormControl(); |
1204 ASSERT(pControl != NULL); | 1204 ASSERT(pControl != NULL); |
1205 CPDF_FormField* pField = pControl->GetField(); | 1205 CPDF_FormField* pField = pControl->GetField(); |
1206 ASSERT(pField != NULL); | 1206 ASSERT(pField != NULL); |
1207 | 1207 |
1208 CFX_ByteTextBuf sBody, sLines; | 1208 CFX_ByteTextBuf sBody, sLines; |
1209 | 1209 |
1210 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) | 1210 if (IFX_Edit * pEdit = IFX_Edit::NewEdit()) |
1211 { | 1211 { |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2035 sValue = Value; | 2035 sValue = Value; |
2036 bFormated = TRUE; | 2036 bFormated = TRUE; |
2037 } | 2037 } |
2038 } | 2038 } |
2039 } | 2039 } |
2040 } | 2040 } |
2041 | 2041 |
2042 return sValue; | 2042 return sValue; |
2043 } | 2043 } |
2044 | 2044 |
2045 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, FX_LPCW
STR sValue, FX_BOOL bValueChanged) | 2045 void CPDFSDK_InterForm::ResetFieldAppearance(CPDF_FormField* pFormField, const F
X_WCHAR* sValue, FX_BOOL bValueChanged) |
2046 { | 2046 { |
2047 ASSERT(pFormField != NULL); | 2047 ASSERT(pFormField != NULL); |
2048 | 2048 |
2049 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) | 2049 for (int i=0,sz=pFormField->CountControls(); i<sz; i++) |
2050 { | 2050 { |
2051 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); | 2051 CPDF_FormControl* pFormCtrl = pFormField->GetControl(i); |
2052 ASSERT(pFormCtrl != NULL); | 2052 ASSERT(pFormCtrl != NULL); |
2053 | 2053 |
2054 ASSERT(m_pInterForm != NULL); | 2054 ASSERT(m_pInterForm != NULL); |
2055 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) | 2055 if(CPDFSDK_Widget* pWidget = GetWidget(pFormCtrl)) |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2248 | 2248 |
2249 FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, con
st CFX_PtrArray& fields, | 2249 FX_BOOL CPDFSDK_InterForm::SubmitFields(const CFX_WideString& csDestination, con
st CFX_PtrArray& fields, |
2250 FX_BOOL
bIncludeOrExclude, FX_BOOL bUrlEncoded) | 2250 FX_BOOL
bIncludeOrExclude, FX_BOOL bUrlEncoded) |
2251 { | 2251 { |
2252 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); | 2252 CPDFDoc_Environment* pEnv = m_pDocument->GetEnv(); |
2253 ASSERT(pEnv != NULL); | 2253 ASSERT(pEnv != NULL); |
2254 | 2254 |
2255 CFX_ByteTextBuf textBuf; | 2255 CFX_ByteTextBuf textBuf; |
2256 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); | 2256 ExportFieldsToFDFTextBuf(fields, bIncludeOrExclude, textBuf); |
2257 | 2257 |
2258 » FX_LPBYTE pBuffer = textBuf.GetBuffer(); | 2258 » uint8_t* pBuffer = textBuf.GetBuffer(); |
2259 FX_STRSIZE nBufSize = textBuf.GetLength(); | 2259 FX_STRSIZE nBufSize = textBuf.GetLength(); |
2260 | 2260 |
2261 if (bUrlEncoded) | 2261 if (bUrlEncoded) |
2262 { | 2262 { |
2263 if(!FDFToURLEncodedData(pBuffer, nBufSize)) | 2263 if(!FDFToURLEncodedData(pBuffer, nBufSize)) |
2264 return FALSE; | 2264 return FALSE; |
2265 } | 2265 } |
2266 | 2266 |
2267 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); | 2267 pEnv->JS_docSubmitForm(pBuffer, nBufSize, csDestination.c_str()); |
2268 | 2268 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2303 } | 2303 } |
2304 | 2304 |
2305 sBuffer.ReleaseBuffer(); | 2305 sBuffer.ReleaseBuffer(); |
2306 } | 2306 } |
2307 | 2307 |
2308 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_Wid
eString csTxtFile) | 2308 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(CFX_WideString csFDFFile, CFX_Wid
eString csTxtFile) |
2309 { | 2309 { |
2310 return TRUE; | 2310 return TRUE; |
2311 } | 2311 } |
2312 | 2312 |
2313 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(FX_LPBYTE& pBuf, FX_STRSIZE& nBuf
Size) | 2313 FX_BOOL CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, FX_STRSIZE& nBufS
ize) |
2314 { | 2314 { |
2315 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); | 2315 CFDF_Document* pFDF = CFDF_Document::ParseMemory(pBuf, nBufSize); |
2316 if (pFDF) | 2316 if (pFDF) |
2317 { | 2317 { |
2318 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); | 2318 CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDict("FDF"); |
2319 if (pMainDict == NULL) return FALSE; | 2319 if (pMainDict == NULL) return FALSE; |
2320 | 2320 |
2321 // Get fields | 2321 // Get fields |
2322 CPDF_Array* pFields = pMainDict->GetArray("Fields"); | 2322 CPDF_Array* pFields = pMainDict->GetArray("Fields"); |
2323 if (pFields == NULL) return FALSE; | 2323 if (pFields == NULL) return FALSE; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2382 | 2382 |
2383 if(NULL == m_pInterForm) return FALSE; | 2383 if(NULL == m_pInterForm) return FALSE; |
2384 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); | 2384 CFDF_Document* pFDFDoc = m_pInterForm->ExportToFDF(wsPDFFilePath); |
2385 if (NULL == pFDFDoc) return FALSE; | 2385 if (NULL == pFDFDoc) return FALSE; |
2386 | 2386 |
2387 CFX_ByteTextBuf FdfBuffer; | 2387 CFX_ByteTextBuf FdfBuffer; |
2388 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); | 2388 FX_BOOL bRet = pFDFDoc->WriteBuf(FdfBuffer); |
2389 delete pFDFDoc; | 2389 delete pFDFDoc; |
2390 if (!bRet) return FALSE; | 2390 if (!bRet) return FALSE; |
2391 | 2391 |
2392 » FX_LPBYTE pBuffer = FdfBuffer.GetBuffer(); | 2392 » uint8_t* pBuffer = FdfBuffer.GetBuffer(); |
2393 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); | 2393 FX_STRSIZE nBufSize = FdfBuffer.GetLength(); |
2394 | 2394 |
2395 if (bUrlEncoded) | 2395 if (bUrlEncoded) |
2396 { | 2396 { |
2397 if(!FDFToURLEncodedData(pBuffer, nBufSize)) | 2397 if(!FDFToURLEncodedData(pBuffer, nBufSize)) |
2398 return FALSE; | 2398 return FALSE; |
2399 } | 2399 } |
2400 | 2400 |
2401 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); | 2401 pEnv->JS_docSubmitForm(pBuffer, nBufSize, sDestination.c_str()); |
2402 | 2402 |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2984 | 2984 |
2985 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); | 2985 CPDF_Annot* pPDFAnnot = pAnnot->GetPDFAnnot(); |
2986 ASSERT(pPDFAnnot != NULL); | 2986 ASSERT(pPDFAnnot != NULL); |
2987 | 2987 |
2988 CPDF_Rect rcAnnot; | 2988 CPDF_Rect rcAnnot; |
2989 pPDFAnnot->GetRect(rcAnnot); | 2989 pPDFAnnot->GetRect(rcAnnot); |
2990 | 2990 |
2991 return rcAnnot; | 2991 return rcAnnot; |
2992 } | 2992 } |
2993 | 2993 |
OLD | NEW |