summaryrefslogtreecommitdiff
path: root/fpdfsdk/fpdfview.cpp
diff options
context:
space:
mode:
authorthestig <thestig@chromium.org>2016-11-04 16:07:25 -0700
committerCommit bot <commit-bot@chromium.org>2016-11-04 16:07:25 -0700
commit04bebfe590d6d27a825b881fd234e31501843edc (patch)
tree127477b084005457579c599b2ec9eef0668a1479 /fpdfsdk/fpdfview.cpp
parent931d087b991a986cc8bfa72131fe8eda0d987fc4 (diff)
downloadpdfium-04bebfe590d6d27a825b881fd234e31501843edc.tar.xz
Implement FPDF_VIEWERREF_GetName() API.chromium/2910
This is a generic API function to retrieve any viewer preference of type name. BUG=pdfium:414 Review-Url: https://codereview.chromium.org/2475923003
Diffstat (limited to 'fpdfsdk/fpdfview.cpp')
-rw-r--r--fpdfsdk/fpdfview.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index cde15dff9b..9142dc78c9 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -942,6 +942,25 @@ FPDF_VIEWERREF_GetDuplex(FPDF_DOCUMENT document) {
return DuplexUndefined;
}
+DLLEXPORT unsigned long STDCALL FPDF_VIEWERREF_GetName(FPDF_DOCUMENT document,
+ FPDF_BYTESTRING key,
+ char* buffer,
+ unsigned long length) {
+ CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
+ if (!pDoc)
+ return 0;
+
+ CPDF_ViewerPreferences viewRef(pDoc);
+ CFX_ByteString bsVal;
+ if (!viewRef.GenericName(key, &bsVal))
+ return 0;
+
+ unsigned long dwStringLen = bsVal.GetLength() + 1;
+ if (buffer && length >= dwStringLen)
+ memcpy(buffer, bsVal.c_str(), dwStringLen);
+ return dwStringLen;
+}
+
DLLEXPORT FPDF_DWORD STDCALL FPDF_CountNamedDests(FPDF_DOCUMENT document) {
CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document);
if (!pDoc)