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

Side by Side Diff: xfa/fxfa/parser/cxfa_stroke.cpp

Issue 1861353002: Split fxfa_objectacc.h into pieces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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 | « xfa/fxfa/parser/cxfa_stroke.h ('k') | xfa/fxfa/parser/cxfa_submit.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "xfa/fxfa/parser/cxfa_stroke.h"
8
9 #include "xfa/fxfa/parser/xfa_object.h"
10
11 int32_t CXFA_Stroke::GetPresence() const {
12 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence)
13 : XFA_ATTRIBUTEENUM_Invisible;
14 }
15
16 int32_t CXFA_Stroke::GetCapType() const {
17 if (!m_pNode)
18 return XFA_ATTRIBUTEENUM_Square;
19 return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap);
20 }
21
22 int32_t CXFA_Stroke::GetStrokeType() const {
23 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke)
24 : XFA_ATTRIBUTEENUM_Solid;
25 }
26
27 FX_FLOAT CXFA_Stroke::GetThickness() const {
28 return GetMSThickness().ToUnit(XFA_UNIT_Pt);
29 }
30
31 CXFA_Measurement CXFA_Stroke::GetMSThickness() const {
32 return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness)
33 : XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT_Edge,
34 XFA_ATTRIBUTE_Thickness,
35 XFA_XDPPACKET_Form);
36 }
37
38 void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) {
39 if (!m_pNode)
40 return;
41
42 m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness);
43 }
44
45 FX_ARGB CXFA_Stroke::GetColor() const {
46 if (!m_pNode)
47 return 0xFF000000;
48
49 CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color);
50 if (!pNode)
51 return 0xFF000000;
52
53 CFX_WideStringC wsColor;
54 pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor);
55 return CXFA_Data::ToColor(wsColor);
56 }
57
58 void CXFA_Stroke::SetColor(FX_ARGB argb) {
59 if (!m_pNode)
60 return;
61
62 CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
63 CFX_WideString wsColor;
64 int a;
65 int r;
66 int g;
67 int b;
68 ArgbDecode(argb, a, r, g, b);
69 wsColor.Format(L"%d,%d,%d", r, g, b);
70 pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
71 }
72
73 int32_t CXFA_Stroke::GetJoinType() const {
74 return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join)
75 : XFA_ATTRIBUTEENUM_Square;
76 }
77
78 FX_BOOL CXFA_Stroke::IsInverted() const {
79 return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : FALSE;
80 }
81
82 FX_FLOAT CXFA_Stroke::GetRadius() const {
83 return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt)
84 : 0;
85 }
86
87 FX_BOOL CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const {
88 if (m_pNode == stroke.GetNode())
89 return TRUE;
90 if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f)
91 return FALSE;
92 if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 &&
93 IsVisible() != stroke.IsVisible()) {
94 return FALSE;
95 }
96 if (GetStrokeType() != stroke.GetStrokeType())
97 return FALSE;
98 if (GetColor() != stroke.GetColor())
99 return FALSE;
100 if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 &&
101 FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) {
102 return FALSE;
103 }
104 return TRUE;
105 }
OLDNEW
« no previous file with comments | « xfa/fxfa/parser/cxfa_stroke.h ('k') | xfa/fxfa/parser/cxfa_submit.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698