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

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

Issue 2475923003: Implement FPDF_VIEWERREF_GetName() API. (Closed)
Patch Set: Comment Created 4 years, 1 month 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/cpdf_viewerpreferences.h ('k') | fpdfsdk/fpdfview.cpp » ('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 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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/fpdfdoc/cpdf_viewerpreferences.h" 7 #include "core/fpdfdoc/cpdf_viewerpreferences.h"
8 8
9 #include "core/fpdfapi/parser/cpdf_document.h" 9 #include "core/fpdfapi/parser/cpdf_document.h"
10 #include "core/fpdfapi/parser/cpdf_name.h"
10 11
11 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc) 12 CPDF_ViewerPreferences::CPDF_ViewerPreferences(CPDF_Document* pDoc)
12 : m_pDoc(pDoc) {} 13 : m_pDoc(pDoc) {}
13 14
14 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {} 15 CPDF_ViewerPreferences::~CPDF_ViewerPreferences() {}
15 16
16 bool CPDF_ViewerPreferences::IsDirectionR2L() const { 17 bool CPDF_ViewerPreferences::IsDirectionR2L() const {
17 CPDF_Dictionary* pDict = GetViewerPreferences(); 18 CPDF_Dictionary* pDict = GetViewerPreferences();
18 return pDict ? pDict->GetStringFor("Direction") == "R2L" : false; 19 return pDict ? pDict->GetStringFor("Direction") == "R2L" : false;
19 } 20 }
(...skipping 11 matching lines...) Expand all
31 CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const { 32 CPDF_Array* CPDF_ViewerPreferences::PrintPageRange() const {
32 CPDF_Dictionary* pDict = GetViewerPreferences(); 33 CPDF_Dictionary* pDict = GetViewerPreferences();
33 return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr; 34 return pDict ? pDict->GetArrayFor("PrintPageRange") : nullptr;
34 } 35 }
35 36
36 CFX_ByteString CPDF_ViewerPreferences::Duplex() const { 37 CFX_ByteString CPDF_ViewerPreferences::Duplex() const {
37 CPDF_Dictionary* pDict = GetViewerPreferences(); 38 CPDF_Dictionary* pDict = GetViewerPreferences();
38 return pDict ? pDict->GetStringFor("Duplex") : CFX_ByteString("None"); 39 return pDict ? pDict->GetStringFor("Duplex") : CFX_ByteString("None");
39 } 40 }
40 41
42 bool CPDF_ViewerPreferences::GenericName(const CFX_ByteString& bsKey,
43 CFX_ByteString* bsVal) const {
44 ASSERT(bsVal);
45 CPDF_Dictionary* pDict = GetViewerPreferences();
46 if (!pDict)
47 return false;
48
49 const CPDF_Name* pName = ToName(pDict->GetObjectFor(bsKey));
50 if (!pName)
51 return false;
52
53 *bsVal = pName->GetString();
54 return true;
55 }
56
41 CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const { 57 CPDF_Dictionary* CPDF_ViewerPreferences::GetViewerPreferences() const {
42 CPDF_Dictionary* pDict = m_pDoc->GetRoot(); 58 CPDF_Dictionary* pDict = m_pDoc->GetRoot();
43 return pDict ? pDict->GetDictFor("ViewerPreferences") : nullptr; 59 return pDict ? pDict->GetDictFor("ViewerPreferences") : nullptr;
44 } 60 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_viewerpreferences.h ('k') | fpdfsdk/fpdfview.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698