Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: core/fpdfapi/fpdf_page/cpdf_textstatedata.cpp

Issue 2287313004: Make CPDF_TextState have a CPDF_TextStateData rather than inheriting one. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@moar_better_constness
Patch Set: Casts, Casts, New -> Emplace. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_textstate.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_textstatedata.h" 7 #include "core/fpdfapi/fpdf_page/include/cpdf_textstatedata.h"
8 8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" 9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfapi/fpdf_page/pageint.h" 10 #include "core/fpdfapi/fpdf_page/pageint.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 } 66 }
67 67
68 CPDF_TextStateData::~CPDF_TextStateData() { 68 CPDF_TextStateData::~CPDF_TextStateData() {
69 if (m_pDocument && m_pFont) { 69 if (m_pDocument && m_pFont) {
70 CPDF_DocPageData* pPageData = m_pDocument->GetPageData(); 70 CPDF_DocPageData* pPageData = m_pDocument->GetPageData();
71 if (pPageData && !pPageData->IsForceClear()) 71 if (pPageData && !pPageData->IsForceClear())
72 pPageData->ReleaseFont(m_pFont->GetFontDict()); 72 pPageData->ReleaseFont(m_pFont->GetFontDict());
73 } 73 }
74 } 74 }
75
76 void CPDF_TextStateData::SetFont(CPDF_Font* pFont) {
77 CPDF_Document* pDoc = m_pDocument;
78 CPDF_DocPageData* pPageData = pDoc ? pDoc->GetPageData() : nullptr;
79 if (pPageData && m_pFont && !pPageData->IsForceClear())
80 pPageData->ReleaseFont(m_pFont->GetFontDict());
81
82 m_pDocument = pFont ? pFont->m_pDocument : nullptr;
83 m_pFont = pFont;
84 }
85
86 FX_FLOAT CPDF_TextStateData::GetFontSizeV() const {
87 return FXSYS_fabs(FXSYS_sqrt2(m_Matrix[1], m_Matrix[3]) * m_FontSize);
88 }
89
90 FX_FLOAT CPDF_TextStateData::GetFontSizeH() const {
91 return FXSYS_fabs(FXSYS_sqrt2(m_Matrix[0], m_Matrix[2]) * m_FontSize);
92 }
93
94 FX_FLOAT CPDF_TextStateData::GetBaselineAngle() const {
95 return FXSYS_atan2(m_Matrix[2], m_Matrix[0]);
96 }
97
98 FX_FLOAT CPDF_TextStateData::GetShearAngle() const {
99 return GetBaselineAngle() + FXSYS_atan2(m_Matrix[1], m_Matrix[3]);
100 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_page/cpdf_textstate.cpp ('k') | core/fpdfapi/fpdf_page/fpdf_page_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698