Index: core/fpdfdoc/cpdf_dest.cpp |
diff --git a/core/fpdfdoc/cpdf_dest.cpp b/core/fpdfdoc/cpdf_dest.cpp |
index 312ef8734634167cf53f55b978549b692f27c1fc..51e2d0b53427974a5a70613135064a8c551eb72a 100644 |
--- a/core/fpdfdoc/cpdf_dest.cpp |
+++ b/core/fpdfdoc/cpdf_dest.cpp |
@@ -8,6 +8,8 @@ |
#include "core/fpdfapi/parser/cpdf_array.h" |
#include "core/fpdfapi/parser/cpdf_document.h" |
+#include "core/fpdfapi/parser/cpdf_name.h" |
+#include "core/fpdfapi/parser/cpdf_number.h" |
namespace { |
@@ -64,6 +66,53 @@ int CPDF_Dest::GetZoomMode() { |
return 0; |
} |
+bool CPDF_Dest::GetXYZ(bool* pHasX, |
+ bool* pHasY, |
+ bool* pHasZoom, |
+ float* pX, |
+ float* pY, |
+ float* pZoom) const { |
+ *pHasX = false; |
+ *pHasY = false; |
+ *pHasZoom = false; |
+ |
+ CPDF_Array* pArray = ToArray(m_pObj); |
+ if (!pArray) |
+ return false; |
+ |
+ if (pArray->GetCount() < 5) |
+ return false; |
+ |
+ const CPDF_Name* xyz = ToName(pArray->GetDirectObjectAt(1)); |
+ if (!xyz || xyz->GetString() != "XYZ") |
+ return false; |
+ |
+ const CPDF_Number* numX = ToNumber(pArray->GetDirectObjectAt(2)); |
+ const CPDF_Number* numY = ToNumber(pArray->GetDirectObjectAt(3)); |
+ const CPDF_Number* numZoom = ToNumber(pArray->GetDirectObjectAt(4)); |
+ |
+ // If the value is a CPDF_Null then ToNumber will return nullptr. |
+ *pHasX = !!numX; |
+ *pHasY = !!numY; |
+ *pHasZoom = !!numZoom; |
+ |
+ if (numX) |
+ *pX = numX->GetNumber(); |
+ if (numY) |
+ *pY = numY->GetNumber(); |
+ |
+ // A zoom value of 0 is equivalent to a null value, so treat it as a null. |
+ if (numZoom) { |
+ float num = numZoom->GetNumber(); |
+ if (num == 0.0) |
+ *pHasZoom = false; |
+ else |
+ *pZoom = num; |
+ } |
+ |
+ return true; |
+} |
+ |
FX_FLOAT CPDF_Dest::GetParam(int index) { |
CPDF_Array* pArray = ToArray(m_pObj); |
return pArray ? pArray->GetNumberAt(2 + index) : 0; |