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/fsdk_define.h" | 7 #include "../include/fsdk_define.h" |
8 #include "../include/fpdftext.h" | 8 #include "../include/fpdftext.h" |
9 | 9 |
10 #ifdef _WIN32 | 10 #ifdef _WIN32 |
11 #include <tchar.h> | 11 #include <tchar.h> |
12 #endif | 12 #endif |
13 | 13 |
14 // jabdelmalek: commented out to build on Linux. Not used. | 14 // jabdelmalek: commented out to build on Linux. Not used. |
15 // extern HANDLE g_hModule; | 15 // extern HANDLE g_hModule; |
16 | 16 |
17 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) | 17 DLLEXPORT FPDF_TEXTPAGE STDCALL FPDFText_LoadPage(FPDF_PAGE page) |
18 { | 18 { |
19 if (!page) return NULL; | 19 if (!page) return NULL; |
20 IPDF_TextPage* textpage=NULL; | 20 IPDF_TextPage* textpage=NULL; |
21 » try | 21 » CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument); |
22 » { | 22 » textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.IsDirect
ionR2L()); |
23 » » CPDF_ViewerPreferences viewRef(((CPDF_Page*)page)->m_pDocument); | 23 » textpage->ParseTextPage(); |
24 » » textpage=IPDF_TextPage::CreateTextPage((CPDF_Page*)page,viewRef.
IsDirectionR2L()); | |
25 » » textpage->ParseTextPage(); | |
26 » } | |
27 » catch (...) | |
28 » { | |
29 » » if (textpage) | |
30 » » » delete textpage; | |
31 » » return NULL; | |
32 » } | |
33 return textpage; | 24 return textpage; |
34 } | 25 } |
35 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) | 26 DLLEXPORT void STDCALL FPDFText_ClosePage(FPDF_TEXTPAGE text_page) |
36 { | 27 { |
37 if (text_page){ | 28 if (text_page){ |
38 IPDF_TextPage* textpage=(IPDF_TextPage*)text_page; | 29 IPDF_TextPage* textpage=(IPDF_TextPage*)text_page; |
39 delete textpage; | 30 delete textpage; |
40 text_page=NULL; | 31 text_page=NULL; |
41 } | 32 } |
42 } | 33 } |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 return size; | 143 return size; |
153 | 144 |
154 } | 145 } |
155 | 146 |
156 //Search | 147 //Search |
157 //-1 for end | 148 //-1 for end |
158 DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page,FPDF
_WIDESTRING findwhat,unsigned long flags,int start_index) | 149 DLLEXPORT FPDF_SCHHANDLE STDCALL FPDFText_FindStart(FPDF_TEXTPAGE text_page,FPDF
_WIDESTRING findwhat,unsigned long flags,int start_index) |
159 { | 150 { |
160 if (!text_page) return NULL; | 151 if (!text_page) return NULL; |
161 IPDF_TextPageFind* textpageFind=NULL; | 152 IPDF_TextPageFind* textpageFind=NULL; |
162 » try | 153 » textpageFind=IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)text_page
); |
163 » { | 154 » FX_STRSIZE len = CFX_WideString::WStringLength(findwhat); |
164 » » textpageFind=IPDF_TextPageFind::CreatePageFind((IPDF_TextPage*)t
ext_page); | 155 » textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, len),flags
,start_index); |
165 » » FX_STRSIZE len = CFX_WideString::WStringLength(findwhat); | |
166 » » textpageFind->FindFirst(CFX_WideString::FromUTF16LE(findwhat, le
n),flags,start_index); | |
167 » } | |
168 » catch (...) | |
169 » { | |
170 » » if (textpageFind) | |
171 » » » delete textpageFind; | |
172 » » return NULL;» » | |
173 » } | |
174 return textpageFind; | 156 return textpageFind; |
175 } | 157 } |
176 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle) | 158 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindNext(FPDF_SCHHANDLE handle) |
177 { | 159 { |
178 if (!handle) return FALSE; | 160 if (!handle) return FALSE; |
179 IPDF_TextPageFind* textpageFind=(IPDF_TextPageFind*)handle; | 161 IPDF_TextPageFind* textpageFind=(IPDF_TextPageFind*)handle; |
180 return textpageFind->FindNext(); | 162 return textpageFind->FindNext(); |
181 } | 163 } |
182 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle) | 164 DLLEXPORT FPDF_BOOL STDCALL FPDFText_FindPrev(FPDF_SCHHANDLE handle) |
183 { | 165 { |
(...skipping 19 matching lines...) Expand all Loading... |
203 IPDF_TextPageFind* textpageFind=(IPDF_TextPageFind*)handle; | 185 IPDF_TextPageFind* textpageFind=(IPDF_TextPageFind*)handle; |
204 delete textpageFind; | 186 delete textpageFind; |
205 handle=NULL; | 187 handle=NULL; |
206 } | 188 } |
207 | 189 |
208 //web link | 190 //web link |
209 DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page) | 191 DLLEXPORT FPDF_PAGELINK STDCALL FPDFLink_LoadWebLinks(FPDF_TEXTPAGE text_page) |
210 { | 192 { |
211 if (!text_page) return NULL; | 193 if (!text_page) return NULL; |
212 IPDF_LinkExtract* pageLink=NULL; | 194 IPDF_LinkExtract* pageLink=NULL; |
213 » try | 195 » pageLink=IPDF_LinkExtract::CreateLinkExtract(); |
214 » { | 196 » pageLink->ExtractLinks((IPDF_TextPage*)text_page); |
215 » » pageLink=IPDF_LinkExtract::CreateLinkExtract(); | |
216 » » pageLink->ExtractLinks((IPDF_TextPage*)text_page); | |
217 » } | |
218 » catch (...) | |
219 » { | |
220 » » if (pageLink) | |
221 » » » delete pageLink; | |
222 » » return NULL; | |
223 » } | |
224 return pageLink; | 197 return pageLink; |
225 } | 198 } |
226 DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page) | 199 DLLEXPORT int STDCALL FPDFLink_CountWebLinks(FPDF_PAGELINK link_page) |
227 { | 200 { |
228 if (!link_page) return 0; | 201 if (!link_page) return 0; |
229 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; | 202 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; |
230 return pageLink->CountLinks(); | 203 return pageLink->CountLinks(); |
231 } | 204 } |
232 DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page,int link_index, un
signed short* buffer,int buflen) | 205 DLLEXPORT int STDCALL FPDFLink_GetURL(FPDF_PAGELINK link_page,int link_index, un
signed short* buffer,int buflen) |
233 { | 206 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 *bottom=rect.bottom; | 243 *bottom=rect.bottom; |
271 } | 244 } |
272 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) | 245 DLLEXPORT void STDCALL FPDFLink_CloseWebLinks(FPDF_PAGELINK link_page) |
273 { | 246 { |
274 if (!link_page) return; | 247 if (!link_page) return; |
275 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; | 248 IPDF_LinkExtract* pageLink=(IPDF_LinkExtract*)link_page; |
276 delete pageLink; | 249 delete pageLink; |
277 pageLink =NULL; | 250 pageLink =NULL; |
278 } | 251 } |
279 | 252 |
OLD | NEW |