Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: core/src/fpdfdoc/doc_annot.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fpdfdoc/doc_action.cpp ('k') | core/src/fpdfdoc/doc_ap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 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 = new CPDF_Reference(m_pDocument, dwObjNum); 34 CPDF_Reference* pAction = new CPDF_Reference(m_pDocument, dwObjNum);
35 pAnnots->InsertAt(i, pAction); 35 pAnnots->InsertAt(i, pAction);
(...skipping 12 matching lines...) Expand all
48 { 48 {
49 int i = 0; 49 int i = 0;
50 for (i = 0; i < m_AnnotList.GetSize(); ++i) { 50 for (i = 0; i < m_AnnotList.GetSize(); ++i) {
51 delete (CPDF_Annot*)m_AnnotList[i]; 51 delete (CPDF_Annot*)m_AnnotList[i];
52 } 52 }
53 for (i = 0; i < m_Borders.GetSize(); ++i) { 53 for (i = 0; i < m_Borders.GetSize(); ++i) {
54 delete (CPDF_PageObjects*)m_Borders[i]; 54 delete (CPDF_PageObjects*)m_Borders[i];
55 } 55 }
56 } 56 }
57 void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevi ce, 57 void CPDF_AnnotList::DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevi ce,
58 CPDF_RenderContext* pContext, FX_BOOL bPrinting , CFX_AffineMatrix* pMatrix, 58 CPDF_RenderContext* pContext, bool bPrinting, C FX_AffineMatrix* pMatrix,
59 FX_BOOL bWidgetPass, CPDF_RenderOptions* pOptio ns, FX_RECT* clip_rect) 59 bool bWidgetPass, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect)
60 { 60 {
61 for (int i = 0; i < m_AnnotList.GetSize(); ++i) { 61 for (int i = 0; i < m_AnnotList.GetSize(); ++i) {
62 CPDF_Annot* pAnnot = (CPDF_Annot*)m_AnnotList[i]; 62 CPDF_Annot* pAnnot = (CPDF_Annot*)m_AnnotList[i];
63 FX_BOOL bWidget = pAnnot->GetSubType() == "Widget"; 63 bool bWidget = pAnnot->GetSubType() == "Widget";
64 if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) { 64 if ((bWidgetPass && !bWidget) || (!bWidgetPass && bWidget)) {
65 continue; 65 continue;
66 } 66 }
67 FX_DWORD annot_flags = pAnnot->GetFlags(); 67 FX_DWORD annot_flags = pAnnot->GetFlags();
68 if (annot_flags & ANNOTFLAG_HIDDEN) { 68 if (annot_flags & ANNOTFLAG_HIDDEN) {
69 continue; 69 continue;
70 } 70 }
71 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) { 71 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) {
72 continue; 72 continue;
73 } 73 }
(...skipping 22 matching lines...) Expand all
96 } 96 }
97 if (pContext) { 97 if (pContext) {
98 pAnnot->DrawInContext(pPage, pContext, &matrix, CPDF_Annot::Normal); 98 pAnnot->DrawInContext(pPage, pContext, &matrix, CPDF_Annot::Normal);
99 } else if (!pAnnot->DrawAppearance(pPage, pDevice, &matrix, CPDF_Annot:: Normal, pOptions)) { 99 } else if (!pAnnot->DrawAppearance(pPage, pDevice, &matrix, CPDF_Annot:: Normal, pOptions)) {
100 pAnnot->DrawBorder(pDevice, &matrix, pOptions); 100 pAnnot->DrawBorder(pDevice, &matrix, pOptions);
101 } 101 }
102 } 102 }
103 } 103 }
104 void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDe vice, 104 void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDe vice,
105 CFX_AffineMatrix* pUser2Device, 105 CFX_AffineMatrix* pUser2Device,
106 FX_BOOL bShowWidget, CPDF_RenderOptions* pOpt ions) 106 bool bShowWidget, CPDF_RenderOptions* pOption s)
107 { 107 {
108 FX_RECT clip_rect; 108 FX_RECT clip_rect;
109 if (pDevice) { 109 if (pDevice) {
110 clip_rect = pDevice->GetClipBox(); 110 clip_rect = pDevice->GetClipBox();
111 } 111 }
112 FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions & & (pOptions->m_Flags & RENDER_PRINTPREVIEW)); 112 bool bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions && ( pOptions->m_Flags & RENDER_PRINTPREVIEW));
113 DisplayAnnots(pPage, pDevice, NULL, bPrinting, pUser2Device, bShowWidget ? 3 : 1, pOptions, &clip_rect); 113 DisplayAnnots(pPage, pDevice, NULL, bPrinting, pUser2Device, bShowWidget ? 3 : 1, pOptions, &clip_rect);
114 } 114 }
115 void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDe vice, CPDF_RenderContext* pContext, 115 void CPDF_AnnotList::DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDe vice, CPDF_RenderContext* pContext,
116 FX_BOOL bPrinting, CFX_AffineMatrix* pUser2De vice, FX_DWORD dwAnnotFlags, 116 bool bPrinting, CFX_AffineMatrix* pUser2Devic e, FX_DWORD dwAnnotFlags,
117 CPDF_RenderOptions* pOptions, FX_RECT* pClipR ect) 117 CPDF_RenderOptions* pOptions, FX_RECT* pClipR ect)
118 { 118 {
119 if (dwAnnotFlags & 0x01) { 119 if (dwAnnotFlags & 0x01) {
120 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, FALSE, pO ptions, pClipRect); 120 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, false, pO ptions, pClipRect);
121 } 121 }
122 if (dwAnnotFlags & 0x02) { 122 if (dwAnnotFlags & 0x02) {
123 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, TRUE, pOp tions, pClipRect); 123 DisplayPass(pPage, pDevice, pContext, bPrinting, pUser2Device, true, pOp tions, pClipRect);
124 } 124 }
125 } 125 }
126 int CPDF_AnnotList::GetIndex(CPDF_Annot* pAnnot) 126 int CPDF_AnnotList::GetIndex(CPDF_Annot* pAnnot)
127 { 127 {
128 for (int i = 0; i < m_AnnotList.GetSize(); ++i) 128 for (int i = 0; i < m_AnnotList.GetSize(); ++i)
129 if (m_AnnotList[i] == (void*)pAnnot) { 129 if (m_AnnotList[i] == (void*)pAnnot) {
130 return i; 130 return i;
131 } 131 }
132 return -1; 132 return -1;
133 } 133 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 } 239 }
240 CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRect(FX_BSTRC("BBox")); 240 CFX_FloatRect form_bbox = pForm->m_pFormDict->GetRect(FX_BSTRC("BBox"));
241 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matrix")); 241 CFX_Matrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matrix"));
242 form_matrix.TransformRect(form_bbox); 242 form_matrix.TransformRect(form_bbox);
243 CPDF_Rect arect; 243 CPDF_Rect arect;
244 pAnnot->GetRect(arect); 244 pAnnot->GetRect(arect);
245 matrix.MatchRect(arect, form_bbox); 245 matrix.MatchRect(arect, form_bbox);
246 matrix.Concat(*pUser2Device); 246 matrix.Concat(*pUser2Device);
247 return pForm; 247 return pForm;
248 } 248 }
249 FX_BOOL CPDF_Annot::DrawAppearance(const CPDF_Page* pPage, CFX_RenderDevice* pDe vice, const CFX_AffineMatrix* pUser2Device, 249 bool CPDF_Annot::DrawAppearance(const CPDF_Page* pPage, CFX_RenderDevice* pDevic e, const CFX_AffineMatrix* pUser2Device,
250 AppearanceMode mode, const CPDF_RenderOptions * pOptions) 250 AppearanceMode mode, const CPDF_RenderOptions * pOptions)
251 { 251 {
252 CFX_Matrix matrix; 252 CFX_Matrix matrix;
253 CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 253 CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
254 if (!pForm) { 254 if (!pForm) {
255 return FALSE; 255 return false;
256 } 256 }
257 CPDF_RenderContext context; 257 CPDF_RenderContext context;
258 context.Create((CPDF_Page*)pPage); 258 context.Create((CPDF_Page*)pPage);
259 context.DrawObjectList(pDevice, pForm, &matrix, pOptions); 259 context.DrawObjectList(pDevice, pForm, &matrix, pOptions);
260 return TRUE; 260 return true;
261 } 261 }
262 FX_BOOL CPDF_Annot::DrawInContext(const CPDF_Page* pPage, const CPDF_RenderConte xt* pContext, const CFX_AffineMatrix* pUser2Device, AppearanceMode mode) 262 bool CPDF_Annot::DrawInContext(const CPDF_Page* pPage, const CPDF_RenderContext* pContext, const CFX_AffineMatrix* pUser2Device, AppearanceMode mode)
263 { 263 {
264 CFX_Matrix matrix; 264 CFX_Matrix matrix;
265 CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix); 265 CPDF_Form* pForm = FPDFDOC_Annot_GetMatrix(pPage, this, mode, pUser2Device, matrix);
266 if (!pForm) { 266 if (!pForm) {
267 return FALSE; 267 return false;
268 } 268 }
269 ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix); 269 ((CPDF_RenderContext*)pContext)->AppendObjectList(pForm, &matrix);
270 return TRUE; 270 return true;
271 } 271 }
272 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p User2Device, const CPDF_RenderOptions* pOptions) 272 void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* p User2Device, const CPDF_RenderOptions* pOptions)
273 { 273 {
274 if (GetSubType() == "Popup") { 274 if (GetSubType() == "Popup") {
275 return; 275 return;
276 } 276 }
277 FX_DWORD annot_flags = GetFlags(); 277 FX_DWORD annot_flags = GetFlags();
278 if (annot_flags & ANNOTFLAG_HIDDEN) { 278 if (annot_flags & ANNOTFLAG_HIDDEN) {
279 return; 279 return;
280 } 280 }
281 FX_BOOL bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions & & (pOptions->m_Flags & RENDER_PRINTPREVIEW)); 281 bool bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions && ( pOptions->m_Flags & RENDER_PRINTPREVIEW));
282 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) { 282 if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) {
283 return; 283 return;
284 } 284 }
285 if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) { 285 if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) {
286 return; 286 return;
287 } 287 }
288 CPDF_Dictionary* pBS = m_pAnnotDict->GetDict("BS"); 288 CPDF_Dictionary* pBS = m_pAnnotDict->GetDict("BS");
289 char style_char; 289 char style_char;
290 FX_FLOAT width; 290 FX_FLOAT width;
291 CPDF_Array* pDashArray = NULL; 291 CPDF_Array* pDashArray = NULL;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 GetRect(rect); 359 GetRect(rect);
360 CPDF_PathData path; 360 CPDF_PathData path;
361 width /= 2; 361 width /= 2;
362 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); 362 path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);
363 int fill_type = 0; 363 int fill_type = 0;
364 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { 364 if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) {
365 fill_type |= FXFILL_NOPATHSMOOTH; 365 fill_type |= FXFILL_NOPATHSMOOTH;
366 } 366 }
367 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); 367 pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type);
368 } 368 }
OLDNEW
« no previous file with comments | « core/src/fpdfdoc/doc_action.cpp ('k') | core/src/fpdfdoc/doc_ap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698