Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #include "xfa/fxfa/app/xfa_ffnotify.h" |
| 8 | |
dsinclair | 4355468 | 2016-09-29 17:29:48 -0700 | [diff] [blame] | 9 | #include "fxjs/cfxjse_value.h" |
Dan Sinclair | 1f5d498 | 2017-01-10 16:37:32 -0500 | [diff] [blame^] | 10 | #include "xfa/fxfa/app/cxfa_textlayout.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 11 | #include "xfa/fxfa/app/xfa_ffbarcode.h" |
| 12 | #include "xfa/fxfa/app/xfa_ffcheckbutton.h" |
| 13 | #include "xfa/fxfa/app/xfa_ffchoicelist.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 14 | #include "xfa/fxfa/app/xfa_ffdraw.h" |
| 15 | #include "xfa/fxfa/app/xfa_ffexclgroup.h" |
| 16 | #include "xfa/fxfa/app/xfa_fffield.h" |
| 17 | #include "xfa/fxfa/app/xfa_ffimage.h" |
| 18 | #include "xfa/fxfa/app/xfa_ffimageedit.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 19 | #include "xfa/fxfa/app/xfa_ffpath.h" |
| 20 | #include "xfa/fxfa/app/xfa_ffpushbutton.h" |
| 21 | #include "xfa/fxfa/app/xfa_ffsignature.h" |
| 22 | #include "xfa/fxfa/app/xfa_ffsubform.h" |
| 23 | #include "xfa/fxfa/app/xfa_fftext.h" |
| 24 | #include "xfa/fxfa/app/xfa_fftextedit.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 25 | #include "xfa/fxfa/app/xfa_ffwidgetacc.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 26 | #include "xfa/fxfa/app/xfa_fwladapter.h" |
dsinclair | 5b49309 | 2016-09-29 20:20:24 -0700 | [diff] [blame] | 27 | #include "xfa/fxfa/xfa_ffapp.h" |
| 28 | #include "xfa/fxfa/xfa_ffdoc.h" |
| 29 | #include "xfa/fxfa/xfa_ffdocview.h" |
| 30 | #include "xfa/fxfa/xfa_ffpageview.h" |
| 31 | #include "xfa/fxfa/xfa_ffwidget.h" |
| 32 | #include "xfa/fxfa/xfa_ffwidgethandler.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 33 | |
| 34 | static void XFA_FFDeleteWidgetAcc(void* pData) { |
| 35 | delete static_cast<CXFA_WidgetAcc*>(pData); |
| 36 | } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 37 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 38 | static XFA_MAPDATABLOCKCALLBACKINFO gs_XFADeleteWidgetAcc = { |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 39 | XFA_FFDeleteWidgetAcc, nullptr}; |
| 40 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 41 | CXFA_FFNotify::CXFA_FFNotify(CXFA_FFDoc* pDoc) : m_pDoc(pDoc) {} |
| 42 | CXFA_FFNotify::~CXFA_FFNotify() {} |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 43 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 44 | void CXFA_FFNotify::OnPageEvent(CXFA_ContainerLayoutItem* pSender, |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 45 | uint32_t dwEvent) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 46 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pSender->GetLayout()); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 47 | if (pDocView) |
| 48 | pDocView->OnPageEvent(pSender, dwEvent); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 49 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 50 | |
| 51 | void CXFA_FFNotify::OnWidgetListItemAdded(CXFA_WidgetData* pSender, |
| 52 | const FX_WCHAR* pLabel, |
| 53 | const FX_WCHAR* pValue, |
| 54 | int32_t iIndex) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 55 | CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 56 | if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList) |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 57 | return; |
| 58 | |
| 59 | CXFA_FFWidget* pWidget = nullptr; |
weili | 038aa53 | 2016-05-20 15:38:29 -0700 | [diff] [blame] | 60 | while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 61 | if (pWidget->IsLoaded()) { |
| 62 | if (pWidgetAcc->IsListBox()) { |
| 63 | static_cast<CXFA_FFListBox*>(pWidget)->InsertItem(pLabel, iIndex); |
| 64 | } else { |
| 65 | static_cast<CXFA_FFComboBox*>(pWidget)->InsertItem(pLabel, iIndex); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 66 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 67 | } |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 68 | } |
| 69 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 70 | |
| 71 | void CXFA_FFNotify::OnWidgetListItemRemoved(CXFA_WidgetData* pSender, |
| 72 | int32_t iIndex) { |
| 73 | CXFA_WidgetAcc* pWidgetAcc = static_cast<CXFA_WidgetAcc*>(pSender); |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 74 | if (pWidgetAcc->GetUIType() != XFA_Element::ChoiceList) |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 75 | return; |
| 76 | |
| 77 | CXFA_FFWidget* pWidget = nullptr; |
weili | 038aa53 | 2016-05-20 15:38:29 -0700 | [diff] [blame] | 78 | while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 79 | if (pWidget->IsLoaded()) { |
| 80 | if (pWidgetAcc->IsListBox()) { |
| 81 | static_cast<CXFA_FFListBox*>(pWidget)->DeleteItem(iIndex); |
| 82 | } else { |
| 83 | static_cast<CXFA_FFComboBox*>(pWidget)->DeleteItem(iIndex); |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 89 | CXFA_LayoutItem* CXFA_FFNotify::OnCreateLayoutItem(CXFA_Node* pNode) { |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 90 | CXFA_LayoutProcessor* pLayout = m_pDoc->GetXFADoc()->GetDocLayout(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 91 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
dsinclair | 070fcdf | 2016-06-22 22:04:54 -0700 | [diff] [blame] | 92 | XFA_Element eType = pNode->GetElementType(); |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 93 | if (eType == XFA_Element::PageArea) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 94 | return new CXFA_FFPageView(pDocView, pNode); |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 95 | if (eType == XFA_Element::ContentArea) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 96 | return new CXFA_ContainerLayoutItem(pNode); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 97 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 98 | CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 99 | if (!pAcc) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 100 | return new CXFA_ContentLayoutItem(pNode); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 101 | |
| 102 | CXFA_FFWidget* pWidget; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 103 | switch (pAcc->GetUIType()) { |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 104 | case XFA_Element::Barcode: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 105 | pWidget = new CXFA_FFBarcode(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 106 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 107 | case XFA_Element::Button: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 108 | pWidget = new CXFA_FFPushButton(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 109 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 110 | case XFA_Element::CheckButton: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 111 | pWidget = new CXFA_FFCheckButton(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 112 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 113 | case XFA_Element::ChoiceList: { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 114 | if (pAcc->IsListBox()) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 115 | pWidget = new CXFA_FFListBox(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 116 | } else { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 117 | pWidget = new CXFA_FFComboBox(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 118 | } |
| 119 | } break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 120 | case XFA_Element::DateTimeEdit: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 121 | pWidget = new CXFA_FFDateTimeEdit(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 122 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 123 | case XFA_Element::ImageEdit: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 124 | pWidget = new CXFA_FFImageEdit(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 125 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 126 | case XFA_Element::NumericEdit: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 127 | pWidget = new CXFA_FFNumericEdit(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 128 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 129 | case XFA_Element::PasswordEdit: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 130 | pWidget = new CXFA_FFPasswordEdit(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 131 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 132 | case XFA_Element::Signature: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 133 | pWidget = new CXFA_FFSignature(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 134 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 135 | case XFA_Element::TextEdit: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 136 | pWidget = new CXFA_FFTextEdit(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 137 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 138 | case XFA_Element::Arc: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 139 | pWidget = new CXFA_FFArc(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 140 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 141 | case XFA_Element::Line: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 142 | pWidget = new CXFA_FFLine(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 143 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 144 | case XFA_Element::Rectangle: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 145 | pWidget = new CXFA_FFRectangle(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 146 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 147 | case XFA_Element::Text: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 148 | pWidget = new CXFA_FFText(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 149 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 150 | case XFA_Element::Image: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 151 | pWidget = new CXFA_FFImage(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 152 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 153 | case XFA_Element::Draw: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 154 | pWidget = new CXFA_FFDraw(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 155 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 156 | case XFA_Element::Subform: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 157 | pWidget = new CXFA_FFSubForm(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 158 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 159 | case XFA_Element::ExclGroup: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 160 | pWidget = new CXFA_FFExclGroup(nullptr, pAcc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 161 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 162 | case XFA_Element::DefaultUi: |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 163 | default: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 164 | pWidget = nullptr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 165 | break; |
| 166 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 167 | |
| 168 | if (pWidget) |
| 169 | pWidget->SetDocView(pDocView); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 170 | return pWidget; |
| 171 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 172 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 173 | void CXFA_FFNotify::StartFieldDrawLayout(CXFA_Node* pItem, |
| 174 | FX_FLOAT& fCalcWidth, |
| 175 | FX_FLOAT& fCalcHeight) { |
| 176 | CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
dsinclair | eea31b7 | 2016-07-19 10:27:12 -0700 | [diff] [blame] | 177 | if (!pAcc) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 178 | return; |
dsinclair | eea31b7 | 2016-07-19 10:27:12 -0700 | [diff] [blame] | 179 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 180 | pAcc->StartWidgetLayout(fCalcWidth, fCalcHeight); |
| 181 | } |
dsinclair | eea31b7 | 2016-07-19 10:27:12 -0700 | [diff] [blame] | 182 | |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 183 | bool CXFA_FFNotify::FindSplitPos(CXFA_Node* pItem, |
| 184 | int32_t iBlockIndex, |
| 185 | FX_FLOAT& fCalcHeightPos) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 186 | CXFA_WidgetAcc* pAcc = static_cast<CXFA_WidgetAcc*>(pItem->GetWidgetData()); |
dsinclair | eea31b7 | 2016-07-19 10:27:12 -0700 | [diff] [blame] | 187 | return pAcc && pAcc->FindSplitPos(iBlockIndex, fCalcHeightPos); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 188 | } |
dsinclair | eea31b7 | 2016-07-19 10:27:12 -0700 | [diff] [blame] | 189 | |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 190 | bool CXFA_FFNotify::RunScript(CXFA_Node* pScript, CXFA_Node* pFormItem) { |
| 191 | bool bRet = false; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 192 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 193 | if (!pDocView) { |
| 194 | return bRet; |
| 195 | } |
| 196 | CXFA_WidgetAcc* pWidgetAcc = |
| 197 | static_cast<CXFA_WidgetAcc*>(pFormItem->GetWidgetData()); |
| 198 | if (!pWidgetAcc) { |
| 199 | return bRet; |
| 200 | } |
| 201 | CXFA_EventParam EventParam; |
| 202 | EventParam.m_eType = XFA_EVENT_Unknown; |
dsinclair | 12a6b0c | 2016-05-26 11:14:08 -0700 | [diff] [blame] | 203 | CFXJSE_Value* pRetValue = nullptr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 204 | int32_t iRet = |
| 205 | pWidgetAcc->ExecuteScript(CXFA_Script(pScript), &EventParam, &pRetValue); |
Wei Li | e98ac2e | 2016-03-18 15:43:04 -0700 | [diff] [blame] | 206 | if (iRet == XFA_EVENTERROR_Success && pRetValue) { |
dsinclair | f27aeec | 2016-06-07 19:36:18 -0700 | [diff] [blame] | 207 | bRet = pRetValue->ToBoolean(); |
dsinclair | 86fad99 | 2016-05-31 11:34:04 -0700 | [diff] [blame] | 208 | delete pRetValue; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 209 | } |
| 210 | return bRet; |
| 211 | } |
| 212 | int32_t CXFA_FFNotify::ExecEventByDeepFirst(CXFA_Node* pFormNode, |
| 213 | XFA_EVENTTYPE eEventType, |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 214 | bool bIsFormReady, |
| 215 | bool bRecursive, |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 216 | CXFA_WidgetAcc* pExclude) { |
| 217 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 218 | if (!pDocView) { |
| 219 | return XFA_EVENTERROR_NotExist; |
| 220 | } |
| 221 | return pDocView->ExecEventActivityByDeepFirst( |
| 222 | pFormNode, eEventType, bIsFormReady, bRecursive, |
dsinclair | 85d1f2c | 2016-06-23 12:40:16 -0700 | [diff] [blame] | 223 | pExclude ? pExclude->GetNode() : nullptr); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 224 | } |
| 225 | void CXFA_FFNotify::AddCalcValidate(CXFA_Node* pNode) { |
| 226 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 227 | if (!pDocView) { |
| 228 | return; |
| 229 | } |
| 230 | CXFA_WidgetAcc* pWidgetAcc = |
| 231 | static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()); |
| 232 | if (!pWidgetAcc) { |
| 233 | return; |
| 234 | } |
| 235 | pDocView->AddCalculateWidgetAcc(pWidgetAcc); |
| 236 | pDocView->AddValidateWidget(pWidgetAcc); |
| 237 | } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 238 | CXFA_FFDoc* CXFA_FFNotify::GetHDOC() { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 239 | return m_pDoc; |
| 240 | } |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 241 | IXFA_DocEnvironment* CXFA_FFNotify::GetDocEnvironment() const { |
| 242 | return m_pDoc->GetDocEnvironment(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 243 | } |
| 244 | IXFA_AppProvider* CXFA_FFNotify::GetAppProvider() { |
| 245 | return m_pDoc->GetApp()->GetAppProvider(); |
| 246 | } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 247 | CXFA_FFWidgetHandler* CXFA_FFNotify::GetWidgetHandler() { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 248 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
dsinclair | 85d1f2c | 2016-06-23 12:40:16 -0700 | [diff] [blame] | 249 | return pDocView ? pDocView->GetWidgetHandler() : nullptr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 250 | } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 251 | CXFA_FFWidget* CXFA_FFNotify::GetHWidget(CXFA_LayoutItem* pLayoutItem) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 252 | return XFA_GetWidgetFromLayoutItem(pLayoutItem); |
| 253 | } |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 254 | void CXFA_FFNotify::OpenDropDownList(CXFA_FFWidget* hWidget) { |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 255 | if (hWidget->GetDataAcc()->GetUIType() != XFA_Element::ChoiceList) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 256 | return; |
| 257 | } |
| 258 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 259 | pDocView->LockUpdate(); |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 260 | static_cast<CXFA_FFComboBox*>(hWidget)->OpenDropDownList(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 261 | pDocView->UnlockUpdate(); |
| 262 | pDocView->UpdateDocView(); |
| 263 | } |
| 264 | CFX_WideString CXFA_FFNotify::GetCurrentDateTime() { |
| 265 | CFX_Unitime dataTime; |
| 266 | dataTime.Now(); |
| 267 | CFX_WideString wsDateTime; |
| 268 | wsDateTime.Format(L"%d%02d%02dT%02d%02d%02d", dataTime.GetYear(), |
| 269 | dataTime.GetMonth(), dataTime.GetDay(), dataTime.GetHour(), |
| 270 | dataTime.GetMinute(), dataTime.GetSecond()); |
| 271 | return wsDateTime; |
| 272 | } |
| 273 | void CXFA_FFNotify::ResetData(CXFA_WidgetData* pWidgetData) { |
| 274 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 275 | if (!pDocView) { |
| 276 | return; |
| 277 | } |
| 278 | pDocView->ResetWidgetData(static_cast<CXFA_WidgetAcc*>(pWidgetData)); |
| 279 | } |
| 280 | int32_t CXFA_FFNotify::GetLayoutStatus() { |
| 281 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 282 | return pDocView ? pDocView->GetLayoutStatus() : 0; |
| 283 | } |
| 284 | void CXFA_FFNotify::RunNodeInitialize(CXFA_Node* pNode) { |
| 285 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 286 | if (!pDocView) { |
| 287 | return; |
| 288 | } |
| 289 | pDocView->AddNewFormNode(pNode); |
| 290 | } |
| 291 | void CXFA_FFNotify::RunSubformIndexChange(CXFA_Node* pSubformNode) { |
| 292 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 293 | if (!pDocView) { |
| 294 | return; |
| 295 | } |
| 296 | pDocView->AddIndexChangedSubform(pSubformNode); |
| 297 | } |
| 298 | CXFA_Node* CXFA_FFNotify::GetFocusWidgetNode() { |
| 299 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 300 | if (!pDocView) { |
dsinclair | 85d1f2c | 2016-06-23 12:40:16 -0700 | [diff] [blame] | 301 | return nullptr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 302 | } |
| 303 | CXFA_WidgetAcc* pAcc = pDocView->GetFocusWidgetAcc(); |
dsinclair | 85d1f2c | 2016-06-23 12:40:16 -0700 | [diff] [blame] | 304 | return pAcc ? pAcc->GetNode() : nullptr; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 305 | } |
| 306 | void CXFA_FFNotify::SetFocusWidgetNode(CXFA_Node* pNode) { |
| 307 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 308 | if (!pDocView) { |
| 309 | return; |
| 310 | } |
| 311 | CXFA_WidgetAcc* pAcc = |
| 312 | pNode ? static_cast<CXFA_WidgetAcc*>(pNode->GetWidgetData()) : nullptr; |
| 313 | pDocView->SetFocusWidgetAcc(pAcc); |
| 314 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 315 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 316 | void CXFA_FFNotify::OnNodeReady(CXFA_Node* pNode) { |
| 317 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 318 | if (!pDocView) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 319 | return; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 320 | |
dsinclair | 41cb62e | 2016-06-23 09:20:32 -0700 | [diff] [blame] | 321 | XFA_Element eType = pNode->GetElementType(); |
| 322 | if (XFA_IsCreateWidget(eType)) { |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 323 | CXFA_WidgetAcc* pAcc = new CXFA_WidgetAcc(pDocView, pNode); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 324 | pNode->SetObject(XFA_ATTRIBUTE_WidgetData, pAcc, &gs_XFADeleteWidgetAcc); |
| 325 | return; |
| 326 | } |
dsinclair | 41cb62e | 2016-06-23 09:20:32 -0700 | [diff] [blame] | 327 | switch (eType) { |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 328 | case XFA_Element::BindItems: |
tsepez | d654d78 | 2017-01-03 14:18:07 -0800 | [diff] [blame] | 329 | pDocView->m_BindItems.push_back(pNode); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 330 | break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 331 | case XFA_Element::Validate: { |
dsinclair | c5a8f21 | 2016-06-20 11:11:12 -0700 | [diff] [blame] | 332 | pNode->SetFlag(XFA_NodeFlag_NeedsInitApp, false); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 333 | } break; |
| 334 | default: |
| 335 | break; |
| 336 | } |
| 337 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 338 | |
| 339 | void CXFA_FFNotify::OnValueChanging(CXFA_Node* pSender, XFA_ATTRIBUTE eAttr) { |
| 340 | if (eAttr != XFA_ATTRIBUTE_Presence) |
| 341 | return; |
| 342 | |
| 343 | if (pSender->GetPacketID() & XFA_XDPPACKET_Datasets) |
| 344 | return; |
| 345 | |
| 346 | if (!pSender->IsFormContainer()) |
| 347 | return; |
| 348 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 349 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 350 | if (!pDocView) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 351 | return; |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 352 | |
| 353 | if (pDocView->GetLayoutStatus() < XFA_DOCVIEW_LAYOUTSTATUS_End) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 354 | return; |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 355 | |
| 356 | CXFA_WidgetAcc* pWidgetAcc = |
| 357 | static_cast<CXFA_WidgetAcc*>(pSender->GetWidgetData()); |
| 358 | if (!pWidgetAcc) |
| 359 | return; |
| 360 | |
| 361 | CXFA_FFWidget* pWidget = nullptr; |
weili | 038aa53 | 2016-05-20 15:38:29 -0700 | [diff] [blame] | 362 | while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 363 | if (pWidget->IsLoaded()) |
| 364 | pWidget->AddInvalidateRect(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 365 | } |
| 366 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 367 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 368 | void CXFA_FFNotify::OnValueChanged(CXFA_Node* pSender, |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 369 | XFA_ATTRIBUTE eAttr, |
| 370 | CXFA_Node* pParentNode, |
| 371 | CXFA_Node* pWidgetNode) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 372 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 373 | if (!pDocView) |
| 374 | return; |
| 375 | |
| 376 | if (!(pSender->GetPacketID() & XFA_XDPPACKET_Form)) { |
| 377 | if (eAttr == XFA_ATTRIBUTE_Value) |
| 378 | pDocView->AddCalculateNodeNotify(pSender); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 379 | return; |
| 380 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 381 | |
dsinclair | 41cb62e | 2016-06-23 09:20:32 -0700 | [diff] [blame] | 382 | XFA_Element eType = pParentNode->GetElementType(); |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 383 | bool bIsContainerNode = pParentNode->IsContainerNode(); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 384 | CXFA_WidgetAcc* pWidgetAcc = |
| 385 | static_cast<CXFA_WidgetAcc*>(pWidgetNode->GetWidgetData()); |
| 386 | if (!pWidgetAcc) |
| 387 | return; |
| 388 | |
| 389 | bool bUpdateProperty = false; |
| 390 | pDocView->SetChangeMark(); |
dsinclair | 41cb62e | 2016-06-23 09:20:32 -0700 | [diff] [blame] | 391 | switch (eType) { |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 392 | case XFA_Element::Caption: { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 393 | CXFA_TextLayout* pCapOut = pWidgetAcc->GetCaptionTextLayout(); |
| 394 | if (!pCapOut) |
| 395 | return; |
| 396 | |
| 397 | pCapOut->Unload(); |
| 398 | } break; |
dsinclair | 56a8b19 | 2016-06-21 14:15:25 -0700 | [diff] [blame] | 399 | case XFA_Element::Ui: |
| 400 | case XFA_Element::Para: |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 401 | bUpdateProperty = true; |
| 402 | break; |
| 403 | default: |
| 404 | break; |
| 405 | } |
| 406 | if (bIsContainerNode && eAttr == XFA_ATTRIBUTE_Access) |
| 407 | bUpdateProperty = true; |
| 408 | |
| 409 | if (eAttr == XFA_ATTRIBUTE_Value) { |
| 410 | pDocView->AddCalculateNodeNotify(pSender); |
dsinclair | 41cb62e | 2016-06-23 09:20:32 -0700 | [diff] [blame] | 411 | if (eType == XFA_Element::Value || bIsContainerNode) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 412 | if (bIsContainerNode) { |
| 413 | pWidgetAcc->UpdateUIDisplay(); |
| 414 | pDocView->AddCalculateWidgetAcc(pWidgetAcc); |
| 415 | pDocView->AddValidateWidget(pWidgetAcc); |
dsinclair | 070fcdf | 2016-06-22 22:04:54 -0700 | [diff] [blame] | 416 | } else if (pWidgetNode->GetNodeItem(XFA_NODEITEM_Parent) |
| 417 | ->GetElementType() == XFA_Element::ExclGroup) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 418 | pWidgetAcc->UpdateUIDisplay(); |
| 419 | } |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 420 | return; |
| 421 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 422 | } |
| 423 | CXFA_FFWidget* pWidget = nullptr; |
weili | 038aa53 | 2016-05-20 15:38:29 -0700 | [diff] [blame] | 424 | while ((pWidget = pWidgetAcc->GetNextWidget(pWidget)) != nullptr) { |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 425 | if (!pWidget->IsLoaded()) |
| 426 | continue; |
| 427 | |
| 428 | if (bUpdateProperty) |
| 429 | pWidget->UpdateWidgetProperty(); |
| 430 | pWidget->PerformLayout(); |
| 431 | pWidget->AddInvalidateRect(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 432 | } |
| 433 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 434 | |
| 435 | void CXFA_FFNotify::OnChildAdded(CXFA_Node* pSender) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 436 | if (!pSender->IsFormContainer()) { |
| 437 | return; |
| 438 | } |
| 439 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 440 | if (!pDocView) { |
| 441 | return; |
| 442 | } |
tsepez | d19e912 | 2016-11-02 15:43:18 -0700 | [diff] [blame] | 443 | bool bLayoutReady = |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 444 | !(pDocView->m_bInLayoutStatus) && |
| 445 | (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 446 | if (bLayoutReady) |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 447 | m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 448 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 449 | |
| 450 | void CXFA_FFNotify::OnChildRemoved() { |
| 451 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(); |
| 452 | if (!pDocView) |
| 453 | return; |
| 454 | |
| 455 | bool bLayoutReady = |
| 456 | !(pDocView->m_bInLayoutStatus) && |
| 457 | (pDocView->GetLayoutStatus() == XFA_DOCVIEW_LAYOUTSTATUS_End); |
| 458 | if (bLayoutReady) |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 459 | m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 460 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 461 | |
| 462 | void CXFA_FFNotify::OnLayoutItemAdded(CXFA_LayoutProcessor* pLayout, |
| 463 | CXFA_LayoutItem* pSender, |
| 464 | int32_t iPageIdx, |
| 465 | uint32_t dwStatus) { |
| 466 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
| 467 | if (!pDocView) |
| 468 | return; |
| 469 | |
| 470 | CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
| 471 | if (!pWidget) |
| 472 | return; |
| 473 | |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 474 | CXFA_FFPageView* pNewPageView = pDocView->GetPageView(iPageIdx); |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 475 | uint32_t dwFilter = XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable | |
| 476 | XFA_WidgetStatus_Printable; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 477 | pWidget->ModifyStatus(dwStatus, dwFilter); |
dsinclair | df4bc59 | 2016-03-31 20:34:43 -0700 | [diff] [blame] | 478 | CXFA_FFPageView* pPrePageView = pWidget->GetPageView(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 479 | if (pPrePageView != pNewPageView || |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 480 | (dwStatus & (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) == |
| 481 | (XFA_WidgetStatus_Visible | XFA_WidgetStatus_Viewable)) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 482 | pWidget->SetPageView(pNewPageView); |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 483 | m_pDoc->GetDocEnvironment()->WidgetPostAdd(pWidget, pWidget->GetDataAcc()); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 484 | } |
| 485 | if (pDocView->GetLayoutStatus() != XFA_DOCVIEW_LAYOUTSTATUS_End || |
dsinclair | 935d8d5 | 2016-05-17 10:32:18 -0700 | [diff] [blame] | 486 | !(dwStatus & XFA_WidgetStatus_Visible)) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 487 | return; |
| 488 | } |
| 489 | if (pWidget->IsLoaded()) { |
| 490 | CFX_RectF rtOld; |
| 491 | pWidget->GetWidgetRect(rtOld); |
| 492 | if (rtOld != pWidget->ReCacheWidgetRect()) |
| 493 | pWidget->PerformLayout(); |
| 494 | } else { |
| 495 | pWidget->LoadWidget(); |
| 496 | } |
| 497 | pWidget->AddInvalidateRect(nullptr); |
| 498 | } |
thestig | b1a5959 | 2016-04-14 18:29:56 -0700 | [diff] [blame] | 499 | |
| 500 | void CXFA_FFNotify::OnLayoutItemRemoving(CXFA_LayoutProcessor* pLayout, |
| 501 | CXFA_LayoutItem* pSender) { |
| 502 | CXFA_FFDocView* pDocView = m_pDoc->GetDocView(pLayout); |
| 503 | if (!pDocView) |
| 504 | return; |
| 505 | |
| 506 | CXFA_FFWidget* pWidget = XFA_GetWidgetFromLayoutItem(pSender); |
| 507 | if (!pWidget) |
| 508 | return; |
| 509 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 510 | pDocView->DeleteLayoutItem(pWidget); |
dsinclair | a440bb3 | 2016-09-14 07:01:54 -0700 | [diff] [blame] | 511 | m_pDoc->GetDocEnvironment()->WidgetPreRemove(pWidget, pWidget->GetDataAcc()); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 512 | pWidget->AddInvalidateRect(nullptr); |
| 513 | } |