OLD | NEW |
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/app/xfa_ffpageview.h" | 7 #include "xfa/include/fxfa/xfa_ffpageview.h" |
8 | 8 |
9 #include "xfa/fde/fde_render.h" | 9 #include "xfa/fde/fde_render.h" |
10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" | 10 #include "xfa/fxfa/app/xfa_ffcheckbutton.h" |
11 #include "xfa/fxfa/app/xfa_ffchoicelist.h" | 11 #include "xfa/fxfa/app/xfa_ffchoicelist.h" |
12 #include "xfa/fxfa/app/xfa_ffdoc.h" | |
13 #include "xfa/fxfa/app/xfa_ffdocview.h" | |
14 #include "xfa/fxfa/app/xfa_fffield.h" | 12 #include "xfa/fxfa/app/xfa_fffield.h" |
15 #include "xfa/fxfa/app/xfa_ffimageedit.h" | 13 #include "xfa/fxfa/app/xfa_ffimageedit.h" |
16 #include "xfa/fxfa/app/xfa_ffpushbutton.h" | 14 #include "xfa/fxfa/app/xfa_ffpushbutton.h" |
17 #include "xfa/fxfa/app/xfa_fftextedit.h" | 15 #include "xfa/fxfa/app/xfa_fftextedit.h" |
18 #include "xfa/fxfa/app/xfa_ffwidget.h" | 16 #include "xfa/fxfa/app/xfa_ffwidget.h" |
19 #include "xfa/fxfa/app/xfa_fwladapter.h" | 17 #include "xfa/fxfa/app/xfa_fwladapter.h" |
| 18 #include "xfa/include/fxfa/xfa_ffdoc.h" |
| 19 #include "xfa/include/fxfa/xfa_ffdocview.h" |
20 | 20 |
21 CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) | 21 CXFA_FFPageView::CXFA_FFPageView(CXFA_FFDocView* pDocView, CXFA_Node* pPageArea) |
22 : CXFA_ContainerLayoutItem(pPageArea), | 22 : CXFA_ContainerLayoutItem(pPageArea), |
23 m_pDocView(pDocView), | 23 m_pDocView(pDocView), |
24 m_bLoaded(FALSE) {} | 24 m_bLoaded(FALSE) {} |
25 CXFA_FFPageView::~CXFA_FFPageView() {} | 25 CXFA_FFPageView::~CXFA_FFPageView() {} |
26 IXFA_DocView* CXFA_FFPageView::GetDocView() { | 26 CXFA_FFDocView* CXFA_FFPageView::GetDocView() { |
27 return m_pDocView; | 27 return m_pDocView; |
28 } | 28 } |
29 int32_t CXFA_FFPageView::GetPageViewIndex() { | 29 int32_t CXFA_FFPageView::GetPageViewIndex() { |
30 return GetPageIndex(); | 30 return GetPageIndex(); |
31 } | 31 } |
32 void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) { | 32 void CXFA_FFPageView::GetPageViewRect(CFX_RectF& rtPage) { |
33 CFX_SizeF sz; | 33 CFX_SizeF sz; |
34 GetPageSize(sz); | 34 GetPageSize(sz); |
35 rtPage.Set(0, 0, sz); | 35 rtPage.Set(0, 0, sz); |
36 } | 36 } |
(...skipping 14 matching lines...) Expand all Loading... |
51 return 100; | 51 return 100; |
52 } | 52 } |
53 void CXFA_FFPageView::UnloadPageView() { | 53 void CXFA_FFPageView::UnloadPageView() { |
54 if (!m_bLoaded) { | 54 if (!m_bLoaded) { |
55 return; | 55 return; |
56 } | 56 } |
57 } | 57 } |
58 FX_BOOL CXFA_FFPageView::IsPageViewLoaded() { | 58 FX_BOOL CXFA_FFPageView::IsPageViewLoaded() { |
59 return m_bLoaded; | 59 return m_bLoaded; |
60 } | 60 } |
61 IXFA_Widget* CXFA_FFPageView::GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) { | 61 CXFA_FFWidget* CXFA_FFPageView::GetWidgetByPos(FX_FLOAT fx, FX_FLOAT fy) { |
62 if (!m_bLoaded) { | 62 if (!m_bLoaded) { |
63 return nullptr; | 63 return nullptr; |
64 } | 64 } |
65 IXFA_WidgetIterator* pIterator = CreateWidgetIterator(); | 65 IXFA_WidgetIterator* pIterator = CreateWidgetIterator(); |
66 CXFA_FFWidget* pWidget = nullptr; | 66 CXFA_FFWidget* pWidget = nullptr; |
67 while ((pWidget = static_cast<CXFA_FFWidget*>(pIterator->MoveToNext()))) { | 67 while ((pWidget = static_cast<CXFA_FFWidget*>(pIterator->MoveToNext()))) { |
68 if (!(pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { | 68 if (!(pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { |
69 continue; | 69 continue; |
70 } | 70 } |
71 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); | 71 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 m_dwFilter = dwFilter; | 123 m_dwFilter = dwFilter; |
124 m_sIterator.Init(pPageView); | 124 m_sIterator.Init(pPageView); |
125 m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) | 125 m_bIgnorerelevant = ((CXFA_FFDoc*)m_pPageView->GetDocView()->GetDoc()) |
126 ->GetXFADoc() | 126 ->GetXFADoc() |
127 ->GetCurVersionMode() < XFA_VERSION_205; | 127 ->GetCurVersionMode() < XFA_VERSION_205; |
128 } | 128 } |
129 CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} | 129 CXFA_FFPageWidgetIterator::~CXFA_FFPageWidgetIterator() {} |
130 void CXFA_FFPageWidgetIterator::Reset() { | 130 void CXFA_FFPageWidgetIterator::Reset() { |
131 m_sIterator.Reset(); | 131 m_sIterator.Reset(); |
132 } | 132 } |
133 IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToFirst() { | 133 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToFirst() { |
134 m_sIterator.Reset(); | 134 m_sIterator.Reset(); |
135 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; | 135 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); pLayoutItem; |
136 pLayoutItem = m_sIterator.MoveToNext()) { | 136 pLayoutItem = m_sIterator.MoveToNext()) { |
137 if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { | 137 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { |
138 return hWidget; | 138 return hWidget; |
139 } | 139 } |
140 } | 140 } |
141 return NULL; | 141 return NULL; |
142 } | 142 } |
143 IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToLast() { | 143 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToLast() { |
144 m_sIterator.SetCurrent(NULL); | 144 m_sIterator.SetCurrent(NULL); |
145 return MoveToPrevious(); | 145 return MoveToPrevious(); |
146 } | 146 } |
147 IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToNext() { | 147 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToNext() { |
148 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; | 148 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToNext(); pLayoutItem; |
149 pLayoutItem = m_sIterator.MoveToNext()) { | 149 pLayoutItem = m_sIterator.MoveToNext()) { |
150 if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { | 150 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { |
151 return hWidget; | 151 return hWidget; |
152 } | 152 } |
153 } | 153 } |
154 return NULL; | 154 return NULL; |
155 } | 155 } |
156 IXFA_Widget* CXFA_FFPageWidgetIterator::MoveToPrevious() { | 156 CXFA_FFWidget* CXFA_FFPageWidgetIterator::MoveToPrevious() { |
157 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; | 157 for (CXFA_LayoutItem* pLayoutItem = m_sIterator.MoveToPrev(); pLayoutItem; |
158 pLayoutItem = m_sIterator.MoveToPrev()) { | 158 pLayoutItem = m_sIterator.MoveToPrev()) { |
159 if (IXFA_Widget* hWidget = GetWidget(pLayoutItem)) { | 159 if (CXFA_FFWidget* hWidget = GetWidget(pLayoutItem)) { |
160 return hWidget; | 160 return hWidget; |
161 } | 161 } |
162 } | 162 } |
163 return NULL; | 163 return NULL; |
164 } | 164 } |
165 IXFA_Widget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { | 165 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetCurrentWidget() { |
166 CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); | 166 CXFA_LayoutItem* pLayoutItem = m_sIterator.GetCurrent(); |
167 return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL; | 167 return pLayoutItem ? XFA_GetWidgetFromLayoutItem(pLayoutItem) : NULL; |
168 } | 168 } |
169 FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(IXFA_Widget* hWidget) { | 169 FX_BOOL CXFA_FFPageWidgetIterator::SetCurrentWidget(CXFA_FFWidget* hWidget) { |
170 CXFA_FFWidget* pWidget = static_cast<CXFA_FFWidget*>(hWidget); | 170 return hWidget && m_sIterator.SetCurrent(hWidget); |
171 return pWidget && m_sIterator.SetCurrent(pWidget); | |
172 } | 171 } |
173 IXFA_Widget* CXFA_FFPageWidgetIterator::GetWidget( | 172 CXFA_FFWidget* CXFA_FFPageWidgetIterator::GetWidget( |
174 CXFA_LayoutItem* pLayoutItem) { | 173 CXFA_LayoutItem* pLayoutItem) { |
175 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { | 174 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { |
176 if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { | 175 if (!XFA_PageWidgetFilter(pWidget, m_dwFilter, FALSE, m_bIgnorerelevant)) { |
177 return NULL; | 176 return NULL; |
178 } | 177 } |
179 if (!pWidget->IsLoaded() && | 178 if (!pWidget->IsLoaded() && |
180 (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) { | 179 (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible) != 0) { |
181 pWidget->LoadWidget(); | 180 pWidget->LoadWidget(); |
182 } | 181 } |
183 return pWidget; | 182 return pWidget; |
(...skipping 10 matching lines...) Expand all Loading... |
194 Reset(); | 193 Reset(); |
195 } | 194 } |
196 CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} | 195 CXFA_FFTabOrderPageWidgetIterator::~CXFA_FFTabOrderPageWidgetIterator() {} |
197 void CXFA_FFTabOrderPageWidgetIterator::Release() { | 196 void CXFA_FFTabOrderPageWidgetIterator::Release() { |
198 delete this; | 197 delete this; |
199 } | 198 } |
200 void CXFA_FFTabOrderPageWidgetIterator::Reset() { | 199 void CXFA_FFTabOrderPageWidgetIterator::Reset() { |
201 CreateTabOrderWidgetArray(); | 200 CreateTabOrderWidgetArray(); |
202 m_iCurWidget = -1; | 201 m_iCurWidget = -1; |
203 } | 202 } |
204 IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { | 203 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToFirst() { |
205 if (m_TabOrderWidgetArray.GetSize() > 0) { | 204 if (m_TabOrderWidgetArray.GetSize() > 0) { |
206 for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { | 205 for (int32_t i = 0; i < m_TabOrderWidgetArray.GetSize(); i++) { |
207 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 206 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
208 m_bIgnorerelevant)) { | 207 m_bIgnorerelevant)) { |
209 m_iCurWidget = i; | 208 m_iCurWidget = i; |
210 return m_TabOrderWidgetArray[m_iCurWidget]; | 209 return m_TabOrderWidgetArray[m_iCurWidget]; |
211 } | 210 } |
212 } | 211 } |
213 } | 212 } |
214 return NULL; | 213 return NULL; |
215 } | 214 } |
216 IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { | 215 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToLast() { |
217 if (m_TabOrderWidgetArray.GetSize() > 0) { | 216 if (m_TabOrderWidgetArray.GetSize() > 0) { |
218 for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { | 217 for (int32_t i = m_TabOrderWidgetArray.GetSize() - 1; i >= 0; i--) { |
219 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 218 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
220 m_bIgnorerelevant)) { | 219 m_bIgnorerelevant)) { |
221 m_iCurWidget = i; | 220 m_iCurWidget = i; |
222 return m_TabOrderWidgetArray[m_iCurWidget]; | 221 return m_TabOrderWidgetArray[m_iCurWidget]; |
223 } | 222 } |
224 } | 223 } |
225 } | 224 } |
226 return NULL; | 225 return NULL; |
227 } | 226 } |
228 IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { | 227 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToNext() { |
229 for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { | 228 for (int32_t i = m_iCurWidget + 1; i < m_TabOrderWidgetArray.GetSize(); i++) { |
230 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 229 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
231 m_bIgnorerelevant)) { | 230 m_bIgnorerelevant)) { |
232 m_iCurWidget = i; | 231 m_iCurWidget = i; |
233 return m_TabOrderWidgetArray[m_iCurWidget]; | 232 return m_TabOrderWidgetArray[m_iCurWidget]; |
234 } | 233 } |
235 } | 234 } |
236 m_iCurWidget = -1; | 235 m_iCurWidget = -1; |
237 return NULL; | 236 return NULL; |
238 } | 237 } |
239 IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { | 238 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::MoveToPrevious() { |
240 for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { | 239 for (int32_t i = m_iCurWidget - 1; i >= 0; i--) { |
241 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, | 240 if (XFA_PageWidgetFilter(m_TabOrderWidgetArray[i], m_dwFilter, TRUE, |
242 m_bIgnorerelevant)) { | 241 m_bIgnorerelevant)) { |
243 m_iCurWidget = i; | 242 m_iCurWidget = i; |
244 return m_TabOrderWidgetArray[m_iCurWidget]; | 243 return m_TabOrderWidgetArray[m_iCurWidget]; |
245 } | 244 } |
246 } | 245 } |
247 m_iCurWidget = -1; | 246 m_iCurWidget = -1; |
248 return NULL; | 247 return NULL; |
249 } | 248 } |
250 IXFA_Widget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { | 249 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetCurrentWidget() { |
251 if (m_iCurWidget >= 0) { | 250 if (m_iCurWidget >= 0) { |
252 return m_TabOrderWidgetArray[m_iCurWidget]; | 251 return m_TabOrderWidgetArray[m_iCurWidget]; |
253 } | 252 } |
254 return NULL; | 253 return NULL; |
255 } | 254 } |
256 FX_BOOL CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( | 255 FX_BOOL CXFA_FFTabOrderPageWidgetIterator::SetCurrentWidget( |
257 IXFA_Widget* hWidget) { | 256 CXFA_FFWidget* hWidget) { |
258 int32_t iWidgetIndex = | 257 int32_t iWidgetIndex = m_TabOrderWidgetArray.Find(hWidget); |
259 m_TabOrderWidgetArray.Find(static_cast<CXFA_FFWidget*>(hWidget)); | |
260 if (iWidgetIndex >= 0) { | 258 if (iWidgetIndex >= 0) { |
261 m_iCurWidget = iWidgetIndex; | 259 m_iCurWidget = iWidgetIndex; |
262 return TRUE; | 260 return TRUE; |
263 } | 261 } |
264 return FALSE; | 262 return FALSE; |
265 } | 263 } |
266 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( | 264 CXFA_FFWidget* CXFA_FFTabOrderPageWidgetIterator::GetTraverseWidget( |
267 CXFA_FFWidget* pWidget) { | 265 CXFA_FFWidget* pWidget) { |
268 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); | 266 CXFA_WidgetAcc* pAcc = pWidget->GetDataAcc(); |
269 CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_ELEMENT_Traversal); | 267 CXFA_Node* pTraversal = pAcc->GetNode()->GetChild(0, XFA_ELEMENT_Traversal); |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 CXFA_LayoutItem* pLayoutItem) { | 413 CXFA_LayoutItem* pLayoutItem) { |
416 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { | 414 if (CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pLayoutItem)) { |
417 if (!pWidget->IsLoaded() && | 415 if (!pWidget->IsLoaded() && |
418 (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { | 416 (pWidget->GetStatus() & XFA_WIDGETSTATUS_Visible)) { |
419 pWidget->LoadWidget(); | 417 pWidget->LoadWidget(); |
420 } | 418 } |
421 return pWidget; | 419 return pWidget; |
422 } | 420 } |
423 return NULL; | 421 return NULL; |
424 } | 422 } |
OLD | NEW |