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