summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfapi/fpdf_page/fpdf_page_parser.cpp8
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_array.cpp6
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp14
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_object.cpp4
-rw-r--r--core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp34
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_array.h1
-rw-r--r--core/fpdfapi/fpdf_parser/include/cpdf_object.h1
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp22
-rw-r--r--core/fpdfdoc/doc_formfield.cpp51
-rw-r--r--fpdfsdk/fpdfsave.cpp5
-rw-r--r--fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp145
11 files changed, 121 insertions, 170 deletions
diff --git a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
index 4a7b6ad403..b30006bf35 100644
--- a/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
+++ b/core/fpdfapi/fpdf_page/fpdf_page_parser.cpp
@@ -697,7 +697,7 @@ void CPDF_StreamContentParser::Handle_SetColorSpace_Stroke() {
}
void CPDF_StreamContentParser::Handle_SetDash() {
- CPDF_Array* pArray = GetObject(1) ? GetObject(1)->GetArray() : nullptr;
+ CPDF_Array* pArray = ToArray(GetObject(1));
if (!pArray)
return;
@@ -1305,10 +1305,10 @@ void CPDF_StreamContentParser::Handle_ShowText() {
}
void CPDF_StreamContentParser::Handle_ShowText_Positioning() {
- CPDF_Array* pArray = GetObject(0) ? GetObject(0)->GetArray() : NULL;
- if (!pArray) {
+ CPDF_Array* pArray = ToArray(GetObject(0));
+ if (!pArray)
return;
- }
+
size_t n = pArray->GetCount();
size_t nsegs = 0;
for (size_t i = 0; i < n; i++) {
diff --git a/core/fpdfapi/fpdf_parser/cpdf_array.cpp b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
index d588f339a7..20073772b7 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_array.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_array.cpp
@@ -25,12 +25,6 @@ CPDF_Object::Type CPDF_Array::GetType() const {
return ARRAY;
}
-CPDF_Array* CPDF_Array::GetArray() const {
- // The method should be made non-const if we want to not be const.
- // See bug #234.
- return const_cast<CPDF_Array*>(this);
-}
-
bool CPDF_Array::IsArray() const {
return true;
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
index e47d4244ac..f371e673ed 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_data_avail.cpp
@@ -151,7 +151,7 @@ FX_BOOL CPDF_DataAvail::IsObjectsAvail(
int32_t type = pObj->GetType();
switch (type) {
case CPDF_Object::ARRAY: {
- CPDF_Array* pArray = pObj->GetArray();
+ CPDF_Array* pArray = pObj->AsArray();
for (size_t k = 0; k < pArray->GetCount(); ++k)
new_obj_array.Add(pArray->GetObjectAt(k));
} break;
@@ -509,13 +509,11 @@ FX_BOOL CPDF_DataAvail::CheckPage(IPDF_DataAvail::DownloadHints* pHints) {
continue;
}
- if (pObj->IsArray()) {
- CPDF_Array* pArray = pObj->GetArray();
- if (pArray) {
- for (size_t j = 0; j < pArray->GetCount(); ++j) {
- if (CPDF_Reference* pRef = ToReference(pArray->GetObjectAt(j)))
- UnavailObjList.Add(pRef->GetRefObjNum());
- }
+ CPDF_Array* pArray = ToArray(pObj);
+ if (pArray) {
+ for (CPDF_Object* pArrayObj : *pArray) {
+ if (CPDF_Reference* pRef = ToReference(pArrayObj))
+ UnavailObjList.Add(pRef->GetRefObjNum());
}
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_object.cpp b/core/fpdfapi/fpdf_parser/cpdf_object.cpp
index 86b9449cf8..ec967d1032 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_object.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_object.cpp
@@ -49,10 +49,6 @@ CPDF_Dictionary* CPDF_Object::GetDict() const {
return nullptr;
}
-CPDF_Array* CPDF_Object::GetArray() const {
- return nullptr;
-}
-
void CPDF_Object::SetString(const CFX_ByteString& str) {
ASSERT(FALSE);
}
diff --git a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp
index d3dc5257a3..a77f022c40 100644
--- a/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp
+++ b/core/fpdfapi/fpdf_parser/cpdf_object_unittest.cpp
@@ -183,7 +183,7 @@ class PDFObjectsTest : public testing::Test {
};
TEST_F(PDFObjectsTest, GetString) {
- const char* direct_obj_results[] = {
+ const char* const direct_obj_results[] = {
"false", "true", "1245", "9.00345", "A simple test", "\t\n", "space",
"", "", "", ""};
// Check for direct objects.
@@ -191,15 +191,15 @@ TEST_F(PDFObjectsTest, GetString) {
EXPECT_STREQ(direct_obj_results[i], m_DirectObjs[i]->GetString().c_str());
// Check indirect references.
- const char* indirect_obj_results[] = {"true", "1245", "\t\n", "space",
- "", "", ""};
+ const char* const indirect_obj_results[] = {"true", "1245", "\t\n", "space",
+ "", "", ""};
for (size_t i = 0; i < m_RefObjs.size(); ++i) {
EXPECT_STREQ(indirect_obj_results[i], m_RefObjs[i]->GetString().c_str());
}
}
TEST_F(PDFObjectsTest, GetUnicodeText) {
- const wchar_t* direct_obj_results[] = {
+ const wchar_t* const direct_obj_results[] = {
L"", L"", L"", L"", L"A simple test",
L"\t\n", L"space", L"", L"", L"abcdefghijklmnopqrstuvwxyz",
L""};
@@ -240,7 +240,7 @@ TEST_F(PDFObjectsTest, GetInteger) {
}
TEST_F(PDFObjectsTest, GetDict) {
- const CPDF_Dictionary* direct_obj_results[] = {
+ const CPDF_Dictionary* const direct_obj_results[] = {
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, m_DictObj, m_StreamDictObj, nullptr};
// Check for direct objects.
@@ -248,23 +248,23 @@ TEST_F(PDFObjectsTest, GetDict) {
EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetDict());
// Check indirect references.
- const CPDF_Dictionary* indirect_obj_results[] = {
+ const CPDF_Dictionary* const indirect_obj_results[] = {
nullptr, nullptr, nullptr, nullptr, nullptr, m_DictObj, m_StreamDictObj};
for (size_t i = 0; i < m_RefObjs.size(); ++i)
EXPECT_EQ(indirect_obj_results[i], m_RefObjs[i]->GetDict());
}
TEST_F(PDFObjectsTest, GetArray) {
- const CPDF_Array* direct_obj_results[] = {
+ const CPDF_Array* const direct_obj_results[] = {
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
nullptr, m_ArrayObj, nullptr, nullptr, nullptr};
// Check for direct objects.
for (size_t i = 0; i < m_DirectObjs.size(); ++i)
- EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->GetArray());
+ EXPECT_EQ(direct_obj_results[i], m_DirectObjs[i]->AsArray());
// Check indirect references.
for (const auto& it : m_RefObjs)
- EXPECT_EQ(nullptr, it->GetArray());
+ EXPECT_EQ(nullptr, it->AsArray());
}
TEST_F(PDFObjectsTest, Clone) {
@@ -305,8 +305,8 @@ TEST_F(PDFObjectsTest, SetString) {
// Check for direct objects.
const char* const set_values[] = {"true", "fake", "3.125f", "097",
"changed", "", "NewName"};
- const char* expected[] = {"true", "false", "3.125", "97",
- "changed", "", "NewName"};
+ const char* const expected[] = {"true", "false", "3.125", "97",
+ "changed", "", "NewName"};
for (size_t i = 0; i < FX_ArraySize(set_values); ++i) {
m_DirectObjs[i]->SetString(set_values[i]);
EXPECT_STREQ(expected[i], m_DirectObjs[i]->GetString().c_str());
@@ -424,7 +424,7 @@ TEST(PDFArrayTest, GetRect) {
TEST(PDFArrayTest, GetTypeAt) {
{
// Boolean array.
- bool vals[] = {true, false, false, true, true};
+ const bool vals[] = {true, false, false, true, true};
ScopedArray arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i)
arr->InsertAt(i, new CPDF_Boolean(vals[i]));
@@ -441,7 +441,7 @@ TEST(PDFArrayTest, GetTypeAt) {
}
{
// Integer array.
- int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767};
+ const int vals[] = {10, 0, -345, 2089345456, -1000000000, 567, 93658767};
ScopedArray arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i)
arr->InsertAt(i, new CPDF_Number(vals[i]));
@@ -459,10 +459,10 @@ TEST(PDFArrayTest, GetTypeAt) {
}
{
// Float array.
- float vals[] = {0.0f, 0, 10, 10.0f, 0.0345f,
- 897.34f, -2.5f, -1.0f, -345.0f, -0.0f};
- const char* expected_str[] = {"0", "0", "10", "10", "0.0345",
- "897.34", "-2.5", "-1", "-345", "0"};
+ const float vals[] = {0.0f, 0, 10, 10.0f, 0.0345f,
+ 897.34f, -2.5f, -1.0f, -345.0f, -0.0f};
+ const char* const expected_str[] = {
+ "0", "0", "10", "10", "0.0345", "897.34", "-2.5", "-1", "-345", "0"};
ScopedArray arr(new CPDF_Array);
for (size_t i = 0; i < FX_ArraySize(vals); ++i) {
arr->InsertAt(i, new CPDF_Number(vals[i]));
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_array.h b/core/fpdfapi/fpdf_parser/include/cpdf_array.h
index dfe03b9d70..0629046d9e 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_array.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_array.h
@@ -24,7 +24,6 @@ class CPDF_Array : public CPDF_Object {
// CPDF_Object.
Type GetType() const override;
CPDF_Object* Clone(FX_BOOL bDirect = FALSE) const override;
- CPDF_Array* GetArray() const override;
bool IsArray() const override;
CPDF_Array* AsArray() override;
const CPDF_Array* AsArray() const override;
diff --git a/core/fpdfapi/fpdf_parser/include/cpdf_object.h b/core/fpdfapi/fpdf_parser/include/cpdf_object.h
index c0c442157f..0d2e87e9f1 100644
--- a/core/fpdfapi/fpdf_parser/include/cpdf_object.h
+++ b/core/fpdfapi/fpdf_parser/include/cpdf_object.h
@@ -50,7 +50,6 @@ class CPDF_Object {
virtual FX_FLOAT GetNumber() const;
virtual int GetInteger() const;
virtual CPDF_Dictionary* GetDict() const;
- virtual CPDF_Array* GetArray() const;
virtual void SetString(const CFX_ByteString& str);
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index aa49f79c12..db2ee6c01d 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -344,15 +344,10 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
pDoc, pStreamDict ? pStreamDict->GetDictBy("Resources") : nullptr,
pDefFont, sFontName.Right(sFontName.GetLength() - 1));
CPDF_VariableText::Provider prd(&map);
- CPDF_Array* pOpts = FPDF_GetFieldAttr(pAnnotDict, "Opt")
- ? FPDF_GetFieldAttr(pAnnotDict, "Opt")->GetArray()
- : nullptr;
- CPDF_Array* pSels = FPDF_GetFieldAttr(pAnnotDict, "I")
- ? FPDF_GetFieldAttr(pAnnotDict, "I")->GetArray()
- : nullptr;
- int32_t nTop = FPDF_GetFieldAttr(pAnnotDict, "TI")
- ? FPDF_GetFieldAttr(pAnnotDict, "TI")->GetInteger()
- : 0;
+ CPDF_Array* pOpts = ToArray(FPDF_GetFieldAttr(pAnnotDict, "Opt"));
+ CPDF_Array* pSels = ToArray(FPDF_GetFieldAttr(pAnnotDict, "I"));
+ CPDF_Object* pTi = FPDF_GetFieldAttr(pAnnotDict, "TI");
+ int32_t nTop = pTi ? pTi->GetInteger() : 0;
CFX_ByteTextBuf sBody;
if (pOpts) {
FX_FLOAT fy = rcBody.top;
@@ -415,11 +410,10 @@ FX_BOOL GenerateWidgetAP(CPDF_Document* pDoc,
}
}
if (sBody.GetSize() > 0) {
- sAppStream << "/Tx BMC\n"
- << "q\n";
- sAppStream << rcBody.left << " " << rcBody.bottom << " "
- << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n";
- sAppStream << sBody.AsStringC() << "Q\nEMC\n";
+ sAppStream << "/Tx BMC\nq\n"
+ << rcBody.left << " " << rcBody.bottom << " "
+ << rcBody.Width() << " " << rcBody.Height() << " re\nW\nn\n"
+ << sBody.AsStringC() << "Q\nEMC\n";
}
} break;
}
diff --git a/core/fpdfdoc/doc_formfield.cpp b/core/fpdfdoc/doc_formfield.cpp
index 84d9a52dac..9849fa1e35 100644
--- a/core/fpdfdoc/doc_formfield.cpp
+++ b/core/fpdfdoc/doc_formfield.cpp
@@ -893,56 +893,37 @@ FX_BOOL CPDF_FormField::SetCheckValue(const CFX_WideString& value,
int CPDF_FormField::GetTopVisibleIndex() {
CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "TI");
- if (!pObj) {
- return 0;
- }
- return pObj->GetInteger();
+ return pObj ? pObj->GetInteger() : 0;
}
int CPDF_FormField::CountSelectedOptions() {
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
- if (!pObj) {
- return 0;
- }
- CPDF_Array* pArray = pObj->GetArray();
- if (!pArray) {
- return 0;
- }
- return static_cast<int>(pArray->GetCount());
+ CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
+ return pArray ? pArray->GetCount() : 0;
}
int CPDF_FormField::GetSelectedOptionIndex(int index) {
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
- if (!pObj) {
+ CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
+ if (!pArray)
return -1;
- }
- CPDF_Array* pArray = pObj->GetArray();
- if (!pArray) {
+
+ int iCount = pArray->GetCount();
+ if (iCount < 0 || index >= iCount)
return -1;
- }
- int iCount = static_cast<int>(pArray->GetCount());
- if (iCount > 0 && index < iCount) {
- return pArray->GetIntegerAt(index);
- }
- return -1;
+ return pArray->GetIntegerAt(index);
}
+
FX_BOOL CPDF_FormField::IsOptionSelected(int iOptIndex) {
- CPDF_Object* pObj = FPDF_GetFieldAttr(m_pDict, "I");
- if (!pObj) {
- return FALSE;
- }
- CPDF_Array* pArray = pObj->GetArray();
- if (!pArray) {
+ CPDF_Array* pArray = ToArray(FPDF_GetFieldAttr(m_pDict, "I"));
+ if (!pArray)
return FALSE;
- }
- size_t iCount = pArray->GetCount();
- for (size_t i = 0; i < iCount; i++) {
- if (pArray->GetIntegerAt(i) == iOptIndex) {
+
+ for (CPDF_Object* pObj : *pArray) {
+ if (pObj->GetInteger() == iOptIndex)
return TRUE;
- }
}
return FALSE;
}
+
FX_BOOL CPDF_FormField::SelectOption(int iOptIndex,
FX_BOOL bSelected,
FX_BOOL bNotify) {
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 7b08194bf4..9a006530c2 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -107,10 +107,7 @@ bool SaveXFADocumentData(CPDFXFA_Document* pDocument,
if (!pXFA)
return true;
- if (!pXFA->IsArray())
- return false;
-
- CPDF_Array* pArray = pXFA->GetArray();
+ CPDF_Array* pArray = pXFA->AsArray();
if (!pArray)
return false;
diff --git a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
index 85a1f16f5d..701d999908 100644
--- a/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
+++ b/fpdfsdk/fpdfxfa/fpdfxfa_doc.cpp
@@ -663,22 +663,18 @@ void CPDFXFA_Document::ExportData(CXFA_FFDoc* hDoc,
m_pXFADocView->GetDoc()->SavePackage(XFA_HASHCODE_Data, &fileWrite,
nullptr);
} else if (fileType == FXFA_SAVEAS_XDP) {
- if (m_pPDFDoc == NULL)
+ if (!m_pPDFDoc)
return;
CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
- if (pRoot == NULL)
+ if (!pRoot)
return;
CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
- if (NULL == pAcroForm)
+ if (!pAcroForm)
return;
- CPDF_Object* pXFA = pAcroForm->GetObjectBy("XFA");
- if (pXFA == NULL)
- return;
- if (!pXFA->IsArray())
- return;
- CPDF_Array* pArray = pXFA->GetArray();
- if (NULL == pArray)
+ CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA"));
+ if (!pArray)
return;
+
int size = pArray->GetCount();
for (int i = 1; i < size; i += 2) {
CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
@@ -952,73 +948,70 @@ FX_BOOL CPDFXFA_Document::_ExportSubmitFile(FPDF_FILEHANDLER* pFileHandler,
CFPDF_FileStream fileStream(pFileHandler);
if (fileType == FXFA_SAVEAS_XML) {
- const char* content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
- fileStream.WriteBlock(content, 0, strlen(content));
+ const char kContent[] = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n";
+ fileStream.WriteBlock(kContent, 0, strlen(kContent));
m_pXFADoc->SavePackage(XFA_HASHCODE_Data, &fileStream, nullptr);
- } else if (fileType == FXFA_SAVEAS_XDP) {
- if (flag == 0)
- flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
- FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
- if (m_pPDFDoc == NULL) {
- fileStream.Flush();
- return FALSE;
- }
- CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
- if (pRoot == NULL) {
- fileStream.Flush();
- return FALSE;
- }
- CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
- if (NULL == pAcroForm) {
- fileStream.Flush();
- return FALSE;
- }
- CPDF_Object* pXFA = pAcroForm->GetObjectBy("XFA");
- if (pXFA == NULL) {
- fileStream.Flush();
- return FALSE;
- }
- if (!pXFA->IsArray()) {
- fileStream.Flush();
- return FALSE;
- }
- CPDF_Array* pArray = pXFA->GetArray();
- if (NULL == pArray) {
- fileStream.Flush();
- return FALSE;
- }
- int size = pArray->GetCount();
- for (int i = 1; i < size; i += 2) {
- CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
- CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
- if (!pPrePDFObj->IsString())
- continue;
- if (!pPDFObj->IsReference())
- continue;
- CPDF_Object* pDirectObj = pPDFObj->GetDirect();
- if (!pDirectObj->IsStream())
- continue;
- if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG))
- continue;
- if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE))
- continue;
- if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET))
- continue;
- if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS))
- continue;
- if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA))
- continue;
- if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF))
- continue;
- if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
- continue;
- if (pPrePDFObj->GetString() == "form") {
- m_pXFADoc->SavePackage(XFA_HASHCODE_Form, &fileStream, nullptr);
- } else if (pPrePDFObj->GetString() == "datasets") {
- m_pXFADoc->SavePackage(XFA_HASHCODE_Datasets, &fileStream, nullptr);
- } else {
- // PDF,creator.
- }
+ return TRUE;
+ }
+
+ if (fileType != FXFA_SAVEAS_XDP)
+ return TRUE;
+
+ if (!flag) {
+ flag = FXFA_CONFIG | FXFA_TEMPLATE | FXFA_LOCALESET | FXFA_DATASETS |
+ FXFA_XMPMETA | FXFA_XFDF | FXFA_FORM;
+ }
+ if (!m_pPDFDoc) {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Dictionary* pRoot = m_pPDFDoc->GetRoot();
+ if (!pRoot) {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Dictionary* pAcroForm = pRoot->GetDictBy("AcroForm");
+ if (!pAcroForm) {
+ fileStream.Flush();
+ return FALSE;
+ }
+ CPDF_Array* pArray = ToArray(pAcroForm->GetObjectBy("XFA"));
+ if (!pArray) {
+ fileStream.Flush();
+ return FALSE;
+ }
+
+ int size = pArray->GetCount();
+ for (int i = 1; i < size; i += 2) {
+ CPDF_Object* pPDFObj = pArray->GetObjectAt(i);
+ CPDF_Object* pPrePDFObj = pArray->GetObjectAt(i - 1);
+ if (!pPrePDFObj->IsString())
+ continue;
+ if (!pPDFObj->IsReference())
+ continue;
+ CPDF_Object* pDirectObj = pPDFObj->GetDirect();
+ if (!pDirectObj->IsStream())
+ continue;
+ if (pPrePDFObj->GetString() == "config" && !(flag & FXFA_CONFIG))
+ continue;
+ if (pPrePDFObj->GetString() == "template" && !(flag & FXFA_TEMPLATE))
+ continue;
+ if (pPrePDFObj->GetString() == "localeSet" && !(flag & FXFA_LOCALESET))
+ continue;
+ if (pPrePDFObj->GetString() == "datasets" && !(flag & FXFA_DATASETS))
+ continue;
+ if (pPrePDFObj->GetString() == "xmpmeta" && !(flag & FXFA_XMPMETA))
+ continue;
+ if (pPrePDFObj->GetString() == "xfdf" && !(flag & FXFA_XFDF))
+ continue;
+ if (pPrePDFObj->GetString() == "form" && !(flag & FXFA_FORM))
+ continue;
+ if (pPrePDFObj->GetString() == "form") {
+ m_pXFADoc->SavePackage(XFA_HASHCODE_Form, &fileStream, nullptr);
+ } else if (pPrePDFObj->GetString() == "datasets") {
+ m_pXFADoc->SavePackage(XFA_HASHCODE_Datasets, &fileStream, nullptr);
+ } else {
+ // PDF,creator.
}
}
return TRUE;