diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/app/xfa_ffpageview.cpp | 136 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidget.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_box.cpp | 58 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_box.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_stroke.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/xfa_ffpageview.h | 11 |
7 files changed, 126 insertions, 110 deletions
diff --git a/xfa/fxfa/app/xfa_ffpageview.cpp b/xfa/fxfa/app/xfa_ffpageview.cpp index 5ef108693a..3dfa237c0f 100644 --- a/xfa/fxfa/app/xfa_ffpageview.cpp +++ b/xfa/fxfa/app/xfa_ffpageview.cpp @@ -6,6 +6,11 @@ #include "xfa/fxfa/xfa_ffpageview.h" +#include <memory> +#include <vector> + +#include "third_party/base/ptr_util.h" +#include "third_party/base/stl_util.h" #include "xfa/fde/fde_render.h" #include "xfa/fxfa/app/xfa_ffcheckbutton.h" #include "xfa/fxfa/app/xfa_ffchoicelist.h" @@ -228,32 +233,34 @@ void CXFA_FFTabOrderPageWidgetIterator::Reset() { CreateTabOrderWidgetArray(); m_iCurWidget = -1; } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { - if (m_TabOrderWidgetArray.GetSize() > 0) { - for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { - if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } + for (int32_t i = 0; + i < pdfium::CollectionSize<int32_t>(m_TabOrderWidgetArray); i++) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; } } return nullptr; } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { - if (m_TabOrderWidgetArray.GetSize() > 0) { - for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { - if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, - m_bIgnorerelevant)) { - m_iCurWidget = i; - return m_TabOrderWidgetArray[m_iCurWidget]; - } + for (int32_t i = pdfium::CollectionSize<int32_t>(m_TabOrderWidgetArray) - 1; + i >= 0; i--) { + if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, + m_bIgnorerelevant)) { + m_iCurWidget = i; + return m_TabOrderWidgetArray[m_iCurWidget]; } } return nullptr; } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { - for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { + for (int32_t i = m_iCurWidget + 1; + i < pdfium::CollectionSize<int32_t>(m_TabOrderWidgetArray); i++) { if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, m_bIgnorerelevant)) { m_iCurWidget = i; @@ -263,6 +270,7 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { m_iCurWidget = -1; return nullptr; } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { if (PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, true, @@ -274,21 +282,22 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { m_iCurWidget = -1; return nullptr; } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { - if (m_iCurWidget >= 0) { - return m_TabOrderWidgetArray[m_iCurWidget]; - } - return nullptr; + return m_iCurWidget >= 0 ? m_TabOrderWidgetArray[m_iCurWidget] : nullptr; } + bool CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( CXFA_FFWidget* hWidget) { - int32_t iWidgetIndex = m_TabOrderWidgetArray.Find(hWidget); - if (iWidgetIndex >= 0) { - m_iCurWidget = iWidgetIndex; - return true; - } - return false; + auto it = std::find(m_TabOrderWidgetArray.begin(), + m_TabOrderWidgetArray.end(), hWidget); + if (it == m_TabOrderWidgetArray.end()) + return false; + + m_iCurWidget = it - m_TabOrderWidgetArray.begin(); + return true; } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( CXFA_FFWidget* pWidget) { CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); @@ -309,29 +318,36 @@ CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::FindWidgetByName( CXFA_FFWidget* pRefWidget) { return pRefWidget->GetDocView()->GetWidgetByName(wsWidgetName, pRefWidget); } + void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { - m_TabOrderWidgetArray.RemoveAll(); - CXFA_WidgetArray SpaceOrderWidgetArray; - CreateSpaceOrderWidgetArray(SpaceOrderWidgetArray); - int32_t nWidgetCount = SpaceOrderWidgetArray.GetSize(); - if (nWidgetCount < 1) { + m_TabOrderWidgetArray.clear(); + + std::vector<CXFA_FFWidget*> SpaceOrderWidgetArray; + CreateSpaceOrderWidgetArray(&SpaceOrderWidgetArray); + if (SpaceOrderWidgetArray.empty()) return; - } + + int32_t nWidgetCount = pdfium::CollectionSize<int32_t>(SpaceOrderWidgetArray); CXFA_FFWidget* hWidget = SpaceOrderWidgetArray[0]; - for (; m_TabOrderWidgetArray.GetSize() < nWidgetCount;) { - if (m_TabOrderWidgetArray.Find(hWidget) < 0) { - m_TabOrderWidgetArray.Add(hWidget); + while (pdfium::CollectionSize<int32_t>(m_TabOrderWidgetArray) < + nWidgetCount) { + if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) { + m_TabOrderWidgetArray.push_back(hWidget); CXFA_WidgetAcc* pWidgetAcc = hWidget->GetDataAcc(); if (pWidgetAcc->GetUIType() == XFA_Element::ExclGroup) { - int32_t iWidgetIndex = SpaceOrderWidgetArray.Find(hWidget) + 1; + auto it = std::find(SpaceOrderWidgetArray.begin(), + SpaceOrderWidgetArray.end(), hWidget); + int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end() + ? it - SpaceOrderWidgetArray.begin() + 1 + : 0; while (true) { CXFA_FFWidget* pRadio = - SpaceOrderWidgetArray[(iWidgetIndex) % nWidgetCount]; + SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount]; if (pRadio->GetDataAcc()->GetExclGroup() != pWidgetAcc) { break; } - if (m_TabOrderWidgetArray.Find(hWidget) < 0) { - m_TabOrderWidgetArray.Add(pRadio); + if (!pdfium::ContainsValue(m_TabOrderWidgetArray, hWidget)) { + m_TabOrderWidgetArray.push_back(pRadio); } iWidgetIndex++; } @@ -341,10 +357,15 @@ void CXFA_FFTabOrderPageWidgetIterator::CreateTabOrderWidgetArray() { continue; } } - int32_t iWidgetIndex = SpaceOrderWidgetArray.Find(hWidget); - hWidget = SpaceOrderWidgetArray[(iWidgetIndex + 1) % nWidgetCount]; + auto it = std::find(SpaceOrderWidgetArray.begin(), + SpaceOrderWidgetArray.end(), hWidget); + int32_t iWidgetIndex = it != SpaceOrderWidgetArray.end() + ? it - SpaceOrderWidgetArray.begin() + 1 + : 0; + hWidget = SpaceOrderWidgetArray[iWidgetIndex % nWidgetCount]; } } + static int32_t XFA_TabOrderWidgetComparator(const void* phWidget1, const void* phWidget2) { CXFA_FFWidget* pWidget1 = (*(CXFA_TabParam**)phWidget1)->m_pWidget; @@ -407,36 +428,35 @@ void CXFA_FFTabOrderPageWidgetIterator::OrderContainer( XFA_TabOrderWidgetComparator); } for (int32_t iStart = 0; iStart < iChildren; iStart++) { - CXFA_TabParam* pParam = tabParams[iStart]; - pContainer->m_Children.Add(pParam->m_pWidget); - if (pParam->m_Children.GetSize() > 0) { - pContainer->m_Children.Append(pParam->m_Children); - } - delete pParam; + std::unique_ptr<CXFA_TabParam> pParam(tabParams[iStart]); + pContainer->m_Children.push_back(pParam->m_pWidget); + pContainer->m_Children.insert(pContainer->m_Children.end(), + pParam->m_Children.begin(), + pParam->m_Children.end()); } tabParams.RemoveAll(); } void CXFA_FFTabOrderPageWidgetIterator::CreateSpaceOrderWidgetArray( - CXFA_WidgetArray& WidgetArray) { + std::vector<CXFA_FFWidget*>* WidgetArray) { CXFA_LayoutItemIterator sIterator; sIterator.Init(m_pPageView); - CXFA_TabParam* pParam = new CXFA_TabParam; + auto pParam = pdfium::MakeUnique<CXFA_TabParam>(); bool bCurrentItem = false; bool bContentArea = false; - OrderContainer(&sIterator, nullptr, pParam, bCurrentItem, bContentArea); - if (pParam->m_Children.GetSize() > 0) { - WidgetArray.Append(pParam->m_Children); - } + OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea); + WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), + pParam->m_Children.end()); + sIterator.Reset(); bCurrentItem = false; bContentArea = false; - pParam->m_Children.RemoveAll(); - OrderContainer(&sIterator, nullptr, pParam, bCurrentItem, bContentArea, true); - if (pParam->m_Children.GetSize() > 0) { - WidgetArray.Append(pParam->m_Children); - } - delete pParam; + pParam->m_Children.clear(); + OrderContainer(&sIterator, nullptr, pParam.get(), bCurrentItem, bContentArea, + true); + WidgetArray->insert(WidgetArray->end(), pParam->m_Children.begin(), + pParam->m_Children.end()); } + CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetWidget( CXFA_LayoutItem* pLayoutItem) { if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 64aed4f328..c1822470e0 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -1217,7 +1217,7 @@ static void XFA_BOX_GetPath_Arc(CXFA_Box box, startAngle, sweepAngle); } static void XFA_BOX_GetPath(CXFA_Box box, - const CXFA_StrokeArray& strokes, + const std::vector<CXFA_Stroke>& strokes, CFX_RectF rtWidget, CFX_Path& path, int32_t nIndex, @@ -1385,7 +1385,7 @@ static void XFA_BOX_GetPath(CXFA_Box box, } } static void XFA_BOX_GetFillPath(CXFA_Box box, - const CXFA_StrokeArray& strokes, + const std::vector<CXFA_Stroke>& strokes, CFX_RectF rtWidget, CFX_Path& fillPath, uint16_t dwFlags) { @@ -1631,7 +1631,7 @@ static void XFA_BOX_Fill_Linear(CXFA_Box box, pGS->FillPath(&fillPath, FXFILL_WINDING, pMatrix); } static void XFA_BOX_Fill(CXFA_Box box, - const CXFA_StrokeArray& strokes, + const std::vector<CXFA_Stroke>& strokes, CFX_Graphics* pGS, const CFX_RectF& rtWidget, CFX_Matrix* pMatrix, @@ -1870,7 +1870,7 @@ static void XFA_BOX_Stroke_3DRect_Embossed(CFX_Graphics* pGS, XFA_Draw3DRect(pGS, rtInner, fHalfWidth, pMatrix, 0xFF000000, 0xFF808080); } static void XFA_BOX_Stroke_Rect(CXFA_Box box, - const CXFA_StrokeArray& strokes, + const std::vector<CXFA_Stroke>& strokes, CFX_Graphics* pGS, CFX_RectF rtWidget, CFX_Matrix* pMatrix) { @@ -1961,7 +1961,7 @@ static void XFA_BOX_Stroke_Rect(CXFA_Box box, } } static void XFA_BOX_Stroke(CXFA_Box box, - const CXFA_StrokeArray& strokes, + const std::vector<CXFA_Stroke>& strokes, CFX_Graphics* pGS, CFX_RectF rtWidget, CFX_Matrix* pMatrix, @@ -2038,10 +2038,10 @@ void XFA_DrawBox(CXFA_Box box, eType != XFA_Element::Rectangle) { return; } - CXFA_StrokeArray strokes; - if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) { - box.GetStrokes(strokes); - } + std::vector<CXFA_Stroke> strokes; + if (!(dwFlags & XFA_DRAWBOX_ForceRound) && eType != XFA_Element::Arc) + box.GetStrokes(&strokes); + XFA_BOX_Fill(box, strokes, pGS, rtWidget, pMatrix, dwFlags); XFA_BOX_Stroke(box, strokes, pGS, rtWidget, pMatrix, dwFlags); } diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp index 9d9b4b47ad..552c98031a 100644 --- a/xfa/fxfa/parser/cxfa_box.cpp +++ b/xfa/fxfa/parser/cxfa_box.cpp @@ -13,53 +13,47 @@ namespace { void GetStrokesInternal(CXFA_Node* pNode, - CXFA_StrokeArray& strokes, + std::vector<CXFA_Stroke>* strokes, bool bNull) { - strokes.RemoveAll(); + strokes->clear(); if (!pNode) return; - strokes.SetSize(8); + strokes->resize(8); int32_t i, j; for (i = 0, j = 0; i < 4; i++) { CXFA_Corner corner = CXFA_Corner(pNode->GetProperty(i, XFA_Element::Corner, i == 0)); - if (corner || i == 0) - strokes.SetAt(j, corner); - else if (bNull) - strokes.SetAt(j, CXFA_Stroke(nullptr)); - else if (i == 1) - strokes.SetAt(j, strokes[0]); - else if (i == 2) - strokes.SetAt(j, strokes[0]); - else - strokes.SetAt(j, strokes[2]); - + if (corner || i == 0) { + (*strokes)[j] = corner; + } else if (!bNull) { + if (i == 1 || i == 2) + (*strokes)[j] = (*strokes)[0]; + else + (*strokes)[j] = (*strokes)[2]; + } j++; CXFA_Edge edge = CXFA_Edge(pNode->GetProperty(i, XFA_Element::Edge, i == 0)); - if (edge || i == 0) - strokes.SetAt(j, edge); - else if (bNull) - strokes.SetAt(j, CXFA_Stroke(nullptr)); - else if (i == 1) - strokes.SetAt(j, strokes[1]); - else if (i == 2) - strokes.SetAt(j, strokes[1]); - else - strokes.SetAt(j, strokes[3]); - + if (edge || i == 0) { + (*strokes)[j] = edge; + } else if (!bNull) { + if (i == 1 || i == 2) + (*strokes)[j] = (*strokes)[1]; + else + (*strokes)[j] = (*strokes)[3]; + } j++; } } -static int32_t Style3D(const CXFA_StrokeArray& strokes, CXFA_Stroke& stroke) { - int32_t iCount = strokes.GetSize(); - if (iCount < 1) +static int32_t Style3D(const std::vector<CXFA_Stroke>& strokes, + CXFA_Stroke& stroke) { + if (strokes.empty()) return 0; stroke = strokes[0]; - for (int32_t i = 1; i < iCount; i++) { + for (size_t i = 1; i < strokes.size(); i++) { CXFA_Stroke find = strokes[i]; if (!find) continue; @@ -105,7 +99,7 @@ CXFA_Edge CXFA_Box::GetEdge(int32_t nIndex) const { : nullptr); } -void CXFA_Box::GetStrokes(CXFA_StrokeArray& strokes) const { +void CXFA_Box::GetStrokes(std::vector<CXFA_Stroke>* strokes) const { GetStrokesInternal(m_pNode, strokes, false); } @@ -158,8 +152,8 @@ int32_t CXFA_Box::Get3DStyle(bool& bVisible, FX_FLOAT& fThickness) const { if (IsArc()) return 0; - CXFA_StrokeArray strokes; - GetStrokesInternal(m_pNode, strokes, true); + std::vector<CXFA_Stroke> strokes; + GetStrokesInternal(m_pNode, &strokes, true); CXFA_Stroke stroke(nullptr); int32_t iType = Style3D(strokes, stroke); if (iType) { diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h index 014155ceb7..a0af2f449b 100644 --- a/xfa/fxfa/parser/cxfa_box.h +++ b/xfa/fxfa/parser/cxfa_box.h @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_PARSER_CXFA_BOX_H_ #define XFA_FXFA_PARSER_CXFA_BOX_H_ +#include <vector> + #include "core/fxcrt/fx_system.h" #include "xfa/fxfa/parser/cxfa_data.h" #include "xfa/fxfa/parser/cxfa_edge.h" @@ -28,7 +30,7 @@ class CXFA_Box : public CXFA_Data { int32_t GetPresence() const; int32_t CountEdges() const; CXFA_Edge GetEdge(int32_t nIndex = 0) const; - void GetStrokes(CXFA_StrokeArray& strokes) const; + void GetStrokes(std::vector<CXFA_Stroke>* strokes) const; bool IsCircular() const; bool GetStartAngle(FX_FLOAT& fStartAngle) const; FX_FLOAT GetStartAngle() const { diff --git a/xfa/fxfa/parser/cxfa_stroke.h b/xfa/fxfa/parser/cxfa_stroke.h index a3287d2855..cf941c8f0f 100644 --- a/xfa/fxfa/parser/cxfa_stroke.h +++ b/xfa/fxfa/parser/cxfa_stroke.h @@ -21,6 +21,7 @@ class CXFA_Node; class CXFA_Stroke : public CXFA_Data { public: + CXFA_Stroke() : CXFA_Stroke(nullptr) {} explicit CXFA_Stroke(CXFA_Node* pNode) : CXFA_Data(pNode) {} bool IsCorner() const { return GetElementType() == XFA_Element::Corner; } @@ -40,6 +41,4 @@ class CXFA_Stroke : public CXFA_Data { bool SameStyles(CXFA_Stroke stroke, uint32_t dwFlags = 0) const; }; -typedef CFX_ArrayTemplate<CXFA_Stroke> CXFA_StrokeArray; - #endif // XFA_FXFA_PARSER_CXFA_STROKE_H_ diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 31c5cf48e6..e77fa55d50 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -18,7 +18,7 @@ namespace { -FX_FLOAT GetEdgeThickness(const CXFA_StrokeArray& strokes, +FX_FLOAT GetEdgeThickness(const std::vector<CXFA_Stroke>& strokes, bool b3DStyle, int32_t nIndex) { FX_FLOAT fThickness = 0; @@ -431,8 +431,8 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() { FX_FLOAT fThickness = 0; border.Get3DStyle(bVisible, fThickness); if (!bLeft || !bTop || !bRight || !bBottom) { - CXFA_StrokeArray strokes; - border.GetStrokes(strokes); + std::vector<CXFA_Stroke> strokes; + border.GetStrokes(&strokes); if (!bTop) fTopInset = GetEdgeThickness(strokes, bVisible, 0); if (!bRight) diff --git a/xfa/fxfa/xfa_ffpageview.h b/xfa/fxfa/xfa_ffpageview.h index c6bbe7dbe9..089e276d6e 100644 --- a/xfa/fxfa/xfa_ffpageview.h +++ b/xfa/fxfa/xfa_ffpageview.h @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyrig 2014 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. @@ -7,6 +7,8 @@ #ifndef XFA_FXFA_XFA_FFPAGEVIEW_H_ #define XFA_FXFA_XFA_FFPAGEVIEW_H_ +#include <vector> + #include "xfa/fxfa/parser/cxfa_containerlayoutitem.h" #include "xfa/fxfa/parser/cxfa_contentlayoutitem.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_layoutitem.h" @@ -59,7 +61,6 @@ class CXFA_FFPageWidgetIterator : public IXFA_WidgetIterator { bool m_bIgnorerelevant; CXFA_LayoutItemIterator m_sIterator; }; -typedef CFX_ArrayTemplate<CXFA_FFWidget*> CXFA_WidgetArray; class CXFA_TabParam { public: @@ -67,7 +68,7 @@ class CXFA_TabParam { ~CXFA_TabParam(); CXFA_FFWidget* m_pWidget; - CXFA_WidgetArray m_Children; + std::vector<CXFA_FFWidget*> m_Children; }; class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { @@ -89,7 +90,7 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { CXFA_FFWidget* FindWidgetByName(const CFX_WideString& wsWidgetName, CXFA_FFWidget* pRefWidget); void CreateTabOrderWidgetArray(); - void CreateSpaceOrderWidgetArray(CXFA_WidgetArray& WidgetArray); + void CreateSpaceOrderWidgetArray(std::vector<CXFA_FFWidget*>* WidgetArray); CXFA_FFWidget* GetWidget(CXFA_LayoutItem* pLayoutItem); void OrderContainer(CXFA_LayoutItemIterator* sIterator, CXFA_LayoutItem* pContainerItem, @@ -98,7 +99,7 @@ class CXFA_FFTabOrderPageWidgetIterator : public IXFA_WidgetIterator { bool& bContentArea, bool bMarsterPage = false); - CXFA_WidgetArray m_TabOrderWidgetArray; + std::vector<CXFA_FFWidget*> m_TabOrderWidgetArray; CXFA_FFPageView* m_pPageView; uint32_t m_dwFilter; int32_t m_iCurWidget; |