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 "core/include/fpdfapi/fpdf_page.h" | 7 #include "core/include/fpdfapi/fpdf_page.h" |
8 #include "core/include/fpdfapi/fpdf_pageobj.h" | 8 #include "core/include/fpdfapi/fpdf_pageobj.h" |
9 #include "text_int.h" | 9 #include "text_int.h" |
10 | 10 |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 return FALSE; | 296 return FALSE; |
297 } | 297 } |
298 void GetTextStream_Unicode(CFX_WideTextBuf& buffer, | 298 void GetTextStream_Unicode(CFX_WideTextBuf& buffer, |
299 CPDF_PageObjects* pPage, | 299 CPDF_PageObjects* pPage, |
300 FX_BOOL bUseLF, | 300 FX_BOOL bUseLF, |
301 CFX_PtrArray* pObjArray) { | 301 CFX_PtrArray* pObjArray) { |
302 CPDF_TextStream textstream(buffer, bUseLF, pObjArray); | 302 CPDF_TextStream textstream(buffer, bUseLF, pObjArray); |
303 FX_POSITION pos = pPage->GetFirstObjectPosition(); | 303 FX_POSITION pos = pPage->GetFirstObjectPosition(); |
304 while (pos) { | 304 while (pos) { |
305 CPDF_PageObject* pObject = pPage->GetNextObject(pos); | 305 CPDF_PageObject* pObject = pPage->GetNextObject(pos); |
306 if (pObject == NULL) { | 306 if (pObject && pObject->m_Type == PDFPAGE_TEXT) |
307 continue; | 307 textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE); |
308 } | |
309 if (pObject->m_Type != PDFPAGE_TEXT) { | |
310 continue; | |
311 } | |
312 textstream.ProcessObject((CPDF_TextObject*)pObject, FALSE); | |
313 } | 308 } |
314 } | 309 } |
315 CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc, | 310 CFX_WideString PDF_GetFirstTextLine_Unicode(CPDF_Document* pDoc, |
316 CPDF_Dictionary* pPage) { | 311 CPDF_Dictionary* pPage) { |
317 CFX_WideTextBuf buffer; | 312 CFX_WideTextBuf buffer; |
318 buffer.EstimateSize(0, 1024); | 313 buffer.EstimateSize(0, 1024); |
319 CPDF_Page page; | 314 CPDF_Page page; |
320 page.Load(pDoc, pPage); | 315 page.Load(pDoc, pPage); |
321 CPDF_ParseOptions options; | 316 CPDF_ParseOptions options; |
322 options.m_bTextOnly = TRUE; | 317 options.m_bTextOnly = TRUE; |
323 options.m_bSeparateForm = FALSE; | 318 options.m_bSeparateForm = FALSE; |
324 page.ParseContent(&options); | 319 page.ParseContent(&options); |
325 CPDF_TextStream textstream(buffer, FALSE, NULL); | 320 CPDF_TextStream textstream(buffer, FALSE, NULL); |
326 FX_POSITION pos = page.GetFirstObjectPosition(); | 321 FX_POSITION pos = page.GetFirstObjectPosition(); |
327 while (pos) { | 322 while (pos) { |
328 CPDF_PageObject* pObject = page.GetNextObject(pos); | 323 CPDF_PageObject* pObject = page.GetNextObject(pos); |
329 if (pObject->m_Type != PDFPAGE_TEXT) { | 324 if (pObject->m_Type != PDFPAGE_TEXT) { |
330 continue; | 325 continue; |
331 } | 326 } |
332 if (textstream.ProcessObject((CPDF_TextObject*)pObject, TRUE)) { | 327 if (textstream.ProcessObject((CPDF_TextObject*)pObject, TRUE)) { |
333 break; | 328 break; |
334 } | 329 } |
335 } | 330 } |
336 return buffer.GetWideString(); | 331 return buffer.GetWideString(); |
337 } | 332 } |
OLD | NEW |