blob: 34072392f7b700e81908a2e7c56d37d6972ed40a [file] [log] [blame]
dsinclair44d054c2016-04-06 10:23:46 -07001// Copyright 2016 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "xfa/fxfa/parser/cxfa_image.h"
8
Dan Sinclairefcae5d2017-03-29 14:47:46 -04009#include "xfa/fxfa/parser/cxfa_node.h"
dsinclair44d054c2016-04-06 10:23:46 -070010
tsepezd19e9122016-11-02 15:43:18 -070011CXFA_Image::CXFA_Image(CXFA_Node* pNode, bool bDefValue)
dsinclair44d054c2016-04-06 10:23:46 -070012 : CXFA_Data(pNode), m_bDefValue(bDefValue) {}
13
14int32_t CXFA_Image::GetAspect() {
Dan Sinclaire5434b52017-11-01 16:04:36 +000015 return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_Aspect);
dsinclair44d054c2016-04-06 10:23:46 -070016}
17
Ryan Harrison275e2602017-09-18 14:23:18 -040018bool CXFA_Image::GetContentType(WideString& wsContentType) {
Dan Sinclaire5434b52017-11-01 16:04:36 +000019 return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
dsinclair44d054c2016-04-06 10:23:46 -070020}
21
Ryan Harrison275e2602017-09-18 14:23:18 -040022bool CXFA_Image::GetHref(WideString& wsHref) {
dsinclair44d054c2016-04-06 10:23:46 -070023 if (m_bDefValue)
Dan Sinclaire5434b52017-11-01 16:04:36 +000024 return m_pNode->JSNode()->TryCData(XFA_ATTRIBUTE_Href, wsHref);
25 return m_pNode->JSNode()->GetAttribute(L"href", wsHref);
dsinclair44d054c2016-04-06 10:23:46 -070026}
27
28int32_t CXFA_Image::GetTransferEncoding() {
29 if (m_bDefValue)
Dan Sinclaire5434b52017-11-01 16:04:36 +000030 return m_pNode->JSNode()->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
dsinclair44d054c2016-04-06 10:23:46 -070031 return XFA_ATTRIBUTEENUM_Base64;
32}
33
Ryan Harrison275e2602017-09-18 14:23:18 -040034bool CXFA_Image::GetContent(WideString& wsText) {
Dan Sinclaire5434b52017-11-01 16:04:36 +000035 return m_pNode->JSNode()->TryContent(wsText);
dsinclair44d054c2016-04-06 10:23:46 -070036}
37
Ryan Harrison275e2602017-09-18 14:23:18 -040038bool CXFA_Image::SetContentType(const WideString& wsContentType) {
Dan Sinclaire5434b52017-11-01 16:04:36 +000039 return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
dsinclair44d054c2016-04-06 10:23:46 -070040}
41
Ryan Harrison275e2602017-09-18 14:23:18 -040042bool CXFA_Image::SetHref(const WideString& wsHref) {
dsinclair44d054c2016-04-06 10:23:46 -070043 if (m_bDefValue)
Dan Sinclaire5434b52017-11-01 16:04:36 +000044 return m_pNode->JSNode()->SetCData(XFA_ATTRIBUTE_Href, wsHref);
45 return m_pNode->JSNode()->SetAttribute(XFA_ATTRIBUTE_Href,
Dan Sinclair77fe0692017-11-02 18:15:07 +000046 wsHref.AsStringView(), false);
dsinclair44d054c2016-04-06 10:23:46 -070047}
48
tsepezd19e9122016-11-02 15:43:18 -070049bool CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) {
dsinclair44d054c2016-04-06 10:23:46 -070050 if (m_bDefValue) {
Dan Sinclaire5434b52017-11-01 16:04:36 +000051 return m_pNode->JSNode()->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
52 (XFA_ATTRIBUTEENUM)iTransferEncoding);
dsinclair44d054c2016-04-06 10:23:46 -070053 }
tsepezd19e9122016-11-02 15:43:18 -070054 return true;
dsinclair44d054c2016-04-06 10:23:46 -070055}