diff options
author | Jane Liu <janeliulwq@google.com> | 2017-07-06 12:01:25 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-07-06 17:11:48 +0000 |
commit | 2e1a32bc49f2b7b871cf0d04f25ec45b337f06fb (patch) | |
tree | bbdadb63a74dab598f7990a7aa296eb71f8a99da /public | |
parent | 3656774aa2b654f3c26c188c45a1d284962e9c43 (diff) | |
download | pdfium-2e1a32bc49f2b7b871cf0d04f25ec45b337f06fb.tar.xz |
Added APIs for getting/setting string pairs in annotation dictionaries
1. Added APIs for getting/setting arbitary key + value string pairs in
annotation dictionaries.
* Added an embedder test testing all the new functions.
Bug=pdfium:737
Change-Id: I93c9ca6fccf787028e106607ef8cf549ebca95d8
Reviewed-on: https://pdfium-review.googlesource.com/7150
Commit-Queue: Jane Liu <janeliulwq@google.com>
Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'public')
-rw-r--r-- | public/fpdf_annot.h | 73 | ||||
-rw-r--r-- | public/fpdfview.h | 3 |
2 files changed, 56 insertions, 20 deletions
diff --git a/public/fpdf_annot.h b/public/fpdf_annot.h index 7c3b7247c8..31779a5cd8 100644 --- a/public/fpdf_annot.h +++ b/public/fpdf_annot.h @@ -57,16 +57,22 @@ extern "C" { #define FPDF_ANNOT_FLAG_LOCKED (1 << 7) #define FPDF_ANNOT_FLAG_TOGGLENOVIEW (1 << 8) +#define FPDF_OBJECT_UNKNOWN 0 +#define FPDF_OBJECT_BOOLEAN 1 +#define FPDF_OBJECT_NUMBER 2 +#define FPDF_OBJECT_STRING 3 +#define FPDF_OBJECT_NAME 4 +#define FPDF_OBJECT_ARRAY 5 +#define FPDF_OBJECT_DICTIONARY 6 +#define FPDF_OBJECT_STREAM 7 +#define FPDF_OBJECT_NULLOBJ 8 +#define FPDF_OBJECT_REFERENCE 9 + typedef enum FPDFANNOT_COLORTYPE { FPDFANNOT_COLORTYPE_Color = 0, FPDFANNOT_COLORTYPE_InteriorColor } FPDFANNOT_COLORTYPE; -typedef enum FPDFANNOT_TEXTTYPE { - FPDFANNOT_TEXTTYPE_Contents = 0, - FPDFANNOT_TEXTTYPE_Author -} FPDFANNOT_TEXTTYPE; - // Experimental API. // Check if an annotation subtype is currently supported for creation. // Currently supported subtypes: circle, highlight, ink, popup, square, @@ -281,31 +287,58 @@ DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetRect(FPDF_ANNOTATION annot, DLLEXPORT FS_RECTF STDCALL FPDFAnnot_GetRect(FPDF_ANNOTATION annot); // Experimental API. -// Set the contents of an annotation. +// Check if |annot|'s dictionary has |key| as a key. +// +// annot - handle to an annotation. +// key - the key to look for. +// +// Returns true if |key| exists. +DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_HasKey(FPDF_ANNOTATION annot, + FPDF_WIDESTRING key); + +// Experimental API. +// Get the type of the value corresponding to |key| in |annot|'s dictioanry. +// +// annot - handle to an annotation. +// key - the key to look for. +// +// Returns the type of the dictionary value. +DLLEXPORT FPDF_OBJECT_TYPE STDCALL FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, + FPDF_WIDESTRING key); + +// Experimental API. +// Set the string value corresponding to |key| in |annot|'s dictionary, +// overwriting the existing value if any. The value type would be +// FPDF_OBJECT_STRING after this function call. // // annot - handle to an annotation. -// type - type of the text to be set. -// text - the text to be set. +// key - the key to the dictionary entry to be set, encoded in UTF16-LE. +// value - the string value to be set, encoded in UTF16-LE. // // Returns true if successful. -DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetText(FPDF_ANNOTATION annot, - FPDFANNOT_TEXTTYPE type, - FPDF_WIDESTRING text); +DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, + FPDF_WIDESTRING key, + FPDF_WIDESTRING value); // Experimental API. -// Get the contents of an annotation. |buffer| is only modified if |buflen| -// is longer than the length of contents. +// Get the string value corresponding to |key| in |annot|'s dictionary. |buffer| +// is only modified if |buflen| is longer than the length of contents. Note that +// if |key| does not exist in the dictionary or if |key|'s corresponding value +// in the dictionary is not a string (i.e. the value is not of type +// FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied +// to |buffer| and the return value would be 2. On other errors, nothing would +// be added to |buffer| and the return value would be 0. // // annot - handle to an annotation. -// type - type of the text requested. -// buffer - buffer for holding the contents string, encoded in UTF16-LE. +// key - the key to the requested dictionary entry. +// buffer - buffer for holding the value string, encoded in UTF16-LE. // buflen - length of the buffer. // -// Returns the length of the contents. -DLLEXPORT unsigned long STDCALL FPDFAnnot_GetText(FPDF_ANNOTATION annot, - FPDFANNOT_TEXTTYPE type, - void* buffer, - unsigned long buflen); +// Returns the length of the string value. +DLLEXPORT unsigned long STDCALL FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, + FPDF_WIDESTRING key, + void* buffer, + unsigned long buflen); // Experimental API. // Get the annotation flags of |annot|. diff --git a/public/fpdfview.h b/public/fpdfview.h index ba5cb4ff66..1ff0aeb267 100644 --- a/public/fpdfview.h +++ b/public/fpdfview.h @@ -126,6 +126,9 @@ typedef const FS_RECTF* FS_LPCRECTF; // Annotation subtype. typedef int FPDF_ANNOTATION_SUBTYPE; +// Dictionary value types. +typedef int FPDF_OBJECT_TYPE; + #if defined(_WIN32) && defined(FPDFSDK_EXPORTS) // On Windows system, functions are exported in a DLL #define DLLEXPORT __declspec(dllexport) |