| 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 "public/fpdf_doc.h" | 7 #include "public/fpdf_doc.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 269 } |
| 270 | 270 |
| 271 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, | 271 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page, |
| 272 int* startPos, | 272 int* startPos, |
| 273 FPDF_LINK* linkAnnot) { | 273 FPDF_LINK* linkAnnot) { |
| 274 if (!startPos || !linkAnnot) | 274 if (!startPos || !linkAnnot) |
| 275 return FALSE; | 275 return FALSE; |
| 276 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); | 276 CPDF_Page* pPage = CPDFPageFromFPDFPage(page); |
| 277 if (!pPage || !pPage->m_pFormDict) | 277 if (!pPage || !pPage->m_pFormDict) |
| 278 return FALSE; | 278 return FALSE; |
| 279 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayBy("Annots"); | 279 CPDF_Array* pAnnots = pPage->m_pFormDict->GetArrayFor("Annots"); |
| 280 if (!pAnnots) | 280 if (!pAnnots) |
| 281 return FALSE; | 281 return FALSE; |
| 282 for (size_t i = *startPos; i < pAnnots->GetCount(); i++) { | 282 for (size_t i = *startPos; i < pAnnots->GetCount(); i++) { |
| 283 CPDF_Dictionary* pDict = | 283 CPDF_Dictionary* pDict = |
| 284 ToDictionary(static_cast<CPDF_Object*>(pAnnots->GetDirectObjectAt(i))); | 284 ToDictionary(static_cast<CPDF_Object*>(pAnnots->GetDirectObjectAt(i))); |
| 285 if (!pDict) | 285 if (!pDict) |
| 286 continue; | 286 continue; |
| 287 if (pDict->GetStringBy("Subtype") == "Link") { | 287 if (pDict->GetStringFor("Subtype") == "Link") { |
| 288 *startPos = static_cast<int>(i + 1); | 288 *startPos = static_cast<int>(i + 1); |
| 289 *linkAnnot = static_cast<FPDF_LINK>(pDict); | 289 *linkAnnot = static_cast<FPDF_LINK>(pDict); |
| 290 return TRUE; | 290 return TRUE; |
| 291 } | 291 } |
| 292 } | 292 } |
| 293 return FALSE; | 293 return FALSE; |
| 294 } | 294 } |
| 295 | 295 |
| 296 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, | 296 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot, |
| 297 FS_RECTF* rect) { | 297 FS_RECTF* rect) { |
| 298 if (!linkAnnot || !rect) | 298 if (!linkAnnot || !rect) |
| 299 return FALSE; | 299 return FALSE; |
| 300 CPDF_Dictionary* pAnnotDict = | 300 CPDF_Dictionary* pAnnotDict = |
| 301 ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); | 301 ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); |
| 302 CFX_FloatRect rt = pAnnotDict->GetRectBy("Rect"); | 302 CFX_FloatRect rt = pAnnotDict->GetRectFor("Rect"); |
| 303 rect->left = rt.left; | 303 rect->left = rt.left; |
| 304 rect->bottom = rt.bottom; | 304 rect->bottom = rt.bottom; |
| 305 rect->right = rt.right; | 305 rect->right = rt.right; |
| 306 rect->top = rt.top; | 306 rect->top = rt.top; |
| 307 return TRUE; | 307 return TRUE; |
| 308 } | 308 } |
| 309 | 309 |
| 310 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) { | 310 DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot) { |
| 311 if (!linkAnnot) | 311 if (!linkAnnot) |
| 312 return 0; | 312 return 0; |
| 313 CPDF_Dictionary* pAnnotDict = | 313 CPDF_Dictionary* pAnnotDict = |
| 314 ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); | 314 ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); |
| 315 CPDF_Array* pArray = pAnnotDict->GetArrayBy("QuadPoints"); | 315 CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); |
| 316 if (!pArray) | 316 if (!pArray) |
| 317 return 0; | 317 return 0; |
| 318 return static_cast<int>(pArray->GetCount() / 8); | 318 return static_cast<int>(pArray->GetCount() / 8); |
| 319 } | 319 } |
| 320 | 320 |
| 321 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, | 321 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, |
| 322 int quadIndex, | 322 int quadIndex, |
| 323 FS_QUADPOINTSF* quadPoints) { | 323 FS_QUADPOINTSF* quadPoints) { |
| 324 if (!linkAnnot || !quadPoints) | 324 if (!linkAnnot || !quadPoints) |
| 325 return FALSE; | 325 return FALSE; |
| 326 CPDF_Dictionary* pAnnotDict = | 326 CPDF_Dictionary* pAnnotDict = |
| 327 ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); | 327 ToDictionary(static_cast<CPDF_Object*>(linkAnnot)); |
| 328 CPDF_Array* pArray = pAnnotDict->GetArrayBy("QuadPoints"); | 328 CPDF_Array* pArray = pAnnotDict->GetArrayFor("QuadPoints"); |
| 329 if (pArray) { | 329 if (pArray) { |
| 330 if (quadIndex < 0 || | 330 if (quadIndex < 0 || |
| 331 static_cast<size_t>(quadIndex) >= pArray->GetCount() / 8 || | 331 static_cast<size_t>(quadIndex) >= pArray->GetCount() / 8 || |
| 332 (static_cast<size_t>(quadIndex * 8 + 7) >= pArray->GetCount())) | 332 (static_cast<size_t>(quadIndex * 8 + 7) >= pArray->GetCount())) |
| 333 return FALSE; | 333 return FALSE; |
| 334 quadPoints->x1 = pArray->GetNumberAt(quadIndex * 8); | 334 quadPoints->x1 = pArray->GetNumberAt(quadIndex * 8); |
| 335 quadPoints->y1 = pArray->GetNumberAt(quadIndex * 8 + 1); | 335 quadPoints->y1 = pArray->GetNumberAt(quadIndex * 8 + 1); |
| 336 quadPoints->x2 = pArray->GetNumberAt(quadIndex * 8 + 2); | 336 quadPoints->x2 = pArray->GetNumberAt(quadIndex * 8 + 2); |
| 337 quadPoints->y2 = pArray->GetNumberAt(quadIndex * 8 + 3); | 337 quadPoints->y2 = pArray->GetNumberAt(quadIndex * 8 + 3); |
| 338 quadPoints->x3 = pArray->GetNumberAt(quadIndex * 8 + 4); | 338 quadPoints->x3 = pArray->GetNumberAt(quadIndex * 8 + 4); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 349 void* buffer, | 349 void* buffer, |
| 350 unsigned long buflen) { | 350 unsigned long buflen) { |
| 351 if (!tag) | 351 if (!tag) |
| 352 return 0; | 352 return 0; |
| 353 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); | 353 CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(doc); |
| 354 if (!pDoc) | 354 if (!pDoc) |
| 355 return 0; | 355 return 0; |
| 356 CPDF_Dictionary* pInfo = pDoc->GetInfo(); | 356 CPDF_Dictionary* pInfo = pDoc->GetInfo(); |
| 357 if (!pInfo) | 357 if (!pInfo) |
| 358 return 0; | 358 return 0; |
| 359 CFX_WideString text = pInfo->GetUnicodeTextBy(tag); | 359 CFX_WideString text = pInfo->GetUnicodeTextFor(tag); |
| 360 // Use UTF-16LE encoding | 360 // Use UTF-16LE encoding |
| 361 CFX_ByteString encodedText = text.UTF16LE_Encode(); | 361 CFX_ByteString encodedText = text.UTF16LE_Encode(); |
| 362 unsigned long len = encodedText.GetLength(); | 362 unsigned long len = encodedText.GetLength(); |
| 363 if (buffer && buflen >= len) { | 363 if (buffer && buflen >= len) { |
| 364 FXSYS_memcpy(buffer, encodedText.c_str(), len); | 364 FXSYS_memcpy(buffer, encodedText.c_str(), len); |
| 365 } | 365 } |
| 366 return len; | 366 return len; |
| 367 } | 367 } |
| OLD | NEW |