OLD | NEW |
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 "../../public/fpdf_doc.h" | 8 #include "../../public/fpdf_doc.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { | 120 DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK pDict) { |
121 if (!pDict) | 121 if (!pDict) |
122 return NULL; | 122 return NULL; |
123 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); | 123 CPDF_Bookmark bookmark((CPDF_Dictionary*)pDict); |
124 return bookmark.GetAction().GetDict(); | 124 return bookmark.GetAction().GetDict(); |
125 } | 125 } |
126 | 126 |
127 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) { | 127 DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION pDict) { |
128 if (!pDict) | 128 if (!pDict) |
129 return 0; | 129 return PDFACTION_UNSUPPORTED; |
| 130 |
130 CPDF_Action action((CPDF_Dictionary*)pDict); | 131 CPDF_Action action((CPDF_Dictionary*)pDict); |
131 CPDF_Action::ActionType type = action.GetType(); | 132 CPDF_Action::ActionType type = action.GetType(); |
132 switch (type) { | 133 switch (type) { |
133 case CPDF_Action::GoTo: | 134 case CPDF_Action::GoTo: |
134 return PDFACTION_GOTO; | 135 return PDFACTION_GOTO; |
135 case CPDF_Action::GoToR: | 136 case CPDF_Action::GoToR: |
136 return PDFACTION_REMOTEGOTO; | 137 return PDFACTION_REMOTEGOTO; |
137 case CPDF_Action::URI: | 138 case CPDF_Action::URI: |
138 return PDFACTION_URI; | 139 return PDFACTION_URI; |
139 case CPDF_Action::Launch: | 140 case CPDF_Action::Launch: |
140 return PDFACTION_LAUNCH; | 141 return PDFACTION_LAUNCH; |
141 default: | 142 default: |
142 return PDFACTION_UNSUPPORTED; | 143 return PDFACTION_UNSUPPORTED; |
143 } | 144 } |
144 return PDFACTION_UNSUPPORTED; | |
145 } | 145 } |
146 | 146 |
147 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, | 147 DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document, |
148 FPDF_ACTION pDict) { | 148 FPDF_ACTION pDict) { |
149 if (!document) | 149 if (!document || !pDict) |
150 return NULL; | 150 return nullptr; |
151 if (!pDict) | 151 |
152 return NULL; | |
153 CPDF_Document* pDoc = (CPDF_Document*)document; | 152 CPDF_Document* pDoc = (CPDF_Document*)document; |
154 CPDF_Action action((CPDF_Dictionary*)pDict); | 153 CPDF_Action action((CPDF_Dictionary*)pDict); |
155 return action.GetDest(pDoc).GetObject(); | 154 return action.GetDest(pDoc).GetObject(); |
156 } | 155 } |
157 | 156 |
| 157 DLLEXPORT unsigned long STDCALL |
| 158 FPDFAction_GetFilePath(FPDF_ACTION pDict, void* buffer, unsigned long buflen) { |
| 159 unsigned long type = FPDFAction_GetType(pDict); |
| 160 if (type != PDFACTION_REMOTEGOTO && type != PDFACTION_LAUNCH) |
| 161 return 0; |
| 162 |
| 163 CPDF_Action action((CPDF_Dictionary*)pDict); |
| 164 CFX_ByteString path = action.GetFilePath().UTF8Encode(); |
| 165 unsigned long len = path.GetLength() + 1; |
| 166 if (buffer && buflen >= len) |
| 167 FXSYS_memcpy(buffer, path.c_str(), len); |
| 168 return len; |
| 169 } |
| 170 |
158 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, | 171 DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document, |
159 FPDF_ACTION pDict, | 172 FPDF_ACTION pDict, |
160 void* buffer, | 173 void* buffer, |
161 unsigned long buflen) { | 174 unsigned long buflen) { |
162 if (!document) | 175 if (!document || !pDict) |
163 return 0; | 176 return 0; |
164 if (!pDict) | 177 |
165 return 0; | |
166 CPDF_Document* pDoc = (CPDF_Document*)document; | 178 CPDF_Document* pDoc = (CPDF_Document*)document; |
167 CPDF_Action action((CPDF_Dictionary*)pDict); | 179 CPDF_Action action((CPDF_Dictionary*)pDict); |
168 CFX_ByteString path = action.GetURI(pDoc); | 180 CFX_ByteString path = action.GetURI(pDoc); |
169 unsigned long len = path.GetLength() + 1; | 181 unsigned long len = path.GetLength() + 1; |
170 if (buffer != NULL && buflen >= len) | 182 if (buffer && buflen >= len) |
171 FXSYS_memcpy(buffer, path.c_str(), len); | 183 FXSYS_memcpy(buffer, path.c_str(), len); |
172 return len; | 184 return len; |
173 } | 185 } |
174 | 186 |
175 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, | 187 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, |
176 FPDF_DEST pDict) { | 188 FPDF_DEST pDict) { |
177 if (!document) | 189 if (!document || !pDict) |
178 return 0; | 190 return 0; |
179 if (!pDict) | 191 |
180 return 0; | |
181 CPDF_Document* pDoc = (CPDF_Document*)document; | 192 CPDF_Document* pDoc = (CPDF_Document*)document; |
182 CPDF_Dest dest((CPDF_Array*)pDict); | 193 CPDF_Dest dest((CPDF_Array*)pDict); |
183 return dest.GetPageIndex(pDoc); | 194 return dest.GetPageIndex(pDoc); |
184 } | 195 } |
185 | 196 |
186 DLLEXPORT FPDF_LINK STDCALL | 197 DLLEXPORT FPDF_LINK STDCALL |
187 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { | 198 FPDFLink_GetLinkAtPoint(FPDF_PAGE page, double x, double y) { |
188 CPDF_Page* pPage = (CPDF_Page*)page; | 199 CPDF_Page* pPage = (CPDF_Page*)page; |
189 CPDF_LinkList* pLinkList = GetLinkList(pPage); | 200 CPDF_LinkList* pLinkList = GetLinkList(pPage); |
190 if (!pLinkList) | 201 if (!pLinkList) |
(...skipping 10 matching lines...) Expand all Loading... |
201 if (!pLinkList) | 212 if (!pLinkList) |
202 return -1; | 213 return -1; |
203 | 214 |
204 int z_order = -1; | 215 int z_order = -1; |
205 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); | 216 pLinkList->GetLinkAtPoint(pPage, (FX_FLOAT)x, (FX_FLOAT)y, &z_order); |
206 return z_order; | 217 return z_order; |
207 } | 218 } |
208 | 219 |
209 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, | 220 DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document, |
210 FPDF_LINK pDict) { | 221 FPDF_LINK pDict) { |
211 if (!document) | 222 if (!document || !pDict) |
212 return NULL; | 223 return nullptr; |
213 if (!pDict) | 224 |
214 return NULL; | |
215 CPDF_Document* pDoc = (CPDF_Document*)document; | 225 CPDF_Document* pDoc = (CPDF_Document*)document; |
216 CPDF_Link link((CPDF_Dictionary*)pDict); | 226 CPDF_Link link((CPDF_Dictionary*)pDict); |
217 FPDF_DEST dest = link.GetDest(pDoc).GetObject(); | 227 FPDF_DEST dest = link.GetDest(pDoc).GetObject(); |
218 if (dest) | 228 if (dest) |
219 return dest; | 229 return dest; |
220 // If this link is not directly associated with a dest, we try to get action | 230 // If this link is not directly associated with a dest, we try to get action |
221 CPDF_Action action = link.GetAction(); | 231 CPDF_Action action = link.GetAction(); |
222 if (!action) | 232 if (!action) |
223 return NULL; | 233 return nullptr; |
224 return action.GetDest(pDoc).GetObject(); | 234 return action.GetDest(pDoc).GetObject(); |
225 } | 235 } |
226 | 236 |
227 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) { | 237 DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK pDict) { |
228 if (!pDict) | 238 if (!pDict) |
229 return NULL; | 239 return nullptr; |
| 240 |
230 CPDF_Link link((CPDF_Dictionary*)pDict); | 241 CPDF_Link link((CPDF_Dictionary*)pDict); |
231 return link.GetAction().GetDict(); | 242 return link.GetAction().GetDict(); |
232 } | 243 } |
233 | 244 |
234 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, | 245 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, |
235 int* startPos, | 246 int* startPos, |
236 FPDF_LINK* linkAnnot) { | 247 FPDF_LINK* linkAnnot) { |
237 if (!page || !startPos || !linkAnnot) | 248 if (!page || !startPos || !linkAnnot) |
238 return FALSE; | 249 return FALSE; |
239 CPDF_Page* pPage = (CPDF_Page*)page; | 250 CPDF_Page* pPage = (CPDF_Page*)page; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 return 0; | 326 return 0; |
316 CFX_WideString text = pInfo->GetUnicodeText(tag); | 327 CFX_WideString text = pInfo->GetUnicodeText(tag); |
317 // Use UTF-16LE encoding | 328 // Use UTF-16LE encoding |
318 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 329 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
319 unsigned long len = encodedText.GetLength(); | 330 unsigned long len = encodedText.GetLength(); |
320 if (buffer && buflen >= len) { | 331 if (buffer && buflen >= len) { |
321 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 332 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
322 } | 333 } |
323 return len; | 334 return len; |
324 } | 335 } |
OLD | NEW |