| 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 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return NULL; | 312 return NULL; |
| 311 } | 313 } |
| 312 CPDF_Array* pColor = m_pAnnotDict->GetArray("C"); | 314 CPDF_Array* pColor = m_pAnnotDict->GetArray("C"); |
| 313 FX_DWORD argb = 0xff000000; | 315 FX_DWORD argb = 0xff000000; |
| 314 if (pColor != NULL) { | 316 if (pColor != NULL) { |
| 315 int R = (FX_INT32)(pColor->GetNumber(0) * 255); | 317 int R = (FX_INT32)(pColor->GetNumber(0) * 255); |
| 316 int G = (FX_INT32)(pColor->GetNumber(1) * 255); | 318 int G = (FX_INT32)(pColor->GetNumber(1) * 255); |
| 317 int B = (FX_INT32)(pColor->GetNumber(2) * 255); | 319 int B = (FX_INT32)(pColor->GetNumber(2) * 255); |
| 318 argb = ArgbEncode(0xff, R, G, B); | 320 argb = ArgbEncode(0xff, R, G, B); |
| 319 } | 321 } |
| 320 CPDF_PathObject *pPathObject = new CPDF_PathObject(); | 322 nonstd::unique_ptr<CPDF_PathObject> pPathObject(new CPDF_PathObject()); |
| 321 CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify(); | 323 CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify(); |
| 322 if (!pGraphState) { | 324 if (!pGraphState) { |
| 323 pPathObject->Release(); | |
| 324 return NULL; | 325 return NULL; |
| 325 } | 326 } |
| 326 pGraphState->m_LineWidth = width; | 327 pGraphState->m_LineWidth = width; |
| 327 CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify(); | 328 CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify(); |
| 328 if (!pColorData) { | 329 if (!pColorData) { |
| 329 pPathObject->Release(); | |
| 330 return NULL; | 330 return NULL; |
| 331 } | 331 } |
| 332 pColorData->m_StrokeRGB = argb; | 332 pColorData->m_StrokeRGB = argb; |
| 333 pPathObject->m_bStroke = TRUE; | 333 pPathObject->m_bStroke = TRUE; |
| 334 pPathObject->m_FillType = 0; | 334 pPathObject->m_FillType = 0; |
| 335 if (style_char == 'D') { | 335 if (style_char == 'D') { |
| 336 if (pDashArray) { | 336 if (pDashArray) { |
| 337 FX_DWORD dash_count = pDashArray->GetCount(); | 337 FX_DWORD dash_count = pDashArray->GetCount(); |
| 338 if (dash_count % 2) { | 338 if (dash_count % 2) { |
| 339 dash_count ++; | 339 dash_count ++; |
| 340 } | 340 } |
| 341 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); | 341 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); |
| 342 if (pGraphState->m_DashArray == NULL) { | 342 if (pGraphState->m_DashArray == NULL) { |
| 343 pPathObject->Release(); | |
| 344 return NULL; | 343 return NULL; |
| 345 } | 344 } |
| 346 pGraphState->m_DashCount = dash_count; | 345 pGraphState->m_DashCount = dash_count; |
| 347 FX_DWORD i; | 346 FX_DWORD i; |
| 348 for (i = 0; i < pDashArray->GetCount(); i ++) { | 347 for (i = 0; i < pDashArray->GetCount(); i ++) { |
| 349 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); | 348 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); |
| 350 } | 349 } |
| 351 if (i < dash_count) { | 350 if (i < dash_count) { |
| 352 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; | 351 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; |
| 353 } | 352 } |
| 354 } else { | 353 } else { |
| 355 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); | 354 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); |
| 356 if (pGraphState->m_DashArray == NULL) { | 355 if (pGraphState->m_DashArray == NULL) { |
| 357 pPathObject->Release(); | |
| 358 return NULL; | 356 return NULL; |
| 359 } | 357 } |
| 360 pGraphState->m_DashCount = 2; | 358 pGraphState->m_DashCount = 2; |
| 361 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f
; | 359 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f
; |
| 362 } | 360 } |
| 363 } | 361 } |
| 364 CFX_FloatRect rect; | 362 CFX_FloatRect rect; |
| 365 GetRect(rect); | 363 GetRect(rect); |
| 366 width /= 2; | 364 width /= 2; |
| 367 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); | 365 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); |
| 368 if (pPathData) { | 366 if (pPathData) { |
| 369 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right
- width, rect.top - width); | 367 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right
- width, rect.top - width); |
| 370 } | 368 } |
| 371 pPathObject->CalcBoundingBox(); | 369 pPathObject->CalcBoundingBox(); |
| 372 return pPathObject; | 370 return pPathObject.release(); |
| 373 } | 371 } |
| 374 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p
User2Device, const CPDF_RenderOptions* pOptions) | 372 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p
User2Device, const CPDF_RenderOptions* pOptions) |
| 375 { | 373 { |
| 376 if (GetSubType() == "Popup") { | 374 if (GetSubType() == "Popup") { |
| 377 return; | 375 return; |
| 378 } | 376 } |
| 379 FX_DWORD annot_flags = GetFlags(); | 377 FX_DWORD annot_flags = GetFlags(); |
| 380 if (annot_flags & ANNOTFLAG_HIDDEN) { | 378 if (annot_flags & ANNOTFLAG_HIDDEN) { |
| 381 return; | 379 return; |
| 382 } | 380 } |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 if (pIRT != m_pAnnotDict) { | 500 if (pIRT != m_pAnnotDict) { |
| 503 continue; | 501 continue; |
| 504 } | 502 } |
| 505 if (count == index) { | 503 if (count == index) { |
| 506 return pAnnot; | 504 return pAnnot; |
| 507 } | 505 } |
| 508 count ++; | 506 count ++; |
| 509 } | 507 } |
| 510 return NULL; | 508 return NULL; |
| 511 } | 509 } |
| OLD | NEW |