summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-22 21:09:48 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-22 21:09:48 +0000
commit19991292768336013649c61dd56976d0698aa804 (patch)
tree5aeb7b6734b7627bd86ebe94086ef7d5b6640527 /xfa
parentec06e1186d0dc1b5bcac6a0d73c5d51e8a4682df (diff)
downloadpdfium-19991292768336013649c61dd56976d0698aa804.tar.xz
Convert CXFA_TextProvider to use a CXFA_Node
This CL changes CXFA_TextProvider to accept a CXFA_Node instead of a CXFA_WidgetAcc. The internal uses were updated as needed. Change-Id: Iaa9e4024371a3ae9521caf1444b298fb3710f829 Reviewed-on: https://pdfium-review.googlesource.com/23390 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_ffpushbutton.cpp4
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp44
-rw-r--r--xfa/fxfa/cxfa_textprovider.h10
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp6
4 files changed, 29 insertions, 35 deletions
diff --git a/xfa/fxfa/cxfa_ffpushbutton.cpp b/xfa/fxfa/cxfa_ffpushbutton.cpp
index fdf7512d08..d4d591f87a 100644
--- a/xfa/fxfa/cxfa_ffpushbutton.cpp
+++ b/xfa/fxfa/cxfa_ffpushbutton.cpp
@@ -144,7 +144,7 @@ void CXFA_FFPushButton::LoadHighlightCaption() {
if (m_pNode->GetWidgetAcc()->HasButtonRollover()) {
if (!m_pRollProvider) {
m_pRollProvider = pdfium::MakeUnique<CXFA_TextProvider>(
- m_pNode->GetWidgetAcc(), XFA_TEXTPROVIDERTYPE_Rollover);
+ m_pNode.Get(), XFA_TEXTPROVIDERTYPE_Rollover);
}
m_pRolloverTextLayout =
pdfium::MakeUnique<CXFA_TextLayout>(GetDoc(), m_pRollProvider.get());
@@ -153,7 +153,7 @@ void CXFA_FFPushButton::LoadHighlightCaption() {
if (m_pNode->GetWidgetAcc()->HasButtonDown()) {
if (!m_pDownProvider) {
m_pDownProvider = pdfium::MakeUnique<CXFA_TextProvider>(
- m_pNode->GetWidgetAcc(), XFA_TEXTPROVIDERTYPE_Down);
+ m_pNode.Get(), XFA_TEXTPROVIDERTYPE_Down);
}
m_pDownTextLayout =
pdfium::MakeUnique<CXFA_TextLayout>(GetDoc(), m_pDownProvider.get());
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index 6e5db65b57..9ea083831f 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -28,6 +28,7 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/cxfa_fontmgr.h"
#include "xfa/fxfa/cxfa_fwladapterwidgetmgr.h"
+#include "xfa/fxfa/cxfa_widgetacc.h"
#include "xfa/fxfa/parser/cxfa_caption.h"
#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_items.h"
@@ -43,9 +44,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
bRichText = false;
if (m_eType == XFA_TEXTPROVIDERTYPE_Text) {
- CXFA_Node* pElementNode = m_pWidgetAcc->GetNode();
CXFA_Value* pValueNode =
- pElementNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
+ m_pNode->GetChild<CXFA_Value>(0, XFA_Element::Value, false);
if (!pValueNode)
return nullptr;
@@ -60,7 +60,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
}
if (m_eType == XFA_TEXTPROVIDERTYPE_Datasets) {
- CXFA_Node* pBind = m_pWidgetAcc->GetNode()->GetBindData();
+ CXFA_Node* pBind = m_pNode->GetBindData();
CFX_XMLNode* pXMLNode = pBind->GetXMLMappingNode();
ASSERT(pXMLNode);
for (CFX_XMLNode* pXMLChild =
@@ -78,8 +78,7 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
if (m_eType == XFA_TEXTPROVIDERTYPE_Caption) {
CXFA_Caption* pCaptionNode =
- m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(0, XFA_Element::Caption,
- false);
+ m_pNode->GetChild<CXFA_Caption>(0, XFA_Element::Caption, false);
if (!pCaptionNode)
return nullptr;
@@ -98,8 +97,8 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
return pChildNode;
}
- CXFA_Items* pItemNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Items>(
- 0, XFA_Element::Items, false);
+ CXFA_Items* pItemNode =
+ m_pNode->GetChild<CXFA_Items>(0, XFA_Element::Items, false);
if (!pItemNode)
return nullptr;
@@ -118,28 +117,28 @@ CXFA_Node* CXFA_TextProvider::GetTextNode(bool& bRichText) {
CXFA_Para* CXFA_TextProvider::GetParaIfExists() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
- return m_pWidgetAcc->GetNode()->GetParaIfExists();
+ return m_pNode->GetParaIfExists();
- CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
- 0, XFA_Element::Caption, false);
+ CXFA_Caption* pNode =
+ m_pNode->GetChild<CXFA_Caption>(0, XFA_Element::Caption, false);
return pNode->GetChild<CXFA_Para>(0, XFA_Element::Para, false);
}
CXFA_Font* CXFA_TextProvider::GetFontIfExists() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
- return m_pWidgetAcc->GetNode()->GetFontIfExists();
+ return m_pNode->GetFontIfExists();
- CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
- 0, XFA_Element::Caption, false);
+ CXFA_Caption* pNode =
+ m_pNode->GetChild<CXFA_Caption>(0, XFA_Element::Caption, false);
CXFA_Font* font = pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false);
- return font ? font : m_pWidgetAcc->GetNode()->GetFontIfExists();
+ return font ? font : m_pNode->GetFontIfExists();
}
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
- XFA_Element eType = m_pWidgetAcc->GetNode()->GetUIType();
+ XFA_Element eType = m_pNode->GetUIType();
if (eType != XFA_Element::CheckButton)
return false;
- return !m_pWidgetAcc->GetNode()->TryWidth();
+ return !m_pNode->TryWidth();
}
bool CXFA_TextProvider::GetEmbbedObj(bool bURI,
@@ -152,11 +151,9 @@ bool CXFA_TextProvider::GetEmbbedObj(bool bURI,
if (!bURI)
return false;
- CXFA_Node* pWidgetNode = m_pWidgetAcc->GetNode();
- CXFA_Node* pParent = pWidgetNode->GetParent();
- CXFA_Document* pDocument = pWidgetNode->GetDocument();
+ CXFA_Node* pParent = m_pNode->GetParent();
+ CXFA_Document* pDocument = m_pNode->GetDocument();
CXFA_Node* pIDNode = nullptr;
- CXFA_WidgetAcc* pEmbAcc = nullptr;
if (pParent)
pIDNode = pDocument->GetNodeByID(pParent, wsAttr.AsStringView());
@@ -165,12 +162,9 @@ bool CXFA_TextProvider::GetEmbbedObj(bool bURI,
ToNode(pDocument->GetXFAObject(XFA_HASHCODE_Form)),
wsAttr.AsStringView());
}
- if (pIDNode)
- pEmbAcc = pIDNode->IsWidgetReady() ? pIDNode->GetWidgetAcc() : nullptr;
-
- if (!pEmbAcc)
+ if (!pIDNode || !pIDNode->IsWidgetReady())
return false;
- wsValue = pEmbAcc->GetValue(XFA_VALUEPICTURE_Display);
+ wsValue = pIDNode->GetWidgetAcc()->GetValue(XFA_VALUEPICTURE_Display);
return true;
}
diff --git a/xfa/fxfa/cxfa_textprovider.h b/xfa/fxfa/cxfa_textprovider.h
index 3431c9a30c..7746dc7486 100644
--- a/xfa/fxfa/cxfa_textprovider.h
+++ b/xfa/fxfa/cxfa_textprovider.h
@@ -9,7 +9,7 @@
#include "core/fxcrt/fx_string.h"
#include "xfa/fxfa/cxfa_textlayout.h"
-#include "xfa/fxfa/cxfa_widgetacc.h"
+#include "xfa/fxfa/parser/cxfa_node.h"
class CXFA_Font;
class CXFA_Node;
@@ -24,9 +24,9 @@ enum XFA_TEXTPROVIDERTYPE {
class CXFA_TextProvider {
public:
- CXFA_TextProvider(CXFA_WidgetAcc* pWidgetAcc, XFA_TEXTPROVIDERTYPE eType)
- : m_pWidgetAcc(pWidgetAcc), m_eType(eType) {
- ASSERT(m_pWidgetAcc);
+ CXFA_TextProvider(CXFA_Node* pNode, XFA_TEXTPROVIDERTYPE eType)
+ : m_pNode(pNode), m_eType(eType) {
+ ASSERT(m_pNode);
}
~CXFA_TextProvider() {}
@@ -40,7 +40,7 @@ class CXFA_TextProvider {
WideString& wsValue);
private:
- CXFA_WidgetAcc* m_pWidgetAcc;
+ CXFA_Node* m_pNode;
XFA_TEXTPROVIDERTYPE m_eType;
};
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 4fa744a098..f10c2155a7 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -221,8 +221,8 @@ class CXFA_TextLayoutData : public CXFA_WidgetLayoutData {
if (m_pTextLayout)
return;
- m_pTextProvider =
- pdfium::MakeUnique<CXFA_TextProvider>(pAcc, XFA_TEXTPROVIDERTYPE_Text);
+ m_pTextProvider = pdfium::MakeUnique<CXFA_TextProvider>(
+ pAcc->GetNode(), XFA_TEXTPROVIDERTYPE_Text);
m_pTextLayout =
pdfium::MakeUnique<CXFA_TextLayout>(doc, m_pTextProvider.get());
}
@@ -275,7 +275,7 @@ class CXFA_FieldLayoutData : public CXFA_WidgetLayoutData {
return false;
m_pCapTextProvider = pdfium::MakeUnique<CXFA_TextProvider>(
- pAcc, XFA_TEXTPROVIDERTYPE_Caption);
+ pAcc->GetNode(), XFA_TEXTPROVIDERTYPE_Caption);
m_pCapTextLayout =
pdfium::MakeUnique<CXFA_TextLayout>(doc, m_pCapTextProvider.get());
return true;