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 "xfa/fxfa/parser/cxfa_fill.h" | 7 #include "xfa/fxfa/parser/cxfa_fill.h" |
8 | 8 |
9 #include "xfa/fxfa/parser/xfa_object.h" | 9 #include "xfa/fxfa/parser/xfa_object.h" |
10 | 10 |
11 CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {} | 11 CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {} |
12 | 12 |
13 CXFA_Fill::~CXFA_Fill() {} | 13 CXFA_Fill::~CXFA_Fill() {} |
14 | 14 |
15 int32_t CXFA_Fill::GetPresence() { | 15 int32_t CXFA_Fill::GetPresence() { |
16 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); | 16 return m_pNode->GetEnum(XFA_ATTRIBUTE_Presence); |
17 } | 17 } |
18 | 18 |
19 void CXFA_Fill::SetColor(FX_ARGB color) { | 19 void CXFA_Fill::SetColor(FX_ARGB color) { |
20 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Color); | 20 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Color); |
21 CFX_WideString wsColor; | 21 CFX_WideString wsColor; |
22 int a, r, g, b; | 22 int a, r, g, b; |
23 ArgbDecode(color, a, r, g, b); | 23 ArgbDecode(color, a, r, g, b); |
24 wsColor.Format(L"%d,%d,%d", r, g, b); | 24 wsColor.Format(L"%d,%d,%d", r, g, b); |
25 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); | 25 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor); |
26 } | 26 } |
27 | 27 |
28 FX_ARGB CXFA_Fill::GetColor(FX_BOOL bText) { | 28 FX_ARGB CXFA_Fill::GetColor(bool bText) { |
29 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color)) { | 29 if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color)) { |
30 CFX_WideStringC wsColor; | 30 CFX_WideStringC wsColor; |
31 if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE)) | 31 if (pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor, false)) |
32 return CXFA_Data::ToColor(wsColor); | 32 return CXFA_Data::ToColor(wsColor); |
33 } | 33 } |
34 if (bText) | 34 if (bText) |
35 return 0xFF000000; | 35 return 0xFF000000; |
36 return 0xFFFFFFFF; | 36 return 0xFFFFFFFF; |
37 } | 37 } |
38 | 38 |
39 XFA_Element CXFA_Fill::GetFillType() { | 39 XFA_Element CXFA_Fill::GetFillType() { |
40 CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); | 40 CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); |
41 while (pChild) { | 41 while (pChild) { |
42 XFA_Element eType = pChild->GetElementType(); | 42 XFA_Element eType = pChild->GetElementType(); |
43 if (eType != XFA_Element::Color && eType != XFA_Element::Extras) | 43 if (eType != XFA_Element::Color && eType != XFA_Element::Extras) |
44 return eType; | 44 return eType; |
45 | 45 |
46 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); | 46 pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); |
47 } | 47 } |
48 return XFA_Element::Solid; | 48 return XFA_Element::Solid; |
49 } | 49 } |
50 | 50 |
51 int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) { | 51 int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) { |
52 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Pattern); | 52 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Pattern); |
53 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { | 53 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { |
54 CFX_WideStringC wsColor; | 54 CFX_WideStringC wsColor; |
55 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | 55 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); |
56 foreColor = CXFA_Data::ToColor(wsColor); | 56 foreColor = CXFA_Data::ToColor(wsColor); |
57 } else { | 57 } else { |
58 foreColor = 0xFF000000; | 58 foreColor = 0xFF000000; |
59 } | 59 } |
60 return pNode->GetEnum(XFA_ATTRIBUTE_Type); | 60 return pNode->GetEnum(XFA_ATTRIBUTE_Type); |
61 } | 61 } |
62 | 62 |
63 int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) { | 63 int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) { |
64 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Stipple); | 64 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Stipple); |
65 int32_t eAttr = 50; | 65 int32_t eAttr = 50; |
66 pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr); | 66 pNode->TryInteger(XFA_ATTRIBUTE_Rate, eAttr); |
67 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { | 67 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { |
68 CFX_WideStringC wsColor; | 68 CFX_WideStringC wsColor; |
69 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | 69 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); |
70 stippleColor = CXFA_Data::ToColor(wsColor); | 70 stippleColor = CXFA_Data::ToColor(wsColor); |
71 } else { | 71 } else { |
72 stippleColor = 0xFF000000; | 72 stippleColor = 0xFF000000; |
73 } | 73 } |
74 return eAttr; | 74 return eAttr; |
75 } | 75 } |
76 | 76 |
77 int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) { | 77 int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) { |
78 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Linear); | 78 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Linear); |
79 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight; | 79 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight; |
80 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr); | 80 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr); |
81 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { | 81 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { |
82 CFX_WideStringC wsColor; | 82 CFX_WideStringC wsColor; |
83 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | 83 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); |
84 endColor = CXFA_Data::ToColor(wsColor); | 84 endColor = CXFA_Data::ToColor(wsColor); |
85 } else { | 85 } else { |
86 endColor = 0xFF000000; | 86 endColor = 0xFF000000; |
87 } | 87 } |
88 return eAttr; | 88 return eAttr; |
89 } | 89 } |
90 | 90 |
91 int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) { | 91 int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) { |
92 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Radial); | 92 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_Element::Radial); |
93 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge; | 93 XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge; |
94 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr); | 94 pNode->TryEnum(XFA_ATTRIBUTE_Type, eAttr); |
95 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { | 95 if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color)) { |
96 CFX_WideStringC wsColor; | 96 CFX_WideStringC wsColor; |
97 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, FALSE); | 97 pColor->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); |
98 endColor = CXFA_Data::ToColor(wsColor); | 98 endColor = CXFA_Data::ToColor(wsColor); |
99 } else { | 99 } else { |
100 endColor = 0xFF000000; | 100 endColor = 0xFF000000; |
101 } | 101 } |
102 return eAttr; | 102 return eAttr; |
103 } | 103 } |
OLD | NEW |