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

Side by Side Diff: fpdfsdk/fpdfview.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.cpp ('k') | fpdfsdk/fpdfview_c_api_test.c » ('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 "public/fpdfview.h" 7 #include "public/fpdfview.h"
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 CFX_ByteString duplex = viewRef.Duplex(); 935 CFX_ByteString duplex = viewRef.Duplex();
936 if ("Simplex" == duplex) 936 if ("Simplex" == duplex)
937 return Simplex; 937 return Simplex;
938 if ("DuplexFlipShortEdge" == duplex) 938 if ("DuplexFlipShortEdge" == duplex)
939 return DuplexFlipShortEdge; 939 return DuplexFlipShortEdge;
940 if ("DuplexFlipLongEdge" == duplex) 940 if ("DuplexFlipLongEdge" == duplex)
941 return DuplexFlipLongEdge; 941 return DuplexFlipLongEdge;
942 return DuplexUndefined; 942 return DuplexUndefined;
943 } 943 }
944 944
945 DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
946 FPDF_BYTESTRING key,
947 char* buffer,
948 unsigned long length) {
949 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
950 if (!pDoc)
951 return 0;
952
953 CPDF_ViewerPreferences viewRef(pDoc);
954 CFX_ByteString bsVal;
955 if (!viewRef.GenericName(key, &bsVal))
956 return 0;
957
958 unsigned long dwStringLen = bsVal.GetLength() + 1;
959 if (buffer && length >= dwStringLen)
960 memcpy(buffer, bsVal.c_str(), dwStringLen);
961 return dwStringLen;
962 }
963
945 DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document) { 964 DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document) {
946 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document); 965 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
947 if (!pDoc) 966 if (!pDoc)
948 return 0; 967 return 0;
949 968
950 CPDF_Dictionary* pRoot = pDoc->GetRoot(); 969 CPDF_Dictionary* pRoot = pDoc->GetRoot();
951 if (!pRoot) 970 if (!pRoot)
952 return 0; 971 return 0;
953 972
954 CPDF_NameTree nameTree(pDoc, "Dests"); 973 CPDF_NameTree nameTree(pDoc, "Dests");
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 if (!buffer) { 1110 if (!buffer) {
1092 *buflen = len; 1111 *buflen = len;
1093 } else if (*buflen >= len) { 1112 } else if (*buflen >= len) {
1094 memcpy(buffer, utf16Name.c_str(), len); 1113 memcpy(buffer, utf16Name.c_str(), len);
1095 *buflen = len; 1114 *buflen = len;
1096 } else { 1115 } else {
1097 *buflen = -1; 1116 *buflen = -1;
1098 } 1117 }
1099 return (FPDF_DEST)pDestObj; 1118 return (FPDF_DEST)pDestObj;
1100 } 1119 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpdf_viewerpreferences.cpp ('k') | fpdfsdk/fpdfview_c_api_test.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698