diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-07 21:34:00 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-07 21:34:00 +0000 |
commit | 31ed75b714b80b8497b35825bb926c5abb035299 (patch) | |
tree | 01b2ed5bee1665b665f77a0d8f6f676906bfbb82 /xfa/fxfa | |
parent | 71335de2577ae27d00f03aeb007bf6b9c90d9391 (diff) | |
download | pdfium-31ed75b714b80b8497b35825bb926c5abb035299.tar.xz |
Rename CXFA_Stroke to CXFA_StrokeData
This CL renames CXFA_Stroke to CXFA_StrokeData to show it is part of the
data hierarchy.
Change-Id: If0041c410630c61129ed1ff0879c68244ad01aa5
Reviewed-on: https://pdfium-review.googlesource.com/18013
Commit-Queue: dsinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/cxfa_ffdocview.cpp | 1 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 123 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.cpp | 56 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_cornerdata.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_edgedata.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_strokedata.cpp (renamed from xfa/fxfa/parser/cxfa_stroke.cpp) | 27 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_strokedata.h (renamed from xfa/fxfa/parser/cxfa_stroke.h) | 14 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 4 |
10 files changed, 125 insertions, 126 deletions
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp index d39f7f48be..1779b9e2f0 100644 --- a/xfa/fxfa/cxfa_ffdocview.cpp +++ b/xfa/fxfa/cxfa_ffdocview.cpp @@ -417,6 +417,7 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView, return XFA_EVENTERROR_NotExist; if (pWidgetAcc->GetNode()->IsUserInteractive()) return XFA_EVENTERROR_Disabled; + return pWidgetAcc->ExecuteScript(calcData.GetScriptData(), pParam); } default: diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 6ca1710298..baa9aaf592 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -66,7 +66,7 @@ void XFA_BOX_GetPath_Arc(CXFA_BoxData boxData, fillPath.AddArc(rtDraw.TopLeft(), rtDraw.Size(), startAngle, sweepAngle); } -void XFA_BOX_GetPath(const std::vector<CXFA_Stroke>& strokes, +void XFA_BOX_GetPath(const std::vector<CXFA_StrokeData>& strokes, CFX_RectF rtWidget, CXFA_Path& path, int32_t nIndex, @@ -84,22 +84,22 @@ void XFA_BOX_GetPath(const std::vector<CXFA_Stroke>& strokes, bool bRound = cornerData1.GetJoinType() == XFA_ATTRIBUTEENUM_Round; float halfAfter = 0.0f; float halfBefore = 0.0f; - CXFA_Stroke stroke = strokes[nIndex]; - if (stroke.IsCorner()) { - CXFA_Stroke strokeBefore = strokes[(nIndex + 1 * 8 - 1) % 8]; - CXFA_Stroke strokeAfter = strokes[nIndex + 1]; - if (stroke.IsInverted()) { - if (!stroke.SameStyles(strokeBefore)) - halfBefore = strokeBefore.GetThickness() / 2; - if (!stroke.SameStyles(strokeAfter)) - halfAfter = strokeAfter.GetThickness() / 2; + CXFA_StrokeData strokeData = strokes[nIndex]; + if (strokeData.IsCorner()) { + CXFA_StrokeData strokeBeforeData = strokes[(nIndex + 1 * 8 - 1) % 8]; + CXFA_StrokeData strokeAfterData = strokes[nIndex + 1]; + if (strokeData.IsInverted()) { + if (!strokeData.SameStyles(strokeBeforeData)) + halfBefore = strokeBeforeData.GetThickness() / 2; + if (!strokeData.SameStyles(strokeAfterData)) + halfAfter = strokeAfterData.GetThickness() / 2; } } else { - CXFA_Stroke strokeBefore = strokes[(nIndex + 8 - 2) % 8]; - CXFA_Stroke strokeAfter = strokes[(nIndex + 2) % 8]; + CXFA_StrokeData strokeBeforeData = strokes[(nIndex + 8 - 2) % 8]; + CXFA_StrokeData strokeAfterData = strokes[(nIndex + 2) % 8]; if (!bRound && !bInverted) { - halfBefore = strokeBefore.GetThickness() / 2; - halfAfter = strokeAfter.GetThickness() / 2; + halfBefore = strokeBeforeData.GetThickness() / 2; + halfAfter = strokeAfterData.GetThickness() / 2; } } @@ -235,7 +235,7 @@ void XFA_BOX_GetPath(const std::vector<CXFA_Stroke>& strokes, } void XFA_BOX_GetFillPath(CXFA_BoxData boxData, - const std::vector<CXFA_Stroke>& strokes, + const std::vector<CXFA_StrokeData>& strokes, CFX_RectF rtWidget, CXFA_Path& fillPath, uint16_t dwFlags) { @@ -253,32 +253,33 @@ void XFA_BOX_GetFillPath(CXFA_BoxData boxData, } bool bSameStyles = true; - CXFA_Stroke stroke1 = strokes[0]; + CXFA_StrokeData strokeData1 = strokes[0]; for (int32_t i = 1; i < 8; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2)) { + CXFA_StrokeData strokeData2 = strokes[i]; + if (!strokeData1.SameStyles(strokeData2)) { bSameStyles = false; break; } - stroke1 = stroke2; + strokeData1 = strokeData2; } if (bSameStyles) { - stroke1 = strokes[0]; + strokeData1 = strokes[0]; for (int32_t i = 2; i < 8; i += 2) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | - XFA_STROKE_SAMESTYLE_Corner)) { + CXFA_StrokeData strokeData2 = strokes[i]; + if (!strokeData1.SameStyles( + strokeData2, + XFA_STROKE_SAMESTYLE_NoPresence | XFA_STROKE_SAMESTYLE_Corner)) { bSameStyles = false; break; } - stroke1 = stroke2; + strokeData1 = strokeData2; } if (bSameStyles) { - stroke1 = strokes[0]; - if (stroke1.IsInverted()) { + strokeData1 = strokes[0]; + if (strokeData1.IsInverted()) { bSameStyles = false; } - if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { + if (strokeData1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) { bSameStyles = false; } } @@ -478,7 +479,7 @@ void XFA_BOX_Fill_Linear(CXFA_BoxData boxData, } void XFA_BOX_Fill(CXFA_BoxData boxData, - const std::vector<CXFA_Stroke>& strokes, + const std::vector<CXFA_StrokeData>& strokes, CXFA_Graphics* pGS, const CFX_RectF& rtWidget, const CFX_Matrix& matrix, @@ -523,27 +524,27 @@ void XFA_BOX_Fill(CXFA_BoxData boxData, pGS->RestoreGraphState(); } -void XFA_BOX_StrokePath(CXFA_Stroke stroke, +void XFA_BOX_StrokePath(CXFA_StrokeData strokeData, CXFA_Path* pPath, CXFA_Graphics* pGS, const CFX_Matrix& matrix) { - if (!stroke || !stroke.IsVisible()) { + if (!strokeData || !strokeData.IsVisible()) return; - } - float fThickness = stroke.GetThickness(); - if (fThickness < 0.001f) { + + float fThickness = strokeData.GetThickness(); + if (fThickness < 0.001f) return; - } + pGS->SaveGraphState(); - if (stroke.IsCorner() && fThickness > 2 * stroke.GetRadius()) { - fThickness = 2 * stroke.GetRadius(); - } + if (strokeData.IsCorner() && fThickness > 2 * strokeData.GetRadius()) + fThickness = 2 * strokeData.GetRadius(); + pGS->SetLineWidth(fThickness); pGS->EnableActOnDash(); pGS->SetLineCap(CFX_GraphStateData::LineCapButt); - XFA_StrokeTypeSetLineDash(pGS, stroke.GetStrokeType(), + XFA_StrokeTypeSetLineDash(pGS, strokeData.GetStrokeType(), XFA_ATTRIBUTEENUM_Butt); - pGS->SetStrokeColor(CXFA_Color(stroke.GetColor())); + pGS->SetStrokeColor(CXFA_Color(strokeData.GetColor())); pGS->StrokePath(pPath, &matrix); pGS->RestoreGraphState(); } @@ -720,7 +721,7 @@ void XFA_BOX_Stroke_3DRect_Embossed(CXFA_Graphics* pGS, } void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData, - const std::vector<CXFA_Stroke>& strokes, + const std::vector<CXFA_StrokeData>& strokes, CXFA_Graphics* pGS, CFX_RectF rtWidget, const CFX_Matrix& matrix) { @@ -749,53 +750,53 @@ void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData, } bool bClose = false; bool bSameStyles = true; - CXFA_Stroke stroke1 = strokes[0]; + CXFA_StrokeData strokeData1 = strokes[0]; for (int32_t i = 1; i < 8; i++) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2)) { + CXFA_StrokeData strokeData2 = strokes[i]; + if (!strokeData1.SameStyles(strokeData2)) { bSameStyles = false; break; } - stroke1 = stroke2; + strokeData1 = strokeData2; } if (bSameStyles) { - stroke1 = strokes[0]; + strokeData1 = strokes[0]; bClose = true; for (int32_t i = 2; i < 8; i += 2) { - CXFA_Stroke stroke2 = strokes[i]; - if (!stroke1.SameStyles(stroke2, XFA_STROKE_SAMESTYLE_NoPresence | - XFA_STROKE_SAMESTYLE_Corner)) { + CXFA_StrokeData strokeData2 = strokes[i]; + if (!strokeData1.SameStyles( + strokeData2, + XFA_STROKE_SAMESTYLE_NoPresence | XFA_STROKE_SAMESTYLE_Corner)) { bSameStyles = false; break; } - stroke1 = stroke2; + strokeData1 = strokeData2; } if (bSameStyles) { - stroke1 = strokes[0]; - if (stroke1.IsInverted()) + strokeData1 = strokes[0]; + if (strokeData1.IsInverted()) bSameStyles = false; - if (stroke1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) + if (strokeData1.GetJoinType() != XFA_ATTRIBUTEENUM_Square) bSameStyles = false; } } bool bStart = true; CXFA_Path path; for (int32_t i = 0; i < 8; i++) { - CXFA_Stroke stroke = strokes[i]; - if ((i % 1) == 0 && stroke.GetRadius() < 0) { + CXFA_StrokeData strokeData = strokes[i]; + if ((i % 1) == 0 && strokeData.GetRadius() < 0) { bool bEmpty = path.IsEmpty(); if (!bEmpty) { - XFA_BOX_StrokePath(stroke, &path, pGS, matrix); + XFA_BOX_StrokePath(strokeData, &path, pGS, matrix); path.Clear(); } bStart = true; continue; } XFA_BOX_GetPath(strokes, rtWidget, path, i, bStart, !bSameStyles); - CXFA_Stroke stroke2 = strokes[(i + 1) % 8]; - bStart = !stroke.SameStyles(stroke2); + bStart = !strokeData.SameStyles(strokes[(i + 1) % 8]); if (bStart) { - XFA_BOX_StrokePath(stroke, &path, pGS, matrix); + XFA_BOX_StrokePath(strokeData, &path, pGS, matrix); path.Clear(); } } @@ -809,7 +810,7 @@ void XFA_BOX_Stroke_Rect(CXFA_BoxData boxData, } void XFA_BOX_Stroke(CXFA_BoxData boxData, - const std::vector<CXFA_Stroke>& strokes, + const std::vector<CXFA_StrokeData>& strokes, CXFA_Graphics* pGS, CFX_RectF rtWidget, const CFX_Matrix& matrix, @@ -884,9 +885,9 @@ void XFA_DrawBox(CXFA_BoxData boxData, eType != XFA_Element::Rectangle) { return; } - std::vector<CXFA_Stroke> strokes; + std::vector<CXFA_StrokeData> strokes; if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) - boxData.GetStrokes(&strokes); + strokes = boxData.GetStrokes(); XFA_BOX_Fill(boxData, strokes, pGS, rtWidget, matrix, dwFlags); XFA_BOX_Stroke(boxData, strokes, pGS, rtWidget, matrix, dwFlags); diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp index b7c9561bd0..07eae64ace 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.cpp +++ b/xfa/fxfa/parser/cxfa_boxdata.cpp @@ -12,59 +12,58 @@ namespace { -void GetStrokesInternal(CXFA_Node* pNode, - std::vector<CXFA_Stroke>* strokes, - bool bNull) { - strokes->clear(); +std::vector<CXFA_StrokeData> GetStrokesInternal(CXFA_Node* pNode, bool bNull) { if (!pNode) - return; + return {}; - strokes->resize(8); + std::vector<CXFA_StrokeData> strokes; + strokes.resize(8); int32_t i, j; for (i = 0, j = 0; i < 4; i++) { CXFA_CornerData cornerData = CXFA_CornerData( pNode->JSNode()->GetProperty(i, XFA_Element::Corner, i == 0)); if (cornerData || i == 0) { - (*strokes)[j] = cornerData; + strokes[j] = cornerData; } else if (!bNull) { if (i == 1 || i == 2) - (*strokes)[j] = (*strokes)[0]; + strokes[j] = strokes[0]; else - (*strokes)[j] = (*strokes)[2]; + strokes[j] = strokes[2]; } j++; CXFA_EdgeData edgeData = CXFA_EdgeData( pNode->JSNode()->GetProperty(i, XFA_Element::Edge, i == 0)); if (edgeData || i == 0) { - (*strokes)[j] = edgeData; + strokes[j] = edgeData; } else if (!bNull) { if (i == 1 || i == 2) - (*strokes)[j] = (*strokes)[1]; + strokes[j] = strokes[1]; else - (*strokes)[j] = (*strokes)[3]; + strokes[j] = strokes[3]; } j++; } + return strokes; } -static int32_t Style3D(const std::vector<CXFA_Stroke>& strokes, - CXFA_Stroke& stroke) { +static int32_t Style3D(const std::vector<CXFA_StrokeData>& strokes, + CXFA_StrokeData& strokeData) { if (strokes.empty()) return 0; - stroke = strokes[0]; + strokeData = strokes[0]; for (size_t i = 1; i < strokes.size(); i++) { - CXFA_Stroke find = strokes[i]; + CXFA_StrokeData find = strokes[i]; if (!find) continue; - if (!stroke) - stroke = find; - else if (stroke.GetStrokeType() != find.GetStrokeType()) - stroke = find; + if (!strokeData) + strokeData = find; + else if (strokeData.GetStrokeType() != find.GetStrokeType()) + strokeData = find; break; } - int32_t iType = stroke.GetStrokeType(); + int32_t iType = strokeData.GetStrokeType(); if (iType == XFA_ATTRIBUTEENUM_Lowered || iType == XFA_ATTRIBUTEENUM_Raised || iType == XFA_ATTRIBUTEENUM_Etched || iType == XFA_ATTRIBUTEENUM_Embossed) { @@ -99,8 +98,8 @@ CXFA_EdgeData CXFA_BoxData::GetEdgeData(int32_t nIndex) const { : nullptr); } -void CXFA_BoxData::GetStrokes(std::vector<CXFA_Stroke>* strokes) const { - GetStrokesInternal(m_pNode, strokes, false); +std::vector<CXFA_StrokeData> CXFA_BoxData::GetStrokes() const { + return GetStrokesInternal(m_pNode, false); } bool CXFA_BoxData::IsCircular() const { @@ -155,13 +154,12 @@ int32_t CXFA_BoxData::Get3DStyle(bool& bVisible, float& fThickness) const { if (IsArc()) return 0; - std::vector<CXFA_Stroke> strokes; - GetStrokesInternal(m_pNode, &strokes, true); - CXFA_Stroke stroke(nullptr); - int32_t iType = Style3D(strokes, stroke); + std::vector<CXFA_StrokeData> strokes = GetStrokesInternal(m_pNode, true); + CXFA_StrokeData strokeData(nullptr); + int32_t iType = Style3D(strokes, strokeData); if (iType) { - bVisible = stroke.IsVisible(); - fThickness = stroke.GetThickness(); + bVisible = strokeData.IsVisible(); + fThickness = strokeData.GetThickness(); } return iType; } diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h index af8b26bfed..b4c348311c 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.h +++ b/xfa/fxfa/parser/cxfa_boxdata.h @@ -30,7 +30,7 @@ class CXFA_BoxData : public CXFA_Data { int32_t GetPresence() const; int32_t CountEdges() const; CXFA_EdgeData GetEdgeData(int32_t nIndex = 0) const; - void GetStrokes(std::vector<CXFA_Stroke>* strokes) const; + std::vector<CXFA_StrokeData> GetStrokes() const; bool IsCircular() const; bool GetStartAngle(float& fStartAngle) const; float GetStartAngle() const { diff --git a/xfa/fxfa/parser/cxfa_cornerdata.h b/xfa/fxfa/parser/cxfa_cornerdata.h index be0b602d78..fd17bd5c89 100644 --- a/xfa/fxfa/parser/cxfa_cornerdata.h +++ b/xfa/fxfa/parser/cxfa_cornerdata.h @@ -7,13 +7,13 @@ #ifndef XFA_FXFA_PARSER_CXFA_CORNERDATA_H_ #define XFA_FXFA_PARSER_CXFA_CORNERDATA_H_ -#include "xfa/fxfa/parser/cxfa_stroke.h" +#include "xfa/fxfa/parser/cxfa_strokedata.h" class CXFA_Node; -class CXFA_CornerData : public CXFA_Stroke { +class CXFA_CornerData : public CXFA_StrokeData { public: - explicit CXFA_CornerData(CXFA_Node* pNode) : CXFA_Stroke(pNode) {} + explicit CXFA_CornerData(CXFA_Node* pNode) : CXFA_StrokeData(pNode) {} }; #endif // XFA_FXFA_PARSER_CXFA_CORNERDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_edgedata.h b/xfa/fxfa/parser/cxfa_edgedata.h index 5e9ebf3db5..2a55814a31 100644 --- a/xfa/fxfa/parser/cxfa_edgedata.h +++ b/xfa/fxfa/parser/cxfa_edgedata.h @@ -7,13 +7,13 @@ #ifndef XFA_FXFA_PARSER_CXFA_EDGEDATA_H_ #define XFA_FXFA_PARSER_CXFA_EDGEDATA_H_ -#include "xfa/fxfa/parser/cxfa_stroke.h" +#include "xfa/fxfa/parser/cxfa_strokedata.h" class CXFA_Node; -class CXFA_EdgeData : public CXFA_Stroke { +class CXFA_EdgeData : public CXFA_StrokeData { public: - explicit CXFA_EdgeData(CXFA_Node* pNode) : CXFA_Stroke(pNode) {} + explicit CXFA_EdgeData(CXFA_Node* pNode) : CXFA_StrokeData(pNode) {} }; #endif // XFA_FXFA_PARSER_CXFA_EDGEDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_stroke.cpp b/xfa/fxfa/parser/cxfa_strokedata.cpp index 17b269fda3..1f8a56ea12 100644 --- a/xfa/fxfa/parser/cxfa_stroke.cpp +++ b/xfa/fxfa/parser/cxfa_strokedata.cpp @@ -4,47 +4,47 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "xfa/fxfa/parser/cxfa_stroke.h" +#include "xfa/fxfa/parser/cxfa_strokedata.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/xfa_utils.h" -int32_t CXFA_Stroke::GetPresence() const { +int32_t CXFA_StrokeData::GetPresence() const { return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence) : XFA_ATTRIBUTEENUM_Invisible; } -int32_t CXFA_Stroke::GetCapType() const { +int32_t CXFA_StrokeData::GetCapType() const { if (!m_pNode) return XFA_ATTRIBUTEENUM_Square; return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Cap); } -int32_t CXFA_Stroke::GetStrokeType() const { +int32_t CXFA_StrokeData::GetStrokeType() const { return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Stroke) : XFA_ATTRIBUTEENUM_Solid; } -float CXFA_Stroke::GetThickness() const { +float CXFA_StrokeData::GetThickness() const { return GetMSThickness().ToUnit(XFA_UNIT_Pt); } -CXFA_Measurement CXFA_Stroke::GetMSThickness() const { +CXFA_Measurement CXFA_StrokeData::GetMSThickness() const { return m_pNode ? m_pNode->JSNode()->GetMeasure(XFA_ATTRIBUTE_Thickness) : XFA_GetAttributeDefaultValue_Measure(XFA_Element::Edge, XFA_ATTRIBUTE_Thickness, XFA_XDPPACKET_Form); } -void CXFA_Stroke::SetMSThickness(CXFA_Measurement msThinkness) { +void CXFA_StrokeData::SetMSThickness(CXFA_Measurement msThinkness) { if (!m_pNode) return; m_pNode->JSNode()->SetMeasure(XFA_ATTRIBUTE_Thickness, msThinkness, false); } -FX_ARGB CXFA_Stroke::GetColor() const { +FX_ARGB CXFA_StrokeData::GetColor() const { if (!m_pNode) return 0xFF000000; @@ -57,7 +57,7 @@ FX_ARGB CXFA_Stroke::GetColor() const { return CXFA_Data::ToColor(wsColor); } -void CXFA_Stroke::SetColor(FX_ARGB argb) { +void CXFA_StrokeData::SetColor(FX_ARGB argb) { if (!m_pNode) return; @@ -73,24 +73,25 @@ void CXFA_Stroke::SetColor(FX_ARGB argb) { pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsColor, false, false); } -int32_t CXFA_Stroke::GetJoinType() const { +int32_t CXFA_StrokeData::GetJoinType() const { return m_pNode ? m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Join) : XFA_ATTRIBUTEENUM_Square; } -bool CXFA_Stroke::IsInverted() const { +bool CXFA_StrokeData::IsInverted() const { return m_pNode ? m_pNode->JSNode()->GetBoolean(XFA_ATTRIBUTE_Inverted) : false; } -float CXFA_Stroke::GetRadius() const { +float CXFA_StrokeData::GetRadius() const { return m_pNode ? m_pNode->JSNode() ->GetMeasure(XFA_ATTRIBUTE_Radius) .ToUnit(XFA_UNIT_Pt) : 0; } -bool CXFA_Stroke::SameStyles(CXFA_Stroke stroke, uint32_t dwFlags) const { +bool CXFA_StrokeData::SameStyles(CXFA_StrokeData stroke, + uint32_t dwFlags) const { if (m_pNode == stroke.GetNode()) return true; if (fabs(GetThickness() - stroke.GetThickness()) >= 0.01f) diff --git a/xfa/fxfa/parser/cxfa_stroke.h b/xfa/fxfa/parser/cxfa_strokedata.h index 63709b9160..050b76671a 100644 --- a/xfa/fxfa/parser/cxfa_stroke.h +++ b/xfa/fxfa/parser/cxfa_strokedata.h @@ -4,8 +4,8 @@ // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#ifndef XFA_FXFA_PARSER_CXFA_STROKE_H_ -#define XFA_FXFA_PARSER_CXFA_STROKE_H_ +#ifndef XFA_FXFA_PARSER_CXFA_STROKEDATA_H_ +#define XFA_FXFA_PARSER_CXFA_STROKEDATA_H_ #include "core/fxcrt/fx_system.h" #include "core/fxge/fx_dib.h" @@ -19,10 +19,10 @@ enum StrokeSameStyle { class CXFA_Node; -class CXFA_Stroke : public CXFA_Data { +class CXFA_StrokeData : public CXFA_Data { public: - CXFA_Stroke() : CXFA_Stroke(nullptr) {} - explicit CXFA_Stroke(CXFA_Node* pNode) : CXFA_Data(pNode) {} + CXFA_StrokeData() : CXFA_StrokeData(nullptr) {} + explicit CXFA_StrokeData(CXFA_Node* pNode) : CXFA_Data(pNode) {} bool IsCorner() const { return GetElementType() == XFA_Element::Corner; } bool IsEdge() const { return GetElementType() == XFA_Element::Edge; } @@ -38,7 +38,7 @@ class CXFA_Stroke : public CXFA_Data { int32_t GetJoinType() const; bool IsInverted() const; float GetRadius() const; - bool SameStyles(CXFA_Stroke stroke, uint32_t dwFlags = 0) const; + bool SameStyles(CXFA_StrokeData stroke, uint32_t dwFlags = 0) const; }; -#endif // XFA_FXFA_PARSER_CXFA_STROKE_H_ +#endif // XFA_FXFA_PARSER_CXFA_STROKEDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 841fbd065a..b9a54bd447 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -20,7 +20,7 @@ namespace { -float GetEdgeThickness(const std::vector<CXFA_Stroke>& strokes, +float GetEdgeThickness(const std::vector<CXFA_StrokeData>& strokes, bool b3DStyle, int32_t nIndex) { float fThickness = 0; @@ -397,11 +397,10 @@ CXFA_BorderData CXFA_WidgetData::GetUIBorderData() { CFX_RectF CXFA_WidgetData::GetUIMargin() { CXFA_Node* pUIChild = GetUIChild(); - if (!pUIChild) - return CFX_RectF(); - CXFA_MarginData mgUI = CXFA_MarginData( - pUIChild->JSNode()->GetProperty(0, XFA_Element::Margin, false)); + pUIChild ? pUIChild->JSNode()->GetProperty(0, XFA_Element::Margin, false) + : nullptr); + if (!mgUI) return CFX_RectF(); @@ -419,8 +418,7 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() { float fThickness = 0; borderData.Get3DStyle(bVisible, fThickness); if (!bLeft || !bTop || !bRight || !bBottom) { - std::vector<CXFA_Stroke> strokes; - borderData.GetStrokes(&strokes); + std::vector<CXFA_StrokeData> strokes = borderData.GetStrokes(); if (!bTop) fTopInset = GetEdgeThickness(strokes, bVisible, 0); if (!bRight) diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index f7df149ceb..64d38bf0da 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -49,8 +49,8 @@ bool GetOccurInfo(CXFA_Node* pOccurNode, int32_t& iMin, int32_t& iMax, int32_t& iInit) { - return pOccurNode && - CXFA_OccurData(pOccurNode).GetOccurInfo(iMin, iMax, iInit); + return pOccurNode ? CXFA_OccurData(pOccurNode).GetOccurInfo(iMin, iMax, iInit) + : false; } CXFA_Node* FormValueNode_CreateChild(CXFA_Node* pValueNode, XFA_Element iType) { |