summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_stroke.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-06 10:23:46 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-06 10:23:46 -0700
commit44d054c6449edb63d9760ac6602b036ffec75a84 (patch)
tree846b0da4fb6d90fad87b97a3c938fe94f7c9243d /xfa/fxfa/parser/cxfa_stroke.cpp
parent48baa5f230a886b0579a9626711e7d71376b085e (diff)
downloadpdfium-44d054c6449edb63d9760ac6602b036ffec75a84.tar.xz
Split fxfa_objectacc.h into pieces.
This Cl splits apart the fxfa_objectacc.h file and moves the individual classes into the xfa/fxfa/parser directory. Review URL: https://codereview.chromium.org/1861353002
Diffstat (limited to 'xfa/fxfa/parser/cxfa_stroke.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_stroke.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_stroke.cpp
new file mode 100644
index 0000000000..ac175bed58
--- /dev/null
+++ b/xfa/fxfa/parser/cxfa_stroke.cpp
@@ -0,0 +1,105 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "xfa/fxfa/parser/cxfa_stroke.h"
+
+#include "xfa/fxfa/parser/xfa_object.h"
+
+int32_t CXFA_Stroke::GetPresence() const {
+ return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Presence)
+ : XFA_ATTRIBUTEENUM_Invisible;
+}
+
+int32_t CXFA_Stroke::GetCapType() const {
+ if (!m_pNode)
+ return XFA_ATTRIBUTEENUM_Square;
+ return m_pNode->GetEnum(XFA_ATTRIBUTE_Cap);
+}
+
+int32_t CXFA_Stroke::GetStrokeType() const {
+ return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Stroke)
+ : XFA_ATTRIBUTEENUM_Solid;
+}
+
+FX_FLOAT CXFA_Stroke::GetThickness() const {
+ return GetMSThickness().ToUnit(XFA_UNIT_Pt);
+}
+
+CXFA_Measurement CXFA_Stroke::GetMSThickness() const {
+ return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Thickness)
+ : XFA_GetAttributeDefaultValue_Measure(XFA_ELEMENT_Edge,
+ XFA_ATTRIBUTE_Thickness,
+ XFA_XDPPACKET_Form);
+}
+
+void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) {
+ if (!m_pNode)
+ return;
+
+ m_pNode->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness);
+}
+
+FX_ARGB CXFA_Stroke::GetColor() const {
+ if (!m_pNode)
+ return 0xFF000000;
+
+ CXFA_Node* pNode = m_pNode->GetChild(0, XFA_ELEMENT_Color);
+ if (!pNode)
+ return 0xFF000000;
+
+ CFX_WideStringC wsColor;
+ pNode->TryCData(XFA_ATTRIBUTE_Value, wsColor);
+ return CXFA_Data::ToColor(wsColor);
+}
+
+void CXFA_Stroke::SetColor(FX_ARGB argb) {
+ if (!m_pNode)
+ return;
+
+ CXFA_Node* pNode = m_pNode->GetProperty(0, XFA_ELEMENT_Color);
+ CFX_WideString wsColor;
+ int a;
+ int r;
+ int g;
+ int b;
+ ArgbDecode(argb, a, r, g, b);
+ wsColor.Format(L"%d,%d,%d", r, g, b);
+ pNode->SetCData(XFA_ATTRIBUTE_Value, wsColor);
+}
+
+int32_t CXFA_Stroke::GetJoinType() const {
+ return m_pNode ? m_pNode->GetEnum(XFA_ATTRIBUTE_Join)
+ : XFA_ATTRIBUTEENUM_Square;
+}
+
+FX_BOOL CXFA_Stroke::IsInverted() const {
+ return m_pNode ? m_pNode->GetBoolean(XFA_ATTRIBUTE_Inverted) : FALSE;
+}
+
+FX_FLOAT CXFA_Stroke::GetRadius() const {
+ return m_pNode ? m_pNode->GetMeasure(XFA_ATTRIBUTE_Radius).ToUnit(XFA_UNIT_Pt)
+ : 0;
+}
+
+FX_BOOL CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const {
+ if (m_pNode == stroke.GetNode())
+ return TRUE;
+ if (FXSYS_fabs(GetThickness() - stroke.GetThickness()) >= 0.01f)
+ return FALSE;
+ if ((dwFlags & XFA_STROKE_SAMESTYLE_NoPresence) == 0 &&
+ IsVisible() != stroke.IsVisible()) {
+ return FALSE;
+ }
+ if (GetStrokeType() != stroke.GetStrokeType())
+ return FALSE;
+ if (GetColor() != stroke.GetColor())
+ return FALSE;
+ if ((dwFlags & XFA_STROKE_SAMESTYLE_Corner) != 0 &&
+ FXSYS_fabs(GetRadius() - stroke.GetRadius()) >= 0.01f) {
+ return FALSE;
+ }
+ return TRUE;
+}