diff options
-rw-r--r-- | BUILD.gn | 2 | ||||
-rw-r--r-- | fxjs/xfa/cjx_field.cpp | 5 | ||||
-rw-r--r-- | fxjs/xfa/cjx_object.cpp | 1 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffarc.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffdatetimeedit.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimage.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimageedit.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffline.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffrectangle.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 39 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_captiondata.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_captiondata.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_value.cpp | 36 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_value.h | 17 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_valuedata.cpp | 58 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_valuedata.h | 35 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.cpp | 22 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_widgetdata.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 39 |
20 files changed, 148 insertions, 168 deletions
@@ -2740,8 +2740,6 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_validationmessaging.h", "xfa/fxfa/parser/cxfa_value.cpp", "xfa/fxfa/parser/cxfa_value.h", - "xfa/fxfa/parser/cxfa_valuedata.cpp", - "xfa/fxfa/parser/cxfa_valuedata.h", "xfa/fxfa/parser/cxfa_variables.cpp", "xfa/fxfa/parser/cxfa_variables.h", "xfa/fxfa/parser/cxfa_version.cpp", diff --git a/fxjs/xfa/cjx_field.cpp b/fxjs/xfa/cjx_field.cpp index 059aead0f9..a3e4405a17 100644 --- a/fxjs/xfa/cjx_field.cpp +++ b/fxjs/xfa/cjx_field.cpp @@ -16,6 +16,7 @@ #include "xfa/fxfa/fxfa.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_field.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" const CJX_MethodSpec CJX_Field::MethodSpecs[] = { @@ -276,8 +277,8 @@ void CJX_Field::defaultValue(CFXJSE_Value* pValue, } CXFA_Node* pUIChild = pWidgetData->GetUIChild(); - CXFA_Node* pNode = pWidgetData->GetFormValueData().GetNode()->GetNodeItem( - XFA_NODEITEM_FirstChild); + CXFA_Node* pNode = + pWidgetData->GetFormValue()->GetNodeItem(XFA_NODEITEM_FirstChild); if (pNode && pNode->GetElementType() == XFA_Element::Decimal) { if (pUIChild->GetElementType() == XFA_Element::NumericEdit && (pNode->JSObject()->GetInteger(XFA_Attribute::FracDigits) == -1)) { diff --git a/fxjs/xfa/cjx_object.cpp b/fxjs/xfa/cjx_object.cpp index 77de53ec64..f4f3030188 100644 --- a/fxjs/xfa/cjx_object.cpp +++ b/fxjs/xfa/cjx_object.cpp @@ -28,6 +28,7 @@ #include "xfa/fxfa/parser/cxfa_object.h" #include "xfa/fxfa/parser/cxfa_occurdata.h" #include "xfa/fxfa/parser/cxfa_validate.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { diff --git a/xfa/fxfa/cxfa_ffarc.cpp b/xfa/fxfa/cxfa_ffarc.cpp index 12ab629d87..7f9e938925 100644 --- a/xfa/fxfa/cxfa_ffarc.cpp +++ b/xfa/fxfa/cxfa_ffarc.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/cxfa_ffarc.h" +#include "xfa/fxfa/parser/cxfa_value.h" + CXFA_FFArc::CXFA_FFArc(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} CXFA_FFArc::~CXFA_FFArc() {} @@ -16,8 +18,8 @@ void CXFA_FFArc::RenderWidget(CXFA_Graphics* pGS, if (!IsMatchVisibleStatus(dwStatus)) return; - CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (!valueData.HasValidNode()) + CXFA_Value* value = m_pDataAcc->GetFormValue(); + if (!value) return; CFX_RectF rtArc = GetRectWithoutRotate(); @@ -28,5 +30,5 @@ void CXFA_FFArc::RenderWidget(CXFA_Graphics* pGS, CFX_Matrix mtRotate = GetRotateMatrix(); mtRotate.Concat(matrix); - DrawBorder(pGS, valueData.GetArcData(), rtArc, mtRotate); + DrawBorder(pGS, value->GetArcData(), rtArc, mtRotate); } diff --git a/xfa/fxfa/cxfa_ffdatetimeedit.cpp b/xfa/fxfa/cxfa_ffdatetimeedit.cpp index 2fab4c8738..ddc1450b51 100644 --- a/xfa/fxfa/cxfa_ffdatetimeedit.cpp +++ b/xfa/fxfa/cxfa_ffdatetimeedit.cpp @@ -15,6 +15,7 @@ #include "xfa/fxfa/cxfa_eventparam.h" #include "xfa/fxfa/cxfa_ffdoc.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_utils.h" CXFA_FFDateTimeEdit::CXFA_FFDateTimeEdit(CXFA_WidgetAcc* pDataAcc) @@ -50,9 +51,9 @@ bool CXFA_FFDateTimeEdit::LoadWidget() { WideString wsText = m_pDataAcc->GetValue(XFA_VALUEPICTURE_Display); pWidget->SetEditText(wsText); - CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (valueData.HasValidNode()) { - switch (valueData.GetChildValueClassID()) { + CXFA_Value* value = m_pDataAcc->GetFormValue(); + if (value) { + switch (value->GetChildValueClassID()) { case XFA_Element::Date: { if (!wsText.IsEmpty()) { CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc.Get()); diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index 7a94c76a6a..159c6648b5 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -11,6 +11,7 @@ #include "xfa/fxfa/cxfa_ffdraw.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/parser/cxfa_value.h" CXFA_FFImage::CXFA_FFImage(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} @@ -64,7 +65,10 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); - XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, - m_pDataAcc->GetFormValueData().GetImageData().GetAspect(), + auto* value = m_pDataAcc->GetFormValue(); + CXFA_ImageData imageData = + value ? value->GetImageData() : CXFA_ImageData(nullptr); + + XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, imageData.GetAspect(), iImageXDpi, iImageYDpi, iHorzAlign, iVertAlign); } diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 558e597992..6d63514a18 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -18,6 +18,7 @@ #include "xfa/fxfa/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" +#include "xfa/fxfa/parser/cxfa_value.h" CXFA_FFImageEdit::CXFA_FFImageEdit(CXFA_WidgetAcc* pDataAcc) : CXFA_FFField(pDataAcc), m_pOldDelegate(nullptr) {} @@ -77,9 +78,9 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, } XFA_AttributeEnum iAspect = XFA_AttributeEnum::Fit; - CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (valueData.HasValidNode()) { - CXFA_ImageData imageData = valueData.GetImageData(); + CXFA_Value* value = m_pDataAcc->GetFormValue(); + if (value) { + CXFA_ImageData imageData = value->GetImageData(); if (imageData.HasValidNode()) iAspect = imageData.GetAspect(); } diff --git a/xfa/fxfa/cxfa_ffline.cpp b/xfa/fxfa/cxfa_ffline.cpp index 1af7f4e705..fb2c98a1a9 100644 --- a/xfa/fxfa/cxfa_ffline.cpp +++ b/xfa/fxfa/cxfa_ffline.cpp @@ -6,6 +6,7 @@ #include "xfa/fxfa/cxfa_ffline.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxgraphics/cxfa_gecolor.h" #include "xfa/fxgraphics/cxfa_gepath.h" #include "xfa/fxgraphics/cxfa_graphics.h" @@ -84,11 +85,11 @@ void CXFA_FFLine::RenderWidget(CXFA_Graphics* pGS, if (!IsMatchVisibleStatus(dwStatus)) return; - CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (!valueData.HasValidNode()) + CXFA_Value* value = m_pDataAcc->GetFormValue(); + if (!value) return; - CXFA_LineData lineData = valueData.GetLineData(); + CXFA_LineData lineData = value->GetLineData(); FX_ARGB lineColor = 0xFF000000; float fLineWidth = 1.0f; XFA_AttributeEnum iStrokeType = XFA_AttributeEnum::Unknown; diff --git a/xfa/fxfa/cxfa_ffrectangle.cpp b/xfa/fxfa/cxfa_ffrectangle.cpp index 716ef2e840..063a9e9865 100644 --- a/xfa/fxfa/cxfa_ffrectangle.cpp +++ b/xfa/fxfa/cxfa_ffrectangle.cpp @@ -6,6 +6,8 @@ #include "xfa/fxfa/cxfa_ffrectangle.h" +#include "xfa/fxfa/parser/cxfa_value.h" + CXFA_FFRectangle::CXFA_FFRectangle(CXFA_WidgetAcc* pDataAcc) : CXFA_FFDraw(pDataAcc) {} @@ -17,8 +19,8 @@ void CXFA_FFRectangle::RenderWidget(CXFA_Graphics* pGS, if (!IsMatchVisibleStatus(dwStatus)) return; - CXFA_ValueData valueData = m_pDataAcc->GetFormValueData(); - if (!valueData.HasValidNode()) + CXFA_Value* value = m_pDataAcc->GetFormValue(); + if (!value) return; CFX_RectF rect = GetRectWithoutRotate(); @@ -29,5 +31,5 @@ void CXFA_FFRectangle::RenderWidget(CXFA_Graphics* pGS, CFX_Matrix mtRotate = GetRotateMatrix(); mtRotate.Concat(matrix); - DrawBorder(pGS, valueData.GetRectangleData(), rect, mtRotate); + DrawBorder(pGS, value->GetRectangleData(), rect, mtRotate); } diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 74717b998c..65c4649fed 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -25,6 +25,7 @@ #include "xfa/fxfa/parser/cxfa_localevalue.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_validate.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_utils.h" class CXFA_WidgetLayoutData { @@ -70,11 +71,11 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { if (m_pDIBitmap) return true; - CXFA_ValueData valueData = pAcc->GetFormValueData(); - if (!valueData.HasValidNode()) + CXFA_Value* value = pAcc->GetFormValue(); + if (!value) return false; - CXFA_ImageData imageData = valueData.GetImageData(); + CXFA_ImageData imageData = value->GetImageData(); if (!imageData.HasValidNode()) return false; @@ -130,11 +131,11 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { if (m_pDIBitmap) return true; - CXFA_ValueData valueData = pAcc->GetFormValueData(); - if (!valueData.HasValidNode()) + CXFA_Value* value = pAcc->GetFormValue(); + if (!value) return false; - CXFA_ImageData imageData = valueData.GetImageData(); + CXFA_ImageData imageData = value->GetImageData(); CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageData, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); @@ -171,8 +172,9 @@ void CXFA_WidgetAcc::ResetData() { XFA_Element eUIType = GetUIType(); switch (eUIType) { case XFA_Element::ImageEdit: { - CXFA_ValueData imageValueData = GetDefaultValueData(); - CXFA_ImageData imageData = imageValueData.GetImageData(); + CXFA_Value* imageValue = GetDefaultValue(); + CXFA_ImageData imageData = + imageValue ? imageValue->GetImageData() : CXFA_ImageData(nullptr); WideString wsContentType, wsHref; if (imageData.HasValidNode()) { wsValue = imageData.GetContent(); @@ -194,9 +196,9 @@ void CXFA_WidgetAcc::ResetData() { bool done = false; if (wsValue.IsEmpty()) { - CXFA_ValueData defValueData = pAcc->GetDefaultValueData(); - if (defValueData.HasValidNode()) { - wsValue = defValueData.GetChildValueContent(); + CXFA_Value* defValue = pAcc->GetDefaultValue(); + if (defValue) { + wsValue = defValue->GetChildValueContent(); SetValue(XFA_VALUEPICTURE_Raw, wsValue); pAcc->SetValue(XFA_VALUEPICTURE_Raw, wsValue); done = true; @@ -223,9 +225,9 @@ void CXFA_WidgetAcc::ResetData() { case XFA_Element::ChoiceList: ClearAllSelections(); default: { - CXFA_ValueData defValueData = GetDefaultValueData(); - if (defValueData.HasValidNode()) - wsValue = defValueData.GetChildValueContent(); + CXFA_Value* defValue = GetDefaultValue(); + if (defValue) + wsValue = defValue->GetChildValueContent(); SetValue(XFA_VALUEPICTURE_Raw, wsValue); break; @@ -236,7 +238,8 @@ void CXFA_WidgetAcc::ResetData() { void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType, const WideString& wsHref, const WideString& wsData) { - CXFA_ImageData imageData = GetFormValueData().GetImageData(); + CXFA_ImageData imageData = + GetFormValue() ? GetFormValue()->GetImageData() : CXFA_ImageData(nullptr); if (imageData.HasValidNode()) { imageData.SetContentType(WideString(wsContentType)); imageData.SetHref(wsHref); @@ -497,9 +500,9 @@ WideString CXFA_WidgetAcc::GetValidateCaptionName(bool bVersionFlag) { if (!bVersionFlag) { CXFA_CaptionData captionData = GetCaptionData(); if (captionData.HasValidNode()) { - CXFA_ValueData capValue = captionData.GetValueData(); - if (capValue.HasValidNode()) { - CXFA_TextData captionTextData = capValue.GetTextData(); + CXFA_Value* capValue = captionData.GetValue(); + if (capValue) { + CXFA_TextData captionTextData = capValue->GetTextData(); if (captionTextData.HasValidNode()) wsCaptionName = captionTextData.GetContent(); } diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 96afeb4bde..4a46a9d80b 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -19,7 +19,6 @@ #include "xfa/fxfa/parser/cxfa_imagedata.h" #include "xfa/fxfa/parser/cxfa_margindata.h" #include "xfa/fxfa/parser/cxfa_scriptdata.h" -#include "xfa/fxfa/parser/cxfa_valuedata.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" class CFGAS_GEFont; diff --git a/xfa/fxfa/parser/cxfa_captiondata.cpp b/xfa/fxfa/parser/cxfa_captiondata.cpp index 6d9f02b1ab..e48e5f34bb 100644 --- a/xfa/fxfa/parser/cxfa_captiondata.cpp +++ b/xfa/fxfa/parser/cxfa_captiondata.cpp @@ -8,6 +8,7 @@ #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_value.h" CXFA_CaptionData::CXFA_CaptionData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} @@ -46,7 +47,8 @@ CXFA_FontData CXFA_CaptionData::GetFontData() const { : nullptr); } -CXFA_ValueData CXFA_CaptionData::GetValueData() const { - return CXFA_ValueData( - m_pNode ? m_pNode->GetChild(0, XFA_Element::Value, false) : nullptr); +CXFA_Value* CXFA_CaptionData::GetValue() const { + return m_pNode ? static_cast<CXFA_Value*>( + m_pNode->GetChild(0, XFA_Element::Value, false)) + : nullptr; } diff --git a/xfa/fxfa/parser/cxfa_captiondata.h b/xfa/fxfa/parser/cxfa_captiondata.h index fd8af7273b..119c34e4b1 100644 --- a/xfa/fxfa/parser/cxfa_captiondata.h +++ b/xfa/fxfa/parser/cxfa_captiondata.h @@ -10,9 +10,9 @@ #include "xfa/fxfa/parser/cxfa_datadata.h" #include "xfa/fxfa/parser/cxfa_fontdata.h" #include "xfa/fxfa/parser/cxfa_margindata.h" -#include "xfa/fxfa/parser/cxfa_valuedata.h" class CXFA_Node; +class CXFA_Value; class CXFA_CaptionData : public CXFA_DataData { public: @@ -24,7 +24,7 @@ class CXFA_CaptionData : public CXFA_DataData { float GetReserve() const; CXFA_MarginData GetMarginData() const; CXFA_FontData GetFontData() const; - CXFA_ValueData GetValueData() const; + CXFA_Value* GetValue() const; }; #endif // XFA_FXFA_PARSER_CXFA_CAPTIONDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp index 4de833a8fc..aae11da211 100644 --- a/xfa/fxfa/parser/cxfa_value.cpp +++ b/xfa/fxfa/parser/cxfa_value.cpp @@ -50,3 +50,39 @@ CXFA_Value::CXFA_Value(CXFA_Document* doc, XFA_PacketType packet) pdfium::MakeUnique<CJX_Value>(this)) {} CXFA_Value::~CXFA_Value() {} + +XFA_Element CXFA_Value::GetChildValueClassID() const { + CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); + return pNode ? pNode->GetElementType() : XFA_Element::Unknown; +} + +WideString CXFA_Value::GetChildValueContent() const { + CXFA_Node* pNode = GetNodeItem(XFA_NODEITEM_FirstChild); + if (!pNode) + return L""; + return pNode->JSObject()->TryContent(false, true).value_or(L""); +} + +CXFA_ArcData CXFA_Value::GetArcData() const { + return CXFA_ArcData(GetNodeItem(XFA_NODEITEM_FirstChild)); +} + +CXFA_LineData CXFA_Value::GetLineData() const { + return CXFA_LineData(GetNodeItem(XFA_NODEITEM_FirstChild)); +} + +CXFA_RectangleData CXFA_Value::GetRectangleData() const { + return CXFA_RectangleData(GetNodeItem(XFA_NODEITEM_FirstChild)); +} + +CXFA_TextData CXFA_Value::GetTextData() const { + return CXFA_TextData(GetNodeItem(XFA_NODEITEM_FirstChild)); +} + +CXFA_ExDataData CXFA_Value::GetExData() const { + return CXFA_ExDataData(GetNodeItem(XFA_NODEITEM_FirstChild)); +} + +CXFA_ImageData CXFA_Value::GetImageData() const { + return CXFA_ImageData(GetNodeItem(XFA_NODEITEM_FirstChild)); +} diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h index 01f8c4a1ee..0a964ff353 100644 --- a/xfa/fxfa/parser/cxfa_value.h +++ b/xfa/fxfa/parser/cxfa_value.h @@ -7,12 +7,29 @@ #ifndef XFA_FXFA_PARSER_CXFA_VALUE_H_ #define XFA_FXFA_PARSER_CXFA_VALUE_H_ +#include "core/fxcrt/fx_string.h" +#include "xfa/fxfa/parser/cxfa_arcdata.h" +#include "xfa/fxfa/parser/cxfa_datadata.h" +#include "xfa/fxfa/parser/cxfa_exdatadata.h" +#include "xfa/fxfa/parser/cxfa_imagedata.h" +#include "xfa/fxfa/parser/cxfa_linedata.h" #include "xfa/fxfa/parser/cxfa_node.h" +#include "xfa/fxfa/parser/cxfa_rectangledata.h" +#include "xfa/fxfa/parser/cxfa_textdata.h" class CXFA_Value : public CXFA_Node { public: CXFA_Value(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Value() override; + + XFA_Element GetChildValueClassID() const; + WideString GetChildValueContent() const; + CXFA_ArcData GetArcData() const; + CXFA_LineData GetLineData() const; + CXFA_RectangleData GetRectangleData() const; + CXFA_TextData GetTextData() const; + CXFA_ExDataData GetExData() const; + CXFA_ImageData GetImageData() const; }; #endif // XFA_FXFA_PARSER_CXFA_VALUE_H_ diff --git a/xfa/fxfa/parser/cxfa_valuedata.cpp b/xfa/fxfa/parser/cxfa_valuedata.cpp deleted file mode 100644 index c88af7a422..0000000000 --- a/xfa/fxfa/parser/cxfa_valuedata.cpp +++ /dev/null @@ -1,58 +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_valuedata.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -XFA_Element CXFA_ValueData::GetChildValueClassID() const { - if (!m_pNode) - return XFA_Element::Unknown; - if (CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) - return pNode->GetElementType(); - return XFA_Element::Unknown; -} - -WideString CXFA_ValueData::GetChildValueContent() const { - if (!m_pNode) - return L""; - - CXFA_Node* pNode = m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild); - if (!pNode) - return L""; - - return pNode->JSObject()->TryContent(false, true).value_or(L""); -} - -CXFA_ArcData CXFA_ValueData::GetArcData() const { - return CXFA_ArcData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) - : nullptr); -} - -CXFA_LineData CXFA_ValueData::GetLineData() const { - return CXFA_LineData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) - : nullptr); -} - -CXFA_RectangleData CXFA_ValueData::GetRectangleData() const { - return CXFA_RectangleData( - m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) : nullptr); -} - -CXFA_TextData CXFA_ValueData::GetTextData() const { - return CXFA_TextData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) - : nullptr); -} - -CXFA_ExDataData CXFA_ValueData::GetExData() const { - return CXFA_ExDataData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) - : nullptr); -} - -CXFA_ImageData CXFA_ValueData::GetImageData() const { - return CXFA_ImageData(m_pNode ? m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild) - : nullptr); -} diff --git a/xfa/fxfa/parser/cxfa_valuedata.h b/xfa/fxfa/parser/cxfa_valuedata.h deleted file mode 100644 index 101c960325..0000000000 --- a/xfa/fxfa/parser/cxfa_valuedata.h +++ /dev/null @@ -1,35 +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_VALUEDATA_H_ -#define XFA_FXFA_PARSER_CXFA_VALUEDATA_H_ - -#include "core/fxcrt/fx_string.h" -#include "xfa/fxfa/parser/cxfa_arcdata.h" -#include "xfa/fxfa/parser/cxfa_datadata.h" -#include "xfa/fxfa/parser/cxfa_exdatadata.h" -#include "xfa/fxfa/parser/cxfa_imagedata.h" -#include "xfa/fxfa/parser/cxfa_linedata.h" -#include "xfa/fxfa/parser/cxfa_rectangledata.h" -#include "xfa/fxfa/parser/cxfa_textdata.h" - -class CXFA_Node; - -class CXFA_ValueData : public CXFA_DataData { - public: - explicit CXFA_ValueData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} - - XFA_Element GetChildValueClassID() const; - WideString GetChildValueContent() const; - CXFA_ArcData GetArcData() const; - CXFA_LineData GetLineData() const; - CXFA_RectangleData GetRectangleData() const; - CXFA_TextData GetTextData() const; - CXFA_ExDataData GetExData() const; - CXFA_ImageData GetImageData() const; -}; - -#endif // XFA_FXFA_PARSER_CXFA_VALUEDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_widgetdata.cpp b/xfa/fxfa/parser/cxfa_widgetdata.cpp index 58c934132c..bb1f259d00 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.cpp +++ b/xfa/fxfa/parser/cxfa_widgetdata.cpp @@ -16,6 +16,7 @@ #include "xfa/fxfa/parser/cxfa_measurement.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxfa/parser/cxfa_validate.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_utils.h" namespace { @@ -69,9 +70,10 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { eWidgetType = XFA_Element::Unknown; XFA_Element eUIType = XFA_Element::Unknown; - CXFA_ValueData defValueData( + auto* defValue = static_cast<CXFA_Value*>( pNode->JSObject()->GetProperty(0, XFA_Element::Value, true)); - XFA_Element eValueType = defValueData.GetChildValueClassID(); + XFA_Element eValueType = + defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown; switch (eValueType) { case XFA_Element::Boolean: eUIType = XFA_Element::CheckButton; @@ -152,8 +154,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { if (!pUIChild) { if (eUIType == XFA_Element::Unknown) { eUIType = XFA_Element::TextEdit; - defValueData.GetNode()->JSObject()->GetProperty(0, XFA_Element::Text, - true); + defValue->JSObject()->GetProperty(0, XFA_Element::Text, true); } return pUI->JSObject()->GetProperty(0, eUIType, true); } @@ -195,7 +196,7 @@ CXFA_Node* CreateUIChild(CXFA_Node* pNode, XFA_Element& eWidgetType) { eValueType = XFA_Element::Text; break; } - defValueData.GetNode()->JSObject()->GetProperty(0, eValueType, true); + defValue->JSObject()->GetProperty(0, eValueType, true); return pUIChild; } @@ -295,15 +296,14 @@ std::vector<CXFA_Node*> CXFA_WidgetData::GetEventByActivity( return events; } -CXFA_ValueData CXFA_WidgetData::GetDefaultValueData() { +CXFA_Value* CXFA_WidgetData::GetDefaultValue() { CXFA_Node* pTemNode = m_pNode->GetTemplateNode(); - return CXFA_ValueData( - pTemNode ? pTemNode->JSObject()->GetProperty(0, XFA_Element::Value, false) - : nullptr); + return static_cast<CXFA_Value*>( + pTemNode->JSObject()->GetProperty(0, XFA_Element::Value, false)); } -CXFA_ValueData CXFA_WidgetData::GetFormValueData() { - return CXFA_ValueData( +CXFA_Value* CXFA_WidgetData::GetFormValue() { + return static_cast<CXFA_Value*>( m_pNode->JSObject()->GetProperty(0, XFA_Element::Value, false)); } diff --git a/xfa/fxfa/parser/cxfa_widgetdata.h b/xfa/fxfa/parser/cxfa_widgetdata.h index 592226cb0b..21e4e848ec 100644 --- a/xfa/fxfa/parser/cxfa_widgetdata.h +++ b/xfa/fxfa/parser/cxfa_widgetdata.h @@ -63,8 +63,8 @@ class CXFA_WidgetData : public CXFA_DataData { CXFA_FontData GetFontData(bool bModified); CXFA_MarginData GetMarginData(); CXFA_ParaData GetParaData(); - CXFA_ValueData GetDefaultValueData(); - CXFA_ValueData GetFormValueData(); + CXFA_Value* GetDefaultValue(); + CXFA_Value* GetFormValue(); CXFA_CalculateData GetCalculateData(); CXFA_Validate* GetValidate(bool bModified); CXFA_BorderData GetUIBorderData(); diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 66f4a2eb21..30d45787f5 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -23,6 +23,7 @@ #include "xfa/fxfa/parser/cxfa_occurdata.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_xfacontainernode.h" #include "xfa/fxfa/parser/cxfa_traversestrategy_xfanode.h" +#include "xfa/fxfa/parser/cxfa_value.h" #include "xfa/fxfa/parser/xfa_resolvenode_rs.h" #include "xfa/fxfa/parser/xfa_utils.h" @@ -123,13 +124,14 @@ void CreateDataBinding(CXFA_Node* pFormNode, CXFA_WidgetData* pWidgetData = pFormNode->GetWidgetData(); ASSERT(pWidgetData); XFA_Element eUIType = pWidgetData->GetUIType(); - CXFA_ValueData defValueData( + auto* defValue = static_cast<CXFA_Value*>( pFormNode->JSObject()->GetProperty(0, XFA_Element::Value, true)); if (!bDataToForm) { WideString wsValue; switch (eUIType) { case XFA_Element::ImageEdit: { - CXFA_ImageData imageData = defValueData.GetImageData(); + CXFA_ImageData imageData = + defValue ? defValue->GetImageData() : CXFA_ImageData(nullptr); WideString wsContentType; WideString wsHref; if (imageData.HasValidNode()) { @@ -151,7 +153,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, break; } case XFA_Element::ChoiceList: - wsValue = defValueData.GetChildValueContent(); + wsValue = defValue ? defValue->GetChildValueContent() : L""; if (pWidgetData->IsChoiceListMultiSelect()) { std::vector<WideString> wsSelTextArray = pWidgetData->GetSelectedItemsValue(); @@ -178,7 +180,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, } break; case XFA_Element::CheckButton: - wsValue = defValueData.GetChildValueContent(); + wsValue = defValue ? defValue->GetChildValueContent() : L""; if (wsValue.IsEmpty()) break; @@ -192,11 +194,12 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (pChild->GetElementType() != XFA_Element::Field) continue; - CXFA_Node* pValue = pChild->GetChild(0, XFA_Element::Value, false); + auto* pValue = static_cast<CXFA_Value*>( + pChild->GetChild(0, XFA_Element::Value, false)); if (!pValue) continue; - wsValue = CXFA_ValueData(pValue).GetChildValueContent(); + wsValue = pValue->GetChildValueContent(); if (wsValue.IsEmpty()) continue; @@ -245,7 +248,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, break; } case XFA_Element::NumericEdit: { - wsValue = defValueData.GetChildValueContent(); + wsValue = defValue ? defValue->GetChildValueContent() : L""; if (wsValue.IsEmpty()) break; @@ -258,7 +261,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, break; } default: - wsValue = defValueData.GetChildValueContent(); + wsValue = defValue ? defValue->GetChildValueContent() : L""; if (wsValue.IsEmpty()) break; @@ -276,9 +279,10 @@ void CreateDataBinding(CXFA_Node* pFormNode, false); switch (eUIType) { case XFA_Element::ImageEdit: { - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::Image); - CXFA_ImageData imageData = defValueData.GetImageData(); + CXFA_ImageData imageData = + defValue ? defValue->GetImageData() : CXFA_ImageData(nullptr); if (imageData.HasValidNode()) { CFX_XMLElement* pXMLDataElement = static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode()); @@ -314,20 +318,21 @@ void CreateDataBinding(CXFA_Node* pFormNode, wsNormalizeValue += wsItem; } - CXFA_ExDataData exData = defValueData.GetExData(); + CXFA_ExDataData exData = + defValue ? defValue->GetExData() : CXFA_ExDataData(nullptr); ASSERT(exData.HasValidNode()); exData.SetContentType(single ? L"text/plain" : L"text/xml"); } - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::ExData); } else { - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::Text); } break; case XFA_Element::CheckButton: - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::Text); break; case XFA_Element::ExclGroup: { @@ -336,7 +341,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, break; } case XFA_Element::DateTimeEdit: - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::DateTime); break; case XFA_Element::NumericEdit: { @@ -345,7 +350,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (wsPicture.IsEmpty()) wsNormalizeValue = pWidgetData->NormalizeNumStr(wsNormalizeValue); - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::Float); break; } @@ -355,7 +360,7 @@ void CreateDataBinding(CXFA_Node* pFormNode, case XFA_Element::Signature: case XFA_Element::TextEdit: default: - FormValueNode_SetChildContent(defValueData.GetNode(), wsNormalizeValue, + FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::Text); break; } |