| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 7 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 11 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
| 12 #include "core/fpdfapi/fpdf_page/pageint.h" | 12 #include "core/fpdfapi/fpdf_page/pageint.h" |
| 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 13 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
| 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 14 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
| 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" | 15 #include "core/fpdfapi/fpdf_parser/include/cpdf_object.h" |
| 16 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" | 16 #include "core/fpdfapi/fpdf_render/cpdf_pagerendercache.h" |
| 17 #include "core/fpdfapi/include/rendercontext.h" |
| 17 #include "third_party/base/stl_util.h" | 18 #include "third_party/base/stl_util.h" |
| 18 | 19 |
| 19 CPDF_Page::CPDF_Page(CPDF_Document* pDocument, | 20 CPDF_Page::CPDF_Page(CPDF_Document* pDocument, |
| 20 CPDF_Dictionary* pPageDict, | 21 CPDF_Dictionary* pPageDict, |
| 21 bool bPageCache) | 22 bool bPageCache) |
| 22 : m_PageWidth(100), | 23 : m_PageWidth(100), |
| 23 m_PageHeight(100), | 24 m_PageHeight(100), |
| 24 m_pView(nullptr), | 25 m_pView(nullptr), |
| 25 m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) { | 26 m_pPageRender(bPageCache ? new CPDF_PageRenderCache(this) : nullptr) { |
| 26 m_pFormDict = pPageDict; | 27 m_pFormDict = pPageDict; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 m_pParser.reset(new CPDF_ContentParser); | 89 m_pParser.reset(new CPDF_ContentParser); |
| 89 m_pParser->Start(this); | 90 m_pParser->Start(this); |
| 90 m_ParseState = CONTENT_PARSING; | 91 m_ParseState = CONTENT_PARSING; |
| 91 } | 92 } |
| 92 | 93 |
| 93 void CPDF_Page::ParseContent() { | 94 void CPDF_Page::ParseContent() { |
| 94 StartParse(); | 95 StartParse(); |
| 95 ContinueParse(nullptr); | 96 ContinueParse(nullptr); |
| 96 } | 97 } |
| 97 | 98 |
| 99 void CPDF_Page::SetRenderContext(std::unique_ptr<CRenderContext> pContext) { |
| 100 m_pRenderContext = std::move(pContext); |
| 101 } |
| 102 |
| 98 CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const { | 103 CPDF_Object* CPDF_Page::GetPageAttr(const CFX_ByteString& name) const { |
| 99 CPDF_Dictionary* pPageDict = m_pFormDict; | 104 CPDF_Dictionary* pPageDict = m_pFormDict; |
| 100 std::set<CPDF_Dictionary*> visited; | 105 std::set<CPDF_Dictionary*> visited; |
| 101 while (1) { | 106 while (1) { |
| 102 visited.insert(pPageDict); | 107 visited.insert(pPageDict); |
| 103 if (CPDF_Object* pObj = pPageDict->GetDirectObjectBy(name)) | 108 if (CPDF_Object* pObj = pPageDict->GetDirectObjectBy(name)) |
| 104 return pObj; | 109 return pObj; |
| 105 | 110 |
| 106 pPageDict = pPageDict->GetDictBy("Parent"); | 111 pPageDict = pPageDict->GetDictBy("Parent"); |
| 107 if (!pPageDict || pdfium::ContainsKey(visited, pPageDict)) | 112 if (!pPageDict || pdfium::ContainsKey(visited, pPageDict)) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 y2 = yPos; | 166 y2 = yPos; |
| 162 break; | 167 break; |
| 163 } | 168 } |
| 164 display_matrix.Set( | 169 display_matrix.Set( |
| 165 ((FX_FLOAT)(x2 - x0)) / m_PageWidth, ((FX_FLOAT)(y2 - y0)) / m_PageWidth, | 170 ((FX_FLOAT)(x2 - x0)) / m_PageWidth, ((FX_FLOAT)(y2 - y0)) / m_PageWidth, |
| 166 ((FX_FLOAT)(x1 - x0)) / m_PageHeight, | 171 ((FX_FLOAT)(x1 - x0)) / m_PageHeight, |
| 167 ((FX_FLOAT)(y1 - y0)) / m_PageHeight, (FX_FLOAT)x0, (FX_FLOAT)y0); | 172 ((FX_FLOAT)(y1 - y0)) / m_PageHeight, (FX_FLOAT)x0, (FX_FLOAT)y0); |
| 168 matrix = m_PageMatrix; | 173 matrix = m_PageMatrix; |
| 169 matrix.Concat(display_matrix); | 174 matrix.Concat(display_matrix); |
| 170 } | 175 } |
| OLD | NEW |