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 static int THISMODULE = 0; | 10 static int THISMODULE = 0; |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 { | 201 { |
202 if (!pDict) | 202 if (!pDict) |
203 return NULL; | 203 return NULL; |
204 CPDF_Link link((CPDF_Dictionary*)pDict); | 204 CPDF_Link link((CPDF_Dictionary*)pDict); |
205 return link.GetAction().GetDict(); | 205 return link.GetAction().GetDict(); |
206 } | 206 } |
207 | 207 |
208 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP
DF_LINK* linkAnnot) | 208 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, int* startPos, FP
DF_LINK* linkAnnot) |
209 { | 209 { |
210 if(!page || !startPos || !linkAnnot) | 210 if(!page || !startPos || !linkAnnot) |
211 » » return FALSE; | 211 » » return false; |
212 CPDF_Page* pPage = (CPDF_Page*)page; | 212 CPDF_Page* pPage = (CPDF_Page*)page; |
213 if(!pPage->m_pFormDict) | 213 if(!pPage->m_pFormDict) |
214 » » return FALSE; | 214 » » return false; |
215 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); | 215 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArray("Annots"); |
216 if(!pAnnots) | 216 if(!pAnnots) |
217 » » return FALSE; | 217 » » return false; |
218 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { | 218 for (int i = *startPos; i < (int)pAnnots->GetCount(); i++) { |
219 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementVa
lue(i); | 219 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementVa
lue(i); |
220 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) | 220 if (!pDict || pDict->GetType() != PDFOBJ_DICTIONARY) |
221 continue; | 221 continue; |
222 if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))
) { | 222 if(pDict->GetString(FX_BSTRC("Subtype")).Equal(FX_BSTRC("Link"))
) { |
223 *startPos = i + 1; | 223 *startPos = i + 1; |
224 *linkAnnot = (FPDF_LINK)pDict; | 224 *linkAnnot = (FPDF_LINK)pDict; |
225 » » » return TRUE; | 225 » » » return true; |
226 } | 226 } |
227 } | 227 } |
228 » return FALSE; | 228 » return false; |
229 } | 229 } |
230 | 230 |
231 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF*
rect) | 231 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, FS_RECTF*
rect) |
232 { | 232 { |
233 if(!linkAnnot || !rect) | 233 if(!linkAnnot || !rect) |
234 » » return FALSE; | 234 » » return false; |
235 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; | 235 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; |
236 CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect")); | 236 CPDF_Rect rt = pAnnotDict->GetRect(FX_BSTRC("Rect")); |
237 rect->left = rt.left; | 237 rect->left = rt.left; |
238 rect->bottom = rt.bottom; | 238 rect->bottom = rt.bottom; |
239 rect->right = rt.right; | 239 rect->right = rt.right; |
240 rect->top = rt.top; | 240 rect->top = rt.top; |
241 » return TRUE; | 241 » return true; |
242 } | 242 } |
243 | 243 |
244 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) | 244 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) |
245 { | 245 { |
246 if(!linkAnnot) | 246 if(!linkAnnot) |
247 return 0; | 247 return 0; |
248 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; | 248 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; |
249 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); | 249 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); |
250 if (!pArray) | 250 if (!pArray) |
251 return 0; | 251 return 0; |
252 else | 252 else |
253 return pArray->GetCount() / 8; | 253 return pArray->GetCount() / 8; |
254 } | 254 } |
255 | 255 |
256 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quad
Index, FS_QUADPOINTSF* quadPoints) | 256 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, int quad
Index, FS_QUADPOINTSF* quadPoints) |
257 { | 257 { |
258 if(!linkAnnot || !quadPoints) | 258 if(!linkAnnot || !quadPoints) |
259 » » return FALSE; | 259 » » return false; |
260 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; | 260 CPDF_Dictionary* pAnnotDict = (CPDF_Dictionary*)linkAnnot; |
261 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); | 261 CPDF_Array* pArray = pAnnotDict->GetArray(FX_BSTRC("QuadPoints")); |
262 if (pArray) { | 262 if (pArray) { |
263 if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || (
(quadIndex*8+7) >= (int)pArray->GetCount())) | 263 if (quadIndex < 0 || quadIndex >= (int)pArray->GetCount()/8 || (
(quadIndex*8+7) >= (int)pArray->GetCount())) |
264 » » » return FALSE; | 264 » » » return false; |
265 quadPoints->x1 = pArray->GetNumber(quadIndex*8); | 265 quadPoints->x1 = pArray->GetNumber(quadIndex*8); |
266 quadPoints->y1 = pArray->GetNumber(quadIndex*8+1); | 266 quadPoints->y1 = pArray->GetNumber(quadIndex*8+1); |
267 quadPoints->x2 = pArray->GetNumber(quadIndex*8+2); | 267 quadPoints->x2 = pArray->GetNumber(quadIndex*8+2); |
268 quadPoints->y2 = pArray->GetNumber(quadIndex*8+3); | 268 quadPoints->y2 = pArray->GetNumber(quadIndex*8+3); |
269 quadPoints->x3 = pArray->GetNumber(quadIndex*8+4); | 269 quadPoints->x3 = pArray->GetNumber(quadIndex*8+4); |
270 quadPoints->y3 = pArray->GetNumber(quadIndex*8+5); | 270 quadPoints->y3 = pArray->GetNumber(quadIndex*8+5); |
271 quadPoints->x4 = pArray->GetNumber(quadIndex*8+6); | 271 quadPoints->x4 = pArray->GetNumber(quadIndex*8+6); |
272 quadPoints->y4 = pArray->GetNumber(quadIndex*8+7); | 272 quadPoints->y4 = pArray->GetNumber(quadIndex*8+7); |
273 » » return TRUE; | 273 » » return true; |
274 } | 274 } |
275 » return FALSE; | 275 » return false; |
276 } | 276 } |
277 | 277 |
278 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR
ING tag, | 278 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, FPDF_BYTESTR
ING tag, |
279
void* buffer, unsigned long buflen) | 279
void* buffer, unsigned long buflen) |
280 { | 280 { |
281 if (!doc || !tag) | 281 if (!doc || !tag) |
282 return 0; | 282 return 0; |
283 CPDF_Document* pDoc = (CPDF_Document*)doc; | 283 CPDF_Document* pDoc = (CPDF_Document*)doc; |
284 // Get info dictionary | 284 // Get info dictionary |
285 CPDF_Dictionary* pInfo = pDoc->GetInfo(); | 285 CPDF_Dictionary* pInfo = pDoc->GetInfo(); |
286 if (!pInfo) | 286 if (!pInfo) |
287 return 0; | 287 return 0; |
288 CFX_WideString text = pInfo->GetUnicodeText(tag); | 288 CFX_WideString text = pInfo->GetUnicodeText(tag); |
289 // Use UTF-16LE encoding | 289 // Use UTF-16LE encoding |
290 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 290 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
291 unsigned long len = encodedText.GetLength(); | 291 unsigned long len = encodedText.GetLength(); |
292 if (buffer && buflen >= len) { | 292 if (buffer && buflen >= len) { |
293 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 293 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
294 } | 294 } |
295 return len; | 295 return len; |
296 } | 296 } |
OLD | NEW |