| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "../../include/fpdfdoc/fpdf_doc.h" | 7 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document *pDoc): m_pDoc(pDoc
) | 8 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) |
| 9 { | 9 : m_pDoc(pDoc) {} |
| 10 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} |
| 11 FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const { |
| 12 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); |
| 13 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); |
| 14 if (!pDict) { |
| 15 return FALSE; |
| 16 } |
| 17 return FX_BSTRC("R2L") == pDict->GetString(FX_BSTRC("Direction")); |
| 10 } | 18 } |
| 11 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() | 19 FX_BOOL CPDF_ViewerPreferences::PrintScaling() const { |
| 12 { | 20 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); |
| 21 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); |
| 22 if (!pDict) { |
| 23 return TRUE; |
| 24 } |
| 25 return FX_BSTRC("None") != pDict->GetString(FX_BSTRC("PrintScaling")); |
| 13 } | 26 } |
| 14 FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const | 27 int32_t CPDF_ViewerPreferences::NumCopies() const { |
| 15 { | 28 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); |
| 16 CPDF_Dictionary *pDict = m_pDoc->GetRoot(); | 29 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); |
| 17 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); | 30 if (!pDict) { |
| 18 if (!pDict)»{ | 31 return 1; |
| 19 return FALSE; | 32 } |
| 20 } | 33 return pDict->GetInteger(FX_BSTRC("NumCopies")); |
| 21 return FX_BSTRC("R2L") == pDict->GetString(FX_BSTRC("Direction")); | |
| 22 } | 34 } |
| 23 FX_BOOL CPDF_ViewerPreferences::PrintScaling() const | 35 CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const { |
| 24 { | 36 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); |
| 25 CPDF_Dictionary *pDict = m_pDoc->GetRoot(); | 37 CPDF_Array* pRange = NULL; |
| 26 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); | 38 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); |
| 27 if (!pDict)»{ | 39 if (!pDict) { |
| 28 return TRUE; | 40 return pRange; |
| 29 } | 41 } |
| 30 return FX_BSTRC("None") != pDict->GetString(FX_BSTRC("PrintScaling")); | 42 pRange = pDict->GetArray(FX_BSTRC("PrintPageRange")); |
| 43 return pRange; |
| 31 } | 44 } |
| 32 int32_t CPDF_ViewerPreferences::NumCopies() const | 45 CFX_ByteString CPDF_ViewerPreferences::Duplex() const { |
| 33 { | 46 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); |
| 34 CPDF_Dictionary *pDict = m_pDoc->GetRoot(); | 47 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); |
| 35 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); | 48 if (!pDict) { |
| 36 if (!pDict) { | 49 return FX_BSTRC("None"); |
| 37 return 1; | 50 } |
| 38 } | 51 return pDict->GetString(FX_BSTRC("Duplex")); |
| 39 return pDict->GetInteger(FX_BSTRC("NumCopies")); | |
| 40 } | 52 } |
| 41 CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const | |
| 42 { | |
| 43 CPDF_Dictionary *pDict = m_pDoc->GetRoot(); | |
| 44 CPDF_Array *pRange = NULL; | |
| 45 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); | |
| 46 if (!pDict) { | |
| 47 return pRange; | |
| 48 } | |
| 49 pRange = pDict->GetArray(FX_BSTRC("PrintPageRange")); | |
| 50 return pRange; | |
| 51 } | |
| 52 CFX_ByteString CPDF_ViewerPreferences::Duplex() const | |
| 53 { | |
| 54 CPDF_Dictionary *pDict = m_pDoc->GetRoot(); | |
| 55 pDict = pDict->GetDict(FX_BSTRC("ViewerPreferences")); | |
| 56 if (!pDict) { | |
| 57 return FX_BSTRC("None"); | |
| 58 } | |
| 59 return pDict->GetString(FX_BSTRC("Duplex")); | |
| 60 } | |
| OLD | NEW |