diff options
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_boxdata.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_captiondata.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_captiondata.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_datadata.cpp | 6 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_margin.cpp | 32 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_margin.h | 10 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_margindata.cpp | 41 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_margindata.h | 30 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 25 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.h | 4 |
11 files changed, 68 insertions, 102 deletions
diff --git a/xfa/fxfa/parser/cxfa_boxdata.cpp b/xfa/fxfa/parser/cxfa_boxdata.cpp index 6e27c71e56..31fefbf93d 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.cpp +++ b/xfa/fxfa/parser/cxfa_boxdata.cpp @@ -139,10 +139,9 @@ CXFA_FillData CXFA_BoxData::GetFillData(bool bModified) const { return CXFA_FillData(pFillNode); } -CXFA_MarginData CXFA_BoxData::GetMarginData() const { - return CXFA_MarginData( - m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false) - : nullptr); +CXFA_Margin* CXFA_BoxData::GetMargin() const { + return m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false) + : nullptr; } std::tuple<XFA_AttributeEnum, bool, float> CXFA_BoxData::Get3DStyle() const { diff --git a/xfa/fxfa/parser/cxfa_boxdata.h b/xfa/fxfa/parser/cxfa_boxdata.h index 38a7faa38c..c44065f67e 100644 --- a/xfa/fxfa/parser/cxfa_boxdata.h +++ b/xfa/fxfa/parser/cxfa_boxdata.h @@ -14,8 +14,8 @@ #include "xfa/fxfa/parser/cxfa_datadata.h" #include "xfa/fxfa/parser/cxfa_edgedata.h" #include "xfa/fxfa/parser/cxfa_filldata.h" -#include "xfa/fxfa/parser/cxfa_margindata.h" +class CXFA_Margin; class CXFA_Node; class CXFA_BoxData : public CXFA_DataData { @@ -32,7 +32,7 @@ class CXFA_BoxData : public CXFA_DataData { int32_t CountEdges() const; CXFA_EdgeData GetEdgeData(int32_t nIndex) const; CXFA_FillData GetFillData(bool bModified) const; - CXFA_MarginData GetMarginData() const; + CXFA_Margin* GetMargin() const; std::vector<CXFA_StrokeData> GetStrokes() const; diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp index 59dbb2b008..276d10c354 100644 --- a/xfa/fxfa/parser/cxfa_captiondata.cpp +++ b/xfa/fxfa/parser/cxfa_captiondata.cpp @@ -39,10 +39,9 @@ float CXFA_CaptionData::GetReserve() const { .ToUnit(XFA_Unit::Pt); } -CXFA_MarginData CXFA_CaptionData::GetMarginData() const { - return CXFA_MarginData( - m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false) - : nullptr); +CXFA_Margin* CXFA_CaptionData::GetMargin() const { + return m_pNode ? m_pNode->GetChild<CXFA_Margin>(0, XFA_Element::Margin, false) + : nullptr; } CXFA_FontData CXFA_CaptionData::GetFontData() const { diff --git a/xfa/fxfa/parser/cxfa_captiondata.h b/xfa/fxfa/parser/cxfa_captiondata.h index 119c34e4b1..4b526b6754 100644 --- a/xfa/fxfa/parser/cxfa_captiondata.h +++ b/xfa/fxfa/parser/cxfa_captiondata.h @@ -9,8 +9,8 @@ #include "xfa/fxfa/parser/cxfa_datadata.h" #include "xfa/fxfa/parser/cxfa_fontdata.h" -#include "xfa/fxfa/parser/cxfa_margindata.h" +class CXFA_Margin; class CXFA_Node; class CXFA_Value; @@ -22,7 +22,7 @@ class CXFA_CaptionData : public CXFA_DataData { bool IsHidden() const; XFA_AttributeEnum GetPlacementType() const; float GetReserve() const; - CXFA_MarginData GetMarginData() const; + CXFA_Margin* GetMargin() const; CXFA_FontData GetFontData() const; CXFA_Value* GetValue() const; }; diff --git a/xfa/fxfa/parser/cxfa_datadata.cpp b/xfa/fxfa/parser/cxfa_datadata.cpp index b2c8119639..76a4651d0d 100644 --- a/xfa/fxfa/parser/cxfa_datadata.cpp +++ b/xfa/fxfa/parser/cxfa_datadata.cpp @@ -71,9 +71,5 @@ XFA_Element CXFA_DataData::GetElementType() const { pdfium::Optional<float> CXFA_DataData::TryMeasureAsFloat( XFA_Attribute attr) const { - pdfium::Optional<CXFA_Measurement> measure = - m_pNode->JSObject()->TryMeasure(attr, false); - if (measure) - return {measure->ToUnit(XFA_Unit::Pt)}; - return {}; + return m_pNode->JSObject()->TryMeasureAsFloat(attr); } diff --git a/xfa/fxfa/parser/cxfa_margin.cpp b/xfa/fxfa/parser/cxfa_margin.cpp index 6a50d13e4d..6dd4d39ee4 100644 --- a/xfa/fxfa/parser/cxfa_margin.cpp +++ b/xfa/fxfa/parser/cxfa_margin.cpp @@ -39,3 +39,35 @@ CXFA_Margin::CXFA_Margin(CXFA_Document* doc, XFA_PacketType packet) pdfium::MakeUnique<CJX_Margin>(this)) {} CXFA_Margin::~CXFA_Margin() {} + +float CXFA_Margin::GetLeftInset() const { + return TryLeftInset().value_or(0); +} + +float CXFA_Margin::GetTopInset() const { + return TryTopInset().value_or(0); +} + +float CXFA_Margin::GetRightInset() const { + return TryRightInset().value_or(0); +} + +float CXFA_Margin::GetBottomInset() const { + return TryBottomInset().value_or(0); +} + +pdfium::Optional<float> CXFA_Margin::TryLeftInset() const { + return JSObject()->TryMeasureAsFloat(XFA_Attribute::LeftInset); +} + +pdfium::Optional<float> CXFA_Margin::TryTopInset() const { + return JSObject()->TryMeasureAsFloat(XFA_Attribute::TopInset); +} + +pdfium::Optional<float> CXFA_Margin::TryRightInset() const { + return JSObject()->TryMeasureAsFloat(XFA_Attribute::RightInset); +} + +pdfium::Optional<float> CXFA_Margin::TryBottomInset() const { + return JSObject()->TryMeasureAsFloat(XFA_Attribute::BottomInset); +} diff --git a/xfa/fxfa/parser/cxfa_margin.h b/xfa/fxfa/parser/cxfa_margin.h index 3ac7657d17..621704ab7a 100644 --- a/xfa/fxfa/parser/cxfa_margin.h +++ b/xfa/fxfa/parser/cxfa_margin.h @@ -13,6 +13,16 @@ class CXFA_Margin : public CXFA_Node { public: CXFA_Margin(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Margin() override; + + float GetLeftInset() const; + float GetTopInset() const; + float GetRightInset() const; + float GetBottomInset() const; + + pdfium::Optional<float> TryLeftInset() const; + pdfium::Optional<float> TryTopInset() const; + pdfium::Optional<float> TryRightInset() const; + pdfium::Optional<float> TryBottomInset() const; }; #endif // XFA_FXFA_PARSER_CXFA_MARGIN_H_ diff --git a/xfa/fxfa/parser/cxfa_margindata.cpp b/xfa/fxfa/parser/cxfa_margindata.cpp deleted file mode 100644 index c8baf2d05a..0000000000 --- a/xfa/fxfa/parser/cxfa_margindata.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "xfa/fxfa/parser/cxfa_margindata.h" - -CXFA_MarginData::CXFA_MarginData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} - -float CXFA_MarginData::GetLeftInset() const { - return TryLeftInset().value_or(0); -} - -float CXFA_MarginData::GetTopInset() const { - return TryTopInset().value_or(0); -} - -float CXFA_MarginData::GetRightInset() const { - return TryRightInset().value_or(0); -} - -float CXFA_MarginData::GetBottomInset() const { - return TryBottomInset().value_or(0); -} - -pdfium::Optional<float> CXFA_MarginData::TryLeftInset() const { - return TryMeasureAsFloat(XFA_Attribute::LeftInset); -} - -pdfium::Optional<float> CXFA_MarginData::TryTopInset() const { - return TryMeasureAsFloat(XFA_Attribute::TopInset); -} - -pdfium::Optional<float> CXFA_MarginData::TryRightInset() const { - return TryMeasureAsFloat(XFA_Attribute::RightInset); -} - -pdfium::Optional<float> CXFA_MarginData::TryBottomInset() const { - return TryMeasureAsFloat(XFA_Attribute::BottomInset); -} diff --git a/xfa/fxfa/parser/cxfa_margindata.h b/xfa/fxfa/parser/cxfa_margindata.h deleted file mode 100644 index 069aa7cc2d..0000000000 --- a/xfa/fxfa/parser/cxfa_margindata.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXFA_PARSER_CXFA_MARGINDATA_H_ -#define XFA_FXFA_PARSER_CXFA_MARGINDATA_H_ - -#include "core/fxcrt/fx_system.h" -#include "xfa/fxfa/parser/cxfa_datadata.h" - -class CXFA_Node; - -class CXFA_MarginData : public CXFA_DataData { - public: - explicit CXFA_MarginData(CXFA_Node* pNode); - - float GetLeftInset() const; - float GetTopInset() const; - float GetRightInset() const; - float GetBottomInset() const; - - pdfium::Optional<float> TryLeftInset() const; - pdfium::Optional<float> TryTopInset() const; - pdfium::Optional<float> TryRightInset() const; - pdfium::Optional<float> TryBottomInset() const; -}; - -#endif // XFA_FXFA_PARSER_CXFA_MARGINDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index ba10f244d3..0f31fbafaa 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -275,9 +275,9 @@ CXFA_FontData CXFA_WidgetData::GetFontData(bool bModified) { 0, XFA_Element::Font, bModified)); } -CXFA_MarginData CXFA_WidgetData::GetMarginData() { - return CXFA_MarginData(m_pNode->JSObject()->GetProperty<CXFA_Margin>( - 0, XFA_Element::Margin, false)); +CXFA_Margin* CXFA_WidgetData::GetMargin() { + return m_pNode->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin, + false); } CXFA_Para* CXFA_WidgetData::GetPara() { @@ -373,12 +373,13 @@ CXFA_BorderData CXFA_WidgetData::GetUIBorderData() { CFX_RectF CXFA_WidgetData::GetUIMargin() { CXFA_Node* pUIChild = GetUIChild(); - CXFA_MarginData mgUI = - CXFA_MarginData(pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Margin>( - 0, XFA_Element::Margin, false) - : nullptr); + CXFA_Margin* mgUI = nullptr; + if (pUIChild) { + mgUI = pUIChild->JSObject()->GetProperty<CXFA_Margin>( + 0, XFA_Element::Margin, false); + } - if (!mgUI.HasValidNode()) + if (!mgUI) return CFX_RectF(); CXFA_BorderData borderData = GetUIBorderData(); @@ -387,10 +388,10 @@ CFX_RectF CXFA_WidgetData::GetUIMargin() { return CFX_RectF(); } - pdfium::Optional<float> left = mgUI.TryLeftInset(); - pdfium::Optional<float> top = mgUI.TryTopInset(); - pdfium::Optional<float> right = mgUI.TryRightInset(); - pdfium::Optional<float> bottom = mgUI.TryBottomInset(); + pdfium::Optional<float> left = mgUI->TryLeftInset(); + pdfium::Optional<float> top = mgUI->TryTopInset(); + pdfium::Optional<float> right = mgUI->TryRightInset(); + pdfium::Optional<float> bottom = mgUI->TryBottomInset(); if (borderData.HasValidNode()) { bool bVisible = false; float fThickness = 0; diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index e7016bda91..e2dbfbfafd 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -19,7 +19,6 @@ #include "xfa/fxfa/parser/cxfa_captiondata.h" #include "xfa/fxfa/parser/cxfa_datadata.h" #include "xfa/fxfa/parser/cxfa_fontdata.h" -#include "xfa/fxfa/parser/cxfa_margindata.h" enum XFA_CHECKSTATE { XFA_CHECKSTATE_On = 0, @@ -35,6 +34,7 @@ enum XFA_VALUEPICTURE { }; class CXFA_Calculate; +class CXFA_Margin; class CXFA_Node; class CXFA_Para; class CXFA_Validate; @@ -61,7 +61,7 @@ class CXFA_WidgetData : public CXFA_DataData { CXFA_BorderData GetBorderData(bool bModified); CXFA_CaptionData GetCaptionData(); CXFA_FontData GetFontData(bool bModified); - CXFA_MarginData GetMarginData(); + CXFA_Margin* GetMargin(); CXFA_Para* GetPara(); CXFA_Value* GetDefaultValue(); CXFA_Value* GetFormValue(); |