diff options
Diffstat (limited to 'fpdfsdk')
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.cpp | 78 | ||||
-rw-r--r-- | fpdfsdk/cpdfsdk_interform.h | 1 |
2 files changed, 39 insertions, 40 deletions
diff --git a/fpdfsdk/cpdfsdk_interform.cpp b/fpdfsdk/cpdfsdk_interform.cpp index 6a4b591ed0..3cd1b67b26 100644 --- a/fpdfsdk/cpdfsdk_interform.cpp +++ b/fpdfsdk/cpdfsdk_interform.cpp @@ -78,6 +78,45 @@ bool IsFormFieldTypeXFA(FormFieldType fieldType) { } #endif // PDF_ENABLE_XFA +bool FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize) { + std::unique_ptr<CFDF_Document> pFDF = + CFDF_Document::ParseMemory(pBuf, nBufSize); + if (!pFDF) + return true; + + CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); + if (!pMainDict) + return false; + + CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); + if (!pFields) + return false; + + std::ostringstream fdfEncodedData; + for (uint32_t i = 0; i < pFields->GetCount(); i++) { + CPDF_Dictionary* pField = pFields->GetDictAt(i); + if (!pField) + continue; + WideString name; + name = pField->GetUnicodeTextFor("T"); + ByteString name_b = name.ToDefANSI(); + ByteString csBValue = pField->GetStringFor("V"); + WideString csWValue = PDF_DecodeText(csBValue); + ByteString csValue_b = csWValue.ToDefANSI(); + fdfEncodedData << name_b << "=" << csValue_b; + if (i != pFields->GetCount() - 1) + fdfEncodedData << "&"; + } + + nBufSize = fdfEncodedData.tellp(); + if (nBufSize <= 0) + return false; + + pBuf = FX_Alloc(uint8_t, nBufSize); + memcpy(pBuf, fdfEncodedData.str().c_str(), nBufSize); + return true; +} + } // namespace CPDFSDK_InterForm::CPDFSDK_InterForm(CPDFSDK_FormFillEnvironment* pFormFillEnv) @@ -485,45 +524,6 @@ bool CPDFSDK_InterForm::SubmitFields(const WideString& csDestination, return true; } -bool CPDFSDK_InterForm::FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize) { - std::unique_ptr<CFDF_Document> pFDF = - CFDF_Document::ParseMemory(pBuf, nBufSize); - if (!pFDF) - return true; - - CPDF_Dictionary* pMainDict = pFDF->GetRoot()->GetDictFor("FDF"); - if (!pMainDict) - return false; - - CPDF_Array* pFields = pMainDict->GetArrayFor("Fields"); - if (!pFields) - return false; - - std::ostringstream fdfEncodedData; - for (uint32_t i = 0; i < pFields->GetCount(); i++) { - CPDF_Dictionary* pField = pFields->GetDictAt(i); - if (!pField) - continue; - WideString name; - name = pField->GetUnicodeTextFor("T"); - ByteString name_b = name.ToDefANSI(); - ByteString csBValue = pField->GetStringFor("V"); - WideString csWValue = PDF_DecodeText(csBValue); - ByteString csValue_b = csWValue.ToDefANSI(); - fdfEncodedData << name_b << "=" << csValue_b; - if (i != pFields->GetCount() - 1) - fdfEncodedData << "&"; - } - - nBufSize = fdfEncodedData.tellp(); - if (nBufSize <= 0) - return false; - - pBuf = FX_Alloc(uint8_t, nBufSize); - memcpy(pBuf, fdfEncodedData.str().c_str(), nBufSize); - return true; -} - ByteString CPDFSDK_InterForm::ExportFieldsToFDFTextBuf( const std::vector<CPDF_FormField*>& fields, bool bIncludeOrExclude) { diff --git a/fpdfsdk/cpdfsdk_interform.h b/fpdfsdk/cpdfsdk_interform.h index bb6d7fc260..14772efe8f 100644 --- a/fpdfsdk/cpdfsdk_interform.h +++ b/fpdfsdk/cpdfsdk_interform.h @@ -111,7 +111,6 @@ class CPDFSDK_InterForm : public IPDF_FormNotify { void AfterCheckedStatusChange(CPDF_FormField* pField) override; void AfterFormReset(CPDF_InterForm* pForm) override; - bool FDFToURLEncodedData(uint8_t*& pBuf, size_t& nBufSize); int GetPageIndexByAnnotDict(CPDF_Document* pDocument, CPDF_Dictionary* pAnnotDict) const; |