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

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

Issue 984783002: Merge to XFA: Make conversion between CPDF_Action and its dictionary explicit. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: 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 #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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 if (!action) 92 if (!action)
93 return NULL; 93 return NULL;
94 return action.GetDest(pDoc); 94 return action.GetDest(pDoc);
95 } 95 }
96 96
97 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) 97 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict)
98 { 98 {
99 if (!pDict) 99 if (!pDict)
100 return NULL; 100 return NULL;
101 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); 101 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict);
102 » return bookmark.GetAction(); 102 » return bookmark.GetAction().GetDict();
103 } 103 }
104 104
105 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) 105 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict)
106 { 106 {
107 if (!pDict) 107 if (!pDict)
108 return 0; 108 return 0;
109 » CPDF_Action action = (CPDF_Dictionary*)pDict; 109 » CPDF_Action action((CPDF_Dictionary*)pDict);
110 CPDF_Action::ActionType type = action.GetType(); 110 CPDF_Action::ActionType type = action.GetType();
111 switch (type) { 111 switch (type) {
112 case CPDF_Action::GoTo: 112 case CPDF_Action::GoTo:
113 return PDFACTION_GOTO; 113 return PDFACTION_GOTO;
114 case CPDF_Action::GoToR: 114 case CPDF_Action::GoToR:
115 return PDFACTION_REMOTEGOTO; 115 return PDFACTION_REMOTEGOTO;
116 case CPDF_Action::URI: 116 case CPDF_Action::URI:
117 return PDFACTION_URI; 117 return PDFACTION_URI;
118 case CPDF_Action::Launch: 118 case CPDF_Action::Launch:
119 return PDFACTION_LAUNCH; 119 return PDFACTION_LAUNCH;
120 default: 120 default:
121 return PDFACTION_UNSUPPORTED; 121 return PDFACTION_UNSUPPORTED;
122 } 122 }
123 return PDFACTION_UNSUPPORTED; 123 return PDFACTION_UNSUPPORTED;
124 } 124 }
125 125
126 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI ON pDict) 126 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, FPDF_ACTI ON pDict)
127 { 127 {
128 if (!document) 128 if (!document)
129 return NULL; 129 return NULL;
130 if (!pDict) 130 if (!pDict)
131 return NULL; 131 return NULL;
132 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 132 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
133 » CPDF_Action action = (CPDF_Dictionary*)pDict; 133 » CPDF_Action action((CPDF_Dictionary*)pDict);
134 return action.GetDest(pDoc); 134 return action.GetDest(pDoc);
135 } 135 }
136 136
137 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP DF_ACTION pDict, 137 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, FP DF_ACTION pDict,
138 void* buffer, unsigned long buflen) 138 void* buffer, unsigned long buflen)
139 { 139 {
140 if (!document) 140 if (!document)
141 return 0; 141 return 0;
142 if (!pDict) 142 if (!pDict)
143 return 0; 143 return 0;
144 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc(); 144 CPDF_Document* pDoc = ((CPDFXFA_Document*)document)->GetPDFDoc();
145 » CPDF_Action action = (CPDF_Dictionary*)pDict; 145 » CPDF_Action action((CPDF_Dictionary*)pDict);
146 CFX_ByteString path = action.GetURI(pDoc); 146 CFX_ByteString path = action.GetURI(pDoc);
147 unsigned long len = path.GetLength() + 1; 147 unsigned long len = path.GetLength() + 1;
148 if (buffer != NULL && buflen >= len) 148 if (buffer != NULL && buflen >= len)
149 FXSYS_memcpy(buffer, path.c_str(), len); 149 FXSYS_memcpy(buffer, path.c_str(), len);
150 return len; 150 return len;
151 } 151 }
152 152
153 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP DF_DEST pDict) 153 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FP DF_DEST pDict)
154 { 154 {
155 if (!document) 155 if (!document)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 if (!action) 200 if (!action)
201 return NULL; 201 return NULL;
202 return action.GetDest(pDoc); 202 return action.GetDest(pDoc);
203 } 203 }
204 204
205 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) 205 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict)
206 { 206 {
207 if (!pDict) 207 if (!pDict)
208 return NULL; 208 return NULL;
209 CPDF_Link link = (CPDF_Dictionary*)pDict; 209 CPDF_Link link = (CPDF_Dictionary*)pDict;
210 » return link.GetAction(); 210 » return link.GetAction().GetDict();
211 } 211 }
212 212
213 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP DF_LINK* linkAnnot) 213 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP DF_LINK* linkAnnot)
214 { 214 {
215 if(!page || !startPos || !linkAnnot) 215 if(!page || !startPos || !linkAnnot)
216 return FALSE; 216 return FALSE;
217 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage(); 217 CPDF_Page* pPage = ((CPDFXFA_Page*)page)->GetPDFPage();
218 if(!pPage->m_pFormDict) 218 if(!pPage->m_pFormDict)
219 return FALSE; 219 return FALSE;
220 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); 220 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots");
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 return 0; 292 return 0;
293 CFX_WideString text = pInfo->GetUnicodeText(tag); 293 CFX_WideString text = pInfo->GetUnicodeText(tag);
294 // Use UTF-16LE encoding 294 // Use UTF-16LE encoding
295 CFX_ByteString encodedText = text.UTF16LE_Encode(); 295 CFX_ByteString encodedText = text.UTF16LE_Encode();
296 unsigned long len = encodedText.GetLength(); 296 unsigned long len = encodedText.GetLength();
297 if (buffer && buflen >= len) { 297 if (buffer && buflen >= len) {
298 FXSYS_memcpy(buffer, encodedText.c_str(), len); 298 FXSYS_memcpy(buffer, encodedText.c_str(), len);
299 } 299 }
300 return len; 300 return len;
301 } 301 }
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