| 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 "../../../third_party/base/nonstd_unique_ptr.h" |
| 8 #include "../../include/fpdfdoc/fpdf_doc.h" | 8 #include "../../include/fpdfdoc/fpdf_doc.h" |
| 9 #include "../../include/fpdfapi/fpdf_pageobj.h" | 9 #include "../../include/fpdfapi/fpdf_pageobj.h" |
| 10 | 10 |
| 11 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) | 11 CPDF_AnnotList::CPDF_AnnotList(CPDF_Page* pPage) |
| 12 { | 12 { |
| 13 ASSERT(pPage != NULL); | 13 ASSERT(pPage != NULL); |
| 14 m_pPageDict = pPage->m_pFormDict; | 14 m_pPageDict = pPage->m_pFormDict; |
| 15 if (m_pPageDict == NULL) { | 15 if (m_pPageDict == NULL) { |
| 16 return; | 16 return; |
| 17 } | 17 } |
| 18 m_pDocument = pPage->m_pDocument; | 18 m_pDocument = pPage->m_pDocument; |
| 19 CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots"); | 19 CPDF_Array* pAnnots = m_pPageDict->GetArray("Annots"); |
| 20 if (pAnnots == NULL) { | 20 if (pAnnots == NULL) { |
| 21 return; | 21 return; |
| 22 } | 22 } |
| 23 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); | 23 CPDF_Dictionary* pRoot = m_pDocument->GetRoot(); |
| 24 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); | 24 CPDF_Dictionary* pAcroForm = pRoot->GetDict("AcroForm"); |
| 25 FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances"
); | 25 FX_BOOL bRegenerateAP = pAcroForm && pAcroForm->GetBoolean("NeedAppearances"
); |
| 26 for (FX_DWORD i = 0; i < pAnnots->GetCount(); i ++) { | 26 for (FX_DWORD i = 0; i < pAnnots->GetCount(); ++i) { |
| 27 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); | 27 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pAnnots->GetElementValue(i); |
| 28 if (pDict == NULL || pDict->GetType() != PDFOBJ_DICTIONARY) { | 28 if (pDict == NULL || pDict->GetType() != PDFOBJ_DICTIONARY) { |
| 29 continue; | 29 continue; |
| 30 } | 30 } |
| 31 FX_DWORD dwObjNum = pDict->GetObjNum(); | 31 FX_DWORD dwObjNum = pDict->GetObjNum(); |
| 32 if (dwObjNum == 0) { | 32 if (dwObjNum == 0) { |
| 33 dwObjNum = m_pDocument->AddIndirectObject(pDict); | 33 dwObjNum = m_pDocument->AddIndirectObject(pDict); |
| 34 CPDF_Reference* pAction = CPDF_Reference::Create(m_pDocument, dwObjN
um); | 34 CPDF_Reference* pAction = CPDF_Reference::Create(m_pDocument, dwObjN
um); |
| 35 if (pAction == NULL) { | 35 if (pAction == NULL) { |
| 36 break; | 36 break; |
| 37 } | 37 } |
| 38 pAnnots->InsertAt(i, pAction); | 38 pAnnots->InsertAt(i, pAction); |
| 39 pAnnots->RemoveAt(i + 1); | 39 pAnnots->RemoveAt(i + 1); |
| 40 pDict = pAnnots->GetDict(i); | 40 pDict = pAnnots->GetDict(i); |
| 41 } | 41 } |
| 42 CPDF_Annot* pAnnot = new CPDF_Annot(pDict); | 42 CPDF_Annot* pAnnot = new CPDF_Annot(pDict, this); |
| 43 pAnnot->m_pList = this; | |
| 44 m_AnnotList.Add(pAnnot); | 43 m_AnnotList.Add(pAnnot); |
| 45 if (bRegenerateAP && pDict->GetConstString(FX_BSTRC("Subtype")) == FX_BS
TRC("Widget")) | 44 if (bRegenerateAP && pDict->GetConstString(FX_BSTRC("Subtype")) == FX_BS
TRC("Widget")) |
| 46 if (CPDF_InterForm::UpdatingAPEnabled()) { | 45 if (CPDF_InterForm::UpdatingAPEnabled()) { |
| 47 FPDF_GenerateAP(m_pDocument, pDict); | 46 FPDF_GenerateAP(m_pDocument, pDict); |
| 48 } | 47 } |
| 49 } | 48 } |
| 50 } | 49 } |
| 51 CPDF_AnnotList::~CPDF_AnnotList() | 50 CPDF_AnnotList::~CPDF_AnnotList() |
| 52 { | 51 { |
| 53 int i = 0; | 52 int i = 0; |
| 54 for (i = 0; i < m_AnnotList.GetSize(); i ++) { | 53 for (i = 0; i < m_AnnotList.GetSize(); ++i) { |
| 55 delete (CPDF_Annot*)m_AnnotList[i]; | 54 delete (CPDF_Annot*)m_AnnotList[i]; |
| 56 } | 55 } |
| 57 for (i = 0; i < m_Borders.GetSize(); ++i) { | 56 for (i = 0; i < m_Borders.GetSize(); ++i) { |
| 58 delete (CPDF_PageObjects*)m_Borders[i]; | 57 delete (CPDF_PageObjects*)m_Borders[i]; |
| 59 } | 58 } |
| 60 } | 59 } |
| 61 void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevi
ce, | 60 void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevi
ce, |
| 62 CPDF_RenderContext* pContext, FX_BOOL bPrinting
, CFX_AffineMatrix* pMatrix, | 61 CPDF_RenderContext* pContext, FX_BOOL bPrinting
, CFX_AffineMatrix* pMatrix, |
| 63 FX_BOOL bWidgetPass, CPDF_RenderOptions* pOptio
ns, FX_RECT* clip_rect) | 62 FX_BOOL bWidgetPass, CPDF_RenderOptions* pOptio
ns, FX_RECT* clip_rect) |
| 64 { | 63 { |
| 65 for (int i = 0; i < m_AnnotList.GetSize(); i ++) { | 64 for (int i = 0; i < m_AnnotList.GetSize(); ++i) { |
| 66 CPDF_Annot* pAnnot = (CPDF_Annot*)m_AnnotList[i]; | 65 CPDF_Annot* pAnnot = (CPDF_Annot*)m_AnnotList[i]; |
| 67 FX_BOOL bWidget = pAnnot->GetSubType() == "Widget"; | 66 FX_BOOL bWidget = pAnnot->GetSubType() == "Widget"; |
| 68 if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) { | 67 if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) { |
| 69 continue; | 68 continue; |
| 70 } | 69 } |
| 71 FX_DWORD annot_flags = pAnnot->GetFlags(); | 70 FX_DWORD annot_flags = pAnnot->GetFlags(); |
| 72 if (annot_flags & ANNOTFLAG_HIDDEN) { | 71 if (annot_flags & ANNOTFLAG_HIDDEN) { |
| 73 continue; | 72 continue; |
| 74 } | 73 } |
| 75 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) { | 74 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) { |
| 76 continue; | 75 continue; |
| 77 } | 76 } |
| 78 if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) { | 77 if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) { |
| 79 continue; | 78 continue; |
| 80 } | 79 } |
| 81 if (pOptions != NULL) { | 80 if (pOptions != NULL) { |
| 82 IPDF_OCContext* pOCContext = pOptions->m_pOCContext; | 81 IPDF_OCContext* pOCContext = pOptions->m_pOCContext; |
| 83 CPDF_Dictionary* pAnnotDict = pAnnot->m_pAnnotDict; | 82 CPDF_Dictionary* pAnnotDict = pAnnot->GetAnnotDict(); |
| 84 if (pOCContext != NULL && pAnnotDict != NULL && | 83 if (pOCContext != NULL && pAnnotDict != NULL && |
| 85 !pOCContext->CheckOCGVisible(pAnnotDict->GetDict(FX_BSTRC("O
C")))) { | 84 !pOCContext->CheckOCGVisible(pAnnotDict->GetDict(FX_BSTRC("O
C")))) { |
| 86 continue; | 85 continue; |
| 87 } | 86 } |
| 88 } | 87 } |
| 89 CPDF_Rect annot_rect_f; | 88 CPDF_Rect annot_rect_f; |
| 90 pAnnot->GetRect(annot_rect_f); | 89 pAnnot->GetRect(annot_rect_f); |
| 91 CFX_Matrix matrix; | 90 CFX_Matrix matrix; |
| 92 matrix = *pMatrix; | 91 matrix = *pMatrix; |
| 93 if (clip_rect) { | 92 if (clip_rect) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 122 { | 121 { |
| 123 if (dwAnnotFlags & 0x01) { | 122 if (dwAnnotFlags & 0x01) { |
| 124 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, FALSE, pO
ptions, pClipRect); | 123 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, FALSE, pO
ptions, pClipRect); |
| 125 } | 124 } |
| 126 if (dwAnnotFlags & 0x02) { | 125 if (dwAnnotFlags & 0x02) { |
| 127 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, TRUE, pOp
tions, pClipRect); | 126 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, TRUE, pOp
tions, pClipRect); |
| 128 } | 127 } |
| 129 } | 128 } |
| 130 int CPDF_AnnotList::GetIndex(CPDF_Annot* pAnnot) | 129 int CPDF_AnnotList::GetIndex(CPDF_Annot* pAnnot) |
| 131 { | 130 { |
| 132 for (int i = 0; i < m_AnnotList.GetSize(); i ++) | 131 for (int i = 0; i < m_AnnotList.GetSize(); ++i) |
| 133 if (m_AnnotList[i] == (FX_LPVOID)pAnnot) { | 132 if (m_AnnotList[i] == (FX_LPVOID)pAnnot) { |
| 134 return i; | 133 return i; |
| 135 } | 134 } |
| 136 return -1; | 135 return -1; |
| 137 } | 136 } |
| 138 CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict) | 137 CPDF_Annot::CPDF_Annot(CPDF_Dictionary* pDict, CPDF_AnnotList* pList) |
| 138 : m_pAnnotDict(pDict), |
| 139 m_pList(pList) |
| 139 { | 140 { |
| 140 m_pList = NULL; | |
| 141 m_pAnnotDict = pDict; | |
| 142 } | 141 } |
| 143 CPDF_Annot::~CPDF_Annot() | 142 CPDF_Annot::~CPDF_Annot() |
| 144 { | 143 { |
| 145 ClearCachedAP(); | 144 ClearCachedAP(); |
| 146 } | 145 } |
| 147 CPDF_Reference* CPDF_Annot::NewAnnotRef() | |
| 148 { | |
| 149 if (m_pAnnotDict->GetObjNum() == 0) { | |
| 150 m_pList->m_pDocument->AddIndirectObject(m_pAnnotDict); | |
| 151 } | |
| 152 return CPDF_Reference::Create(m_pList->m_pDocument, m_pAnnotDict->GetObjNum(
)); | |
| 153 } | |
| 154 void CPDF_Annot::ClearCachedAP() | 146 void CPDF_Annot::ClearCachedAP() |
| 155 { | 147 { |
| 156 FX_POSITION pos = m_APMap.GetStartPosition(); | 148 FX_POSITION pos = m_APMap.GetStartPosition(); |
| 157 while (pos) { | 149 while (pos) { |
| 158 void* pForm; | 150 void* pForm; |
| 159 void* pObjects; | 151 void* pObjects; |
| 160 m_APMap.GetNextAssoc(pos, pForm, pObjects); | 152 m_APMap.GetNextAssoc(pos, pForm, pObjects); |
| 161 delete (CPDF_PageObjects*)pObjects; | 153 delete (CPDF_PageObjects*)pObjects; |
| 162 } | 154 } |
| 163 m_APMap.RemoveAll(); | 155 m_APMap.RemoveAll(); |
| 164 } | 156 } |
| 165 CFX_ByteString CPDF_Annot::GetSubType() const | 157 CFX_ByteString CPDF_Annot::GetSubType() const |
| 166 { | 158 { |
| 167 return m_pAnnotDict ? m_pAnnotDict->GetConstString(FX_BSTRC("Subtype")) : CF
X_ByteStringC(); | 159 return m_pAnnotDict ? m_pAnnotDict->GetConstString(FX_BSTRC("Subtype")) : CF
X_ByteStringC(); |
| 168 } | 160 } |
| 161 |
| 169 void CPDF_Annot::GetRect(CPDF_Rect& rect) const | 162 void CPDF_Annot::GetRect(CPDF_Rect& rect) const |
| 170 { | 163 { |
| 171 if (m_pAnnotDict == NULL) { | 164 if (m_pAnnotDict == NULL) { |
| 172 return; | 165 return; |
| 173 } | 166 } |
| 174 rect = m_pAnnotDict->GetRect("Rect"); | 167 rect = m_pAnnotDict->GetRect("Rect"); |
| 175 rect.Normalize(); | 168 rect.Normalize(); |
| 176 } | 169 } |
| 170 |
| 171 FX_DWORD CPDF_Annot::GetFlags() const |
| 172 { |
| 173 return m_pAnnotDict->GetInteger("F"); |
| 174 } |
| 175 |
| 176 CPDF_Dictionary* CPDF_Annot::GetAnnotDict() |
| 177 { |
| 178 return m_pAnnotDict; |
| 179 } |
| 180 |
| 177 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::Appeara
nceMode mode) | 181 CPDF_Stream* FPDFDOC_GetAnnotAP(CPDF_Dictionary* pAnnotDict, CPDF_Annot::Appeara
nceMode mode) |
| 178 { | 182 { |
| 179 CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP"); | 183 CPDF_Dictionary* pAP = pAnnotDict->GetDict("AP"); |
| 180 if (pAP == NULL) { | 184 if (pAP == NULL) { |
| 181 return NULL; | 185 return NULL; |
| 182 } | 186 } |
| 183 const FX_CHAR* ap_entry = "N"; | 187 const FX_CHAR* ap_entry = "N"; |
| 184 if (mode == CPDF_Annot::Down) { | 188 if (mode == CPDF_Annot::Down) { |
| 185 ap_entry = "D"; | 189 ap_entry = "D"; |
| 186 } else if (mode == CPDF_Annot::Rollover) { | 190 } else if (mode == CPDF_Annot::Rollover) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, const CPDF_RenderConte
xt* pContext, const CFX_AffineMatrix* pUser2Device, AppearanceMode mode) | 264 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, const CPDF_RenderConte
xt* pContext, const CFX_AffineMatrix* pUser2Device, AppearanceMode mode) |
| 261 { | 265 { |
| 262 CFX_Matrix matrix; | 266 CFX_Matrix matrix; |
| 263 CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device,
matrix); | 267 CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device,
matrix); |
| 264 if (!pForm) { | 268 if (!pForm) { |
| 265 return FALSE; | 269 return FALSE; |
| 266 } | 270 } |
| 267 ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix); | 271 ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix); |
| 268 return TRUE; | 272 return TRUE; |
| 269 } | 273 } |
| 270 CPDF_PageObject* CPDF_Annot::GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions*
pOptions) | |
| 271 { | |
| 272 if (GetSubType() == "Popup") { | |
| 273 return NULL; | |
| 274 } | |
| 275 FX_DWORD annot_flags = GetFlags(); | |
| 276 if (annot_flags & ANNOTFLAG_HIDDEN) { | |
| 277 return NULL; | |
| 278 } | |
| 279 FX_BOOL bPrinting = bPrint || (pOptions && (pOptions->m_Flags & RENDER_PRINT
PREVIEW)); | |
| 280 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) { | |
| 281 return NULL; | |
| 282 } | |
| 283 if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) { | |
| 284 return NULL; | |
| 285 } | |
| 286 CPDF_Dictionary* pBS = m_pAnnotDict->GetDict("BS"); | |
| 287 char style_char; | |
| 288 FX_FLOAT width; | |
| 289 CPDF_Array* pDashArray = NULL; | |
| 290 if (pBS == NULL) { | |
| 291 CPDF_Array* pBorderArray = m_pAnnotDict->GetArray("Border"); | |
| 292 style_char = 'S'; | |
| 293 if (pBorderArray) { | |
| 294 width = pBorderArray->GetNumber(2); | |
| 295 if (pBorderArray->GetCount() == 4) { | |
| 296 pDashArray = pBorderArray->GetArray(3); | |
| 297 if (pDashArray == NULL) { | |
| 298 return NULL; | |
| 299 } | |
| 300 style_char = 'D'; | |
| 301 } | |
| 302 } else { | |
| 303 width = 1; | |
| 304 } | |
| 305 } else { | |
| 306 CFX_ByteString style = pBS->GetString("S"); | |
| 307 pDashArray = pBS->GetArray("D"); | |
| 308 style_char = style[1]; | |
| 309 width = pBS->GetNumber("W"); | |
| 310 } | |
| 311 if (width <= 0) { | |
| 312 return NULL; | |
| 313 } | |
| 314 CPDF_Array* pColor = m_pAnnotDict->GetArray("C"); | |
| 315 FX_DWORD argb = 0xff000000; | |
| 316 if (pColor != NULL) { | |
| 317 int R = (FX_INT32)(pColor->GetNumber(0) * 255); | |
| 318 int G = (FX_INT32)(pColor->GetNumber(1) * 255); | |
| 319 int B = (FX_INT32)(pColor->GetNumber(2) * 255); | |
| 320 argb = ArgbEncode(0xff, R, G, B); | |
| 321 } | |
| 322 nonstd::unique_ptr<CPDF_PathObject> pPathObject(new CPDF_PathObject()); | |
| 323 CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify(); | |
| 324 if (!pGraphState) { | |
| 325 return NULL; | |
| 326 } | |
| 327 pGraphState->m_LineWidth = width; | |
| 328 CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify(); | |
| 329 if (!pColorData) { | |
| 330 return NULL; | |
| 331 } | |
| 332 pColorData->m_StrokeRGB = argb; | |
| 333 pPathObject->m_bStroke = TRUE; | |
| 334 pPathObject->m_FillType = 0; | |
| 335 if (style_char == 'D') { | |
| 336 if (pDashArray) { | |
| 337 FX_DWORD dash_count = pDashArray->GetCount(); | |
| 338 if (dash_count % 2) { | |
| 339 dash_count ++; | |
| 340 } | |
| 341 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count); | |
| 342 pGraphState->m_DashCount = dash_count; | |
| 343 FX_DWORD i; | |
| 344 for (i = 0; i < pDashArray->GetCount(); i ++) { | |
| 345 pGraphState->m_DashArray[i] = pDashArray->GetNumber(i); | |
| 346 } | |
| 347 if (i < dash_count) { | |
| 348 pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1]; | |
| 349 } | |
| 350 } else { | |
| 351 pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2); | |
| 352 pGraphState->m_DashCount = 2; | |
| 353 pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f
; | |
| 354 } | |
| 355 } | |
| 356 CFX_FloatRect rect; | |
| 357 GetRect(rect); | |
| 358 width /= 2; | |
| 359 CPDF_PathData *pPathData = pPathObject->m_Path.GetModify(); | |
| 360 if (pPathData) { | |
| 361 pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right
- width, rect.top - width); | |
| 362 } | |
| 363 pPathObject->CalcBoundingBox(); | |
| 364 return pPathObject.release(); | |
| 365 } | |
| 366 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p
User2Device, const CPDF_RenderOptions* pOptions) | 274 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p
User2Device, const CPDF_RenderOptions* pOptions) |
| 367 { | 275 { |
| 368 if (GetSubType() == "Popup") { | 276 if (GetSubType() == "Popup") { |
| 369 return; | 277 return; |
| 370 } | 278 } |
| 371 FX_DWORD annot_flags = GetFlags(); | 279 FX_DWORD annot_flags = GetFlags(); |
| 372 if (annot_flags & ANNOTFLAG_HIDDEN) { | 280 if (annot_flags & ANNOTFLAG_HIDDEN) { |
| 373 return; | 281 return; |
| 374 } | 282 } |
| 375 FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions &
& (pOptions->m_Flags & RENDER_PRINTPREVIEW)); | 283 FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions &
& (pOptions->m_Flags & RENDER_PRINTPREVIEW)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 int G = (FX_INT32)(pColor->GetNumber(1) * 255); | 333 int G = (FX_INT32)(pColor->GetNumber(1) * 255); |
| 426 int B = (FX_INT32)(pColor->GetNumber(2) * 255); | 334 int B = (FX_INT32)(pColor->GetNumber(2) * 255); |
| 427 argb = ArgbEncode(0xff, R, G, B); | 335 argb = ArgbEncode(0xff, R, G, B); |
| 428 } | 336 } |
| 429 CPDF_GraphStateData graph_state; | 337 CPDF_GraphStateData graph_state; |
| 430 graph_state.m_LineWidth = width; | 338 graph_state.m_LineWidth = width; |
| 431 if (style_char == 'D') { | 339 if (style_char == 'D') { |
| 432 if (pDashArray) { | 340 if (pDashArray) { |
| 433 FX_DWORD dash_count = pDashArray->GetCount(); | 341 FX_DWORD dash_count = pDashArray->GetCount(); |
| 434 if (dash_count % 2) { | 342 if (dash_count % 2) { |
| 435 dash_count ++; | 343 dash_count++; |
| 436 } | 344 } |
| 437 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); | 345 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); |
| 438 graph_state.m_DashCount = dash_count; | 346 graph_state.m_DashCount = dash_count; |
| 439 FX_DWORD i; | 347 FX_DWORD i; |
| 440 for (i = 0; i < pDashArray->GetCount(); i ++) { | 348 for (i = 0; i < pDashArray->GetCount(); ++i) { |
| 441 graph_state.m_DashArray[i] = pDashArray->GetNumber(i); | 349 graph_state.m_DashArray[i] = pDashArray->GetNumber(i); |
| 442 } | 350 } |
| 443 if (i < dash_count) { | 351 if (i < dash_count) { |
| 444 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; | 352 graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; |
| 445 } | 353 } |
| 446 } else { | 354 } else { |
| 447 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); | 355 graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); |
| 448 graph_state.m_DashCount = 2; | 356 graph_state.m_DashCount = 2; |
| 449 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; | 357 graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; |
| 450 } | 358 } |
| 451 } | 359 } |
| 452 CFX_FloatRect rect; | 360 CFX_FloatRect rect; |
| 453 GetRect(rect); | 361 GetRect(rect); |
| 454 CPDF_PathData path; | 362 CPDF_PathData path; |
| 455 width /= 2; | 363 width /= 2; |
| 456 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
rect.top - width); | 364 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width,
rect.top - width); |
| 457 int fill_type = 0; | 365 int fill_type = 0; |
| 458 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { | 366 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { |
| 459 fill_type |= FXFILL_NOPATHSMOOTH; | 367 fill_type |= FXFILL_NOPATHSMOOTH; |
| 460 } | 368 } |
| 461 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); | 369 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); |
| 462 } | 370 } |
| 463 int CPDF_Annot::CountIRTNotes() | |
| 464 { | |
| 465 int count = 0; | |
| 466 for (int i = 0; i < m_pList->Count(); i ++) { | |
| 467 CPDF_Annot* pAnnot = m_pList->GetAt(i); | |
| 468 if (pAnnot == NULL) { | |
| 469 continue; | |
| 470 } | |
| 471 CPDF_Dictionary* pIRT = pAnnot->m_pAnnotDict->GetDict("IRT"); | |
| 472 if (pIRT != m_pAnnotDict) { | |
| 473 continue; | |
| 474 } | |
| 475 count ++; | |
| 476 } | |
| 477 return count; | |
| 478 } | |
| 479 CPDF_Annot* CPDF_Annot::GetIRTNote(int index) | |
| 480 { | |
| 481 int count = 0; | |
| 482 for (int i = 0; i < m_pList->Count(); i ++) { | |
| 483 CPDF_Annot* pAnnot = m_pList->GetAt(i); | |
| 484 if (pAnnot == NULL) { | |
| 485 continue; | |
| 486 } | |
| 487 CPDF_Dictionary* pIRT = pAnnot->m_pAnnotDict->GetDict("IRT"); | |
| 488 if (pIRT != m_pAnnotDict) { | |
| 489 continue; | |
| 490 } | |
| 491 if (count == index) { | |
| 492 return pAnnot; | |
| 493 } | |
| 494 count ++; | |
| 495 } | |
| 496 return NULL; | |
| 497 } | |
| OLD | NEW |