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 9 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) 10 : m_pDoc(pDoc) {} 11 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} 12 FX_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 } 20 FX_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 } 28 int32_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 } 36 CPDF_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 } 46 CFX_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