summaryrefslogtreecommitdiff
path: root/xfa/fxfa
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxfa')
-rw-r--r--xfa/fxfa/app/cxfa_fftextedit.cpp21
-rw-r--r--xfa/fxfa/cxfa_ffdocview.cpp68
-rw-r--r--xfa/fxfa/cxfa_ffdocview.h6
-rw-r--r--xfa/fxfa/cxfa_ffwidget.cpp4
-rw-r--r--xfa/fxfa/cxfa_ffwidget.h2
-rw-r--r--xfa/fxfa/parser/cxfa_localevalue.cpp14
6 files changed, 51 insertions, 64 deletions
diff --git a/xfa/fxfa/app/cxfa_fftextedit.cpp b/xfa/fxfa/app/cxfa_fftextedit.cpp
index b61d4ab125..7248abf908 100644
--- a/xfa/fxfa/app/cxfa_fftextedit.cpp
+++ b/xfa/fxfa/app/cxfa_fftextedit.cpp
@@ -249,6 +249,7 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
if (!m_pNormalWidget)
return false;
+ CFWL_Edit* pEdit = static_cast<CFWL_Edit*>(m_pNormalWidget.get());
XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display;
if (IsFocused())
eType = XFA_VALUEPICTURE_Edit;
@@ -260,28 +261,24 @@ bool CXFA_FFTextEdit::UpdateFWLData() {
int32_t iMaxChars = m_pDataAcc->GetMaxChars(elementType);
if (elementType == XFA_Element::ExData)
iMaxChars = eType == XFA_VALUEPICTURE_Edit ? iMaxChars : 0;
- if (static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetLimit() !=
- iMaxChars) {
- static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetLimit(iMaxChars);
+ if (pEdit->GetLimit() != iMaxChars) {
+ pEdit->SetLimit(iMaxChars);
bUpdate = true;
}
- }
-
- if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) {
+ } else if (m_pDataAcc->GetUIType() == XFA_Element::Barcode) {
int32_t nDataLen = 0;
if (eType == XFA_VALUEPICTURE_Edit)
m_pDataAcc->GetBarcodeAttribute_DataLength(&nDataLen);
- static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetLimit(nDataLen);
+ pEdit->SetLimit(nDataLen);
bUpdate = true;
}
CFX_WideString wsText;
m_pDataAcc->GetValue(wsText, eType);
- CFX_WideString wsOldText =
- static_cast<CFWL_Edit*>(m_pNormalWidget.get())->GetText();
+ CFX_WideString wsOldText = pEdit->GetText();
if (wsText != wsOldText || (eType == XFA_VALUEPICTURE_Edit && bUpdate)) {
- static_cast<CFWL_Edit*>(m_pNormalWidget.get())->SetText(wsText);
+ pEdit->SetText(wsText);
bUpdate = true;
}
if (bUpdate)
@@ -323,9 +320,7 @@ void CXFA_FFTextEdit::OnTextFull(CFWL_Widget* pWidget) {
}
bool CXFA_FFTextEdit::CheckWord(const CFX_ByteStringC& sWord) {
- if (sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit)
- return true;
- return false;
+ return sWord.IsEmpty() || m_pDataAcc->GetUIType() != XFA_Element::TextEdit;
}
void CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) {
diff --git a/xfa/fxfa/cxfa_ffdocview.cpp b/xfa/fxfa/cxfa_ffdocview.cpp
index 620f3dab42..03a692be83 100644
--- a/xfa/fxfa/cxfa_ffdocview.cpp
+++ b/xfa/fxfa/cxfa_ffdocview.cpp
@@ -196,28 +196,26 @@ void CXFA_FFDocView::UpdateDocView() {
UnlockUpdate();
}
-int32_t CXFA_FFDocView::CountPageViews() {
- if (!m_pXFADocLayout) {
- return 0;
- }
- return m_pXFADocLayout->CountPages();
+int32_t CXFA_FFDocView::CountPageViews() const {
+ return m_pXFADocLayout ? m_pXFADocLayout->CountPages() : 0;
}
-CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) {
- if (!m_pXFADocLayout) {
+
+CXFA_FFPageView* CXFA_FFDocView::GetPageView(int32_t nIndex) const {
+ if (!m_pXFADocLayout)
return nullptr;
- }
return static_cast<CXFA_FFPageView*>(m_pXFADocLayout->GetPage(nIndex));
}
CXFA_LayoutProcessor* CXFA_FFDocView::GetXFALayout() const {
return m_pDoc->GetXFADoc()->GetDocLayout();
}
+
bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) {
CXFA_Node* pNode = pWidgetAcc->GetNode();
XFA_Element eType = pNode->GetElementType();
- if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup) {
+ if (eType != XFA_Element::Field && eType != XFA_Element::ExclGroup)
return false;
- }
+
pWidgetAcc->ResetData();
pWidgetAcc->UpdateUIDisplay();
if (CXFA_Validate validate = pWidgetAcc->GetValidate(false)) {
@@ -226,6 +224,7 @@ bool CXFA_FFDocView::ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc) {
}
return true;
}
+
void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) {
m_bLayoutEvent = true;
bool bChanged = false;
@@ -236,9 +235,9 @@ void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) {
} else {
pFormNode = GetRootSubform();
}
- if (!pFormNode) {
+ if (!pFormNode)
return;
- }
+
if (pFormNode->GetElementType() != XFA_Element::Field &&
pFormNode->GetElementType() != XFA_Element::ExclGroup) {
CXFA_WidgetAccIterator Iterator(pFormNode);
@@ -253,6 +252,7 @@ void CXFA_FFDocView::ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc) {
m_pDoc->GetDocEnvironment()->SetChangeMark(m_pDoc.Get());
}
}
+
int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
CXFA_WidgetAcc* pWidgetAcc) {
if (!pParam)
@@ -300,7 +300,6 @@ int32_t CXFA_FFDocView::ProcessWidgetEvent(CXFA_EventParam* pParam,
CXFA_FFWidgetHandler* CXFA_FFDocView::GetWidgetHandler() {
if (!m_pWidgetHandler)
m_pWidgetHandler = pdfium::MakeUnique<CXFA_FFWidgetHandler>(this);
-
return m_pWidgetHandler.get();
}
@@ -319,7 +318,7 @@ CXFA_FFWidget* CXFA_FFDocView::GetFocusWidget() const {
void CXFA_FFDocView::KillFocus() {
if (m_pFocusWidget &&
(m_pFocusWidget->GetStatus() & XFA_WidgetStatus_Focused)) {
- (m_pFocusWidget)->OnKillFocus(nullptr);
+ m_pFocusWidget->OnKillFocus(nullptr);
}
m_pFocusAcc = nullptr;
m_pFocusWidget = nullptr;
@@ -429,6 +428,7 @@ static int32_t XFA_ProcessEvent(CXFA_FFDocView* pDocView,
pWidgetAcc->ProcessEvent(gs_EventActivity[pParam->m_eType], pParam);
return iRet;
}
+
int32_t CXFA_FFDocView::ExecEventActivityByDeepFirst(CXFA_Node* pFormNode,
XFA_EVENTTYPE eEventType,
bool bIsFormReady,
@@ -492,9 +492,9 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
uint32_t dwStyle = XFA_RESOLVENODE_Children | XFA_RESOLVENODE_Properties |
XFA_RESOLVENODE_Siblings | XFA_RESOLVENODE_Parent;
CXFA_ScriptContext* pScriptContext = m_pDoc->GetXFADoc()->GetScriptContext();
- if (!pScriptContext) {
+ if (!pScriptContext)
return nullptr;
- }
+
CXFA_Node* refNode = nullptr;
if (pRefWidgetAcc) {
refNode = pRefWidgetAcc->GetNode();
@@ -505,9 +505,9 @@ CXFA_WidgetAcc* CXFA_FFDocView::GetWidgetAccByName(
XFA_RESOLVENODE_RS resoveNodeRS;
int32_t iRet = pScriptContext->ResolveObjects(
refNode, wsExpression.AsStringC(), resoveNodeRS, dwStyle);
- if (iRet < 1) {
+ if (iRet < 1)
return nullptr;
- }
+
if (resoveNodeRS.dwFlags == XFA_RESOVENODE_RSTYPE_Nodes) {
CXFA_Node* pNode = resoveNodeRS.objects.front()->AsNode();
if (pNode)
@@ -525,15 +525,19 @@ void CXFA_FFDocView::OnPageEvent(CXFA_ContainerLayoutItem* pSender,
void CXFA_FFDocView::LockUpdate() {
m_iLock++;
}
+
void CXFA_FFDocView::UnlockUpdate() {
m_iLock--;
}
+
bool CXFA_FFDocView::IsUpdateLocked() {
return m_iLock > 0;
}
+
void CXFA_FFDocView::ClearInvalidateList() {
m_mapPageInvalidate.clear();
}
+
void CXFA_FFDocView::AddInvalidateRect(CXFA_FFWidget* pWidget,
const CFX_RectF& rtInvalidate) {
AddInvalidateRect(pWidget->GetPageView(), rtInvalidate);
@@ -640,34 +644,32 @@ void CXFA_FFDocView::AddCalculateNodeNotify(CXFA_Node* pNodeChange) {
}
}
-void CXFA_FFDocView::RunCalculateRecursive(int32_t& iIndex) {
- while (iIndex < pdfium::CollectionSize<int32_t>(m_CalculateAccs)) {
- CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[iIndex];
+size_t CXFA_FFDocView::RunCalculateRecursive(size_t index) {
+ while (index < m_CalculateAccs.size()) {
+ CXFA_WidgetAcc* pCurAcc = m_CalculateAccs[index];
AddCalculateNodeNotify(pCurAcc->GetNode());
int32_t iRefCount =
(int32_t)(uintptr_t)pCurAcc->GetNode()->GetUserData(XFA_CalcRefCount);
iRefCount++;
pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount,
(void*)(uintptr_t)iRefCount);
- if (iRefCount > 11) {
+ if (iRefCount > 11)
break;
- }
- if ((pCurAcc->ProcessCalculate()) == XFA_EVENTERROR_Success) {
+
+ if (pCurAcc->ProcessCalculate() == XFA_EVENTERROR_Success)
AddValidateWidget(pCurAcc);
- }
- iIndex++;
- RunCalculateRecursive(iIndex);
+
+ index = RunCalculateRecursive(++index);
}
+ return index;
}
int32_t CXFA_FFDocView::RunCalculateWidgets() {
- if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc.Get())) {
+ if (!m_pDoc->GetDocEnvironment()->IsCalculationsEnabled(m_pDoc.Get()))
return XFA_EVENTERROR_Disabled;
- }
- int32_t iCounts = pdfium::CollectionSize<int32_t>(m_CalculateAccs);
- int32_t iIndex = 0;
- if (iCounts > 0)
- RunCalculateRecursive(iIndex);
+
+ if (!m_CalculateAccs.empty())
+ RunCalculateRecursive(0);
for (CXFA_WidgetAcc* pCurAcc : m_CalculateAccs)
pCurAcc->GetNode()->SetUserData(XFA_CalcRefCount, (void*)(uintptr_t)0);
diff --git a/xfa/fxfa/cxfa_ffdocview.h b/xfa/fxfa/cxfa_ffdocview.h
index 3164bcfb6a..314ce29393 100644
--- a/xfa/fxfa/cxfa_ffdocview.h
+++ b/xfa/fxfa/cxfa_ffdocview.h
@@ -49,8 +49,8 @@ class CXFA_FFDocView {
void StopLayout();
int32_t GetLayoutStatus();
void UpdateDocView();
- int32_t CountPageViews();
- CXFA_FFPageView* GetPageView(int32_t nIndex);
+ int32_t CountPageViews() const;
+ CXFA_FFPageView* GetPageView(int32_t nIndex) const;
void ResetWidgetData(CXFA_WidgetAcc* pWidgetAcc);
int32_t ProcessWidgetEvent(CXFA_EventParam* pParam,
@@ -111,7 +111,7 @@ class CXFA_FFDocView {
void RunBindItems();
bool InitCalculate(CXFA_Node* pNode);
void InitLayout(CXFA_Node* pNode);
- void RunCalculateRecursive(int32_t& iIndex);
+ size_t RunCalculateRecursive(size_t index);
void ShowNullTestMsg();
bool ResetSingleWidgetAccData(CXFA_WidgetAcc* pWidgetAcc);
CXFA_Node* GetRootSubform();
diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp
index 2437c53cd3..0bc808f538 100644
--- a/xfa/fxfa/cxfa_ffwidget.cpp
+++ b/xfa/fxfa/cxfa_ffwidget.cpp
@@ -184,10 +184,6 @@ bool CXFA_FFWidget::GetCaptionText(CFX_WideString& wsCap) {
return true;
}
-bool CXFA_FFWidget::IsFocused() {
- return !!(m_dwStatus & XFA_WidgetStatus_Focused);
-}
-
bool CXFA_FFWidget::OnMouseEnter() {
return false;
}
diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h
index b7bb123bda..29161403c2 100644
--- a/xfa/fxfa/cxfa_ffwidget.h
+++ b/xfa/fxfa/cxfa_ffwidget.h
@@ -160,7 +160,7 @@ class CXFA_FFWidget : public CXFA_ContentLayoutItem {
void InvalidateWidget(const CFX_RectF* pRect = nullptr);
void AddInvalidateRect(const CFX_RectF* pRect = nullptr);
bool GetCaptionText(CFX_WideString& wsCap);
- bool IsFocused();
+ bool IsFocused() const { return !!(m_dwStatus & XFA_WidgetStatus_Focused); }
CFX_PointF Rotate2Normal(const CFX_PointF& point);
CFX_Matrix GetRotateMatrix();
bool IsLayoutRectEmpty();
diff --git a/xfa/fxfa/parser/cxfa_localevalue.cpp b/xfa/fxfa/parser/cxfa_localevalue.cpp
index 983d1ef72f..5b5c27f1d4 100644
--- a/xfa/fxfa/parser/cxfa_localevalue.cpp
+++ b/xfa/fxfa/parser/cxfa_localevalue.cpp
@@ -490,16 +490,10 @@ bool CXFA_LocaleValue::ValidateCanonicalDate(const CFX_WideString& wsDate,
return false;
if (wYear < 1900 || wYear > 2029)
return false;
- if (wMonth < 1 || wMonth > 12) {
- if (wMonth == 0 && nLen == wCountY)
- return true;
- return false;
- }
- if (wDay < 1) {
- if (wDay == 0 && (nLen == wCountY + wCountM))
- return true;
- return false;
- }
+ if (wMonth < 1 || wMonth > 12)
+ return wMonth == 0 && nLen == wCountY;
+ if (wDay < 1)
+ return wDay == 0 && (nLen == wCountY + wCountM);
if (wMonth == 2) {
if (wYear % 400 == 0 || (wYear % 100 != 0 && wYear % 4 == 0)) {
if (wDay > 29)