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

Side by Side Diff: xfa/fxfa/app/xfa_ffwidget.cpp

Issue 2089443002: Convert XFA_ELEMENT to an enum class (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: More unknown checks Created 4 years, 6 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/app/xfa_fftextedit.cpp ('k') | xfa/fxfa/app/xfa_ffwidgetacc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 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/include/xfa_ffwidget.h" 7 #include "xfa/fxfa/include/xfa_ffwidget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 return; 1172 return;
1173 } 1173 }
1174 FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset; 1174 FX_FLOAT fLeftInset, fTopInset, fRightInset, fBottomInset;
1175 mg.GetLeftInset(fLeftInset); 1175 mg.GetLeftInset(fLeftInset);
1176 mg.GetTopInset(fTopInset); 1176 mg.GetTopInset(fTopInset);
1177 mg.GetRightInset(fRightInset); 1177 mg.GetRightInset(fRightInset);
1178 mg.GetBottomInset(fBottomInset); 1178 mg.GetBottomInset(fBottomInset);
1179 rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset); 1179 rt.Deflate(fLeftInset, fTopInset, fRightInset, fBottomInset);
1180 } 1180 }
1181 CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) { 1181 CXFA_FFWidget* XFA_GetWidgetFromLayoutItem(CXFA_LayoutItem* pLayoutItem) {
1182 XFA_ELEMENT iType = pLayoutItem->GetFormNode()->GetClassID(); 1182 XFA_Element iType = pLayoutItem->GetFormNode()->GetClassID();
1183 if (XFA_IsCreateWidget(iType)) { 1183 if (XFA_IsCreateWidget(iType)) {
1184 return static_cast<CXFA_FFWidget*>(pLayoutItem); 1184 return static_cast<CXFA_FFWidget*>(pLayoutItem);
1185 } 1185 }
1186 return nullptr; 1186 return nullptr;
1187 } 1187 }
1188 FX_BOOL XFA_IsCreateWidget(XFA_ELEMENT iType) { 1188 FX_BOOL XFA_IsCreateWidget(XFA_Element iType) {
1189 return iType == XFA_ELEMENT_Field || iType == XFA_ELEMENT_Draw || 1189 return iType == XFA_Element::Field || iType == XFA_Element::Draw ||
1190 iType == XFA_ELEMENT_Subform || iType == XFA_ELEMENT_ExclGroup; 1190 iType == XFA_Element::Subform || iType == XFA_Element::ExclGroup;
1191 } 1191 }
1192 static void XFA_BOX_GetPath_Arc(CXFA_Box box, 1192 static void XFA_BOX_GetPath_Arc(CXFA_Box box,
1193 CFX_RectF rtDraw, 1193 CFX_RectF rtDraw,
1194 CFX_Path& fillPath, 1194 CFX_Path& fillPath,
1195 uint32_t dwFlags) { 1195 uint32_t dwFlags) {
1196 FX_FLOAT a, b; 1196 FX_FLOAT a, b;
1197 a = rtDraw.width / 2.0f; 1197 a = rtDraw.width / 2.0f;
1198 b = rtDraw.height / 2.0f; 1198 b = rtDraw.height / 2.0f;
1199 if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) { 1199 if (box.IsCircular() || (dwFlags & XFA_DRAWBOX_ForceRound) != 0) {
1200 a = b = std::min(a, b); 1200 a = b = std::min(a, b);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 CXFA_Fill fill = box.GetFill(); 1639 CXFA_Fill fill = box.GetFill();
1640 if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { 1640 if (!fill || fill.GetPresence() != XFA_ATTRIBUTEENUM_Visible) {
1641 return; 1641 return;
1642 } 1642 }
1643 pGS->SaveGraphState(); 1643 pGS->SaveGraphState();
1644 CFX_Path fillPath; 1644 CFX_Path fillPath;
1645 fillPath.Create(); 1645 fillPath.Create();
1646 XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath, 1646 XFA_BOX_GetFillPath(box, strokes, rtWidget, fillPath,
1647 (dwFlags & XFA_DRAWBOX_ForceRound) != 0); 1647 (dwFlags & XFA_DRAWBOX_ForceRound) != 0);
1648 fillPath.Close(); 1648 fillPath.Close();
1649 int32_t eType = fill.GetFillType(); 1649 XFA_Element eType = fill.GetFillType();
1650 switch (eType) { 1650 switch (eType) {
1651 case XFA_ELEMENT_Radial: 1651 case XFA_Element::Radial:
1652 XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix); 1652 XFA_BOX_Fill_Radial(box, pGS, fillPath, rtWidget, pMatrix);
1653 break; 1653 break;
1654 case XFA_ELEMENT_Pattern: 1654 case XFA_Element::Pattern:
1655 XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix); 1655 XFA_BOX_Fill_Pattern(box, pGS, fillPath, rtWidget, pMatrix);
1656 break; 1656 break;
1657 case XFA_ELEMENT_Linear: 1657 case XFA_Element::Linear:
1658 XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix); 1658 XFA_BOX_Fill_Linear(box, pGS, fillPath, rtWidget, pMatrix);
1659 break; 1659 break;
1660 default: { 1660 default: {
1661 FX_ARGB cr; 1661 FX_ARGB cr;
1662 if (eType == XFA_ELEMENT_Stipple) { 1662 if (eType == XFA_Element::Stipple) {
1663 int32_t iRate = fill.GetStipple(cr); 1663 int32_t iRate = fill.GetStipple(cr);
1664 if (iRate == 0) { 1664 if (iRate == 0) {
1665 iRate = 100; 1665 iRate = 100;
1666 } 1666 }
1667 int32_t a = 0; 1667 int32_t a = 0;
1668 FX_COLORREF rgb; 1668 FX_COLORREF rgb;
1669 ArgbDecode(cr, a, rgb); 1669 ArgbDecode(cr, a, rgb);
1670 cr = ArgbEncode(iRate * a / 100, rgb); 1670 cr = ArgbEncode(iRate * a / 100, rgb);
1671 } else { 1671 } else {
1672 cr = fill.GetColor(); 1672 cr = fill.GetColor();
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 break; 2023 break;
2024 } 2024 }
2025 } 2025 }
2026 XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix); 2026 XFA_BOX_Stroke_Rect(box, strokes, pGS, rtWidget, pMatrix);
2027 } 2027 }
2028 void XFA_DrawBox(CXFA_Box box, 2028 void XFA_DrawBox(CXFA_Box box,
2029 CFX_Graphics* pGS, 2029 CFX_Graphics* pGS,
2030 const CFX_RectF& rtWidget, 2030 const CFX_RectF& rtWidget,
2031 CFX_Matrix* pMatrix, 2031 CFX_Matrix* pMatrix,
2032 uint32_t dwFlags) { 2032 uint32_t dwFlags) {
2033 if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible) { 2033 if (!box || box.GetPresence() != XFA_ATTRIBUTEENUM_Visible)
2034 return; 2034 return;
2035 } 2035
2036 int32_t iType = box.GetClassID(); 2036 XFA_Element iType = box.GetClassID();
2037 if (iType != XFA_ELEMENT_Arc && iType != XFA_ELEMENT_Border && 2037 if (iType != XFA_Element::Arc && iType != XFA_Element::Border &&
2038 iType != XFA_ELEMENT_Rectangle) { 2038 iType != XFA_Element::Rectangle) {
2039 return; 2039 return;
2040 } 2040 }
2041 CXFA_StrokeArray strokes; 2041 CXFA_StrokeArray strokes;
2042 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_ELEMENT_Arc) { 2042 if (!(dwFlags & XFA_DRAWBOX_ForceRound) && iType != XFA_Element::Arc) {
2043 box.GetStrokes(strokes); 2043 box.GetStrokes(strokes);
2044 } 2044 }
2045 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); 2045 XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
2046 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); 2046 XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags);
2047 } 2047 }
2048 2048
2049 CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {} 2049 CXFA_CalcData::CXFA_CalcData() : m_iRefCount(0) {}
2050 2050
2051 CXFA_CalcData::~CXFA_CalcData() { 2051 CXFA_CalcData::~CXFA_CalcData() {
2052 m_Globals.RemoveAll(); 2052 m_Globals.RemoveAll();
2053 } 2053 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_fftextedit.cpp ('k') | xfa/fxfa/app/xfa_ffwidgetacc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698