1 // Copyright 2016 The PDFium Authors 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 "core/fpdfapi/page/cpdf_formobject.h" 8 9 #include <utility> 10 11 #include "core/fpdfapi/page/cpdf_form.h" 12 CPDF_FormObject(int32_t content_stream,std::unique_ptr<CPDF_Form> pForm,const CFX_Matrix & matrix)13CPDF_FormObject::CPDF_FormObject(int32_t content_stream, 14 std::unique_ptr<CPDF_Form> pForm, 15 const CFX_Matrix& matrix) 16 : CPDF_PageObject(content_stream), 17 m_pForm(std::move(pForm)), 18 m_FormMatrix(matrix) {} 19 20 CPDF_FormObject::~CPDF_FormObject() = default; 21 Transform(const CFX_Matrix & matrix)22void CPDF_FormObject::Transform(const CFX_Matrix& matrix) { 23 m_FormMatrix.Concat(matrix); 24 CalcBoundingBox(); 25 SetDirty(true); 26 } 27 IsForm() const28bool CPDF_FormObject::IsForm() const { 29 return true; 30 } 31 AsForm()32CPDF_FormObject* CPDF_FormObject::AsForm() { 33 return this; 34 } 35 AsForm() const36const CPDF_FormObject* CPDF_FormObject::AsForm() const { 37 return this; 38 } 39 GetType() const40CPDF_PageObject::Type CPDF_FormObject::GetType() const { 41 return Type::kForm; 42 } 43 CalcBoundingBox()44void CPDF_FormObject::CalcBoundingBox() { 45 SetRect(m_FormMatrix.TransformRect(m_pForm->CalcBoundingBox())); 46 } 47 SetFormMatrix(const CFX_Matrix & matrix)48void CPDF_FormObject::SetFormMatrix(const CFX_Matrix& matrix) { 49 m_FormMatrix = matrix; 50 CalcBoundingBox(); 51 } 52