From c30eb662f8a8ea20564e887182e422fd5c4e2099 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Mon, 29 Jan 2018 21:17:57 +0000 Subject: Cleanup CXFA_Node visibility Make methods private or remove if not needed. Change-Id: I2f9f718ba08a4b49332c896d2385ec60cf9cf01b Reviewed-on: https://pdfium-review.googlesource.com/24490 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_node.cpp | 12 +++----- xfa/fxfa/parser/cxfa_node.h | 71 ++++++++++++++++++------------------------- 2 files changed, 33 insertions(+), 50 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index c97a0f3bfd..1b53b6b7b0 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -813,7 +813,7 @@ CXFA_Node* CXFA_Node::GetBindData() { } std::vector>* CXFA_Node::GetBindItems() { - return GetBindingNodes(); + return &binding_nodes_; } int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { @@ -843,7 +843,7 @@ int32_t CXFA_Node::AddBindItem(CXFA_Node* pFormNode) { std::vector> items; items.emplace_back(pOldFormItem); items.emplace_back(pFormNode); - SetBindingNodes(std::move(items)); + binding_nodes_ = std::move(items); m_uNodeFlags |= XFA_NodeFlag_BindFormItems; return 2; @@ -3024,11 +3024,6 @@ void CXFA_Node::GetImageEditDpi(int32_t& iImageXDpi, int32_t& iImageYDpi) { iImageYDpi = pData->m_iImageYDpi; } -void CXFA_Node::LoadText(CXFA_FFDoc* doc) { - InitLayoutData(); - static_cast(m_pLayoutData.get())->LoadText(doc, this); -} - float CXFA_Node::CalculateWidgetAutoWidth(float fWidthCalc) { CXFA_Margin* margin = GetMarginIfExists(); if (margin) @@ -3426,7 +3421,8 @@ void CXFA_Node::InitLayoutData() { void CXFA_Node::StartTextLayout(CXFA_FFDoc* doc, float& fCalcWidth, float& fCalcHeight) { - LoadText(doc); + InitLayoutData(); + static_cast(m_pLayoutData.get())->LoadText(doc, this); CXFA_TextLayout* pTextLayout = static_cast(m_pLayoutData.get())->GetTextLayout(); diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 3c532b0dc8..130422e59c 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -103,8 +103,6 @@ class CXFA_Node : public CXFA_Object { ~CXFA_Node() override; - bool IsValidInPacket(XFA_PacketType packet) const; - bool HasProperty(XFA_Element property) const; bool HasPropertyFlags(XFA_Element property, uint8_t flags) const; uint8_t PropertyOccuranceCount(XFA_Element property) const; @@ -130,7 +128,6 @@ class CXFA_Node : public CXFA_Object { bool bMoveDataBindingNodes); bool IsInitialized() const { return HasFlag(XFA_NodeFlag_Initialized); } - bool IsOwnXMLNode() const { return HasFlag(XFA_NodeFlag_OwnXMLNode); } bool IsUserInteractive() const { return HasFlag(XFA_NodeFlag_UserInteractive); } @@ -139,31 +136,19 @@ class CXFA_Node : public CXFA_Object { return HasFlag(XFA_NodeFlag_LayoutGeneratedNode); } - void SetBindingNodes(std::vector> nodes) { - binding_nodes_ = std::move(nodes); - } - std::vector>* GetBindingNodes() { - return &binding_nodes_; - } void SetBindingNode(CXFA_Node* node) { binding_nodes_.clear(); if (node) binding_nodes_.emplace_back(node); } - CXFA_Node* GetBindingNode() const { - if (binding_nodes_.empty()) - return nullptr; - return binding_nodes_[0].Get(); - } + // TODO(dsinclair): This should not be needed. Nodes should get un-bound when // they're deleted instead of us pointing to bad objects. void ReleaseBindingNodes(); - bool BindsFormItems() const { return HasFlag(XFA_NodeFlag_BindFormItems); } bool HasRemovedChildren() const { return HasFlag(XFA_NodeFlag_HasRemovedChildren); } - bool NeedsInitApp() const { return HasFlag(XFA_NodeFlag_NeedsInitApp); } bool IsAttributeInXML(); bool IsFormContainer() const { @@ -237,24 +222,21 @@ class CXFA_Node : public CXFA_Object { CXFA_Node* GetInstanceMgrOfSubform(); - CXFA_Occur* GetOccurIfExists(); - Optional GetDefaultBoolean(XFA_Attribute attr) const; Optional GetDefaultInteger(XFA_Attribute attr) const; Optional GetDefaultMeasurement(XFA_Attribute attr) const; Optional GetDefaultCData(XFA_Attribute attr) const; Optional GetDefaultEnum(XFA_Attribute attr) const; - void SyncValue(const WideString& wsValue, bool bNotify); - bool IsOpenAccess(); + CXFA_Occur* GetOccurIfExists(); CXFA_Border* GetBorderIfExists() const; CXFA_Border* GetOrCreateBorderIfPossible(); CXFA_Caption* GetCaptionIfExists() const; - CXFA_Font* GetFontIfExists() const; CXFA_Font* GetOrCreateFontIfPossible(); + float GetFontSize() const; FX_ARGB GetTextColor() const; float GetLineHeight() const; @@ -265,31 +247,19 @@ class CXFA_Node : public CXFA_Object { CXFA_Validate* GetValidateIfExists() const; CXFA_Validate* GetOrCreateValidateIfPossible(); - CXFA_Value* GetDefaultValueIfExists(); CXFA_Value* GetFormValueIfExists() const; WideString GetRawValue(); - int32_t GetRotate(); - - CXFA_Bind* GetBindIfExists() const; + int32_t GetRotate(); Optional TryWidth(); - Optional TryHeight(); - Optional TryMinWidth(); - Optional TryMinHeight(); - Optional TryMaxWidth(); - Optional TryMaxHeight(); CXFA_Node* GetExclGroupIfExists(); int32_t ProcessEvent(CXFA_FFDocView* docView, XFA_AttributeEnum iActivity, CXFA_EventParam* pEventParam); - int32_t ProcessEvent(CXFA_FFDocView* docView, - CXFA_Event* event, - CXFA_EventParam* pEventParam); int32_t ProcessCalculate(CXFA_FFDocView* docView); int32_t ProcessValidate(CXFA_FFDocView* docView, int32_t iFlags); - int32_t ExecuteScript(CXFA_FFDocView* docView, CXFA_Script* script, CXFA_EventParam* pEventParam); @@ -303,14 +273,12 @@ class CXFA_Node : public CXFA_Object { CFX_RectF GetUIMargin(); CXFA_Border* GetUIBorder(); - bool IsPreNull() const { return m_bPreNull; } void SetPreNull(bool val) { m_bPreNull = val; } bool IsNull() const { return m_bIsNull; } void SetIsNull(bool val) { m_bIsNull = val; } void SetWidgetReady() { is_widget_ready_ = true; } bool IsWidgetReady() const { return is_widget_ready_; } - std::vector GetEventByActivity(XFA_AttributeEnum iActivity, bool bIsFormReady); @@ -326,8 +294,6 @@ class CXFA_Node : public CXFA_Object { bool LoadCaption(CXFA_FFDoc* doc); CXFA_TextLayout* GetCaptionTextLayout(); - - void LoadText(CXFA_FFDoc* doc); CXFA_TextLayout* GetTextLayout(); bool LoadImageImage(CXFA_FFDoc* doc); @@ -337,9 +303,6 @@ class CXFA_Node : public CXFA_Object { RetainPtr GetImageImage(); RetainPtr GetImageEditImage(); - void SetImageEdit(const WideString& wsContentType, - const WideString& wsHref, - const WideString& wsData); void SetImageImage(const RetainPtr& newImage); void SetImageEditImage(const RetainPtr& newImage); void UpdateUIDisplay(CXFA_FFDocView* docView, CXFA_FFWidget* pExcept); @@ -423,10 +386,10 @@ class CXFA_Node : public CXFA_Object { int32_t iLead, int32_t iTread) const; + protected: virtual XFA_Element GetValueNodeType() const; virtual XFA_FFWidgetType GetDefaultFFWidgetType() const; - protected: CXFA_Node(CXFA_Document* pDoc, XFA_PacketType ePacket, uint32_t validPackets, @@ -506,6 +469,30 @@ class CXFA_Node : public CXFA_Object { std::pair CreateChildUIAndValueNodesIfNeeded(); void CreateValueNodeIfNeeded(CXFA_Value* value, CXFA_Node* pUIChild); CXFA_Node* CreateUINodeIfNeeded(CXFA_Ui* ui, XFA_Element type); + bool IsValidInPacket(XFA_PacketType packet) const; + void SetImageEdit(const WideString& wsContentType, + const WideString& wsHref, + const WideString& wsData); + bool IsOwnXMLNode() const { return HasFlag(XFA_NodeFlag_OwnXMLNode); } + CXFA_Node* GetBindingNode() const { + if (binding_nodes_.empty()) + return nullptr; + return binding_nodes_[0].Get(); + } + bool BindsFormItems() const { return HasFlag(XFA_NodeFlag_BindFormItems); } + bool NeedsInitApp() const { return HasFlag(XFA_NodeFlag_NeedsInitApp); } + void SyncValue(const WideString& wsValue, bool bNotify); + CXFA_Value* GetDefaultValueIfExists(); + CXFA_Bind* GetBindIfExists() const; + + Optional TryHeight(); + Optional TryMinWidth(); + Optional TryMinHeight(); + Optional TryMaxWidth(); + Optional TryMaxHeight(); + int32_t ProcessEvent(CXFA_FFDocView* docView, + CXFA_Event* event, + CXFA_EventParam* pEventParam); const PropertyData* const m_Properties; const AttributeData* const m_Attributes; -- cgit v1.2.3