7#include "core/fpdfdoc/cpdf_dest.h"
13#include "core/fpdfapi/parser/cpdf_array.h"
14#include "core/fpdfapi/parser/cpdf_document.h"
15#include "core/fpdfapi/parser/cpdf_name.h"
16#include "core/fpdfapi/parser/cpdf_number.h"
17#include "core/fpdfdoc/cpdf_nametree.h"
24const char*
const kZoomModes[] = {
"Unknown",
"XYZ",
"Fit",
"FitH",
"FitV",
25 "FitR",
"FitB",
"FitBH",
"FitBV",
nullptr};
27constexpr uint8_t kZoomModeMaxParamCount[] = {0, 3, 0, 1, 1, 4, 0, 1, 1, 0};
29static_assert(
std::size(kZoomModes) ==
std::size(kZoomModeMaxParamCount),
30 "Zoom mode count Mismatch");
45 return CPDF_Dest(
nullptr);
47 if (pDest->IsString() || pDest->IsName())
61 if (pPage->IsNumber())
62 return pPage->GetInteger();
64 if (!pPage->IsDictionary())
71 std::vector<
float> result;
75 for (size_t i = 2; i < m_pArray->size(); i++)
76 result.push_back(m_pArray->GetFloatAt(i));
89 ByteString mode = pArray->GetString();
90 for (
int i = 1; kZoomModes[i]; ++i) {
91 if (mode
== kZoomModes[i])
103 float* pZoom)
const {
111 if (m_pArray->size() < 5)
114 RetainPtr<
const CPDF_Name> xyz = ToName(m_pArray->GetDirectObjectAt(1));
115 if (!xyz || xyz->GetString() !=
"XYZ")
118 RetainPtr<
const CPDF_Number> numX = ToNumber(m_pArray->GetDirectObjectAt(2));
119 RetainPtr<
const CPDF_Number> numY = ToNumber(m_pArray->GetDirectObjectAt(3));
121 ToNumber(m_pArray->GetDirectObjectAt(4));
126 *pHasZoom = !!numZoom;
129 *pX = numX->GetNumber();
131 *pY = numY->GetNumber();
135 float num = numZoom->GetNumber();
146 if (!m_pArray || m_pArray->size() < 2)
149 size_t maxParamsForFitType = kZoomModeMaxParamCount[GetZoomMode()];
150 size_t numParamsInArray = m_pArray->size() - 2;
151 return std::min(maxParamsForFitType, numParamsInArray);
155 return m_pArray ? m_pArray->GetFloatAt(2 + index) : 0;
bool GetXYZ(bool *pHasX, bool *pHasY, bool *pHasZoom, float *pX, float *pY, float *pZoom) const
size_t GetNumParams() const
static CPDF_Dest Create(CPDF_Document *pDoc, RetainPtr< const CPDF_Object > pDest)
CPDF_Dest(const CPDF_Dest &that)
int GetDestPageIndex(CPDF_Document *pDoc) const
float GetParam(size_t index) const
std::vector< float > GetScrollPositionArray() const
CPDF_Dest(RetainPtr< const CPDF_Array > pArray)
int GetPageIndex(uint32_t objnum)
static RetainPtr< const CPDF_Array > LookupNamedDest(CPDF_Document *doc, const ByteString &name)
bool operator==(const char *ptr) const