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

Side by Side Diff: xfa/fde/fde_iterator.cpp

Issue 1896893003: Cleanup FDE interfaces. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 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/fde/fde_iterator.h ('k') | xfa/fde/fde_path.h » ('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/fde/fde_iterator.h" 7 #include "xfa/fde/fde_iterator.h"
8 8
9 #include "xfa/fgas/crt/fgas_utils.h" 9 #include "xfa/fgas/crt/fgas_utils.h"
10 10
11 IFDE_VisualSetIterator* IFDE_VisualSetIterator::Create() {
12 return new CFDE_VisualSetIterator;
13 }
14 CFDE_VisualSetIterator::CFDE_VisualSetIterator() : m_dwFilter(0) {} 11 CFDE_VisualSetIterator::CFDE_VisualSetIterator() : m_dwFilter(0) {}
12
15 CFDE_VisualSetIterator::~CFDE_VisualSetIterator() { 13 CFDE_VisualSetIterator::~CFDE_VisualSetIterator() {
16 m_CanvasStack.RemoveAll(); 14 m_CanvasStack.RemoveAll();
17 } 15 }
16
18 FX_BOOL CFDE_VisualSetIterator::AttachCanvas(IFDE_CanvasSet* pCanvas) { 17 FX_BOOL CFDE_VisualSetIterator::AttachCanvas(IFDE_CanvasSet* pCanvas) {
19 FXSYS_assert(pCanvas != NULL); 18 FXSYS_assert(pCanvas);
19
20 m_CanvasStack.RemoveAll(); 20 m_CanvasStack.RemoveAll();
21 FDE_CANVASITEM canvas; 21 FDE_CANVASITEM canvas;
22 canvas.hCanvas = NULL; 22 canvas.hCanvas = nullptr;
23 canvas.pCanvas = pCanvas; 23 canvas.pCanvas = pCanvas;
24 canvas.hPos = pCanvas->GetFirstPosition(NULL); 24 canvas.hPos = pCanvas->GetFirstPosition(nullptr);
25 if (canvas.hPos == NULL) { 25 if (!canvas.hPos)
26 return FALSE; 26 return FALSE;
27 } 27
28 return m_CanvasStack.Push(canvas) == 0; 28 return m_CanvasStack.Push(canvas) == 0;
29 } 29 }
30
30 FX_BOOL CFDE_VisualSetIterator::FilterObjects(uint32_t dwObjects) { 31 FX_BOOL CFDE_VisualSetIterator::FilterObjects(uint32_t dwObjects) {
31 if (m_CanvasStack.GetSize() == 0) 32 if (m_CanvasStack.GetSize() == 0)
32 return FALSE; 33 return FALSE;
33 34
34 while (m_CanvasStack.GetSize() > 1) 35 while (m_CanvasStack.GetSize() > 1)
35 m_CanvasStack.Pop(); 36 m_CanvasStack.Pop();
36 37
37 m_dwFilter = dwObjects; 38 m_dwFilter = dwObjects;
38 39
39 FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement(); 40 FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement();
40 FXSYS_assert(pCanvas != NULL && pCanvas->pCanvas != NULL); 41 FXSYS_assert(pCanvas && pCanvas->pCanvas);
41 pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(NULL); 42
42 return pCanvas->hPos != NULL; 43 pCanvas->hPos = pCanvas->pCanvas->GetFirstPosition(nullptr);
44 return !!pCanvas->hPos;
43 } 45 }
46
44 void CFDE_VisualSetIterator::Reset() { 47 void CFDE_VisualSetIterator::Reset() {
45 FilterObjects(m_dwFilter); 48 FilterObjects(m_dwFilter);
46 } 49 }
50
47 FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet, 51 FDE_HVISUALOBJ CFDE_VisualSetIterator::GetNext(IFDE_VisualSet*& pVisualSet,
48 FDE_HVISUALOBJ* phCanvasObj, 52 FDE_HVISUALOBJ* phCanvasObj,
49 IFDE_CanvasSet** ppCanvasSet) { 53 IFDE_CanvasSet** ppCanvasSet) {
50 while (m_CanvasStack.GetSize() > 0) { 54 while (m_CanvasStack.GetSize() > 0) {
51 FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement(); 55 FDE_CANVASITEM* pCanvas = m_CanvasStack.GetTopElement();
52 FXSYS_assert(pCanvas != NULL && pCanvas->pCanvas != NULL); 56 FXSYS_assert(pCanvas && pCanvas->pCanvas);
53 if (pCanvas->hPos == NULL) { 57
54 if (m_CanvasStack.GetSize() == 1) { 58 if (!pCanvas->hPos) {
59 if (m_CanvasStack.GetSize() == 1)
55 break; 60 break;
56 } 61
57 m_CanvasStack.Pop(); 62 m_CanvasStack.Pop();
58 continue; 63 continue;
59 } 64 }
60 do { 65 do {
61 FDE_HVISUALOBJ hObj = pCanvas->pCanvas->GetNext( 66 FDE_HVISUALOBJ hObj = pCanvas->pCanvas->GetNext(
62 pCanvas->hCanvas, pCanvas->hPos, pVisualSet); 67 pCanvas->hCanvas, pCanvas->hPos, pVisualSet);
63 FXSYS_assert(hObj != NULL); 68 FXSYS_assert(hObj);
69
64 FDE_VISUALOBJTYPE eType = pVisualSet->GetType(); 70 FDE_VISUALOBJTYPE eType = pVisualSet->GetType();
65 if (eType == FDE_VISUALOBJ_Canvas) { 71 if (eType == FDE_VISUALOBJ_Canvas) {
66 FDE_CANVASITEM canvas; 72 FDE_CANVASITEM canvas;
67 canvas.hCanvas = hObj; 73 canvas.hCanvas = hObj;
68 canvas.pCanvas = (IFDE_CanvasSet*)pVisualSet; 74 canvas.pCanvas = (IFDE_CanvasSet*)pVisualSet;
69 canvas.hPos = canvas.pCanvas->GetFirstPosition(hObj); 75 canvas.hPos = canvas.pCanvas->GetFirstPosition(hObj);
70 m_CanvasStack.Push(canvas); 76 m_CanvasStack.Push(canvas);
71 break; 77 break;
72 } 78 }
73 uint32_t dwObj = (uint32_t)eType; 79 uint32_t dwObj = (uint32_t)eType;
74 if ((m_dwFilter & dwObj) != 0) { 80 if ((m_dwFilter & dwObj) != 0) {
75 if (ppCanvasSet) { 81 if (ppCanvasSet)
76 *ppCanvasSet = pCanvas->pCanvas; 82 *ppCanvasSet = pCanvas->pCanvas;
77 } 83 if (phCanvasObj)
78 if (phCanvasObj) {
79 *phCanvasObj = pCanvas->hCanvas; 84 *phCanvasObj = pCanvas->hCanvas;
80 }
81 return hObj; 85 return hObj;
82 } 86 }
83 } while (pCanvas->hPos != NULL); 87 } while (pCanvas->hPos);
84 } 88 }
85 if (ppCanvasSet) { 89 if (ppCanvasSet)
86 *ppCanvasSet = NULL; 90 *ppCanvasSet = nullptr;
87 } 91 if (phCanvasObj)
88 if (phCanvasObj) { 92 *phCanvasObj = nullptr;
89 *phCanvasObj = NULL; 93
90 } 94 pVisualSet = nullptr;
91 pVisualSet = NULL; 95 return nullptr;
92 return NULL;
93 } 96 }
OLDNEW
« no previous file with comments | « xfa/fde/fde_iterator.h ('k') | xfa/fde/fde_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698