| 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 "../../../third_party/base/nonstd_unique_ptr.h" |
| 7 #include "../../include/fpdfdoc/fpdf_doc.h" | 8 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 8 #include "../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../include/fpdfapi/fpdf_pageobj.h" |
| 10 |
| 9 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) | 11 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) |
| 10 { | 12 { |
| 11 ASSERT(pPage != NULL); | 13 ASSERT(pPage != NULL); |
| 12 m_pPageDict = pPage->m_pFormDict; | 14 m_pPageDict = pPage->m_pFormDict; |
| 13 if (m_pPageDict == NULL) { | 15 if (m_pPageDict == NULL) { |
| 14 return; | 16 return; |
| 15 } | 17 } |
| 16 m_pDocument = pPage->m_pDocument; | 18 m_pDocument = pPage->m_pDocument; |
| 17 CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots"); | 19 CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots"); |
| 18 if (pAnnots == NULL) { | 20 if (pAnnots == NULL) { |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 return NULL; | 318 return NULL; |
| 317 } | 319 } |
| 318 CPDF_Array* pColor = m_pAnnotDict->GetArray("C"); | 320 CPDF_Array* pColor = m_pAnnotDict->GetArray("C"); |
| 319 FX_DWORD argb = 0xff000000; | 321 FX_DWORD argb = 0xff000000; |
| 320 if (pColor != NULL) { | 322 if (pColor != NULL) { |
| 321 int R = (FX_INT32)(pColor->GetNumber(0) * 255); | 323 int R = (FX_INT32)(pColor->GetNumber(0) * 255); |
| 322 int G = (FX_INT32)(pColor->GetNumber(1) * 255); | 324 int G = (FX_INT32)(pColor->GetNumber(1) * 255); |
| 323 int B = (FX_INT32)(pColor->GetNumber(2) * 255); | 325 int B = (FX_INT32)(pColor->GetNumber(2) * 255); |
| 324 argb = ArgbEncode(0xff, R, G, B); | 326 argb = ArgbEncode(0xff, R, G, B); |
| 325 } | 327 } |
| 326 CPDF_PathObject *pPathObject = FX_NEW CPDF_PathObject(); | 328 nonstd::unique_ptr<CPDF_PathObject> pPathObject(new CPDF_PathObject()); |
| 327 if (!pPathObject) { | |
| 328 return NULL; | |
| 329 } | |
| 330 CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify(); | 329 CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify(); |
| 331 if (!pGraphState) { | 330 if (!pGraphState) { |
| 332 pPathObject->Release(); | |
| 333 return NULL; | 331 return NULL; |
| 334 } | 332 } |
| 335 pGraphState->m_LineWidth = width; | 333 pGraphState->m_LineWidth = width; |
| 336 CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify(); | 334 CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify(); |
| 337 if (!pColorData) { | 335 if (!pColorData) { |
| 338 pPathObject->Release(); | |
| 339 return NULL; | 336 return NULL; |
| 340 } | 337 } |
| 341 pColorData->m_StrokeRGB = argb; | 338 pColorData->m_StrokeRGB = argb; |
| 342 pPathObject->m_bStroke = TRUE; | 339 pPathObject->m_bStroke = TRUE; |
| 343 pPathObject->m_FillType = 0; | 340 pPathObject->m_FillType = 0; |
| 344 if (style_char == 'D') { | 341 if (style_char == 'D') { |
| 345 if (pDashArray) { | 342 if (pDashArray) { |
| 346 FX_DWORD dash_count = pDashArray->GetCount(); | 343 FX_DWORD dash_count = pDashArray->GetCount(); |
| 347 if (dash_count % 2) { | 344 if (dash_count % 2) { |
| 348 dash_count ++; | 345 dash_count ++; |
| 349 } | 346 } |
| 350 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); | 347 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); |
| 351 if (pGraphState->m_DashArray == NULL) { | 348 if (pGraphState->m_DashArray == NULL) { |
| 352 pPathObject->Release(); | |
| 353 return NULL; | 349 return NULL; |
| 354 } | 350 } |
| 355 pGraphState->m_DashCount = dash_count; | 351 pGraphState->m_DashCount = dash_count; |
| 356 FX_DWORD i; | 352 FX_DWORD i; |
| 357 for (i = 0; i < pDashArray->GetCount(); i ++) { | 353 for (i = 0; i < pDashArray->GetCount(); i ++) { |
| 358 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); | 354 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); |
| 359 } | 355 } |
| 360 if (i < dash_count) { | 356 if (i < dash_count) { |
| 361 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; | 357 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; |
| 362 } | 358 } |
| 363 } else { | 359 } else { |
| 364 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); | 360 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); |
| 365 if (pGraphState->m_DashArray == NULL) { | 361 if (pGraphState->m_DashArray == NULL) { |
| 366 pPathObject->Release(); | |
| 367 return NULL; | 362 return NULL; |
| 368 } | 363 } |
| 369 pGraphState->m_DashCount = 2; | 364 pGraphState->m_DashCount = 2; |
| 370 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f
; | 365 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f
; |
| 371 } | 366 } |
| 372 } | 367 } |
| 373 CFX_FloatRect rect; | 368 CFX_FloatRect rect; |
| 374 GetRect(rect); | 369 GetRect(rect); |
| 375 width /= 2; | 370 width /= 2; |
| 376 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); | 371 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); |
| 377 if (pPathData) { | 372 if (pPathData) { |
| 378 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right
- width, rect.top - width); | 373 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right
- width, rect.top - width); |
| 379 } | 374 } |
| 380 pPathObject->CalcBoundingBox(); | 375 pPathObject->CalcBoundingBox(); |
| 381 return pPathObject; | 376 return pPathObject.release(); |
| 382 } | 377 } |
| 383 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p
User2Device, const CPDF_RenderOptions* pOptions) | 378 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p
User2Device, const CPDF_RenderOptions* pOptions) |
| 384 { | 379 { |
| 385 if (GetSubType() == "Popup") { | 380 if (GetSubType() == "Popup") { |
| 386 return; | 381 return; |
| 387 } | 382 } |
| 388 FX_DWORD annot_flags = GetFlags(); | 383 FX_DWORD annot_flags = GetFlags(); |
| 389 if (annot_flags & ANNOTFLAG_HIDDEN) { | 384 if (annot_flags & ANNOTFLAG_HIDDEN) { |
| 390 return; | 385 return; |
| 391 } | 386 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 if (pIRT != m_pAnnotDict) { | 506 if (pIRT != m_pAnnotDict) { |
| 512 continue; | 507 continue; |
| 513 } | 508 } |
| 514 if (count == index) { | 509 if (count == index) { |
| 515 return pAnnot; | 510 return pAnnot; |
| 516 } | 511 } |
| 517 count ++; | 512 count ++; |
| 518 } | 513 } |
| 519 return NULL; | 514 return NULL; |
| 520 } | 515 } |
| OLD | NEW |