Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1070)

Side by Side Diff: core/fpdfdoc/doc_viewerPreferences.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix a bad merge Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/doc_utils.cpp ('k') | core/fpdfdoc/include/cpdf_variabletext.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/fpdfapi/fpdf_parser/include/cpdf_document.h" 7 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
8 #include "core/fpdfdoc/include/fpdf_doc.h" 8 #include "core/fpdfdoc/include/fpdf_doc.h"
9 9
10 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) 10 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc)
11 : m_pDoc(pDoc) {} 11 : m_pDoc(pDoc) {}
12
12 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} 13 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {}
14
13 FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const { 15 FX_BOOL CPDF_ViewerPreferences::IsDirectionR2L() const {
16 CPDF_Dictionary* pDict = GetViewerPreferences();
17 return pDict ? pDict->GetStringBy("Direction") == "R2L" : FALSE;
18 }
19
20 FX_BOOL CPDF_ViewerPreferences::PrintScaling() const {
21 CPDF_Dictionary* pDict = GetViewerPreferences();
22 return pDict ? pDict->GetStringBy("PrintScaling") != "None" : TRUE;
23 }
24
25 int32_t CPDF_ViewerPreferences::NumCopies() const {
26 CPDF_Dictionary* pDict = GetViewerPreferences();
27 return pDict ? pDict->GetIntegerBy("NumCopies") : 1;
28 }
29
30 CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
31 CPDF_Dictionary* pDict = GetViewerPreferences();
32 return pDict ? pDict->GetArrayBy("PrintPageRange") : nullptr;
33 }
34
35 CFX_ByteString CPDF_ViewerPreferences::Duplex() const {
36 CPDF_Dictionary* pDict = GetViewerPreferences();
37 return pDict ? pDict->GetStringBy("Duplex") : CFX_ByteString("None");
38 }
39
40 CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const {
14 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); 41 CPDF_Dictionary* pDict = m_pDoc->GetRoot();
15 pDict = pDict->GetDictBy("ViewerPreferences"); 42 return pDict ? pDict->GetDictBy("ViewerPreferences") : nullptr;
16 if (!pDict) {
17 return FALSE;
18 }
19 return "R2L" == pDict->GetStringBy("Direction");
20 } 43 }
21 FX_BOOL CPDF_ViewerPreferences::PrintScaling() const {
22 CPDF_Dictionary* pDict = m_pDoc->GetRoot();
23 pDict = pDict->GetDictBy("ViewerPreferences");
24 if (!pDict) {
25 return TRUE;
26 }
27 return "None" != pDict->GetStringBy("PrintScaling");
28 }
29 int32_t CPDF_ViewerPreferences::NumCopies() const {
30 CPDF_Dictionary* pDict = m_pDoc->GetRoot();
31 pDict = pDict->GetDictBy("ViewerPreferences");
32 if (!pDict) {
33 return 1;
34 }
35 return pDict->GetIntegerBy("NumCopies");
36 }
37 CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
38 CPDF_Dictionary* pDict = m_pDoc->GetRoot();
39 CPDF_Array* pRange = NULL;
40 pDict = pDict->GetDictBy("ViewerPreferences");
41 if (!pDict) {
42 return pRange;
43 }
44 pRange = pDict->GetArrayBy("PrintPageRange");
45 return pRange;
46 }
47 CFX_ByteString CPDF_ViewerPreferences::Duplex() const {
48 CPDF_Dictionary* pDict = m_pDoc->GetRoot();
49 pDict = pDict->GetDictBy("ViewerPreferences");
50 if (!pDict) {
51 return "None";
52 }
53 return pDict->GetStringBy("Duplex");
54 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/doc_utils.cpp ('k') | core/fpdfdoc/include/cpdf_variabletext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698