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

Side by Side Diff: fpdfsdk/src/fpdfdoc.cpp

Issue 984773002: Make conversion between CPDF_Action and its dictionary explicit (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Tabs Created 5 years, 9 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/src/fpdfdoc/doc_link.cpp ('k') | fpdfsdk/src/fsdk_actionhandler.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 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 "../include/fsdk_define.h" 7 #include "../include/fsdk_define.h"
8 #include "../include/fpdfdoc.h" 8 #include "../include/fpdfdoc.h"
9 9
10 static int THISMODULE = 0; 10 static int THISMODULE = 0;
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (!action) 90 if (!action)
91 return NULL; 91 return NULL;
92 return action.GetDest(pDoc); 92 return action.GetDest(pDoc);
93 } 93 }
94 94
95 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) 95 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict)
96 { 96 {
97 if (!pDict) 97 if (!pDict)
98 return NULL; 98 return NULL;
99 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); 99 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
100 » return bookmark.GetAction(); 100 » return bookmark.GetAction().GetDict();
101 } 101 }
102 102
103 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) 103 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict)
104 { 104 {
105 if (!pDict) 105 if (!pDict)
106 return 0; 106 return 0;
107 » CPDF_Action action = (CPDF_Dictionary*)pDict; 107 » CPDF_Action action((CPDF_Dictionary*)pDict);
108 CPDF_Action::ActionType type = action.GetType(); 108 CPDF_Action::ActionType type = action.GetType();
109 switch (type) { 109 switch (type) {
110 case CPDF_Action::GoTo: 110 case CPDF_Action::GoTo:
111 return PDFACTION_GOTO; 111 return PDFACTION_GOTO;
112 case CPDF_Action::GoToR: 112 case CPDF_Action::GoToR:
113 return PDFACTION_REMOTEGOTO; 113 return PDFACTION_REMOTEGOTO;
114 case CPDF_Action::URI: 114 case CPDF_Action::URI:
115 return PDFACTION_URI; 115 return PDFACTION_URI;
116 case CPDF_Action::Launch: 116 case CPDF_Action::Launch:
117 return PDFACTION_LAUNCH; 117 return PDFACTION_LAUNCH;
118 default: 118 default:
119 return PDFACTION_UNSUPPORTED; 119 return PDFACTION_UNSUPPORTED;
120 } 120 }
121 return PDFACTION_UNSUPPORTED; 121 return PDFACTION_UNSUPPORTED;
122 } 122 }
123 123
124 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI ON pDict) 124 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI ON pDict)
125 { 125 {
126 if (!document) 126 if (!document)
127 return NULL; 127 return NULL;
128 if (!pDict) 128 if (!pDict)
129 return NULL; 129 return NULL;
130 CPDF_Document* pDoc = (CPDF_Document*)document; 130 CPDF_Document* pDoc = (CPDF_Document*)document;
131 » CPDF_Action action = (CPDF_Dictionary*)pDict; 131 » CPDF_Action action((CPDF_Dictionary*)pDict);
132 return action.GetDest(pDoc); 132 return action.GetDest(pDoc);
133 } 133 }
134 134
135 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP DF_ACTION pDict, 135 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP DF_ACTION pDict,
136 void* buffer, unsigned long buflen) 136 void* buffer, unsigned long buflen)
137 { 137 {
138 if (!document) 138 if (!document)
139 return 0; 139 return 0;
140 if (!pDict) 140 if (!pDict)
141 return 0; 141 return 0;
142 CPDF_Document* pDoc = (CPDF_Document*)document; 142 CPDF_Document* pDoc = (CPDF_Document*)document;
143 » CPDF_Action action = (CPDF_Dictionary*)pDict; 143 » CPDF_Action action((CPDF_Dictionary*)pDict);
144 CFX_ByteString path = action.GetURI(pDoc); 144 CFX_ByteString path = action.GetURI(pDoc);
145 unsigned long len = path.GetLength() + 1; 145 unsigned long len = path.GetLength() + 1;
146 if (buffer != NULL && buflen >= len) 146 if (buffer != NULL && buflen >= len)
147 FXSYS_memcpy(buffer, path.c_str(), len); 147 FXSYS_memcpy(buffer, path.c_str(), len);
148 return len; 148 return len;
149 } 149 }
150 150
151 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP DF_DEST pDict) 151 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP DF_DEST pDict)
152 { 152 {
153 if (!document) 153 if (!document)
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 if (!action) 196 if (!action)
197 return NULL; 197 return NULL;
198 return action.GetDest(pDoc); 198 return action.GetDest(pDoc);
199 } 199 }
200 200
201 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) 201 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict)
202 { 202 {
203 if (!pDict) 203 if (!pDict)
204 return NULL; 204 return NULL;
205 CPDF_Link link = (CPDF_Dictionary*)pDict; 205 CPDF_Link link = (CPDF_Dictionary*)pDict;
206 » return link.GetAction(); 206 » return link.GetAction().GetDict();
207 } 207 }
208 208
209 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP DF_LINK* linkAnnot) 209 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP DF_LINK* linkAnnot)
210 { 210 {
211 if(!page || !startPos || !linkAnnot) 211 if(!page || !startPos || !linkAnnot)
212 return FALSE; 212 return FALSE;
213 CPDF_Page* pPage = (CPDF_Page*)page; 213 CPDF_Page* pPage = (CPDF_Page*)page;
214 if(!pPage->m_pFormDict) 214 if(!pPage->m_pFormDict)
215 return FALSE; 215 return FALSE;
216 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); 216 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 return 0; 288 return 0;
289 CFX_WideString text = pInfo->GetUnicodeText(tag); 289 CFX_WideString text = pInfo->GetUnicodeText(tag);
290 // Use UTF-16LE encoding 290 // Use UTF-16LE encoding
291 CFX_ByteString encodedText = text.UTF16LE_Encode(); 291 CFX_ByteString encodedText = text.UTF16LE_Encode();
292 unsigned long len = encodedText.GetLength(); 292 unsigned long len = encodedText.GetLength();
293 if (buffer && buflen >= len) { 293 if (buffer && buflen >= len) {
294 FXSYS_memcpy(buffer, encodedText.c_str(), len); 294 FXSYS_memcpy(buffer, encodedText.c_str(), len);
295 } 295 }
296 return len; 296 return len;
297 } 297 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_link.cpp ('k') | fpdfsdk/src/fsdk_actionhandler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698