blob: 8061018470c7be7c9130ed54de5fcc85e5d46b2c [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
9#include "xfa/fxfa/parser/xfa_object.h"
10
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() {
15 return m_pNode->GetEnum(XFA_ATTRIBUTE_Aspect);
16}
17
tsepezd19e9122016-11-02 15:43:18 -070018bool CXFA_Image::GetContentType(CFX_WideString& wsContentType) {
dsinclair44d054c2016-04-06 10:23:46 -070019 return m_pNode->TryCData(XFA_ATTRIBUTE_ContentType, wsContentType);
20}
21
tsepezd19e9122016-11-02 15:43:18 -070022bool CXFA_Image::GetHref(CFX_WideString& wsHref) {
dsinclair44d054c2016-04-06 10:23:46 -070023 if (m_bDefValue)
24 return m_pNode->TryCData(XFA_ATTRIBUTE_Href, wsHref);
25 return m_pNode->GetAttribute(FX_WSTRC(L"href"), wsHref);
26}
27
28int32_t CXFA_Image::GetTransferEncoding() {
29 if (m_bDefValue)
30 return m_pNode->GetEnum(XFA_ATTRIBUTE_TransferEncoding);
31 return XFA_ATTRIBUTEENUM_Base64;
32}
33
tsepezd19e9122016-11-02 15:43:18 -070034bool CXFA_Image::GetContent(CFX_WideString& wsText) {
dsinclair44d054c2016-04-06 10:23:46 -070035 return m_pNode->TryContent(wsText);
36}
37
tsepezd19e9122016-11-02 15:43:18 -070038bool CXFA_Image::SetContentType(const CFX_WideString& wsContentType) {
dsinclair44d054c2016-04-06 10:23:46 -070039 return m_pNode->SetCData(XFA_ATTRIBUTE_ContentType, wsContentType);
40}
41
tsepezd19e9122016-11-02 15:43:18 -070042bool CXFA_Image::SetHref(const CFX_WideString& wsHref) {
dsinclair44d054c2016-04-06 10:23:46 -070043 if (m_bDefValue)
44 return m_pNode->SetCData(XFA_ATTRIBUTE_Href, wsHref);
tsepez4c3debb2016-04-08 12:20:38 -070045 return m_pNode->SetAttribute(XFA_ATTRIBUTE_Href, wsHref.AsStringC());
dsinclair44d054c2016-04-06 10:23:46 -070046}
47
tsepezd19e9122016-11-02 15:43:18 -070048bool CXFA_Image::SetTransferEncoding(int32_t iTransferEncoding) {
dsinclair44d054c2016-04-06 10:23:46 -070049 if (m_bDefValue) {
50 return m_pNode->SetEnum(XFA_ATTRIBUTE_TransferEncoding,
51 (XFA_ATTRIBUTEENUM)iTransferEncoding);
52 }
tsepezd19e9122016-11-02 15:43:18 -070053 return true;
dsinclair44d054c2016-04-06 10:23:46 -070054}