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

Unified Diff: core/fpdfdoc/cpdf_dest.cpp

Issue 2187073005: Splitting fpdfdoc/doc_* part II. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@fpdf_doc_III
Patch Set: Rebase to master 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/clines.cpp ('k') | core/fpdfdoc/cpdf_filespec.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpdf_dest.cpp
diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..27626a3d8f02262b1eb4deae06fd5a7417338ee7
--- /dev/null
+++ b/core/fpdfdoc/cpdf_dest.cpp
@@ -0,0 +1,74 @@
+// 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_dest.h"
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
+
+namespace {
+
+const FX_CHAR* const g_sZoomModes[] = {"XYZ", "Fit", "FitH", "FitV", "FitR",
+ "FitB", "FitBH", "FitBV", nullptr};
+
+} // namespace
+
+int CPDF_Dest::GetPageIndex(CPDF_Document* pDoc) {
+ CPDF_Array* pArray = ToArray(m_pObj);
+ if (!pArray)
+ return 0;
+
+ CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
+ if (!pPage)
+ return 0;
+ if (pPage->IsNumber())
+ return pPage->GetInteger();
+ if (!pPage->IsDictionary())
+ return 0;
+ return pDoc->GetPageIndex(pPage->GetObjNum());
+}
+
+uint32_t CPDF_Dest::GetPageObjNum() {
+ CPDF_Array* pArray = ToArray(m_pObj);
+ if (!pArray)
+ return 0;
+
+ CPDF_Object* pPage = pArray->GetDirectObjectAt(0);
+ if (!pPage)
+ return 0;
+ if (pPage->IsNumber())
+ return pPage->GetInteger();
+ if (pPage->IsDictionary())
+ return pPage->GetObjNum();
+ return 0;
+}
+
+int CPDF_Dest::GetZoomMode() {
+ CPDF_Array* pArray = ToArray(m_pObj);
+ if (!pArray)
+ return 0;
+
+ CPDF_Object* pObj = pArray->GetDirectObjectAt(1);
+ if (!pObj)
+ return 0;
+
+ CFX_ByteString mode = pObj->GetString();
+ for (int i = 0; g_sZoomModes[i]; ++i) {
+ if (mode == g_sZoomModes[i])
+ return i + 1;
+ }
+
+ return 0;
+}
+
+FX_FLOAT CPDF_Dest::GetParam(int index) {
+ CPDF_Array* pArray = ToArray(m_pObj);
+ return pArray ? pArray->GetNumberAt(2 + index) : 0;
+}
+
+CFX_ByteString CPDF_Dest::GetRemoteName() {
+ return m_pObj ? m_pObj->GetString() : CFX_ByteString();
+}
« no previous file with comments | « core/fpdfdoc/clines.cpp ('k') | core/fpdfdoc/cpdf_filespec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698