summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-04 10:26:49 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-04 16:45:31 +0000
commit8ee5207f4f792295badd21f90727e8c810e7dbdf (patch)
treebb4138654ad69cd8c3750b687f494d6fefeef803
parent72fe435e80807c91dbf8edc41d5bf3ec3c9bd9e4 (diff)
downloadpdfium-8ee5207f4f792295badd21f90727e8c810e7dbdf.tar.xz
Make CXFA_WidgetData constructor protected
This CL removes all the direct creation of CXFA_WidgetData elements and makes the constructor protected. Change-Id: I2e9aa11cab8c1e26f7cfa9fd32329f0841fab010 Reviewed-on: https://pdfium-review.googlesource.com/22251 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r--fxjs/cfxjse_formcalc_context.cpp11
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp9
-rw-r--r--xfa/fxfa/parser/cxfa_node.h1
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.cpp10
-rw-r--r--xfa/fxfa/parser/cxfa_widgetdata.h3
5 files changed, 17 insertions, 17 deletions
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index f9d130a119..47d6ce6e4f 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -477,7 +477,7 @@ IFX_Locale* LocaleFromString(CXFA_Document* pDoc,
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
ASSERT(pThisNode);
- return CXFA_WidgetData(pThisNode).GetLocale();
+ return pThisNode->GetLocale();
}
WideString FormatFromString(IFX_Locale* pLocale,
@@ -1641,8 +1641,7 @@ void CFXJSE_FormCalcContext::Time2Num(CFXJSE_Value* pThis,
if (localString.IsEmpty()) {
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
ASSERT(pThisNode);
- CXFA_WidgetData widgetData(pThisNode);
- pLocale = widgetData.GetLocale();
+ pLocale = pThisNode->GetLocale();
} else {
pLocale =
pMgr->GetLocaleByName(WideString::FromUTF8(localString.AsStringView()));
@@ -3768,8 +3767,7 @@ void CFXJSE_FormCalcContext::Format(CFXJSE_Value* pThis,
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
ASSERT(pThisNode);
- CXFA_WidgetData widgetData(pThisNode);
- IFX_Locale* pLocale = widgetData.GetLocale();
+ IFX_Locale* pLocale = pThisNode->GetLocale();
uint32_t patternType;
WideString wsPattern = WideString::FromUTF8(szPattern.AsStringView());
WideString wsValue = WideString::FromUTF8(szValue.AsStringView());
@@ -3951,8 +3949,7 @@ void CFXJSE_FormCalcContext::Parse(CFXJSE_Value* pThis,
CXFA_Node* pThisNode = ToNode(pDoc->GetScriptContext()->GetThisObject());
ASSERT(pThisNode);
- CXFA_WidgetData widgetData(pThisNode);
- IFX_Locale* pLocale = widgetData.GetLocale();
+ IFX_Locale* pLocale = pThisNode->GetLocale();
WideString wsPattern = WideString::FromUTF8(szPattern.AsStringView());
WideString wsValue = WideString::FromUTF8(szValue.AsStringView());
uint32_t patternType;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index ac1398822d..9a1dec6716 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -621,6 +621,15 @@ CXFA_WidgetData* CXFA_Node::GetContainerWidgetData() {
: nullptr;
}
+IFX_Locale* CXFA_Node::GetLocale() {
+ WideString wsLocaleName;
+ if (!GetLocaleName(wsLocaleName))
+ return nullptr;
+ if (wsLocaleName == L"ambient")
+ return GetDocument()->GetLocalMgr()->GetDefLocale();
+ return GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName);
+}
+
bool CXFA_Node::GetLocaleName(WideString& wsLocaleName) {
CXFA_Node* pForm = GetDocument()->GetXFAObject(XFA_HASHCODE_Form)->AsNode();
CXFA_Subform* pTopSubform =
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index b41a27ef01..194f870d76 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -183,6 +183,7 @@ class CXFA_Node : public CXFA_Object {
bool HasBindItem();
CXFA_WidgetData* GetWidgetData();
CXFA_WidgetData* GetContainerWidgetData();
+ IFX_Locale* GetLocale();
bool GetLocaleName(WideString& wsLocaleName);
XFA_AttributeEnum GetIntact();
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp
index 7771d33d01..68063e2a07 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.cpp
+++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp
@@ -1500,15 +1500,7 @@ WideString CXFA_WidgetData::GetPictureContent(XFA_VALUEPICTURE ePicture) {
}
IFX_Locale* CXFA_WidgetData::GetLocale() {
- if (!m_pNode)
- return nullptr;
-
- WideString wsLocaleName;
- if (!m_pNode->GetLocaleName(wsLocaleName))
- return nullptr;
- if (wsLocaleName == L"ambient")
- return m_pNode->GetDocument()->GetLocalMgr()->GetDefLocale();
- return m_pNode->GetDocument()->GetLocalMgr()->GetLocaleByName(wsLocaleName);
+ return m_pNode ? m_pNode->GetLocale() : nullptr;
}
WideString CXFA_WidgetData::GetValue(XFA_VALUEPICTURE eValueType) {
diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h
index 941eead3fd..4b11521b6f 100644
--- a/xfa/fxfa/parser/cxfa_widgetdata.h
+++ b/xfa/fxfa/parser/cxfa_widgetdata.h
@@ -44,7 +44,6 @@ class IFX_Locale;
class CXFA_WidgetData {
public:
- explicit CXFA_WidgetData(CXFA_Node* pNode);
virtual ~CXFA_WidgetData();
CXFA_Node* GetNode() const { return m_pNode; }
@@ -178,6 +177,8 @@ class CXFA_WidgetData {
void SetIsNull(bool val) { m_bIsNull = val; }
protected:
+ explicit CXFA_WidgetData(CXFA_Node* pNode);
+
CXFA_Node* m_pNode;
private: