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 <algorithm> |
| 8 |
7 #include "../../include/formfiller/FormFiller.h" | 9 #include "../../include/formfiller/FormFiller.h" |
8 #include "../../include/formfiller/FFL_Utils.h" | 10 #include "../../include/formfiller/FFL_Utils.h" |
9 | 11 |
10 CPDF_Rect CFFL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2) | 12 CPDF_Rect CFFL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2) |
11 { | 13 { |
12 CPDF_Rect rcRet; | 14 CPDF_Rect rcRet; |
13 | 15 |
14 » rcRet.left = FFL_MIN(rect1.left,rect2.left); | 16 » rcRet.left = std::min(rect1.left, rect2.left); |
15 » rcRet.bottom = FFL_MIN(rect1.bottom,rect2.bottom); | 17 » rcRet.bottom = std::min(rect1.bottom, rect2.bottom); |
16 » rcRet.right = FFL_MAX(rect1.right,rect2.right); | 18 » rcRet.right = std::max(rect1.right, rect2.right); |
17 » rcRet.top = FFL_MAX(rect1.top,rect2.top); | 19 » rcRet.top = std::max(rect1.top, rect2.top); |
18 | 20 |
19 return rcRet; | 21 return rcRet; |
20 } | 22 } |
21 | 23 |
22 CPDF_Rect CFFL_Utils::InflateRect(const CPDF_Rect & crRect,const FX_FLOAT & fSiz
e) | 24 CPDF_Rect CFFL_Utils::InflateRect(const CPDF_Rect & crRect,const FX_FLOAT & fSiz
e) |
23 { | 25 { |
24 CPDF_Rect crNew(crRect.left - fSize, | 26 CPDF_Rect crNew(crRect.left - fSize, |
25 crRect.bottom - fSize, | 27 crRect.bottom - fSize, |
26 crRect.right + fSize, | 28 crRect.right + fSize, |
27 crRect.top + fSize); | 29 crRect.top + fSize); |
28 crNew.Normalize(); | 30 crNew.Normalize(); |
29 return crNew; | 31 return crNew; |
30 } | 32 } |
31 | 33 |
32 CPDF_Rect CFFL_Utils::DeflateRect(const CPDF_Rect & crRect,const FX_FLOAT & fSiz
e) | 34 CPDF_Rect CFFL_Utils::DeflateRect(const CPDF_Rect & crRect,const FX_FLOAT & fSiz
e) |
33 { | 35 { |
34 CPDF_Rect crNew(crRect.left + fSize, | 36 CPDF_Rect crNew(crRect.left + fSize, |
35 crRect.bottom + fSize, | 37 crRect.bottom + fSize, |
36 crRect.right - fSize, | 38 crRect.right - fSize, |
37 crRect.top - fSize); | 39 crRect.top - fSize); |
38 crNew.Normalize(); | 40 crNew.Normalize(); |
39 return crNew; | 41 return crNew; |
40 } | 42 } |
41 | 43 |
42 /* | |
43 FX_BOOL CFFL_Utils::RectContainsRect(const CPDF_Rect & father,const CPDF_Rect &
son) | |
44 { | |
45 return (father.left <= son.left && father.right >= son.right && | |
46 father.bottom <= son.bottom && father.top >= son
.top); | |
47 | |
48 } | |
49 | |
50 FX_BOOL CFFL_Utils::RectContainsPoint(const CPDF_Rect & father,const CPDF_Point
& son) | |
51 { | |
52 return (father.left <= son.x && father.right >= son.x && | |
53 father.bottom <= son.y && father.top >= son.y); | |
54 } | |
55 | |
56 FX_BOOL CFFL_Utils::RectContainsXY(const CPDF_Rect & father,FX_FLOAT x,FX_FLOAT
y) | |
57 { | |
58 return (father.left <= x && father.right >= x && | |
59 father.bottom <= y && father.top >= y); | |
60 } | |
61 */ | |
62 | |
63 FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj) | 44 FX_BOOL CFFL_Utils::TraceObject(CPDF_Object* pObj) |
64 { | 45 { |
65 if (!pObj) return FALSE; | 46 if (!pObj) return FALSE; |
66 | 47 |
67 FX_DWORD dwObjNum = pObj->GetObjNum(); | 48 FX_DWORD dwObjNum = pObj->GetObjNum(); |
68 switch (pObj->GetType()) | 49 switch (pObj->GetType()) |
69 { | 50 { |
70 case PDFOBJ_ARRAY: | 51 case PDFOBJ_ARRAY: |
71 { | 52 { |
72 CPDF_Array* pArray = (CPDF_Array*)pObj; | 53 CPDF_Array* pArray = (CPDF_Array*)pObj; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // case PDFOBJ_KEYWORD: | 105 // case PDFOBJ_KEYWORD: |
125 // case PDFOBJ_EOF: | 106 // case PDFOBJ_EOF: |
126 default: | 107 default: |
127 break; | 108 break; |
128 } | 109 } |
129 if (dwObjNum == 0) return FALSE; | 110 if (dwObjNum == 0) return FALSE; |
130 | 111 |
131 return TRUE; | 112 return TRUE; |
132 } | 113 } |
133 | 114 |
OLD | NEW |