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/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" |
11 #include "text_int.h" | 11 #include "text_int.h" |
12 extern FX_LPCSTR FCS_GetAltStr(FX_WCHAR); | 12 extern const FX_CHAR* FCS_GetAltStr(FX_WCHAR); |
13 CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, int destcp, FX_LPCSTR defcha
r) | 13 CFX_ByteString CharFromUnicodeAlt(FX_WCHAR unicode, int destcp, const FX_CHAR* d
efchar) |
14 { | 14 { |
15 if (destcp == 0) { | 15 if (destcp == 0) { |
16 if (unicode < 0x80) { | 16 if (unicode < 0x80) { |
17 return CFX_ByteString((char)unicode); | 17 return CFX_ByteString((char)unicode); |
18 } | 18 } |
19 FX_LPCSTR altstr = FCS_GetAltStr(unicode); | 19 const FX_CHAR* altstr = FCS_GetAltStr(unicode); |
20 if (altstr) { | 20 if (altstr) { |
21 return CFX_ByteString(altstr, -1); | 21 return CFX_ByteString(altstr, -1); |
22 } | 22 } |
23 return CFX_ByteString(defchar, -1); | 23 return CFX_ByteString(defchar, -1); |
24 } | 24 } |
25 FX_BOOL bDef = FALSE; | 25 FX_BOOL bDef = FALSE; |
26 char buf[10]; | 26 char buf[10]; |
27 int ret = FXSYS_WideCharToMultiByte(destcp, 0, (wchar_t*)&unicode, 1, buf, 1
0, NULL, &bDef); | 27 int ret = FXSYS_WideCharToMultiByte(destcp, 0, (wchar_t*)&unicode, 1, buf, 1
0, NULL, &bDef); |
28 if (ret && !bDef) { | 28 if (ret && !bDef) { |
29 return CFX_ByteString(buf, ret); | 29 return CFX_ByteString(buf, ret); |
30 } | 30 } |
31 FX_LPCSTR altstr = FCS_GetAltStr(unicode); | 31 const FX_CHAR* altstr = FCS_GetAltStr(unicode); |
32 if (altstr) { | 32 if (altstr) { |
33 return CFX_ByteString(altstr, -1); | 33 return CFX_ByteString(altstr, -1); |
34 } | 34 } |
35 return CFX_ByteString(defchar, -1); | 35 return CFX_ByteString(defchar, -1); |
36 } | 36 } |
37 CTextPage::CTextPage() | 37 CTextPage::CTextPage() |
38 { | 38 { |
39 } | 39 } |
40 CTextPage::~CTextPage() | 40 CTextPage::~CTextPage() |
41 { | 41 { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 break; | 166 break; |
167 } | 167 } |
168 } | 168 } |
169 if (pBaseLine == NULL) { | 169 if (pBaseLine == NULL) { |
170 pBaseLine = new CTextBaseLine; | 170 pBaseLine = new CTextBaseLine; |
171 pBaseLine->m_BaseLine = basey; | 171 pBaseLine->m_BaseLine = basey; |
172 m_BaseLines.InsertAt(i, pBaseLine); | 172 m_BaseLines.InsertAt(i, pBaseLine); |
173 } | 173 } |
174 } | 174 } |
175 CFX_WideString text; | 175 CFX_WideString text; |
176 FX_LPCSTR pStr = str; | 176 const FX_CHAR* pStr = str; |
177 int len = str.GetLength(), offset = 0; | 177 int len = str.GetLength(), offset = 0; |
178 while (offset < len) { | 178 while (offset < len) { |
179 FX_DWORD ch = pFont->GetNextChar(pStr, len, offset); | 179 FX_DWORD ch = pFont->GetNextChar(pStr, len, offset); |
180 CFX_WideString unicode_str = pFont->UnicodeFromCharCode(ch); | 180 CFX_WideString unicode_str = pFont->UnicodeFromCharCode(ch); |
181 if (unicode_str.IsEmpty()) { | 181 if (unicode_str.IsEmpty()) { |
182 text += (FX_WCHAR)ch; | 182 text += (FX_WCHAR)ch; |
183 } | 183 } |
184 else { | 184 else { |
185 text += unicode_str; | 185 text += unicode_str; |
186 } | 186 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 lastheight = pBaseLine->m_MaxFontSizeV; | 279 lastheight = pBaseLine->m_MaxFontSizeV; |
280 lastbaseline = pBaseLine->m_BaseLine; | 280 lastbaseline = pBaseLine->m_BaseLine; |
281 CFX_WideString str; | 281 CFX_WideString str; |
282 pBaseLine->WriteOutput(str, MinLeftX, MaxRightX - MinLeftX, iMinWidth); | 282 pBaseLine->WriteOutput(str, MinLeftX, MaxRightX - MinLeftX, iMinWidth); |
283 lines.Add(str); | 283 lines.Add(str); |
284 } | 284 } |
285 } | 285 } |
286 void NormalizeCompositeChar(FX_WCHAR wChar, CFX_WideString& sDest) | 286 void NormalizeCompositeChar(FX_WCHAR wChar, CFX_WideString& sDest) |
287 { | 287 { |
288 wChar = FX_GetMirrorChar(wChar, TRUE, FALSE); | 288 wChar = FX_GetMirrorChar(wChar, TRUE, FALSE); |
289 FX_LPWSTR pDst = NULL; | 289 FX_WCHAR* pDst = NULL; |
290 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); | 290 FX_STRSIZE nCount = FX_Unicode_GetNormalization(wChar, pDst); |
291 if (nCount < 1 ) { | 291 if (nCount < 1 ) { |
292 sDest += wChar; | 292 sDest += wChar; |
293 return; | 293 return; |
294 } | 294 } |
295 pDst = new FX_WCHAR[nCount]; | 295 pDst = new FX_WCHAR[nCount]; |
296 FX_Unicode_GetNormalization(wChar, pDst); | 296 FX_Unicode_GetNormalization(wChar, pDst); |
297 for (int nIndex = 0; nIndex < nCount; nIndex++) { | 297 for (int nIndex = 0; nIndex < nCount; nIndex++) { |
298 sDest += pDst[nIndex]; | 298 sDest += pDst[nIndex]; |
299 } | 299 } |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 { | 769 { |
770 buffer.EstimateSize(0, 10240); | 770 buffer.EstimateSize(0, 10240); |
771 CPDF_Page page; | 771 CPDF_Page page; |
772 page.Load(pDoc, pPage); | 772 page.Load(pDoc, pPage); |
773 CPDF_ParseOptions options; | 773 CPDF_ParseOptions options; |
774 options.m_bTextOnly = TRUE; | 774 options.m_bTextOnly = TRUE; |
775 options.m_bSeparateForm = FALSE; | 775 options.m_bSeparateForm = FALSE; |
776 page.ParseContent(&options); | 776 page.ParseContent(&options); |
777 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL); | 777 _PDF_GetTextStream_Unicode(buffer, &page, TRUE, NULL); |
778 } | 778 } |
OLD | NEW |