OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 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 "../../include/reflow/reflowengine.h" | 7 #include "../../include/reflow/reflowengine.h" |
8 #include "reflowedpage.h" | 8 #include "reflowedpage.h" |
9 CPDF_ProgressiveReflowPageParser::CPDF_ProgressiveReflowPageParser() | 9 CPDF_ProgressiveReflowPageParser::CPDF_ProgressiveReflowPageParser() |
10 { | 10 { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 144 } |
145 if (FALSE == RetainPageObjsMemberShip()) { | 145 if (FALSE == RetainPageObjsMemberShip()) { |
146 return NULL; | 146 return NULL; |
147 } | 147 } |
148 CRF_PageInfo* pPageInfo = (CRF_PageInfo*)m_pPageInfos->GetValueAt(pObj); | 148 CRF_PageInfo* pPageInfo = (CRF_PageInfo*)m_pPageInfos->GetValueAt(pObj); |
149 if (NULL == pPageInfo) { | 149 if (NULL == pPageInfo) { |
150 return NULL; | 150 return NULL; |
151 } | 151 } |
152 return pPageInfo->GetFormDict(); | 152 return pPageInfo->GetFormDict(); |
153 } | 153 } |
154 void CPDF_ReflowedPage::GetDisplayMatrix(CFX_AffineMatrix& matrix, FX_INT32 xPos
, FX_INT32 yPos, FX_INT32 xSize, FX_INT32 ySize, FX_INT32 iRotate, const CFX_Aff
ineMatrix* pPageMatrix) | 154 void CPDF_ReflowedPage::GetDisplayMatrix(CFX_AffineMatrix& matrix, int32_t xPos,
int32_t yPos, int32_t xSize, int32_t ySize, int32_t iRotate, const CFX_AffineMa
trix* pPageMatrix) |
155 { | 155 { |
156 CFX_AffineMatrix display_matrix; | 156 CFX_AffineMatrix display_matrix; |
157 if(m_PageHeight == 0) { | 157 if(m_PageHeight == 0) { |
158 matrix.Set(1, 0, 0, -1, 0, 0); | 158 matrix.Set(1, 0, 0, -1, 0, 0); |
159 return; | 159 return; |
160 } | 160 } |
161 FX_INT32 x0, y0, x1, y1, x2, y2; | 161 int32_t x0, y0, x1, y1, x2, y2; |
162 iRotate %= 4; | 162 iRotate %= 4; |
163 switch (iRotate) { | 163 switch (iRotate) { |
164 case 0: | 164 case 0: |
165 x0 = xPos; | 165 x0 = xPos; |
166 y0 = yPos; | 166 y0 = yPos; |
167 x1 = xPos; | 167 x1 = xPos; |
168 y1 = yPos + ySize; | 168 y1 = yPos + ySize; |
169 x2 = xPos + xSize; | 169 x2 = xPos + xSize; |
170 y2 = yPos; | 170 y2 = yPos; |
171 break; | 171 break; |
(...skipping 28 matching lines...) Expand all Loading... |
200 FXSYS_Div((FX_FLOAT)(y1 - y0), m_PageHeight), | 200 FXSYS_Div((FX_FLOAT)(y1 - y0), m_PageHeight), |
201 (FX_FLOAT)(x0), (FX_FLOAT)(y0)); | 201 (FX_FLOAT)(x0), (FX_FLOAT)(y0)); |
202 matrix.Set(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f); | 202 matrix.Set(1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f); |
203 matrix.Concat(display_matrix); | 203 matrix.Concat(display_matrix); |
204 return; | 204 return; |
205 } | 205 } |
206 FX_FLOAT CPDF_ReflowedPage::GetPageHeight() | 206 FX_FLOAT CPDF_ReflowedPage::GetPageHeight() |
207 { | 207 { |
208 return m_PageHeight; | 208 return m_PageHeight; |
209 } | 209 } |
210 void CPDF_ReflowedPage::FocusGetData(const CFX_AffineMatrix matrix, FX_INT32 x,
FX_INT32 y, CFX_ByteString& str) | 210 void CPDF_ReflowedPage::FocusGetData(const CFX_AffineMatrix matrix, int32_t x, i
nt32_t y, CFX_ByteString& str) |
211 { | 211 { |
212 if (NULL == m_pReflowed) { | 212 if (NULL == m_pReflowed) { |
213 return; | 213 return; |
214 } | 214 } |
215 CFX_AffineMatrix revMatrix; | 215 CFX_AffineMatrix revMatrix; |
216 revMatrix.SetReverse(matrix); | 216 revMatrix.SetReverse(matrix); |
217 FX_FLOAT x1, y1; | 217 FX_FLOAT x1, y1; |
218 revMatrix.Transform((float)x, (float)y, x1, y1); | 218 revMatrix.Transform((float)x, (float)y, x1, y1); |
219 int count = m_pReflowed->GetSize(); | 219 int count = m_pReflowed->GetSize(); |
220 FX_FLOAT dx = 1000, dy = 1000; | 220 FX_FLOAT dx = 1000, dy = 1000; |
221 FX_INT32 pos = 0; | 221 int32_t pos = 0; |
222 FX_INT32 i; | 222 int32_t i; |
223 for(i = 0; i < count; i++) { | 223 for(i = 0; i < count; i++) { |
224 CRF_Data* pData = (*m_pReflowed)[i]; | 224 CRF_Data* pData = (*m_pReflowed)[i]; |
225 FX_FLOAT tempdy = FXSYS_fabs(pData->m_PosY - y1); | 225 FX_FLOAT tempdy = FXSYS_fabs(pData->m_PosY - y1); |
226 if(FXSYS_fabs(tempdy - dy) < 1) { | 226 if(FXSYS_fabs(tempdy - dy) < 1) { |
227 continue; | 227 continue; |
228 } | 228 } |
229 CFX_FloatRect rect (0, pData->m_PosY + pData->m_Height, this->m_PageWidt
h, pData->m_PosY); | 229 CFX_FloatRect rect (0, pData->m_PosY + pData->m_Height, this->m_PageWidt
h, pData->m_PosY); |
230 if(rect.Contains(x1, y1)) { | 230 if(rect.Contains(x1, y1)) { |
231 pos = i; | 231 pos = i; |
232 dx = 0; | 232 dx = 0; |
(...skipping 26 matching lines...) Expand all Loading... |
259 FX_FLOAT tempdx = FXSYS_fabs(pData->m_PosX - x1); | 259 FX_FLOAT tempdx = FXSYS_fabs(pData->m_PosX - x1); |
260 if(tempdx < dx) { | 260 if(tempdx < dx) { |
261 dx = tempdx; | 261 dx = tempdx; |
262 pos = i; | 262 pos = i; |
263 } | 263 } |
264 } | 264 } |
265 } | 265 } |
266 } | 266 } |
267 str.Format("%d", pos); | 267 str.Format("%d", pos); |
268 } | 268 } |
269 FX_BOOL CPDF_ReflowedPage::FocusGetPosition(const CFX_AffineMatrix matrix, CFX_B
yteString str, FX_INT32& x, FX_INT32& y) | 269 FX_BOOL CPDF_ReflowedPage::FocusGetPosition(const CFX_AffineMatrix matrix, CFX_B
yteString str, int32_t& x, int32_t& y) |
270 { | 270 { |
271 if (NULL == m_pReflowed) { | 271 if (NULL == m_pReflowed) { |
272 return FALSE; | 272 return FALSE; |
273 } | 273 } |
274 FX_INT32 pos = FXSYS_atoi(str); | 274 int32_t pos = FXSYS_atoi(str); |
275 if(pos < 0 || pos >= m_pReflowed->GetSize()) { | 275 if(pos < 0 || pos >= m_pReflowed->GetSize()) { |
276 return FALSE; | 276 return FALSE; |
277 } | 277 } |
278 CRF_Data* pData = (*m_pReflowed)[pos]; | 278 CRF_Data* pData = (*m_pReflowed)[pos]; |
279 FX_FLOAT x1, y1; | 279 FX_FLOAT x1, y1; |
280 matrix.Transform(pData->m_PosX, pData->m_PosY + pData->m_Height, x1, y1); | 280 matrix.Transform(pData->m_PosX, pData->m_PosY + pData->m_Height, x1, y1); |
281 x = (int)x1; | 281 x = (int)x1; |
282 y = (int)y1; | 282 y = (int)y1; |
283 return TRUE; | 283 return TRUE; |
284 } | 284 } |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 } | 419 } |
420 CPDF_ProgressiveReflowPageRender::CPDF_ProgressiveReflowPageRender() | 420 CPDF_ProgressiveReflowPageRender::CPDF_ProgressiveReflowPageRender() |
421 { | 421 { |
422 m_Status = Ready; | 422 m_Status = Ready; |
423 m_pReflowPage = NULL; | 423 m_pReflowPage = NULL; |
424 m_pDisplayMatrix = NULL; | 424 m_pDisplayMatrix = NULL; |
425 m_CurrNum = 0; | 425 m_CurrNum = 0; |
426 m_pFontEncoding = NULL; | 426 m_pFontEncoding = NULL; |
427 m_DisplayColor = -1; | 427 m_DisplayColor = -1; |
428 } | 428 } |
429 static FX_FLOAT _CIDTransformToFloat(FX_BYTE ch) | 429 static FX_FLOAT _CIDTransformToFloat(uint8_t ch) |
430 { | 430 { |
431 if (ch < 128) { | 431 if (ch < 128) { |
432 return ch * 1.0f / 127; | 432 return ch * 1.0f / 127; |
433 } | 433 } |
434 return (-255 + ch) * 1.0f / 127; | 434 return (-255 + ch) * 1.0f / 127; |
435 } | 435 } |
436 int CPDF_ProgressiveReflowPageRender::GetPosition() | 436 int CPDF_ProgressiveReflowPageRender::GetPosition() |
437 { | 437 { |
438 if(m_CurrNum == 0 || NULL == m_pReflowPage) { | 438 if(m_CurrNum == 0 || NULL == m_pReflowPage) { |
439 return 0; | 439 return 0; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 { | 613 { |
614 if (m_pDisplayMatrix) { | 614 if (m_pDisplayMatrix) { |
615 delete m_pDisplayMatrix; | 615 delete m_pDisplayMatrix; |
616 } | 616 } |
617 m_pDisplayMatrix = NULL; | 617 m_pDisplayMatrix = NULL; |
618 m_pReflowPage = NULL; | 618 m_pReflowPage = NULL; |
619 m_pFXDevice = NULL; | 619 m_pFXDevice = NULL; |
620 m_CurrNum = 0; | 620 m_CurrNum = 0; |
621 m_Status = Ready; | 621 m_Status = Ready; |
622 } | 622 } |
OLD | NEW |