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

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

Issue 1519693002: Merge to XFA: Remove CFX_AffineMatrix/CPDF_Matrix (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: XFA-specific changes Created 5 years 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 "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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 pObj->GetItemInfo(0, &item); 106 pObj->GetItemInfo(0, &item);
107 wstr = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode); 107 wstr = pObj->GetFont()->UnicodeFromCharCode(item.m_CharCode);
108 if (wstr.GetLength()) { 108 if (wstr.GetLength()) {
109 curChar = wstr.GetAt(0); 109 curChar = wstr.GetAt(0);
110 } 110 }
111 int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont()); 111 int nThisWidth = GetCharWidth(item.m_CharCode, pObj->GetFont());
112 FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000; 112 FX_FLOAT this_width = nThisWidth * pObj->GetFontSize() / 1000;
113 this_width = FXSYS_fabs(this_width); 113 this_width = FXSYS_fabs(this_width);
114 FX_FLOAT threshold = 114 FX_FLOAT threshold =
115 last_width > this_width ? last_width / 4 : this_width / 4; 115 last_width > this_width ? last_width / 4 : this_width / 4;
116 CFX_AffineMatrix prev_matrix, prev_reverse; 116 CFX_Matrix prev_matrix, prev_reverse;
117 pPrevObj->GetTextMatrix(&prev_matrix); 117 pPrevObj->GetTextMatrix(&prev_matrix);
118 prev_reverse.SetReverse(prev_matrix); 118 prev_reverse.SetReverse(prev_matrix);
119 FX_FLOAT x = pObj->GetPosX(), y = pObj->GetPosY(); 119 FX_FLOAT x = pObj->GetPosX(), y = pObj->GetPosY();
120 prev_reverse.Transform(x, y); 120 prev_reverse.Transform(x, y);
121 if (FXSYS_fabs(y) > threshold * 2) { 121 if (FXSYS_fabs(y) > threshold * 2) {
122 return 2; 122 return 2;
123 } 123 }
124 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth); 124 threshold = (FX_FLOAT)(nLastWidth > nThisWidth ? nLastWidth : nThisWidth);
125 threshold = threshold > 400 125 threshold = threshold > 400
126 ? (threshold < 700 ? threshold / 4 : threshold / 5) 126 ? (threshold < 700 ? threshold / 4 : threshold / 5)
(...skipping 17 matching lines...) Expand all
144 } 144 }
145 } 145 }
146 if (last_pos + last_width > x + this_width && curChar == L' ') { 146 if (last_pos + last_width > x + this_width && curChar == L' ') {
147 return 3; 147 return 3;
148 } 148 }
149 return 0; 149 return 0;
150 } 150 }
151 FX_BOOL CPDF_TextStream::ProcessObject(const CPDF_TextObject* pObj, 151 FX_BOOL CPDF_TextStream::ProcessObject(const CPDF_TextObject* pObj,
152 FX_BOOL bFirstLine) { 152 FX_BOOL bFirstLine) {
153 CPDF_Font* pFont = pObj->GetFont(); 153 CPDF_Font* pFont = pObj->GetFont();
154 CFX_AffineMatrix matrix; 154 CFX_Matrix matrix;
155 pObj->GetTextMatrix(&matrix); 155 pObj->GetTextMatrix(&matrix);
156 int item_index = 0; 156 int item_index = 0;
157 if (m_pLastObj) { 157 if (m_pLastObj) {
158 int result = FPDFText_ProcessInterObj(m_pLastObj, pObj); 158 int result = FPDFText_ProcessInterObj(m_pLastObj, pObj);
159 if (result == 2) { 159 if (result == 2) {
160 int len = m_Buffer.GetLength(); 160 int len = m_Buffer.GetLength();
161 if (len && m_bUseLF && m_Buffer.GetBuffer()[len - 1] == L'-') { 161 if (len && m_bUseLF && m_Buffer.GetBuffer()[len - 1] == L'-') {
162 m_Buffer.Delete(len - 1, 1); 162 m_Buffer.Delete(len - 1, 1);
163 if (m_pObjArray) { 163 if (m_pObjArray) {
164 m_pObjArray->RemoveAt((len - 1) * 2, 2); 164 m_pObjArray->RemoveAt((len - 1) * 2, 2);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 CPDF_PageObject* pObject = page.GetNextObject(pos); 328 CPDF_PageObject* pObject = page.GetNextObject(pos);
329 if (pObject->m_Type != PDFPAGE_TEXT) { 329 if (pObject->m_Type != PDFPAGE_TEXT) {
330 continue; 330 continue;
331 } 331 }
332 if (textstream.ProcessObject((CPDF_TextObject*)pObject, TRUE)) { 332 if (textstream.ProcessObject((CPDF_TextObject*)pObject, TRUE)) {
333 break; 333 break;
334 } 334 }
335 } 335 }
336 return buffer.GetWideString(); 336 return buffer.GetWideString();
337 } 337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698