| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fpdfdoc/include/cpdf_annot.h" | 7 #include "core/fpdfdoc/include/cpdf_annot.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 9 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
| 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 10 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); | 48 CPVT_GenerateAP::GenerateUnderlineAP(m_pDocument, m_pAnnotDict); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void CPDF_Annot::ClearCachedAP() { | 51 void CPDF_Annot::ClearCachedAP() { |
| 52 m_APMap.clear(); | 52 m_APMap.clear(); |
| 53 } | 53 } |
| 54 CFX_ByteString CPDF_Annot::GetSubType() const { | 54 CFX_ByteString CPDF_Annot::GetSubType() const { |
| 55 return m_sSubtype; | 55 return m_sSubtype; |
| 56 } | 56 } |
| 57 | 57 |
| 58 void CPDF_Annot::GetRect(CFX_FloatRect& rect) const { | 58 CFX_FloatRect CPDF_Annot::GetRect() const { |
| 59 if (!m_pAnnotDict) { | 59 if (!m_pAnnotDict) |
| 60 return; | 60 return CFX_FloatRect(); |
| 61 } | 61 |
| 62 rect = m_pAnnotDict->GetRectBy("Rect"); | 62 CFX_FloatRect rect = m_pAnnotDict->GetRectBy("Rect"); |
| 63 rect.Normalize(); | 63 rect.Normalize(); |
| 64 return rect; |
| 64 } | 65 } |
| 65 | 66 |
| 66 uint32_t CPDF_Annot::GetFlags() const { | 67 uint32_t CPDF_Annot::GetFlags() const { |
| 67 return m_pAnnotDict->GetIntegerBy("F"); | 68 return m_pAnnotDict->GetIntegerBy("F"); |
| 68 } | 69 } |
| 69 | 70 |
| 70 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, | 71 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, |
| 71 CPDF_Annot::AppearanceMode mode) { | 72 CPDF_Annot::AppearanceMode mode) { |
| 72 CPDF_Dictionary* pAP = pAnnotDict->GetDictBy("AP"); | 73 CPDF_Dictionary* pAP = pAnnotDict->GetDictBy("AP"); |
| 73 if (!pAP) { | 74 if (!pAP) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 CPDF_Annot::AppearanceMode mode, | 127 CPDF_Annot::AppearanceMode mode, |
| 127 const CFX_Matrix* pUser2Device, | 128 const CFX_Matrix* pUser2Device, |
| 128 CFX_Matrix& matrix) { | 129 CFX_Matrix& matrix) { |
| 129 CPDF_Form* pForm = pAnnot->GetAPForm(pPage, mode); | 130 CPDF_Form* pForm = pAnnot->GetAPForm(pPage, mode); |
| 130 if (!pForm) { | 131 if (!pForm) { |
| 131 return nullptr; | 132 return nullptr; |
| 132 } | 133 } |
| 133 CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectBy("BBox"); | 134 CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRectBy("BBox"); |
| 134 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); | 135 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrixBy("Matrix"); |
| 135 form_matrix.TransformRect(form_bbox); | 136 form_matrix.TransformRect(form_bbox); |
| 136 CFX_FloatRect arect; | 137 matrix.MatchRect(pAnnot->GetRect(), form_bbox); |
| 137 pAnnot->GetRect(arect); | |
| 138 matrix.MatchRect(arect, form_bbox); | |
| 139 matrix.Concat(*pUser2Device); | 138 matrix.Concat(*pUser2Device); |
| 140 return pForm; | 139 return pForm; |
| 141 } | 140 } |
| 142 | 141 |
| 143 // static | 142 // static |
| 144 bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) { | 143 bool CPDF_Annot::IsAnnotationHidden(CPDF_Dictionary* pAnnotDict) { |
| 145 return !!(pAnnotDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN); | 144 return !!(pAnnotDict->GetIntegerBy("F") & ANNOTFLAG_HIDDEN); |
| 146 } | 145 } |
| 147 | 146 |
| 148 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, | 147 FX_BOOL CPDF_Annot::DrawAppearance(CPDF_Page* pPage, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 264 } |
| 266 if (i < dash_count) { | 265 if (i < dash_count) { |
| 267 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; | 266 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; |
| 268 } | 267 } |
| 269 } else { | 268 } else { |
| 270 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); | 269 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); |
| 271 graph_state.m_DashCount = 2; | 270 graph_state.m_DashCount = 2; |
| 272 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; | 271 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; |
| 273 } | 272 } |
| 274 } | 273 } |
| 275 CFX_FloatRect rect; | 274 CFX_FloatRect rect = GetRect(); |
| 276 GetRect(rect); | |
| 277 CFX_PathData path; | 275 CFX_PathData path; |
| 278 width /= 2; | 276 width /= 2; |
| 279 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, | 277 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, |
| 280 rect.top - width); | 278 rect.top - width); |
| 281 int fill_type = 0; | 279 int fill_type = 0; |
| 282 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { | 280 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { |
| 283 fill_type |= FXFILL_NOPATHSMOOTH; | 281 fill_type |= FXFILL_NOPATHSMOOTH; |
| 284 } | 282 } |
| 285 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); | 283 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); |
| 286 } | 284 } |
| OLD | NEW |