summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-08 12:28:27 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-08 17:58:37 +0000
commit2f265dbf12831dece93a6a932fd99e5737cd1afd (patch)
treeb853bbf28556893ad6abb4a9e5702ebe256a8320 /xfa/fxfa/parser
parent5dc906eeda8cef7aff368e3c8efed37c0a5b3162 (diff)
downloadpdfium-2f265dbf12831dece93a6a932fd99e5737cd1afd.tar.xz
Move proxy methods from CXFA_WidgetAcc to CXFA_Node
This CL moves methods from WidgetAcc which just proxy to CXFA_Node. Change-Id: Icf1006b4be3f91077de411ed1a571b1507117602 Reviewed-on: https://pdfium-review.googlesource.com/22391 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp127
-rw-r--r--xfa/fxfa/parser/cxfa_node.h31
-rw-r--r--xfa/fxfa/parser/xfa_utils.cpp2
3 files changed, 159 insertions, 1 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 141c9f1c6c..86d2300cb4 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -29,15 +29,24 @@
#include "xfa/fxfa/cxfa_ffwidget.h"
#include "xfa/fxfa/parser/cxfa_arraynodelist.h"
#include "xfa/fxfa/parser/cxfa_attachnodelist.h"
+#include "xfa/fxfa/parser/cxfa_bind.h"
+#include "xfa/fxfa/parser/cxfa_border.h"
+#include "xfa/fxfa/parser/cxfa_calculate.h"
+#include "xfa/fxfa/parser/cxfa_caption.h"
#include "xfa/fxfa/parser/cxfa_document.h"
+#include "xfa/fxfa/parser/cxfa_font.h"
#include "xfa/fxfa/parser/cxfa_keep.h"
#include "xfa/fxfa/parser/cxfa_layoutprocessor.h"
+#include "xfa/fxfa/parser/cxfa_margin.h"
#include "xfa/fxfa/parser/cxfa_measurement.h"
#include "xfa/fxfa/parser/cxfa_nodeiteratortemplate.h"
#include "xfa/fxfa/parser/cxfa_occur.h"
+#include "xfa/fxfa/parser/cxfa_para.h"
#include "xfa/fxfa/parser/cxfa_simple_parser.h"
#include "xfa/fxfa/parser/cxfa_subform.h"
#include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h"
+#include "xfa/fxfa/parser/cxfa_validate.h"
+#include "xfa/fxfa/parser/cxfa_value.h"
#include "xfa/fxfa/parser/xfa_basic_data.h"
#include "xfa/fxfa/parser/xfa_utils.h"
@@ -1533,3 +1542,121 @@ void CXFA_Node::SyncValue(const WideString& wsValue, bool bNotify) {
JSObject()->SetContent(wsValue, wsFormatValue, bNotify, false, true);
}
+
+WideString CXFA_Node::GetRawValue() {
+ return JSObject()->GetContent(false);
+}
+
+int32_t CXFA_Node::GetRotate() {
+ Optional<int32_t> degrees =
+ JSObject()->TryInteger(XFA_Attribute::Rotate, false);
+ return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0;
+}
+
+CXFA_Border* CXFA_Node::GetBorder(bool bModified) {
+ return JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border,
+ bModified);
+}
+
+CXFA_Caption* CXFA_Node::GetCaption() {
+ return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption, false);
+}
+
+CXFA_Font* CXFA_Node::GetFont(bool bModified) {
+ return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font, bModified);
+}
+
+float CXFA_Node::GetFontSize() {
+ CXFA_Font* font = GetFont(false);
+ float fFontSize = font ? font->GetFontSize() : 10.0f;
+ return fFontSize < 0.1f ? 10.0f : fFontSize;
+}
+
+float CXFA_Node::GetLineHeight() {
+ float fLineHeight = 0;
+ CXFA_Para* para = GetPara();
+ if (para)
+ fLineHeight = para->GetLineHeight();
+ if (fLineHeight < 1)
+ fLineHeight = GetFontSize() * 1.2f;
+ return fLineHeight;
+}
+
+FX_ARGB CXFA_Node::GetTextColor() {
+ CXFA_Font* font = GetFont(false);
+ return font ? font->GetColor() : 0xFF000000;
+}
+
+CXFA_Margin* CXFA_Node::GetMargin() {
+ return JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin, false);
+}
+
+CXFA_Para* CXFA_Node::GetPara() {
+ return JSObject()->GetProperty<CXFA_Para>(0, XFA_Element::Para, false);
+}
+
+bool CXFA_Node::IsOpenAccess() {
+ for (auto* pNode = this; pNode;
+ pNode = pNode->GetNodeItem(XFA_NODEITEM_Parent,
+ XFA_ObjectType::ContainerNode)) {
+ XFA_AttributeEnum iAcc = pNode->JSObject()->GetEnum(XFA_Attribute::Access);
+ if (iAcc != XFA_AttributeEnum::Open)
+ return false;
+ }
+ return true;
+}
+
+CXFA_Value* CXFA_Node::GetDefaultValue() {
+ CXFA_Node* pTemNode = GetTemplateNode();
+ return pTemNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value,
+ false);
+}
+
+CXFA_Value* CXFA_Node::GetFormValue() {
+ return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value, false);
+}
+
+CXFA_Calculate* CXFA_Node::GetCalculate() {
+ return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate,
+ false);
+}
+
+CXFA_Validate* CXFA_Node::GetValidate(bool bModified) {
+ return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate,
+ bModified);
+}
+
+CXFA_Bind* CXFA_Node::GetBind() {
+ return JSObject()->GetProperty<CXFA_Bind>(0, XFA_Element::Bind, false);
+}
+
+Optional<float> CXFA_Node::TryWidth() {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::W);
+}
+
+Optional<float> CXFA_Node::TryHeight() {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::H);
+}
+
+Optional<float> CXFA_Node::TryMinWidth() {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::MinW);
+}
+
+Optional<float> CXFA_Node::TryMinHeight() {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::MinH);
+}
+
+Optional<float> CXFA_Node::TryMaxWidth() {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxW);
+}
+
+Optional<float> CXFA_Node::TryMaxHeight() {
+ return JSObject()->TryMeasureAsFloat(XFA_Attribute::MaxH);
+}
+
+CXFA_Node* CXFA_Node::GetExclGroup() {
+ CXFA_Node* pExcl = GetNodeItem(XFA_NODEITEM_Parent);
+ if (!pExcl || pExcl->GetElementType() != XFA_Element::ExclGroup)
+ return nullptr;
+ return pExcl;
+}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index c8adbfe080..4def12caaf 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -218,6 +218,37 @@ class CXFA_Node : public CXFA_Object {
void SyncValue(const WideString& wsValue, bool bNotify);
+ bool IsOpenAccess();
+
+ CXFA_Border* GetBorder(bool bModified);
+ CXFA_Caption* GetCaption();
+
+ CXFA_Font* GetFont(bool bModified);
+ float GetFontSize();
+ FX_ARGB GetTextColor();
+ float GetLineHeight();
+
+ CXFA_Margin* GetMargin();
+ CXFA_Para* GetPara();
+ CXFA_Calculate* GetCalculate();
+ CXFA_Validate* GetValidate(bool bModified);
+
+ CXFA_Value* GetDefaultValue();
+ CXFA_Value* GetFormValue();
+ WideString GetRawValue();
+ int32_t GetRotate();
+
+ CXFA_Bind* GetBind();
+
+ Optional<float> TryWidth();
+ Optional<float> TryHeight();
+ Optional<float> TryMinWidth();
+ Optional<float> TryMinHeight();
+ Optional<float> TryMaxWidth();
+ Optional<float> TryMaxHeight();
+
+ CXFA_Node* GetExclGroup();
+
protected:
CXFA_Node(CXFA_Document* pDoc,
XFA_PacketType ePacket,
diff --git a/xfa/fxfa/parser/xfa_utils.cpp b/xfa/fxfa/parser/xfa_utils.cpp
index c41835f19c..3342776adb 100644
--- a/xfa/fxfa/parser/xfa_utils.cpp
+++ b/xfa/fxfa/parser/xfa_utils.cpp
@@ -457,7 +457,7 @@ CXFA_LocaleValue XFA_GetLocaleValue(CXFA_WidgetAcc* pWidgetAcc) {
iVTType = XFA_VT_NULL;
break;
}
- return CXFA_LocaleValue(iVTType, pWidgetAcc->GetRawValue(),
+ return CXFA_LocaleValue(iVTType, pWidgetAcc->GetNode()->GetRawValue(),
pWidgetAcc->GetNode()->GetDocument()->GetLocalMgr());
}