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

Unified Diff: core/fpdfdoc/cpdf_actionfields.cpp

Issue 2192823002: Splitting fpdfdoc/doc_* part I (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@fpdf_doc_II
Patch Set: Stddef not stdint Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpdf_action.cpp ('k') | core/fpdfdoc/cpdf_bookmark.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_actionfields.cpp
diff --git a/core/fpdfdoc/cpdf_actionfields.cpp b/core/fpdfdoc/cpdf_actionfields.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1ad1eb4673dc5519383b1d1aa18627cff6b5ec71
--- /dev/null
+++ b/core/fpdfdoc/cpdf_actionfields.cpp
@@ -0,0 +1,96 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfdoc/include/cpdf_actionfields.h"
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
+#include "core/fpdfdoc/include/cpdf_action.h"
+
+size_t CPDF_ActionFields::GetFieldsCount() const {
+ if (!m_pAction)
+ return 0;
+
+ CPDF_Dictionary* pDict = m_pAction->GetDict();
+ if (!pDict)
+ return 0;
+
+ CFX_ByteString csType = pDict->GetStringBy("S");
+ CPDF_Object* pFields = nullptr;
+ if (csType == "Hide")
+ pFields = pDict->GetDirectObjectBy("T");
+ else
+ pFields = pDict->GetArrayBy("Fields");
+
+ if (!pFields)
+ return 0;
+ if (pFields->IsDictionary())
+ return 1;
+ if (pFields->IsString())
+ return 1;
+ if (CPDF_Array* pArray = pFields->AsArray())
+ return pArray->GetCount();
+ return 0;
+}
+
+std::vector<CPDF_Object*> CPDF_ActionFields::GetAllFields() const {
+ std::vector<CPDF_Object*> fields;
+ if (!m_pAction)
+ return fields;
+
+ CPDF_Dictionary* pDict = m_pAction->GetDict();
+ if (!pDict)
+ return fields;
+
+ CFX_ByteString csType = pDict->GetStringBy("S");
+ CPDF_Object* pFields;
+ if (csType == "Hide")
+ pFields = pDict->GetDirectObjectBy("T");
+ else
+ pFields = pDict->GetArrayBy("Fields");
+
+ if (!pFields)
+ return fields;
+
+ if (pFields->IsDictionary() || pFields->IsString()) {
+ fields.push_back(pFields);
+ } else if (CPDF_Array* pArray = pFields->AsArray()) {
+ for (size_t i = 0; i < pArray->GetCount(); ++i) {
+ CPDF_Object* pObj = pArray->GetDirectObjectAt(i);
+ if (pObj)
+ fields.push_back(pObj);
+ }
+ }
+ return fields;
+}
+
+CPDF_Object* CPDF_ActionFields::GetField(size_t iIndex) const {
+ if (!m_pAction)
+ return nullptr;
+
+ CPDF_Dictionary* pDict = m_pAction->GetDict();
+ if (!pDict)
+ return nullptr;
+
+ CFX_ByteString csType = pDict->GetStringBy("S");
+ CPDF_Object* pFields = nullptr;
+ if (csType == "Hide")
+ pFields = pDict->GetDirectObjectBy("T");
+ else
+ pFields = pDict->GetArrayBy("Fields");
+
+ if (!pFields)
+ return nullptr;
+
+ CPDF_Object* pFindObj = nullptr;
+ if (pFields->IsDictionary() || pFields->IsString()) {
+ if (iIndex == 0)
+ pFindObj = pFields;
+ } else if (CPDF_Array* pArray = pFields->AsArray()) {
+ pFindObj = pArray->GetDirectObjectAt(iIndex);
+ }
+ return pFindObj;
+}
« no previous file with comments | « core/fpdfdoc/cpdf_action.cpp ('k') | core/fpdfdoc/cpdf_bookmark.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698