diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-03 16:23:03 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-03 21:50:51 +0000 |
commit | 8afa22d5701a6c47b3f34267a2c52948efc3d301 (patch) | |
tree | eaa6e06fe2abb5c7cf09c3bd01e1ab89b5909b1f /xfa | |
parent | 4f88617ad2a4d352af87b95c2f7293d12e7bd2c8 (diff) | |
download | pdfium-8afa22d5701a6c47b3f34267a2c52948efc3d301.tar.xz |
Fold CXFA_ImageData into CXFA_Image
This CL folds the CXFA_ImageData wrapper into CXFA_Image.
Change-Id: I36596abc4dff7d17dc6ee13a857a084f41164c7a
Reviewed-on: https://pdfium-review.googlesource.com/22190
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fxfa/cxfa_ffimage.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimageedit.cpp | 7 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 11 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 33 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.h | 1 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_image.cpp | 34 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_image.h | 12 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_imagedata.cpp | 48 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_imagedata.h | 33 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_value.cpp | 5 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_value.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 21 |
13 files changed, 92 insertions, 127 deletions
diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index c37234c686..a285ac907d 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_image.h" #include "xfa/fxfa/parser/cxfa_para.h" #include "xfa/fxfa/parser/cxfa_value.h" @@ -67,9 +68,7 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, int32_t iImageYDpi = 0; m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); auto* value = m_pDataAcc->GetFormValue(); - CXFA_ImageData imageData = - value ? value->GetImageData() : CXFA_ImageData(nullptr); - - XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, imageData.GetAspect(), + CXFA_Image* image = value ? value->GetImage() : nullptr; + XFA_DrawImage(pGS, rtImage, mtRotate, pDIBitmap, image->GetAspect(), iImageXDpi, iImageYDpi, iHorzAlign, iVertAlign); } diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index b3e9ee3383..291b1862bb 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -19,6 +19,7 @@ #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_border.h" +#include "xfa/fxfa/parser/cxfa_image.h" #include "xfa/fxfa/parser/cxfa_para.h" #include "xfa/fxfa/parser/cxfa_value.h" @@ -82,9 +83,9 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, XFA_AttributeEnum iAspect = XFA_AttributeEnum::Fit; CXFA_Value* value = m_pDataAcc->GetFormValue(); if (value) { - CXFA_ImageData imageData = value->GetImageData(); - if (imageData.HasValidNode()) - iAspect = imageData.GetAspect(); + CXFA_Image* image = value->GetImage(); + if (image) + iAspect = image->GetAspect(); } int32_t iImageXDpi = 0; diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index f82f6aba66..74df10ce86 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -34,6 +34,7 @@ #include "xfa/fxfa/parser/cxfa_box.h" #include "xfa/fxfa/parser/cxfa_corner.h" #include "xfa/fxfa/parser/cxfa_edge.h" +#include "xfa/fxfa/parser/cxfa_image.h" #include "xfa/fxfa/parser/cxfa_margin.h" #include "xfa/fxfa/parser/cxfa_node.h" #include "xfa/fxgraphics/cxfa_gecolor.h" @@ -1877,21 +1878,21 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) { } RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_ImageData* pImageData, + CXFA_Image* pImage, bool& bNameImage, int32_t& iImageXDpi, int32_t& iImageYDpi) { - WideString wsHref = pImageData->GetHref(); - WideString wsImage = pImageData->GetContent(); + WideString wsHref = pImage->GetHref(); + WideString wsImage = pImage->GetContent(); if (wsHref.IsEmpty() && wsImage.IsEmpty()) return nullptr; - FXCODEC_IMAGE_TYPE type = XFA_GetImageType(pImageData->GetContentType()); + FXCODEC_IMAGE_TYPE type = XFA_GetImageType(pImage->GetContentType()); ByteString bsContent; uint8_t* pImageBuffer = nullptr; RetainPtr<IFX_SeekableReadStream> pImageFileRead; if (wsImage.GetLength() > 0) { - XFA_AttributeEnum iEncoding = pImageData->GetTransferEncoding(); + XFA_AttributeEnum iEncoding = pImage->GetTransferEncoding(); if (iEncoding == XFA_AttributeEnum::Base64) { ByteString bsData = wsImage.UTF8Encode(); int32_t iLength = bsData.GetLength(); diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 757d6db5d9..13372320b8 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -21,6 +21,7 @@ class CXFA_FFDocView; class CXFA_FFDoc; class CXFA_FFApp; class CXFA_Graphics; +class CXFA_Image; enum class FWL_WidgetHit; inline float XFA_UnitPx2Pt(float fPx, float fDpi) { @@ -50,7 +51,7 @@ void XFA_DrawImage(CXFA_Graphics* pGS, XFA_AttributeEnum iVertAlign = XFA_AttributeEnum::Top); RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_ImageData* pImageData, + CXFA_Image* pImage, bool& bNameImage, int32_t& iImageXDpi, int32_t& iImageYDpi); diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 30f435a6a5..b9d89cdfd5 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -23,6 +23,7 @@ #include "xfa/fxfa/cxfa_textprovider.h" #include "xfa/fxfa/parser/cxfa_calculate.h" #include "xfa/fxfa/parser/cxfa_caption.h" +#include "xfa/fxfa/parser/cxfa_image.h" #include "xfa/fxfa/parser/cxfa_items.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localevalue.h" @@ -81,12 +82,12 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { if (!value) return false; - CXFA_ImageData imageData = value->GetImageData(); - if (!imageData.HasValidNode()) + CXFA_Image* image = value->GetImage(); + if (!image) return false; CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageData, m_bNamedImage, + pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, image, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); return !!m_pDIBitmap; } @@ -141,9 +142,9 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { if (!value) return false; - CXFA_ImageData imageData = value->GetImageData(); + CXFA_Image* image = value->GetImage(); CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageData, m_bNamedImage, + pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, image, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); return !!m_pDIBitmap; } @@ -179,13 +180,12 @@ void CXFA_WidgetAcc::ResetData() { switch (eUIType) { case XFA_Element::ImageEdit: { CXFA_Value* imageValue = GetDefaultValue(); - CXFA_ImageData imageData = - imageValue ? imageValue->GetImageData() : CXFA_ImageData(nullptr); + CXFA_Image* image = imageValue ? imageValue->GetImage() : nullptr; WideString wsContentType, wsHref; - if (imageData.HasValidNode()) { - wsValue = imageData.GetContent(); - wsContentType = imageData.GetContentType(); - wsHref = imageData.GetHref(); + if (image) { + wsValue = image->GetContent(); + wsContentType = image->GetContentType(); + wsHref = image->GetHref(); } SetImageEdit(wsContentType, wsHref, wsValue); break; @@ -246,11 +246,10 @@ void CXFA_WidgetAcc::ResetData() { void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType, const WideString& wsHref, const WideString& wsData) { - CXFA_ImageData imageData = - GetFormValue() ? GetFormValue()->GetImageData() : CXFA_ImageData(nullptr); - if (imageData.HasValidNode()) { - imageData.SetContentType(WideString(wsContentType)); - imageData.SetHref(wsHref); + CXFA_Image* image = GetFormValue() ? GetFormValue()->GetImage() : nullptr; + if (image) { + image->SetContentType(WideString(wsContentType)); + image->SetHref(wsHref); } m_pNode->JSObject()->SetContent(wsData, GetFormatDataValue(wsData), true, @@ -258,7 +257,7 @@ void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType, CXFA_Node* pBind = GetDatasets(); if (!pBind) { - imageData.SetTransferEncoding(XFA_AttributeEnum::Base64); + image->SetTransferEncoding(XFA_AttributeEnum::Base64); return; } pBind->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, false, diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 65cd51747f..e09f447a48 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -15,7 +15,6 @@ #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/fx_dib.h" #include "xfa/fxfa/parser/cxfa_eventdata.h" -#include "xfa/fxfa/parser/cxfa_imagedata.h" #include "xfa/fxfa/parser/cxfa_widgetdata.h" class CFGAS_GEFont; diff --git a/xfa/fxfa/parser/cxfa_image.cpp b/xfa/fxfa/parser/cxfa_image.cpp index 928738109e..88ca977bb2 100644 --- a/xfa/fxfa/parser/cxfa_image.cpp +++ b/xfa/fxfa/parser/cxfa_image.cpp @@ -39,3 +39,37 @@ CXFA_Image::CXFA_Image(CXFA_Document* doc, XFA_PacketType packet) kName) {} CXFA_Image::~CXFA_Image() {} + +XFA_AttributeEnum CXFA_Image::GetAspect() { + return JSObject()->GetEnum(XFA_Attribute::Aspect); +} + +WideString CXFA_Image::GetContentType() { + return JSObject()->TryCData(XFA_Attribute::ContentType, true).value_or(L""); +} + +WideString CXFA_Image::GetHref() { + return JSObject()->TryCData(XFA_Attribute::Href, true).value_or(L""); +} + +XFA_AttributeEnum CXFA_Image::GetTransferEncoding() { + return static_cast<XFA_AttributeEnum>( + JSObject()->GetEnum(XFA_Attribute::TransferEncoding)); +} + +WideString CXFA_Image::GetContent() { + return JSObject()->TryContent(false, true).value_or(L""); +} + +void CXFA_Image::SetContentType(const WideString& wsContentType) { + JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, false, false); +} + +void CXFA_Image::SetHref(const WideString& wsHref) { + JSObject()->SetCData(XFA_Attribute::Href, wsHref, false, false); +} + +void CXFA_Image::SetTransferEncoding(XFA_AttributeEnum iTransferEncoding) { + JSObject()->SetEnum(XFA_Attribute::TransferEncoding, iTransferEncoding, + false); +} diff --git a/xfa/fxfa/parser/cxfa_image.h b/xfa/fxfa/parser/cxfa_image.h index 07ebf9d5d7..3670863a3b 100644 --- a/xfa/fxfa/parser/cxfa_image.h +++ b/xfa/fxfa/parser/cxfa_image.h @@ -13,6 +13,18 @@ class CXFA_Image : public CXFA_Node { public: CXFA_Image(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Image() override; + + XFA_AttributeEnum GetAspect(); + WideString GetContent(); + + WideString GetHref(); + void SetHref(const WideString& wsHref); + + XFA_AttributeEnum GetTransferEncoding(); + void SetTransferEncoding(XFA_AttributeEnum iTransferEncoding); + + WideString GetContentType(); + void SetContentType(const WideString& wsContentType); }; #endif // XFA_FXFA_PARSER_CXFA_IMAGE_H_ diff --git a/xfa/fxfa/parser/cxfa_imagedata.cpp b/xfa/fxfa/parser/cxfa_imagedata.cpp deleted file mode 100644 index cacbf9558d..0000000000 --- a/xfa/fxfa/parser/cxfa_imagedata.cpp +++ /dev/null @@ -1,48 +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_imagedata.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_ImageData::CXFA_ImageData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} - -XFA_AttributeEnum CXFA_ImageData::GetAspect() const { - return m_pNode->JSObject()->GetEnum(XFA_Attribute::Aspect); -} - -WideString CXFA_ImageData::GetContentType() const { - return m_pNode->JSObject() - ->TryCData(XFA_Attribute::ContentType, true) - .value_or(L""); -} - -WideString CXFA_ImageData::GetHref() const { - return m_pNode->JSObject()->TryCData(XFA_Attribute::Href, true).value_or(L""); -} - -XFA_AttributeEnum CXFA_ImageData::GetTransferEncoding() const { - return static_cast<XFA_AttributeEnum>( - m_pNode->JSObject()->GetEnum(XFA_Attribute::TransferEncoding)); -} - -WideString CXFA_ImageData::GetContent() const { - return m_pNode->JSObject()->TryContent(false, true).value_or(L""); -} - -void CXFA_ImageData::SetContentType(const WideString& wsContentType) { - m_pNode->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, - false, false); -} - -void CXFA_ImageData::SetHref(const WideString& wsHref) { - m_pNode->JSObject()->SetCData(XFA_Attribute::Href, wsHref, false, false); -} - -void CXFA_ImageData::SetTransferEncoding(XFA_AttributeEnum iTransferEncoding) { - m_pNode->JSObject()->SetEnum(XFA_Attribute::TransferEncoding, - iTransferEncoding, false); -} diff --git a/xfa/fxfa/parser/cxfa_imagedata.h b/xfa/fxfa/parser/cxfa_imagedata.h deleted file mode 100644 index 9030918541..0000000000 --- a/xfa/fxfa/parser/cxfa_imagedata.h +++ /dev/null @@ -1,33 +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_IMAGEDATA_H_ -#define XFA_FXFA_PARSER_CXFA_IMAGEDATA_H_ - -#include "core/fxcrt/fx_string.h" -#include "core/fxcrt/fx_system.h" -#include "xfa/fxfa/parser/cxfa_datadata.h" - -class CXFA_Node; - -class CXFA_ImageData : public CXFA_DataData { - public: - explicit CXFA_ImageData(CXFA_Node* pNode); - - XFA_AttributeEnum GetAspect() const; - WideString GetContent() const; - - WideString GetHref() const; - void SetHref(const WideString& wsHref); - - XFA_AttributeEnum GetTransferEncoding() const; - void SetTransferEncoding(XFA_AttributeEnum iTransferEncoding); - - WideString GetContentType() const; - void SetContentType(const WideString& wsContentType); -}; - -#endif // XFA_FXFA_PARSER_CXFA_IMAGEDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp index bc5f9faeff..99cca777dc 100644 --- a/xfa/fxfa/parser/cxfa_value.cpp +++ b/xfa/fxfa/parser/cxfa_value.cpp @@ -9,6 +9,7 @@ #include "fxjs/xfa/cjx_value.h" #include "third_party/base/ptr_util.h" #include "xfa/fxfa/parser/cxfa_arc.h" +#include "xfa/fxfa/parser/cxfa_image.h" #include "xfa/fxfa/parser/cxfa_line.h" #include "xfa/fxfa/parser/cxfa_rectangle.h" @@ -86,6 +87,6 @@ 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)); +CXFA_Image* CXFA_Value::GetImage() const { + return static_cast<CXFA_Image*>(GetNodeItem(XFA_NODEITEM_FirstChild)); } diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h index b5de965557..91483b8832 100644 --- a/xfa/fxfa/parser/cxfa_value.h +++ b/xfa/fxfa/parser/cxfa_value.h @@ -10,11 +10,11 @@ #include "core/fxcrt/fx_string.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_node.h" #include "xfa/fxfa/parser/cxfa_text.h" class CXFA_Arc; +class CXFA_Image; class CXFA_Line; class CXFA_Rectangle; @@ -30,7 +30,7 @@ class CXFA_Value : public CXFA_Node { CXFA_Rectangle* GetRectangle() const; CXFA_Text* GetText() const; CXFA_ExDataData GetExData() const; - CXFA_ImageData GetImageData() const; + CXFA_Image* GetImage() const; }; #endif // XFA_FXFA_PARSER_CXFA_VALUE_H_ diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 5a36083e88..c98597f78e 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -19,6 +19,7 @@ #include "xfa/fxfa/parser/cxfa_datagroup.h" #include "xfa/fxfa/parser/cxfa_document.h" #include "xfa/fxfa/parser/cxfa_form.h" +#include "xfa/fxfa/parser/cxfa_image.h" #include "xfa/fxfa/parser/cxfa_items.h" #include "xfa/fxfa/parser/cxfa_layoutprocessor.h" #include "xfa/fxfa/parser/cxfa_localemgr.h" @@ -137,14 +138,13 @@ void CreateDataBinding(CXFA_Node* pFormNode, WideString wsValue; switch (eUIType) { case XFA_Element::ImageEdit: { - CXFA_ImageData imageData = - defValue ? defValue->GetImageData() : CXFA_ImageData(nullptr); + CXFA_Image* image = defValue ? defValue->GetImage() : nullptr; WideString wsContentType; WideString wsHref; - if (imageData.HasValidNode()) { - wsValue = imageData.GetContent(); - wsContentType = imageData.GetContentType(); - wsHref = imageData.GetHref(); + if (image) { + wsValue = image->GetContent(); + wsContentType = image->GetContentType(); + wsHref = image->GetHref(); } CFX_XMLElement* pXMLDataElement = static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode()); @@ -290,9 +290,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, case XFA_Element::ImageEdit: { FormValueNode_SetChildContent(defValue, wsNormalizeValue, XFA_Element::Image); - CXFA_ImageData imageData = - defValue ? defValue->GetImageData() : CXFA_ImageData(nullptr); - if (imageData.HasValidNode()) { + CXFA_Image* image = defValue ? defValue->GetImage() : nullptr; + if (image) { CFX_XMLElement* pXMLDataElement = static_cast<CFX_XMLElement*>(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); @@ -302,12 +301,12 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (!wsContentType.IsEmpty()) { pDataNode->JSObject()->SetCData(XFA_Attribute::ContentType, wsContentType, false, false); - imageData.SetContentType(wsContentType); + image->SetContentType(wsContentType); } WideString wsHref = pXMLDataElement->GetString(L"href"); if (!wsHref.IsEmpty()) - imageData.SetHref(wsHref); + image->SetHref(wsHref); } break; } |