From d32fa8b75a3af1cddc4517a3085a43f7a3544c90 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 7 Nov 2017 20:10:51 +0000 Subject: Rename CXFA_Fill to CXFA_FillData This CL renames CXFA_Fill to CXFA_FillData to show it is part of the data hierarchy. Change-Id: I4f1f3e83621dee4f9ccddb3b3d04785d094315b8 Reviewed-on: https://pdfium-review.googlesource.com/17981 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- xfa/fxfa/cxfa_ffwidget.cpp | 28 +++++----- xfa/fxfa/parser/cxfa_boxdata.cpp | 6 +-- xfa/fxfa/parser/cxfa_boxdata.h | 4 +- xfa/fxfa/parser/cxfa_fill.cpp | 111 -------------------------------------- xfa/fxfa/parser/cxfa_fill.h | 31 ----------- xfa/fxfa/parser/cxfa_filldata.cpp | 111 ++++++++++++++++++++++++++++++++++++++ xfa/fxfa/parser/cxfa_filldata.h | 31 +++++++++++ xfa/fxfa/parser/cxfa_font.cpp | 10 ++-- 8 files changed, 166 insertions(+), 166 deletions(-) delete mode 100644 xfa/fxfa/parser/cxfa_fill.cpp delete mode 100644 xfa/fxfa/parser/cxfa_fill.h create mode 100644 xfa/fxfa/parser/cxfa_filldata.cpp create mode 100644 xfa/fxfa/parser/cxfa_filldata.h (limited to 'xfa/fxfa') diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index dcacf5054d..97dc26846e 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -388,10 +388,10 @@ void XFA_BOX_Fill_Radial(CXFA_BoxData boxData, CXFA_Path& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { - CXFA_Fill fill = boxData.GetFill(); + CXFA_FillData fillData = boxData.GetFillData(); FX_ARGB crStart, crEnd; - crStart = fill.GetColor(); - int32_t iType = fill.GetRadial(crEnd); + crStart = fillData.GetColor(); + int32_t iType = fillData.GetRadial(crEnd); if (iType != XFA_ATTRIBUTEENUM_ToEdge) { FX_ARGB temp = crEnd; crEnd = crStart; @@ -411,10 +411,10 @@ void XFA_BOX_Fill_Pattern(CXFA_BoxData boxData, CXFA_Path& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { - CXFA_Fill fill = boxData.GetFill(); + CXFA_FillData fillData = boxData.GetFillData(); FX_ARGB crStart, crEnd; - crStart = fill.GetColor(); - int32_t iType = fill.GetPattern(crEnd); + crStart = fillData.GetColor(); + int32_t iType = fillData.GetPattern(crEnd); FX_HatchStyle iHatch = FX_HatchStyle::Cross; switch (iType) { case XFA_ATTRIBUTEENUM_CrossDiagonal: @@ -446,10 +446,10 @@ void XFA_BOX_Fill_Linear(CXFA_BoxData boxData, CXFA_Path& fillPath, CFX_RectF rtFill, const CFX_Matrix& matrix) { - CXFA_Fill fill = boxData.GetFill(); - FX_ARGB crStart = fill.GetColor(); + CXFA_FillData fillData = boxData.GetFillData(); + FX_ARGB crStart = fillData.GetColor(); FX_ARGB crEnd; - int32_t iType = fill.GetLinear(crEnd); + int32_t iType = fillData.GetLinear(crEnd); CFX_PointF ptStart; CFX_PointF ptEnd; switch (iType) { @@ -483,8 +483,8 @@ void XFA_BOX_Fill(CXFA_BoxData boxData, const CFX_RectF& rtWidget, const CFX_Matrix& matrix, uint32_t dwFlags) { - CXFA_Fill fill = boxData.GetFill(); - if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) + CXFA_FillData fillData = boxData.GetFillData(); + if (!fillData || fillData.GetPresence() != XFA_ATTRIBUTEENUM_Visible) return; pGS->SaveGraphState(); @@ -492,7 +492,7 @@ void XFA_BOX_Fill(CXFA_BoxData boxData, XFA_BOX_GetFillPath(boxData, strokes, rtWidget, fillPath, (dwFlags & XFA_DRAWBOX_ForceRound) != 0); fillPath.Close(); - XFA_Element eType = fill.GetFillType(); + XFA_Element eType = fillData.GetFillType(); switch (eType) { case XFA_Element::Radial: XFA_BOX_Fill_Radial(boxData, pGS, fillPath, rtWidget, matrix); @@ -506,7 +506,7 @@ void XFA_BOX_Fill(CXFA_BoxData boxData, default: { FX_ARGB cr; if (eType == XFA_Element::Stipple) { - int32_t iRate = fill.GetStipple(cr); + int32_t iRate = fillData.GetStipple(cr); if (iRate == 0) iRate = 100; int32_t a; @@ -514,7 +514,7 @@ void XFA_BOX_Fill(CXFA_BoxData boxData, std::tie(a, rgb) = ArgbToColorRef(cr); cr = ArgbEncode(iRate * a / 100, rgb); } else { - cr = fill.GetColor(); + cr = fillData.GetColor(); } pGS->SetFillColor(CXFA_Color(cr)); pGS->FillPath(&fillPath, FXFILL_WINDING, &matrix); diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp index 607a1571dc..d0c264e3b2 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.cpp +++ b/xfa/fxfa/parser/cxfa_boxdata.cpp @@ -137,13 +137,13 @@ bool CXFA_BoxData::GetSweepAngle(float& fSweepAngle) const { return bRet; } -CXFA_Fill CXFA_BoxData::GetFill(bool bModified) const { +CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const { if (!m_pNode) - return CXFA_Fill(nullptr); + return CXFA_FillData(nullptr); CXFA_Node* pFillNode = m_pNode->JSNode()->GetProperty(0, XFA_Element::Fill, bModified); - return CXFA_Fill(pFillNode); + return CXFA_FillData(pFillNode); } CXFA_Margin CXFA_BoxData::GetMargin() const { diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h index 384d4c1e00..80a39222e2 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.h +++ b/xfa/fxfa/parser/cxfa_boxdata.h @@ -12,7 +12,7 @@ #include "core/fxcrt/fx_system.h" #include "xfa/fxfa/parser/cxfa_data.h" #include "xfa/fxfa/parser/cxfa_edgedata.h" -#include "xfa/fxfa/parser/cxfa_fill.h" +#include "xfa/fxfa/parser/cxfa_filldata.h" #include "xfa/fxfa/parser/cxfa_margin.h" class CXFA_Node; @@ -46,7 +46,7 @@ class CXFA_BoxData : public CXFA_Data { return fSweepAngle; } - CXFA_Fill GetFill(bool bModified = false) const; + CXFA_FillData GetFillData(bool bModified = false) const; CXFA_Margin GetMargin() const; int32_t Get3DStyle(bool& bVisible, float& fThickness) const; }; diff --git a/xfa/fxfa/parser/cxfa_fill.cpp b/xfa/fxfa/parser/cxfa_fill.cpp deleted file mode 100644 index 8430b254a8..0000000000 --- a/xfa/fxfa/parser/cxfa_fill.cpp +++ /dev/null @@ -1,111 +0,0 @@ -// 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_fill.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_Fill::CXFA_Fill(CXFA_Node* pNode) : CXFA_Data(pNode) {} - -CXFA_Fill::~CXFA_Fill() {} - -int32_t CXFA_Fill::GetPresence() { - return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence); -} - -void CXFA_Fill::SetColor(FX_ARGB color) { - CXFA_Node* pNode = - m_pNode->JSNode()->GetProperty(0, XFA_Element::Color, true); - WideString wsColor; - int a; - int r; - int g; - int b; - std::tie(a, r, g, b) = ArgbDecode(color); - wsColor.Format(L"%d,%d,%d", r, g, b); - pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsColor, false, false); -} - -FX_ARGB CXFA_Fill::GetColor(bool bText) { - if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false)) { - WideStringView wsColor; - if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false)) - return CXFA_Data::ToColor(wsColor); - } - if (bText) - return 0xFF000000; - return 0xFFFFFFFF; -} - -XFA_Element CXFA_Fill::GetFillType() { - CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - while (pChild) { - XFA_Element eType = pChild->GetElementType(); - if (eType != XFA_Element::Color && eType != XFA_Element::Extras) - return eType; - - pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); - } - return XFA_Element::Solid; -} - -int32_t CXFA_Fill::GetPattern(FX_ARGB& foreColor) { - CXFA_Node* pNode = - m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern, true); - if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { - WideStringView wsColor; - pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); - foreColor = CXFA_Data::ToColor(wsColor); - } else { - foreColor = 0xFF000000; - } - return pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Type); -} - -int32_t CXFA_Fill::GetStipple(FX_ARGB& stippleColor) { - CXFA_Node* pNode = - m_pNode->JSNode()->GetProperty(0, XFA_Element::Stipple, true); - int32_t eAttr = 50; - pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Rate, eAttr, true); - if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { - WideStringView wsColor; - pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); - stippleColor = CXFA_Data::ToColor(wsColor); - } else { - stippleColor = 0xFF000000; - } - return eAttr; -} - -int32_t CXFA_Fill::GetLinear(FX_ARGB& endColor) { - CXFA_Node* pNode = - m_pNode->JSNode()->GetProperty(0, XFA_Element::Linear, true); - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight; - pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Type, eAttr, true); - if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { - WideStringView wsColor; - pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); - endColor = CXFA_Data::ToColor(wsColor); - } else { - endColor = 0xFF000000; - } - return eAttr; -} - -int32_t CXFA_Fill::GetRadial(FX_ARGB& endColor) { - CXFA_Node* pNode = - m_pNode->JSNode()->GetProperty(0, XFA_Element::Radial, true); - XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge; - pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Type, eAttr, true); - if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { - WideStringView wsColor; - pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); - endColor = CXFA_Data::ToColor(wsColor); - } else { - endColor = 0xFF000000; - } - return eAttr; -} diff --git a/xfa/fxfa/parser/cxfa_fill.h b/xfa/fxfa/parser/cxfa_fill.h deleted file mode 100644 index 4b13565765..0000000000 --- a/xfa/fxfa/parser/cxfa_fill.h +++ /dev/null @@ -1,31 +0,0 @@ -// 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 - -#ifndef XFA_FXFA_PARSER_CXFA_FILL_H_ -#define XFA_FXFA_PARSER_CXFA_FILL_H_ - -#include "core/fxcrt/fx_system.h" -#include "core/fxge/fx_dib.h" -#include "xfa/fxfa/parser/cxfa_data.h" - -class CXFA_Node; - -class CXFA_Fill : public CXFA_Data { - public: - explicit CXFA_Fill(CXFA_Node* pNode); - ~CXFA_Fill(); - - int32_t GetPresence(); - FX_ARGB GetColor(bool bText = false); - XFA_Element GetFillType(); - int32_t GetPattern(FX_ARGB& foreColor); - int32_t GetStipple(FX_ARGB& stippleColor); - int32_t GetLinear(FX_ARGB& endColor); - int32_t GetRadial(FX_ARGB& endColor); - void SetColor(FX_ARGB color); -}; - -#endif // XFA_FXFA_PARSER_CXFA_FILL_H_ diff --git a/xfa/fxfa/parser/cxfa_filldata.cpp b/xfa/fxfa/parser/cxfa_filldata.cpp new file mode 100644 index 0000000000..772b1151c3 --- /dev/null +++ b/xfa/fxfa/parser/cxfa_filldata.cpp @@ -0,0 +1,111 @@ +// 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_filldata.h" + +#include "xfa/fxfa/parser/cxfa_node.h" + +CXFA_FillData::CXFA_FillData(CXFA_Node* pNode) : CXFA_Data(pNode) {} + +CXFA_FillData::~CXFA_FillData() {} + +int32_t CXFA_FillData::GetPresence() { + return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Presence); +} + +void CXFA_FillData::SetColor(FX_ARGB color) { + CXFA_Node* pNode = + m_pNode->JSNode()->GetProperty(0, XFA_Element::Color, true); + WideString wsColor; + int a; + int r; + int g; + int b; + std::tie(a, r, g, b) = ArgbDecode(color); + wsColor.Format(L"%d,%d,%d", r, g, b); + pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Value, wsColor, false, false); +} + +FX_ARGB CXFA_FillData::GetColor(bool bText) { + if (CXFA_Node* pNode = m_pNode->GetChild(0, XFA_Element::Color, false)) { + WideStringView wsColor; + if (pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false)) + return CXFA_Data::ToColor(wsColor); + } + if (bText) + return 0xFF000000; + return 0xFFFFFFFF; +} + +XFA_Element CXFA_FillData::GetFillType() { + CXFA_Node* pChild = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); + while (pChild) { + XFA_Element eType = pChild->GetElementType(); + if (eType != XFA_Element::Color && eType != XFA_Element::Extras) + return eType; + + pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling); + } + return XFA_Element::Solid; +} + +int32_t CXFA_FillData::GetPattern(FX_ARGB& foreColor) { + CXFA_Node* pNode = + m_pNode->JSNode()->GetProperty(0, XFA_Element::Pattern, true); + if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { + WideStringView wsColor; + pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); + foreColor = CXFA_Data::ToColor(wsColor); + } else { + foreColor = 0xFF000000; + } + return pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Type); +} + +int32_t CXFA_FillData::GetStipple(FX_ARGB& stippleColor) { + CXFA_Node* pNode = + m_pNode->JSNode()->GetProperty(0, XFA_Element::Stipple, true); + int32_t eAttr = 50; + pNode->JSNode()->TryInteger(XFA_ATTRIBUTE_Rate, eAttr, true); + if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { + WideStringView wsColor; + pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); + stippleColor = CXFA_Data::ToColor(wsColor); + } else { + stippleColor = 0xFF000000; + } + return eAttr; +} + +int32_t CXFA_FillData::GetLinear(FX_ARGB& endColor) { + CXFA_Node* pNode = + m_pNode->JSNode()->GetProperty(0, XFA_Element::Linear, true); + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToRight; + pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Type, eAttr, true); + if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { + WideStringView wsColor; + pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); + endColor = CXFA_Data::ToColor(wsColor); + } else { + endColor = 0xFF000000; + } + return eAttr; +} + +int32_t CXFA_FillData::GetRadial(FX_ARGB& endColor) { + CXFA_Node* pNode = + m_pNode->JSNode()->GetProperty(0, XFA_Element::Radial, true); + XFA_ATTRIBUTEENUM eAttr = XFA_ATTRIBUTEENUM_ToEdge; + pNode->JSNode()->TryEnum(XFA_ATTRIBUTE_Type, eAttr, true); + if (CXFA_Node* pColor = pNode->GetChild(0, XFA_Element::Color, false)) { + WideStringView wsColor; + pColor->JSNode()->TryCData(XFA_ATTRIBUTE_Value, wsColor, false); + endColor = CXFA_Data::ToColor(wsColor); + } else { + endColor = 0xFF000000; + } + return eAttr; +} diff --git a/xfa/fxfa/parser/cxfa_filldata.h b/xfa/fxfa/parser/cxfa_filldata.h new file mode 100644 index 0000000000..d47fb5d86a --- /dev/null +++ b/xfa/fxfa/parser/cxfa_filldata.h @@ -0,0 +1,31 @@ +// 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 + +#ifndef XFA_FXFA_PARSER_CXFA_FILLDATA_H_ +#define XFA_FXFA_PARSER_CXFA_FILLDATA_H_ + +#include "core/fxcrt/fx_system.h" +#include "core/fxge/fx_dib.h" +#include "xfa/fxfa/parser/cxfa_data.h" + +class CXFA_Node; + +class CXFA_FillData : public CXFA_Data { + public: + explicit CXFA_FillData(CXFA_Node* pNode); + ~CXFA_FillData(); + + int32_t GetPresence(); + FX_ARGB GetColor(bool bText = false); + XFA_Element GetFillType(); + int32_t GetPattern(FX_ARGB& foreColor); + int32_t GetStipple(FX_ARGB& stippleColor); + int32_t GetLinear(FX_ARGB& endColor); + int32_t GetRadial(FX_ARGB& endColor); + void SetColor(FX_ARGB color); +}; + +#endif // XFA_FXFA_PARSER_CXFA_FILLDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_font.cpp b/xfa/fxfa/parser/cxfa_font.cpp index ab0825fbe6..9de43535b5 100644 --- a/xfa/fxfa/parser/cxfa_font.cpp +++ b/xfa/fxfa/parser/cxfa_font.cpp @@ -7,7 +7,7 @@ #include "xfa/fxfa/parser/cxfa_font.h" #include "core/fxge/fx_dib.h" -#include "xfa/fxfa/parser/cxfa_fill.h" +#include "xfa/fxfa/parser/cxfa_filldata.h" #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" @@ -85,11 +85,11 @@ bool CXFA_Font::IsItalic() { } void CXFA_Font::SetColor(FX_ARGB color) { - CXFA_Fill fill(m_pNode->JSNode()->GetProperty(0, XFA_Element::Fill, true)); - fill.SetColor(color); + CXFA_FillData(m_pNode->JSNode()->GetProperty(0, XFA_Element::Fill, true)) + .SetColor(color); } FX_ARGB CXFA_Font::GetColor() { - CXFA_Fill fill(m_pNode->GetChild(0, XFA_Element::Fill, false)); - return fill ? fill.GetColor(true) : 0xFF000000; + CXFA_FillData fillData(m_pNode->GetChild(0, XFA_Element::Fill, false)); + return fillData ? fillData.GetColor(true) : 0xFF000000; } -- cgit v1.2.3