From 73c4b0fe5dd1e1924b2cd7b19910ef9d86dcc9ab Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 7 Nov 2017 20:30:40 +0000 Subject: Rename CXFA_Image to CXFA_ImageData This CL renames CXFA_Image to CXFA_ImageData to make it clear it's part of the data hierarchy. Change-Id: Ia593ef3c9deb872db11f8246b13ef3c39a90d4c7 Reviewed-on: https://pdfium-review.googlesource.com/17984 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- BUILD.gn | 4 +- xfa/fxfa/cxfa_ffimage.cpp | 3 +- xfa/fxfa/cxfa_ffimageedit.cpp | 4 +- xfa/fxfa/cxfa_ffwidget.cpp | 11 ++--- xfa/fxfa/cxfa_ffwidget.h | 2 +- xfa/fxfa/cxfa_widgetacc.cpp | 32 +++++++------- xfa/fxfa/cxfa_widgetacc.h | 2 +- xfa/fxfa/parser/cxfa_image.cpp | 59 ------------------------- xfa/fxfa/parser/cxfa_image.h | 33 -------------- xfa/fxfa/parser/cxfa_imagedata.cpp | 59 +++++++++++++++++++++++++ xfa/fxfa/parser/cxfa_imagedata.h | 33 ++++++++++++++ xfa/fxfa/parser/cxfa_value.cpp | 4 +- xfa/fxfa/parser/cxfa_value.h | 4 +- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 18 ++++---- 14 files changed, 135 insertions(+), 133 deletions(-) delete mode 100644 xfa/fxfa/parser/cxfa_image.cpp delete mode 100644 xfa/fxfa/parser/cxfa_image.h create mode 100644 xfa/fxfa/parser/cxfa_imagedata.cpp create mode 100644 xfa/fxfa/parser/cxfa_imagedata.h diff --git a/BUILD.gn b/BUILD.gn index 02b51bae4a..1d49d7f211 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1827,8 +1827,8 @@ if (pdf_enable_xfa) { "xfa/fxfa/parser/cxfa_filldata.h", "xfa/fxfa/parser/cxfa_fontdata.cpp", "xfa/fxfa/parser/cxfa_fontdata.h", - "xfa/fxfa/parser/cxfa_image.cpp", - "xfa/fxfa/parser/cxfa_image.h", + "xfa/fxfa/parser/cxfa_imagedata.cpp", + "xfa/fxfa/parser/cxfa_imagedata.h", "xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp", "xfa/fxfa/parser/cxfa_itemlayoutprocessor.h", "xfa/fxfa/parser/cxfa_layoutcontext.h", diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index 9903e6b25d..6dda044194 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -60,8 +60,7 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, } CXFA_Value value = m_pDataAcc->GetFormValue(); - CXFA_Image imageObj = value.GetImage(); - int32_t iAspect = imageObj.GetAspect(); + int32_t iAspect = value.GetImageData().GetAspect(); int32_t iImageXDpi = 0; int32_t iImageYDpi = 0; m_pDataAcc->GetImageDpi(iImageXDpi, iImageYDpi); diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 14d66e6198..0a6338aff6 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -77,8 +77,8 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, int32_t iAspect = XFA_ATTRIBUTEENUM_Fit; if (CXFA_Value value = m_pDataAcc->GetFormValue()) { - if (CXFA_Image imageObj = value.GetImage()) - iAspect = imageObj.GetAspect(); + if (CXFA_ImageData imageData = value.GetImageData()) + iAspect = imageData.GetAspect(); } int32_t iImageXDpi = 0; diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index 97dc26846e..48e7ae49ac 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -1890,26 +1890,26 @@ FXCODEC_IMAGE_TYPE XFA_GetImageType(const WideString& wsType) { } RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, + CXFA_ImageData* pImageData, bool& bNameImage, int32_t& iImageXDpi, int32_t& iImageYDpi) { WideString wsHref; WideString wsImage; - pImage->GetHref(wsHref); - pImage->GetContent(wsImage); + pImageData->GetHref(wsHref); + pImageData->GetContent(wsImage); if (wsHref.IsEmpty() && wsImage.IsEmpty()) return nullptr; WideString wsContentType; - pImage->GetContentType(wsContentType); + pImageData->GetContentType(wsContentType); FXCODEC_IMAGE_TYPE type = XFA_GetImageType(wsContentType); ByteString bsContent; uint8_t* pImageBuffer = nullptr; RetainPtr pImageFileRead; if (wsImage.GetLength() > 0) { XFA_ATTRIBUTEENUM iEncoding = - (XFA_ATTRIBUTEENUM)pImage->GetTransferEncoding(); + (XFA_ATTRIBUTEENUM)pImageData->GetTransferEncoding(); if (iEncoding == XFA_ATTRIBUTEENUM_Base64) { ByteString bsData = wsImage.UTF8Encode(); int32_t iLength = bsData.GetLength(); @@ -1947,6 +1947,7 @@ RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, FX_Free(pImageBuffer); return pBitmap; } + static FXDIB_Format XFA_GetDIBFormat(FXCODEC_IMAGE_TYPE type, int32_t iComponents, int32_t iBitsPerComponent) { diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 26cca1ee5b..3f5181792d 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -50,7 +50,7 @@ void XFA_DrawImage(CXFA_Graphics* pGS, int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); RetainPtr XFA_LoadImageData(CXFA_FFDoc* pDoc, - CXFA_Image* pImage, + CXFA_ImageData* pImageData, bool& bNameImage, int32_t& iImageXDpi, int32_t& iImageYDpi); diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 32d925fead..c28f6d4185 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -81,12 +81,12 @@ class CXFA_ImageLayoutData : public CXFA_WidgetLayoutData { if (!value) return false; - CXFA_Image imageObj = value.GetImage(); - if (!imageObj) + CXFA_ImageData imageData = value.GetImageData(); + if (!imageData) return false; CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, + pAcc->SetImageImage(XFA_LoadImageData(pFFDoc, &imageData, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); return !!m_pDIBitmap; } @@ -141,9 +141,9 @@ class CXFA_ImageEditData : public CXFA_FieldLayoutData { if (!value) return false; - CXFA_Image imageObj = value.GetImage(); + CXFA_ImageData imageData = value.GetImageData(); CXFA_FFDoc* pFFDoc = pAcc->GetDoc(); - pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageObj, m_bNamedImage, + pAcc->SetImageEditImage(XFA_LoadImageData(pFFDoc, &imageData, m_bNamedImage, m_iImageXDpi, m_iImageYDpi)); return !!m_pDIBitmap; } @@ -179,12 +179,12 @@ void CXFA_WidgetAcc::ResetData() { switch (eUIType) { case XFA_Element::ImageEdit: { CXFA_Value imageValue = GetDefaultValue(); - CXFA_Image image = imageValue.GetImage(); + CXFA_ImageData imageData = imageValue.GetImageData(); WideString wsContentType, wsHref; - if (image) { - image.GetContent(wsValue); - image.GetContentType(wsContentType); - image.GetHref(wsHref); + if (imageData) { + imageData.GetContent(wsValue); + imageData.GetContentType(wsContentType); + imageData.GetHref(wsHref); } SetImageEdit(wsContentType, wsHref, wsValue); break; @@ -237,17 +237,19 @@ void CXFA_WidgetAcc::ResetData() { void CXFA_WidgetAcc::SetImageEdit(const WideString& wsContentType, const WideString& wsHref, const WideString& wsData) { - CXFA_Image image = GetFormValue().GetImage(); - if (image) { - image.SetContentType(WideString(wsContentType)); - image.SetHref(wsHref); + CXFA_ImageData imageData = GetFormValue().GetImageData(); + if (imageData) { + imageData.SetContentType(WideString(wsContentType)); + imageData.SetHref(wsHref); } + WideString wsFormatValue(wsData); GetFormatDataValue(wsData, wsFormatValue); m_pNode->JSNode()->SetContent(wsData, wsFormatValue, true, false, true); + CXFA_Node* pBind = GetDatasets(); if (!pBind) { - image.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64); + imageData.SetTransferEncoding(XFA_ATTRIBUTEENUM_Base64); return; } pBind->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType, false, diff --git a/xfa/fxfa/cxfa_widgetacc.h b/xfa/fxfa/cxfa_widgetacc.h index 4d66ff3b5a..980a38175e 100644 --- a/xfa/fxfa/cxfa_widgetacc.h +++ b/xfa/fxfa/cxfa_widgetacc.h @@ -16,7 +16,7 @@ #include "core/fxge/fx_dib.h" #include "xfa/fxfa/parser/cxfa_boxdata.h" #include "xfa/fxfa/parser/cxfa_eventdata.h" -#include "xfa/fxfa/parser/cxfa_image.h" +#include "xfa/fxfa/parser/cxfa_imagedata.h" #include "xfa/fxfa/parser/cxfa_margin.h" #include "xfa/fxfa/parser/cxfa_script.h" #include "xfa/fxfa/parser/cxfa_value.h" diff --git a/xfa/fxfa/parser/cxfa_image.cpp b/xfa/fxfa/parser/cxfa_image.cpp deleted file mode 100644 index cd25b5a39e..0000000000 --- a/xfa/fxfa/parser/cxfa_image.cpp +++ /dev/null @@ -1,59 +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_image.h" - -#include "xfa/fxfa/parser/cxfa_node.h" - -CXFA_Image::CXFA_Image(CXFA_Node* pNode, bool bDefValue) - : CXFA_Data(pNode), m_bDefValue(bDefValue) {} - -int32_t CXFA_Image::GetAspect() { - return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Aspect); -} - -bool CXFA_Image::GetContentType(WideString& wsContentType) { - return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType, - true); -} - -bool CXFA_Image::GetHref(WideString& wsHref) { - if (m_bDefValue) - return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Href, wsHref, true); - return m_pNode->JSNode()->GetAttribute(L"href", wsHref, true); -} - -int32_t CXFA_Image::GetTransferEncoding() { - if (m_bDefValue) - return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_TransferEncoding); - return XFA_ATTRIBUTEENUM_Base64; -} - -bool CXFA_Image::GetContent(WideString& wsText) { - return m_pNode->JSNode()->TryContent(wsText, false, true); -} - -bool CXFA_Image::SetContentType(const WideString& wsContentType) { - return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType, - false, false); -} - -bool CXFA_Image::SetHref(const WideString& wsHref) { - if (m_bDefValue) - return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Href, wsHref, false, - false); - return m_pNode->JSNode()->SetAttribute(XFA_ATTRIBUTE_Href, - wsHref.AsStringView(), false); -} - -bool CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) { - if (m_bDefValue) { - return m_pNode->JSNode()->SetEnum(XFA_ATTRIBUTE_TransferEncoding, - (XFA_ATTRIBUTEENUM)iTransferEncoding, - false); - } - return true; -} diff --git a/xfa/fxfa/parser/cxfa_image.h b/xfa/fxfa/parser/cxfa_image.h deleted file mode 100644 index cc08bc3380..0000000000 --- a/xfa/fxfa/parser/cxfa_image.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_IMAGE_H_ -#define XFA_FXFA_PARSER_CXFA_IMAGE_H_ - -#include "core/fxcrt/fx_string.h" -#include "core/fxcrt/fx_system.h" -#include "xfa/fxfa/parser/cxfa_data.h" - -class CXFA_Node; - -class CXFA_Image : public CXFA_Data { - public: - CXFA_Image(CXFA_Node* pNode, bool bDefValue); - - int32_t GetAspect(); - bool GetContentType(WideString& wsContentType); - bool GetHref(WideString& wsHref); - int32_t GetTransferEncoding(); - bool GetContent(WideString& wsText); - bool SetContentType(const WideString& wsContentType); - bool SetHref(const WideString& wsHref); - bool SetTransferEncoding(int32_t iTransferEncoding); - - private: - bool m_bDefValue; -}; - -#endif // XFA_FXFA_PARSER_CXFA_IMAGE_H_ diff --git a/xfa/fxfa/parser/cxfa_imagedata.cpp b/xfa/fxfa/parser/cxfa_imagedata.cpp new file mode 100644 index 0000000000..4beb78c35b --- /dev/null +++ b/xfa/fxfa/parser/cxfa_imagedata.cpp @@ -0,0 +1,59 @@ +// 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, bool bDefValue) + : CXFA_Data(pNode), m_bDefValue(bDefValue) {} + +int32_t CXFA_ImageData::GetAspect() { + return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Aspect); +} + +bool CXFA_ImageData::GetContentType(WideString& wsContentType) { + return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType, + true); +} + +bool CXFA_ImageData::GetHref(WideString& wsHref) { + if (m_bDefValue) + return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Href, wsHref, true); + return m_pNode->JSNode()->GetAttribute(L"href", wsHref, true); +} + +int32_t CXFA_ImageData::GetTransferEncoding() { + if (m_bDefValue) + return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_TransferEncoding); + return XFA_ATTRIBUTEENUM_Base64; +} + +bool CXFA_ImageData::GetContent(WideString& wsText) { + return m_pNode->JSNode()->TryContent(wsText, false, true); +} + +bool CXFA_ImageData::SetContentType(const WideString& wsContentType) { + return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType, + false, false); +} + +bool CXFA_ImageData::SetHref(const WideString& wsHref) { + if (m_bDefValue) + return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Href, wsHref, false, + false); + return m_pNode->JSNode()->SetAttribute(XFA_ATTRIBUTE_Href, + wsHref.AsStringView(), false); +} + +bool CXFA_ImageData::SetTransferEncoding(int32_t iTransferEncoding) { + if (m_bDefValue) { + return m_pNode->JSNode()->SetEnum(XFA_ATTRIBUTE_TransferEncoding, + (XFA_ATTRIBUTEENUM)iTransferEncoding, + false); + } + return true; +} diff --git a/xfa/fxfa/parser/cxfa_imagedata.h b/xfa/fxfa/parser/cxfa_imagedata.h new file mode 100644 index 0000000000..e94615ae1d --- /dev/null +++ b/xfa/fxfa/parser/cxfa_imagedata.h @@ -0,0 +1,33 @@ +// 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_data.h" + +class CXFA_Node; + +class CXFA_ImageData : public CXFA_Data { + public: + CXFA_ImageData(CXFA_Node* pNode, bool bDefValue); + + int32_t GetAspect(); + bool GetContentType(WideString& wsContentType); + bool GetHref(WideString& wsHref); + int32_t GetTransferEncoding(); + bool GetContent(WideString& wsText); + bool SetContentType(const WideString& wsContentType); + bool SetHref(const WideString& wsHref); + bool SetTransferEncoding(int32_t iTransferEncoding); + + private: + bool m_bDefValue; +}; + +#endif // XFA_FXFA_PARSER_CXFA_IMAGEDATA_H_ diff --git a/xfa/fxfa/parser/cxfa_value.cpp b/xfa/fxfa/parser/cxfa_value.cpp index 9b7040c33b..5b812a9f7f 100644 --- a/xfa/fxfa/parser/cxfa_value.cpp +++ b/xfa/fxfa/parser/cxfa_value.cpp @@ -49,8 +49,8 @@ CXFA_ExData CXFA_Value::GetExData() { : nullptr); } -CXFA_Image CXFA_Value::GetImage() { - return CXFA_Image( +CXFA_ImageData CXFA_Value::GetImageData() { + return CXFA_ImageData( m_pNode ? (m_pNode->GetNodeItem(XFA_NODEITEM_FirstChild)) : nullptr, true); } diff --git a/xfa/fxfa/parser/cxfa_value.h b/xfa/fxfa/parser/cxfa_value.h index 513f37509b..65a9c36b00 100644 --- a/xfa/fxfa/parser/cxfa_value.h +++ b/xfa/fxfa/parser/cxfa_value.h @@ -11,7 +11,7 @@ #include "xfa/fxfa/parser/cxfa_arcdata.h" #include "xfa/fxfa/parser/cxfa_data.h" #include "xfa/fxfa/parser/cxfa_exdata.h" -#include "xfa/fxfa/parser/cxfa_image.h" +#include "xfa/fxfa/parser/cxfa_imagedata.h" #include "xfa/fxfa/parser/cxfa_line.h" #include "xfa/fxfa/parser/cxfa_rectangle.h" #include "xfa/fxfa/parser/cxfa_text.h" @@ -29,7 +29,7 @@ class CXFA_Value : public CXFA_Data { CXFA_Rectangle GetRectangle(); CXFA_Text GetText(); CXFA_ExData GetExData(); - CXFA_Image GetImage(); + CXFA_ImageData GetImageData(); }; #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 37d8084399..a6441a68db 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -138,13 +138,13 @@ void CreateDataBinding(CXFA_Node* pFormNode, WideString wsFormattedValue; switch (eUIType) { case XFA_Element::ImageEdit: { - CXFA_Image image = defValue.GetImage(); + CXFA_ImageData imageData = defValue.GetImageData(); WideString wsContentType; WideString wsHref; - if (image) { - image.GetContent(wsValue); - image.GetContentType(wsContentType); - image.GetHref(wsHref); + if (imageData) { + imageData.GetContent(wsValue); + imageData.GetContentType(wsContentType); + imageData.GetHref(wsHref); } CFX_XMLElement* pXMLDataElement = static_cast(pDataNode->GetXMLMappingNode()); @@ -297,8 +297,8 @@ void CreateDataBinding(CXFA_Node* pFormNode, case XFA_Element::ImageEdit: { FormValueNode_SetChildContent(defValue.GetNode(), wsNormalizeValue, XFA_Element::Image); - CXFA_Image image = defValue.GetImage(); - if (image) { + CXFA_ImageData imageData = defValue.GetImageData(); + if (imageData) { CFX_XMLElement* pXMLDataElement = static_cast(pDataNode->GetXMLMappingNode()); ASSERT(pXMLDataElement); @@ -308,12 +308,12 @@ void CreateDataBinding(CXFA_Node* pFormNode, if (!wsContentType.IsEmpty()) { pDataNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType, false, false); - image.SetContentType(wsContentType); + imageData.SetContentType(wsContentType); } WideString wsHref = pXMLDataElement->GetString(L"href"); if (!wsHref.IsEmpty()) - image.SetHref(wsHref); + imageData.SetHref(wsHref); } break; } -- cgit v1.2.3