summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-08-13 21:31:18 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-08-13 21:31:18 +0000
commit4f1aa69662adf8e7038ed3abd6a36fc338119487 (patch)
tree52a7b5399a23960aa5b3398820b4161ebe1744c1
parentd801c9c9caddf3941f6844fab58b19261d7d3cad (diff)
downloadpdfium-4f1aa69662adf8e7038ed3abd6a36fc338119487.tar.xz
Move FDFToURLEncodedData() into an anonymous namespace.
Change-Id: Iac581765f343f464f73a892b300ae20923c3bb32 Reviewed-on: https://pdfium-review.googlesource.com/39971 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--fpdfsdk/cpdfsdk_interform.cpp78
-rw-r--r--fpdfsdk/cpdfsdk_interform.h1
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;