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

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

Issue 1345953002: Merge to XFA: Implement FPDFAction_GetFilePath(). (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: rebase Created 5 years, 3 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_action.cpp ('k') | fpdfsdk/src/fpdfdoc_embeddertest.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 "../../public/fpdf_doc.h" 7 #include "../../public/fpdf_doc.h"
8 #include "../include/fsdk_define.h" 8 #include "../include/fsdk_define.h"
9 #include "../include/fpdfxfa/fpdfxfa_doc.h" 9 #include "../include/fpdfxfa/fpdfxfa_doc.h"
10 #include "../include/fpdfxfa/fpdfxfa_page.h" 10 #include "../include/fpdfxfa/fpdfxfa_page.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 121
122 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { 122 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) {
123 if (!pDict) 123 if (!pDict)
124 return NULL; 124 return NULL;
125 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); 125 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
126 return bookmark.GetAction().GetDict(); 126 return bookmark.GetAction().GetDict();
127 } 127 }
128 128
129 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) { 129 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) {
130 if (!pDict) 130 if (!pDict)
131 return 0; 131 return PDFACTION_UNSUPPORTED;
132
132 CPDF_Action action((CPDF_Dictionary*)pDict); 133 CPDF_Action action((CPDF_Dictionary*)pDict);
133 CPDF_Action::ActionType type = action.GetType(); 134 CPDF_Action::ActionType type = action.GetType();
134 switch (type) { 135 switch (type) {
135 case CPDF_Action::GoTo: 136 case CPDF_Action::GoTo:
136 return PDFACTION_GOTO; 137 return PDFACTION_GOTO;
137 case CPDF_Action::GoToR: 138 case CPDF_Action::GoToR:
138 return PDFACTION_REMOTEGOTO; 139 return PDFACTION_REMOTEGOTO;
139 case CPDF_Action::URI: 140 case CPDF_Action::URI:
140 return PDFACTION_URI; 141 return PDFACTION_URI;
141 case CPDF_Action::Launch: 142 case CPDF_Action::Launch:
142 return PDFACTION_LAUNCH; 143 return PDFACTION_LAUNCH;
143 default: 144 default:
144 return PDFACTION_UNSUPPORTED; 145 return PDFACTION_UNSUPPORTED;
145 } 146 }
146 return PDFACTION_UNSUPPORTED;
147 } 147 }
148 148
149 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, 149 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
150 FPDF_ACTION pDict) { 150 FPDF_ACTION pDict) {
151 if (!document) 151 if (!document || !pDict)
152 return NULL; 152 return nullptr;
153 if (!pDict) 153
154 return NULL;
155 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 154 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
156 CPDF_Action action((CPDF_Dictionary*)pDict); 155 CPDF_Action action((CPDF_Dictionary*)pDict);
157 return action.GetDest(pDoc).GetObject(); 156 return action.GetDest(pDoc).GetObject();
158 } 157 }
159 158
159 DLLEXPORT unsigned long STDCALL
160 FPDFAction_GetFilePath(FPDF_ACTION pDict, void* buffer, unsigned long buflen) {
161 unsigned long type = FPDFAction_GetType(pDict);
162 if (type != PDFACTION_REMOTEGOTO && type != PDFACTION_LAUNCH)
163 return 0;
164
165 CPDF_Action action((CPDF_Dictionary*)pDict);
166 CFX_ByteString path = action.GetFilePath().UTF8Encode();
167 unsigned long len = path.GetLength() + 1;
168 if (buffer && buflen >= len)
169 FXSYS_memcpy(buffer, path.c_str(), len);
170 return len;
171 }
172
160 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, 173 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
161 FPDF_ACTION pDict, 174 FPDF_ACTION pDict,
162 void* buffer, 175 void* buffer,
163 unsigned long buflen) { 176 unsigned long buflen) {
164 if (!document) 177 if (!document || !pDict)
165 return 0; 178 return 0;
166 if (!pDict) 179
167 return 0;
168 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 180 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
169 CPDF_Action action((CPDF_Dictionary*)pDict); 181 CPDF_Action action((CPDF_Dictionary*)pDict);
170 CFX_ByteString path = action.GetURI(pDoc); 182 CFX_ByteString path = action.GetURI(pDoc);
171 unsigned long len = path.GetLength() + 1; 183 unsigned long len = path.GetLength() + 1;
172 if (buffer != NULL && buflen >= len) 184 if (buffer && buflen >= len)
173 FXSYS_memcpy(buffer, path.c_str(), len); 185 FXSYS_memcpy(buffer, path.c_str(), len);
174 return len; 186 return len;
175 } 187 }
176 188
177 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, 189 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
178 FPDF_DEST pDict) { 190 FPDF_DEST pDict) {
179 if (!document) 191 if (!document || !pDict)
180 return 0; 192 return 0;
181 if (!pDict) 193
182 return 0;
183 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 194 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
184 CPDF_Dest dest((CPDF_Array*)pDict); 195 CPDF_Dest dest((CPDF_Array*)pDict);
185 return dest.GetPageIndex(pDoc); 196 return dest.GetPageIndex(pDoc);
186 } 197 }
187 198
188 DLLEXPORT FPDF_LINK STDCALL 199 DLLEXPORT FPDF_LINK STDCALL
189 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { 200 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) {
190 CPDFXFA_Page* pXFAPage = (CPDFXFA_Page*)page; 201 CPDFXFA_Page* pXFAPage = (CPDFXFA_Page*)page;
191 CPDF_Page* pPage = pXFAPage->GetPDFPage(); 202 CPDF_Page* pPage = pXFAPage->GetPDFPage();
192 if (!pPage) 203 if (!pPage)
(...skipping 18 matching lines...) Expand all
211 if (!pLinkList) 222 if (!pLinkList)
212 return -1; 223 return -1;
213 224
214 int z_order = -1; 225 int z_order = -1;
215 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); 226 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order);
216 return z_order; 227 return z_order;
217 } 228 }
218 229
219 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, 230 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
220 FPDF_LINK pDict) { 231 FPDF_LINK pDict) {
221 if (!document) 232 if (!document || !pDict)
222 return NULL; 233 return nullptr;
223 if (!pDict) 234
224 return NULL;
225 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 235 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
226 CPDF_Link link((CPDF_Dictionary*)pDict); 236 CPDF_Link link((CPDF_Dictionary*)pDict);
227 FPDF_DEST dest = link.GetDest(pDoc).GetObject(); 237 FPDF_DEST dest = link.GetDest(pDoc).GetObject();
228 if (dest) 238 if (dest)
229 return dest; 239 return dest;
230 // If this link is not directly associated with a dest, we try to get action 240 // If this link is not directly associated with a dest, we try to get action
231 CPDF_Action action = link.GetAction(); 241 CPDF_Action action = link.GetAction();
232 if (!action) 242 if (!action)
233 return NULL; 243 return nullptr;
234 return action.GetDest(pDoc).GetObject(); 244 return action.GetDest(pDoc).GetObject();
235 } 245 }
236 246
237 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) { 247 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) {
238 if (!pDict) 248 if (!pDict)
239 return NULL; 249 return nullptr;
250
240 CPDF_Link link((CPDF_Dictionary*)pDict); 251 CPDF_Link link((CPDF_Dictionary*)pDict);
241 return link.GetAction().GetDict(); 252 return link.GetAction().GetDict();
242 } 253 }
243 254
244 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, 255 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page,
245 int* startPos, 256 int* startPos,
246 FPDF_LINK* linkAnnot) { 257 FPDF_LINK* linkAnnot) {
247 if (!page || !startPos || !linkAnnot) 258 if (!page || !startPos || !linkAnnot)
248 return FALSE; 259 return FALSE;
249 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 260 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 return 0; 336 return 0;
326 CFX_WideString text = pInfo->GetUnicodeText(tag); 337 CFX_WideString text = pInfo->GetUnicodeText(tag);
327 // Use UTF-16LE encoding 338 // Use UTF-16LE encoding
328 CFX_ByteString encodedText = text.UTF16LE_Encode(); 339 CFX_ByteString encodedText = text.UTF16LE_Encode();
329 unsigned long len = encodedText.GetLength(); 340 unsigned long len = encodedText.GetLength();
330 if (buffer && buflen >= len) { 341 if (buffer && buflen >= len) {
331 FXSYS_memcpy(buffer, encodedText.c_str(), len); 342 FXSYS_memcpy(buffer, encodedText.c_str(), len);
332 } 343 }
333 return len; 344 return len;
334 } 345 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_action.cpp ('k') | fpdfsdk/src/fpdfdoc_embeddertest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698