| Index: core/fpdfapi/fpdf_page/cpdf_textobject.cpp
|
| diff --git a/core/fpdfapi/fpdf_page/fpdf_page.cpp b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
|
| similarity index 56%
|
| rename from core/fpdfapi/fpdf_page/fpdf_page.cpp
|
| rename to core/fpdfapi/fpdf_page/cpdf_textobject.cpp
|
| index ad54e320bc23c65e459ca8fae97889009b04d4f3..b4161f320e2da7c649fcc3203cb53822326222c6 100644
|
| --- a/core/fpdfapi/fpdf_page/fpdf_page.cpp
|
| +++ b/core/fpdfapi/fpdf_page/cpdf_textobject.cpp
|
| @@ -1,57 +1,10 @@
|
| -// Copyright 2014 PDFium Authors. All rights reserved.
|
| +// 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 "core/fpdfapi/fpdf_page/pageint.h"
|
| -
|
| -#include <algorithm>
|
| -
|
| -#include "core/fpdfapi/fpdf_page/include/cpdf_form.h"
|
| -#include "core/fpdfapi/fpdf_page/include/cpdf_page.h"
|
| -#include "core/fpdfapi/fpdf_parser/include/cpdf_array.h"
|
| -#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
|
| -#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
|
| -#include "core/fpdfapi/include/cpdf_modulemgr.h"
|
| -#include "core/fpdfapi/ipdf_rendermodule.h"
|
| -#include "third_party/base/stl_util.h"
|
| -
|
| -CPDF_PageObject::CPDF_PageObject() {}
|
| -
|
| -CPDF_PageObject::~CPDF_PageObject() {}
|
| -
|
| -void CPDF_PageObject::CopyData(const CPDF_PageObject* pSrc) {
|
| - CopyStates(*pSrc);
|
| - m_Left = pSrc->m_Left;
|
| - m_Right = pSrc->m_Right;
|
| - m_Top = pSrc->m_Top;
|
| - m_Bottom = pSrc->m_Bottom;
|
| -}
|
| -
|
| -void CPDF_PageObject::TransformClipPath(CFX_Matrix& matrix) {
|
| - if (m_ClipPath.IsNull()) {
|
| - return;
|
| - }
|
| - m_ClipPath.GetModify();
|
| - m_ClipPath.Transform(matrix);
|
| -}
|
| -
|
| -void CPDF_PageObject::TransformGeneralState(CFX_Matrix& matrix) {
|
| - if (m_GeneralState.IsNull()) {
|
| - return;
|
| - }
|
| - CPDF_GeneralStateData* pGS = m_GeneralState.GetModify();
|
| - pGS->m_Matrix.Concat(matrix);
|
| -}
|
| -
|
| -FX_RECT CPDF_PageObject::GetBBox(const CFX_Matrix* pMatrix) const {
|
| - CFX_FloatRect rect(m_Left, m_Bottom, m_Right, m_Top);
|
| - if (pMatrix) {
|
| - pMatrix->TransformRect(rect);
|
| - }
|
| - return rect.GetOutterRect();
|
| -}
|
| +#include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h"
|
|
|
| CPDF_TextObject::CPDF_TextObject()
|
| : m_PosX(0),
|
| @@ -390,247 +343,3 @@ void CPDF_TextObject::SetPosition(FX_FLOAT x, FX_FLOAT y) {
|
| m_Top += dy;
|
| m_Bottom += dy;
|
| }
|
| -
|
| -CPDF_ShadingObject::CPDF_ShadingObject() : m_pShading(nullptr) {}
|
| -
|
| -CPDF_ShadingObject::~CPDF_ShadingObject() {}
|
| -
|
| -CPDF_ShadingObject* CPDF_ShadingObject::Clone() const {
|
| - CPDF_ShadingObject* obj = new CPDF_ShadingObject;
|
| - obj->CopyData(this);
|
| -
|
| - obj->m_pShading = m_pShading;
|
| - if (obj->m_pShading && obj->m_pShading->m_pDocument) {
|
| - CPDF_DocPageData* pDocPageData =
|
| - obj->m_pShading->m_pDocument->GetPageData();
|
| - obj->m_pShading = (CPDF_ShadingPattern*)pDocPageData->GetPattern(
|
| - obj->m_pShading->m_pShadingObj, m_pShading->m_bShadingObj,
|
| - &obj->m_pShading->m_ParentMatrix);
|
| - }
|
| - obj->m_Matrix = m_Matrix;
|
| - return obj;
|
| -}
|
| -
|
| -void CPDF_ShadingObject::Transform(const CFX_Matrix& matrix) {
|
| - if (!m_ClipPath.IsNull()) {
|
| - m_ClipPath.GetModify();
|
| - m_ClipPath.Transform(matrix);
|
| - }
|
| - m_Matrix.Concat(matrix);
|
| - if (!m_ClipPath.IsNull()) {
|
| - CalcBoundingBox();
|
| - } else {
|
| - matrix.TransformRect(m_Left, m_Right, m_Top, m_Bottom);
|
| - }
|
| -}
|
| -
|
| -void CPDF_ShadingObject::CalcBoundingBox() {
|
| - if (m_ClipPath.IsNull()) {
|
| - return;
|
| - }
|
| - CFX_FloatRect rect = m_ClipPath.GetClipBox();
|
| - m_Left = rect.left;
|
| - m_Bottom = rect.bottom;
|
| - m_Right = rect.right;
|
| - m_Top = rect.top;
|
| -}
|
| -
|
| -CPDF_FormObject::CPDF_FormObject() : m_pForm(nullptr) {}
|
| -
|
| -CPDF_FormObject::~CPDF_FormObject() {
|
| - delete m_pForm;
|
| -}
|
| -
|
| -void CPDF_FormObject::Transform(const CFX_Matrix& matrix) {
|
| - m_FormMatrix.Concat(matrix);
|
| - CalcBoundingBox();
|
| -}
|
| -
|
| -CPDF_FormObject* CPDF_FormObject::Clone() const {
|
| - CPDF_FormObject* obj = new CPDF_FormObject;
|
| - obj->CopyData(this);
|
| -
|
| - obj->m_pForm = m_pForm->Clone();
|
| - obj->m_FormMatrix = m_FormMatrix;
|
| - return obj;
|
| -}
|
| -
|
| -void CPDF_FormObject::CalcBoundingBox() {
|
| - CFX_FloatRect form_rect = m_pForm->CalcBoundingBox();
|
| - form_rect.Transform(&m_FormMatrix);
|
| - m_Left = form_rect.left;
|
| - m_Bottom = form_rect.bottom;
|
| - m_Right = form_rect.right;
|
| - m_Top = form_rect.top;
|
| -}
|
| -
|
| -CPDF_Page::CPDF_Page() : m_pPageRender(nullptr) {}
|
| -
|
| -void CPDF_Page::Load(CPDF_Document* pDocument,
|
| - CPDF_Dictionary* pPageDict,
|
| - FX_BOOL bPageCache) {
|
| - m_pDocument = (CPDF_Document*)pDocument;
|
| - m_pFormDict = pPageDict;
|
| - if (bPageCache) {
|
| - m_pPageRender =
|
| - CPDF_ModuleMgr::Get()->GetRenderModule()->CreatePageCache(this);
|
| - }
|
| - if (!pPageDict) {
|
| - m_PageWidth = m_PageHeight = 100 * 1.0f;
|
| - m_pPageResources = m_pResources = NULL;
|
| - return;
|
| - }
|
| - CPDF_Object* pageAttr = GetPageAttr("Resources");
|
| - m_pResources = pageAttr ? pageAttr->GetDict() : NULL;
|
| - m_pPageResources = m_pResources;
|
| - CPDF_Object* pRotate = GetPageAttr("Rotate");
|
| - int rotate = 0;
|
| - if (pRotate) {
|
| - rotate = pRotate->GetInteger() / 90 % 4;
|
| - }
|
| - if (rotate < 0) {
|
| - rotate += 4;
|
| - }
|
| - CPDF_Array* pMediaBox = ToArray(GetPageAttr("MediaBox"));
|
| - CFX_FloatRect mediabox;
|
| - if (pMediaBox) {
|
| - mediabox = pMediaBox->GetRect();
|
| - mediabox.Normalize();
|
| - }
|
| - if (mediabox.IsEmpty()) {
|
| - mediabox = CFX_FloatRect(0, 0, 612, 792);
|
| - }
|
| -
|
| - CPDF_Array* pCropBox = ToArray(GetPageAttr("CropBox"));
|
| - if (pCropBox) {
|
| - m_BBox = pCropBox->GetRect();
|
| - m_BBox.Normalize();
|
| - }
|
| - if (m_BBox.IsEmpty()) {
|
| - m_BBox = mediabox;
|
| - } else {
|
| - m_BBox.Intersect(mediabox);
|
| - }
|
| - if (rotate % 2) {
|
| - m_PageHeight = m_BBox.right - m_BBox.left;
|
| - m_PageWidth = m_BBox.top - m_BBox.bottom;
|
| - } else {
|
| - m_PageWidth = m_BBox.right - m_BBox.left;
|
| - m_PageHeight = m_BBox.top - m_BBox.bottom;
|
| - }
|
| - switch (rotate) {
|
| - case 0:
|
| - m_PageMatrix.Set(1.0f, 0, 0, 1.0f, -m_BBox.left, -m_BBox.bottom);
|
| - break;
|
| - case 1:
|
| - m_PageMatrix.Set(0, -1.0f, 1.0f, 0, -m_BBox.bottom, m_BBox.right);
|
| - break;
|
| - case 2:
|
| - m_PageMatrix.Set(-1.0f, 0, 0, -1.0f, m_BBox.right, m_BBox.top);
|
| - break;
|
| - case 3:
|
| - m_PageMatrix.Set(0, 1.0f, -1.0f, 0, m_BBox.top, -m_BBox.left);
|
| - break;
|
| - }
|
| - m_Transparency = PDFTRANS_ISOLATED;
|
| - LoadTransInfo();
|
| -}
|
| -
|
| -void CPDF_Page::StartParse(CPDF_ParseOptions* pOptions) {
|
| - if (m_ParseState == CONTENT_PARSED || m_ParseState == CONTENT_PARSING) {
|
| - return;
|
| - }
|
| - m_pParser.reset(new CPDF_ContentParser);
|
| - m_pParser->Start(this, pOptions);
|
| - m_ParseState = CONTENT_PARSING;
|
| -}
|
| -
|
| -void CPDF_Page::ParseContent(CPDF_ParseOptions* pOptions) {
|
| - StartParse(pOptions);
|
| - ContinueParse(nullptr);
|
| -}
|
| -
|
| -CPDF_Page::~CPDF_Page() {
|
| - if (m_pPageRender) {
|
| - IPDF_RenderModule* pModule = CPDF_ModuleMgr::Get()->GetRenderModule();
|
| - pModule->DestroyPageCache(m_pPageRender);
|
| - }
|
| -}
|
| -
|
| -CPDF_Object* FPDFAPI_GetPageAttr(CPDF_Dictionary* pPageDict,
|
| - const CFX_ByteStringC& name) {
|
| - int level = 0;
|
| - while (1) {
|
| - CPDF_Object* pObj = pPageDict->GetElementValue(name);
|
| - if (pObj) {
|
| - return pObj;
|
| - }
|
| - CPDF_Dictionary* pParent = pPageDict->GetDictBy("Parent");
|
| - if (!pParent || pParent == pPageDict) {
|
| - return NULL;
|
| - }
|
| - pPageDict = pParent;
|
| - level++;
|
| - if (level == 1000) {
|
| - return NULL;
|
| - }
|
| - }
|
| -}
|
| -
|
| -CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteStringC& name) const {
|
| - return FPDFAPI_GetPageAttr(m_pFormDict, name);
|
| -}
|
| -
|
| -void CPDF_Page::GetDisplayMatrix(CFX_Matrix& matrix,
|
| - int xPos,
|
| - int yPos,
|
| - int xSize,
|
| - int ySize,
|
| - int iRotate) const {
|
| - if (m_PageWidth == 0 || m_PageHeight == 0) {
|
| - return;
|
| - }
|
| - CFX_Matrix display_matrix;
|
| - int x0, y0, x1, y1, x2, y2;
|
| - iRotate %= 4;
|
| - switch (iRotate) {
|
| - case 0:
|
| - x0 = xPos;
|
| - y0 = yPos + ySize;
|
| - x1 = xPos;
|
| - y1 = yPos;
|
| - x2 = xPos + xSize;
|
| - y2 = yPos + ySize;
|
| - break;
|
| - case 1:
|
| - x0 = xPos;
|
| - y0 = yPos;
|
| - x1 = xPos + xSize;
|
| - y1 = yPos;
|
| - x2 = xPos;
|
| - y2 = yPos + ySize;
|
| - break;
|
| - case 2:
|
| - x0 = xPos + xSize;
|
| - y0 = yPos;
|
| - x1 = xPos + xSize;
|
| - y1 = yPos + ySize;
|
| - x2 = xPos;
|
| - y2 = yPos;
|
| - break;
|
| - case 3:
|
| - x0 = xPos + xSize;
|
| - y0 = yPos + ySize;
|
| - x1 = xPos;
|
| - y1 = yPos + ySize;
|
| - x2 = xPos + xSize;
|
| - y2 = yPos;
|
| - break;
|
| - }
|
| - display_matrix.Set(
|
| - ((FX_FLOAT)(x2 - x0)) / m_PageWidth, ((FX_FLOAT)(y2 - y0)) / m_PageWidth,
|
| - ((FX_FLOAT)(x1 - x0)) / m_PageHeight,
|
| - ((FX_FLOAT)(y1 - y0)) / m_PageHeight, (FX_FLOAT)x0, (FX_FLOAT)y0);
|
| - matrix = m_PageMatrix;
|
| - matrix.Concat(display_matrix);
|
| -}
|
|
|