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

Side by Side Diff: fpdfsdk/src/formfiller/FFL_Utils.cpp

Issue 453133004: clang-format all code (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 6 years, 4 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
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 "../../include/formfiller/FormFiller.h" 7 #include "../../include/formfiller/FormFiller.h"
8 #include "../../include/formfiller/FFL_Utils.h" 8 #include "../../include/formfiller/FFL_Utils.h"
9 9
10 CPDF_Rect CFFL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2) 10 CPDF_Rect CFFL_Utils::MaxRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2) {
11 { 11 CPDF_Rect rcRet;
12 » CPDF_Rect rcRet;
13 12
14 » rcRet.left = FFL_MIN(rect1.left,rect2.left); 13 rcRet.left = FFL_MIN(rect1.left, rect2.left);
15 » rcRet.bottom = FFL_MIN(rect1.bottom,rect2.bottom); 14 rcRet.bottom = FFL_MIN(rect1.bottom, rect2.bottom);
16 » rcRet.right = FFL_MAX(rect1.right,rect2.right); 15 rcRet.right = FFL_MAX(rect1.right, rect2.right);
17 » rcRet.top = FFL_MAX(rect1.top,rect2.top); 16 rcRet.top = FFL_MAX(rect1.top, rect2.top);
18 17
19 » return rcRet; 18 return rcRet;
20 } 19 }
21 20
22 CPDF_Rect CFFL_Utils::InflateRect(const CPDF_Rect & crRect,const FX_FLOAT & fSiz e) 21 CPDF_Rect CFFL_Utils::InflateRect(const CPDF_Rect& crRect,
23 { 22 const FX_FLOAT& fSize) {
24 » CPDF_Rect crNew(crRect.left - fSize, 23 CPDF_Rect crNew(crRect.left - fSize,
25 » » » » » crRect.bottom - fSize, 24 crRect.bottom - fSize,
26 » » » » » crRect.right + fSize, 25 crRect.right + fSize,
27 » » » » » crRect.top + fSize); 26 crRect.top + fSize);
28 » crNew.Normalize(); 27 crNew.Normalize();
29 » return crNew; 28 return crNew;
30 } 29 }
31 30
32 CPDF_Rect CFFL_Utils::DeflateRect(const CPDF_Rect & crRect,const FX_FLOAT & fSiz e) 31 CPDF_Rect CFFL_Utils::DeflateRect(const CPDF_Rect& crRect,
33 { 32 const FX_FLOAT& fSize) {
34 » CPDF_Rect crNew(crRect.left + fSize, 33 CPDF_Rect crNew(crRect.left + fSize,
35 » » » » » crRect.bottom + fSize, 34 crRect.bottom + fSize,
36 » » » » » crRect.right - fSize, 35 crRect.right - fSize,
37 » » » » » crRect.top - fSize); 36 crRect.top - fSize);
38 » crNew.Normalize(); 37 crNew.Normalize();
39 » return crNew; 38 return crNew;
40 } 39 }
41 40
42 /* 41 /*
43 FX_BOOL CFFL_Utils::RectContainsRect(const CPDF_Rect & father,const CPDF_Rect & son) 42 FX_BOOL CFFL_Utils::RectContainsRect(const CPDF_Rect & father,const CPDF_Rect &
43 son)
44 { 44 {
45 » return (father.left <= son.left && father.right >= son.right && 45 return (father.left <= son.left && father.right >= son.right &&
46 » » » » father.bottom <= son.bottom && father.top >= son .top); 46 father.bottom <= son.bottom && father.top >=
47 son.top);
47 48
48 } 49 }
49 50
50 FX_BOOL CFFL_Utils::RectContainsPoint(const CPDF_Rect & father,const CPDF_Point & son) 51 FX_BOOL CFFL_Utils::RectContainsPoint(const CPDF_Rect & father,const CPDF_Point
52 & son)
51 { 53 {
52 » return (father.left <= son.x && father.right >= son.x && 54 return (father.left <= son.x && father.right >= son.x &&
53 » » » » father.bottom <= son.y && father.top >= son.y); 55 father.bottom <= son.y && father.top >= son.y);
54 } 56 }
55 57
56 FX_BOOL CFFL_Utils::RectContainsXY(const CPDF_Rect & father,FX_FLOAT x,FX_FLOAT y) 58 FX_BOOL CFFL_Utils::RectContainsXY(const CPDF_Rect & father,FX_FLOAT x,FX_FLOAT
59 y)
57 { 60 {
58 » return (father.left <= x && father.right >= x && 61 return (father.left <= x && father.right >= x &&
59 » » » » father.bottom <= y && father.top >= y); 62 father.bottom <= y && father.top >= y);
60 } 63 }
61 */ 64 */
62 65
63 FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj) 66 FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj) {
64 { 67 if (!pObj)
65 » if (!pObj) return FALSE; 68 return FALSE;
66 69
67 » FX_DWORD» dwObjNum = pObj->GetObjNum(); 70 FX_DWORD dwObjNum = pObj->GetObjNum();
68 » switch (pObj->GetType()) 71 switch (pObj->GetType()) {
69 » { 72 case PDFOBJ_ARRAY: {
70 » case PDFOBJ_ARRAY: 73 CPDF_Array* pArray = (CPDF_Array*)pObj;
71 » » { 74 for (FX_DWORD i = 0; i < pArray->GetCount(); i++) {
72 » » » CPDF_Array* pArray = (CPDF_Array*)pObj; 75 CPDF_Object* pElement = pArray->GetElementValue(i);
73 » » » for (FX_DWORD i = 0; i < pArray->GetCount(); i ++) 76 TraceObject(pElement);
74 » » » { 77 }
75 » » » » CPDF_Object* pElement = pArray->GetElementValue( i);» » » » 78 } break;
76 » » » » TraceObject(pElement);
77 » » » }
78 » » }
79 » » break;
80 79
81 » case PDFOBJ_DICTIONARY: 80 case PDFOBJ_DICTIONARY: {
82 » » { 81 CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
83 » » » CPDF_Dictionary* pDict = (CPDF_Dictionary*)pObj;
84 82
85 » » » FX_POSITION fPos = pDict->GetStartPos(); 83 FX_POSITION fPos = pDict->GetStartPos();
86 » » » CFX_ByteString csKey; 84 CFX_ByteString csKey;
87 » » » do 85 do {
88 » » » { 86 CPDF_Object* pElement = pDict->GetNextElement(fPos, csKey);
89 » » » » CPDF_Object* pElement = pDict->GetNextElement(fP os, csKey); 87 // TRACE(csKey + "\n");
90 » » » » //TRACE(csKey + "\n"); 88 if (!pElement)
91 » » » » if (!pElement) break; 89 break;
92 » » » » TraceObject(pElement); 90 TraceObject(pElement);
93 » » » }while (TRUE); 91 } while (TRUE);
94 » » } 92 } break;
95 » » break;
96 93
97 » case PDFOBJ_STREAM: 94 case PDFOBJ_STREAM: {
98 » » { 95 CPDF_Stream* pStream = (CPDF_Stream*)pObj;
99 » » » CPDF_Stream* pStream = (CPDF_Stream*)pObj; 96 CPDF_Dictionary* pDict = pStream->GetDict();
100 » » » CPDF_Dictionary* pDict = pStream->GetDict(); 97 TraceObject(pDict);
101 » » » TraceObject(pDict); 98 } break;
102 » » }
103 » » break;
104 99
105 » case PDFOBJ_REFERENCE: 100 case PDFOBJ_REFERENCE: {
106 » » { 101 CPDF_Object* pDirectObj = pObj->GetDirect();
107 » » » CPDF_Object* pDirectObj = pObj->GetDirect(); 102 TraceObject(pDirectObj);
108 » » » TraceObject(pDirectObj); 103 } break;
109 » » }
110 » » break;
111 104
112 » case PDFOBJ_BOOLEAN: 105 case PDFOBJ_BOOLEAN:
113 » » break; 106 break;
114 » case PDFOBJ_NUMBER: 107 case PDFOBJ_NUMBER:
115 » » //TRACE("%d\n",(FX_INT32)pObj); 108 // TRACE("%d\n",(FX_INT32)pObj);
116 » » break; 109 break;
117 » case PDFOBJ_STRING: 110 case PDFOBJ_STRING:
118 » » //TRACE(((CPDF_String*)pObj)->GetString() + "\n"); 111 // TRACE(((CPDF_String*)pObj)->GetString() + "\n");
119 » » break; 112 break;
120 » case PDFOBJ_NAME: 113 case PDFOBJ_NAME:
121 » » //TRACE(((CPDF_Name*)pObj)->GetString() + "\n"); 114 // TRACE(((CPDF_Name*)pObj)->GetString() + "\n");
122 » » break; 115 break;
123 » case PDFOBJ_NULL: 116 case PDFOBJ_NULL:
124 //» case PDFOBJ_KEYWORD: 117 //» case PDFOBJ_KEYWORD:
125 //» case PDFOBJ_EOF: 118 //» case PDFOBJ_EOF:
126 » default: 119 default:
127 » » break; 120 break;
128 » } 121 }
129 » if (dwObjNum == 0) return FALSE; 122 if (dwObjNum == 0)
123 return FALSE;
130 124
131 » return TRUE; 125 return TRUE;
132 } 126 }
133
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698