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

Side by Side Diff: core/src/fpdftext/fpdf_text.cpp

Issue 1136673005: Merge to XFA: Add safe FX_Alloc2D() macro (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 7 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
OLDNEW
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/fpdfapi/fpdf_page.h" 7 #include "../../include/fpdfapi/fpdf_page.h"
8 #include "../../include/fpdfapi/fpdf_pageobj.h" 8 #include "../../include/fpdfapi/fpdf_pageobj.h"
9 #include "../../include/fpdftext/fpdf_text.h" 9 #include "../../include/fpdftext/fpdf_text.h"
10 #include "txtproc.h" 10 #include "txtproc.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 } 51 }
52 void CTextPage::ProcessObject(CPDF_PageObject* pObject) 52 void CTextPage::ProcessObject(CPDF_PageObject* pObject)
53 { 53 {
54 if (pObject->m_Type != PDFPAGE_TEXT) { 54 if (pObject->m_Type != PDFPAGE_TEXT) {
55 return; 55 return;
56 } 56 }
57 CPDF_TextObject* pText = (CPDF_TextObject*)pObject; 57 CPDF_TextObject* pText = (CPDF_TextObject*)pObject;
58 CPDF_Font* pFont = pText->m_TextState.GetFont(); 58 CPDF_Font* pFont = pText->m_TextState.GetFont();
59 int count = pText->CountItems(); 59 int count = pText->CountItems();
60 FX_FLOAT* pPosArray = FX_Alloc(FX_FLOAT, count * 2); 60 FX_FLOAT* pPosArray = FX_Alloc2D(FX_FLOAT, count, 2);
61 if (pPosArray) { 61 pText->CalcCharPos(pPosArray);
62 pText->CalcCharPos(pPosArray); 62
63 }
64 FX_FLOAT fontsize_h = pText->m_TextState.GetFontSizeH(); 63 FX_FLOAT fontsize_h = pText->m_TextState.GetFontSizeH();
65 FX_FLOAT fontsize_v = pText->m_TextState.GetFontSizeV(); 64 FX_FLOAT fontsize_v = pText->m_TextState.GetFontSizeV();
66 FX_DWORD space_charcode = pFont->CharCodeFromUnicode(' '); 65 FX_DWORD space_charcode = pFont->CharCodeFromUnicode(' ');
67 FX_FLOAT spacew = 0; 66 FX_FLOAT spacew = 0;
68 if (space_charcode != -1) { 67 if (space_charcode != -1) {
69 spacew = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000; 68 spacew = fontsize_h * pFont->GetCharWidthF(space_charcode) / 1000;
70 } 69 }
71 if (spacew == 0) { 70 if (spacew == 0) {
72 spacew = fontsize_h / 4; 71 spacew = fontsize_h / 4;
73 } 72 }
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 { 779 {
781 buffer.EstimateSize(0, 10240); 780 buffer.EstimateSize(0, 10240);
782 CPDF_Page page; 781 CPDF_Page page;
783 page.Load(pDoc, pPage); 782 page.Load(pDoc, pPage);
784 CPDF_ParseOptions options; 783 CPDF_ParseOptions options;
785 options.m_bTextOnly = TRUE; 784 options.m_bTextOnly = TRUE;
786 options.m_bSeparateForm = FALSE; 785 options.m_bSeparateForm = FALSE;
787 page.ParseContent(&options); 786 page.ParseContent(&options);
788 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL); 787 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL);
789 } 788 }
OLDNEW
« no previous file with comments | « core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp ('k') | core/src/fxcodec/codec/fx_codec_fax.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698