From dee2d7ba656cdf8111f879485146e0900630826a Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 17 Feb 2016 16:58:49 -0800 Subject: Banish CFX_ObjectArray to the XFA side. Tidy whitespace, add missing consts in a few places. Remove a few pointless typedefs. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1707953002 . --- .../fpdfapi/fpdf_page/fpdf_page_graph_state.cpp | 47 ++++++++++++---------- 1 file changed, 26 insertions(+), 21 deletions(-) (limited to 'core/src/fpdfapi/fpdf_page') diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp index a428287e19..818ec8fd2f 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_graph_state.cpp @@ -11,6 +11,7 @@ #include "core/include/fpdfapi/fpdf_pageobj.h" #include "core/include/fpdfapi/fpdf_render.h" #include "core/src/fpdfapi/fpdf_render/render_int.h" +#include "third_party/base/stl_util.h" void CPDF_GraphicStates::DefaultStates() { m_ColorState.New()->Default(); @@ -610,44 +611,48 @@ FX_BOOL CPDF_ContentMarkItem::HasMCID() const { } return FALSE; } -CPDF_ContentMarkData::CPDF_ContentMarkData(const CPDF_ContentMarkData& src) { - for (int i = 0; i < src.m_Marks.GetSize(); i++) { - m_Marks.Add(src.m_Marks[i]); - } + +CPDF_ContentMarkData::CPDF_ContentMarkData(const CPDF_ContentMarkData& src) + : m_Marks(src.m_Marks) {} + +int CPDF_ContentMarkData::CountItems() const { + return pdfium::CollectionSize(m_Marks); } + int CPDF_ContentMarkData::GetMCID() const { - CPDF_ContentMarkItem::ParamType type = CPDF_ContentMarkItem::None; - for (int i = 0; i < m_Marks.GetSize(); i++) { - type = m_Marks[i].GetParamType(); + for (const auto& mark : m_Marks) { + CPDF_ContentMarkItem::ParamType type = mark.GetParamType(); if (type == CPDF_ContentMarkItem::PropertiesDict || type == CPDF_ContentMarkItem::DirectDict) { - CPDF_Dictionary* pDict = m_Marks[i].GetParam(); - if (pDict->KeyExist("MCID")) { + CPDF_Dictionary* pDict = mark.GetParam(); + if (pDict->KeyExist("MCID")) return pDict->GetIntegerBy("MCID"); - } } } return -1; } + void CPDF_ContentMarkData::AddMark(const CFX_ByteString& name, CPDF_Dictionary* pDict, FX_BOOL bDirect) { - CPDF_ContentMarkItem& item = m_Marks.Add(); + CPDF_ContentMarkItem item; item.SetName(name); - if (!pDict) { - return; + if (pDict) { + if (bDirect) { + item.SetParam(CPDF_ContentMarkItem::DirectDict, + ToDictionary(pDict->Clone())); + } else { + item.SetParam(CPDF_ContentMarkItem::PropertiesDict, pDict); + } } - item.SetParam(bDirect ? CPDF_ContentMarkItem::DirectDict - : CPDF_ContentMarkItem::PropertiesDict, - bDirect ? ToDictionary(pDict->Clone()) : pDict); + m_Marks.push_back(item); } + void CPDF_ContentMarkData::DeleteLastMark() { - int size = m_Marks.GetSize(); - if (size == 0) { - return; - } - m_Marks.RemoveAt(size - 1); + if (!m_Marks.empty()) + m_Marks.pop_back(); } + FX_BOOL CPDF_ContentMark::HasMark(const CFX_ByteStringC& mark) const { if (!m_pObject) { return FALSE; -- cgit v1.2.3