PDFTextManager.h
1 
14 #pragma once
15 
16 namespace foxit {
17  namespace rdk {
18  namespace uiextensions {
19  class CritSec;
20  interface class IPDFTextManager;
21  interface class IPDFTextManagerOverrides;
22  interface class ISearchOnePage;
23  interface class ITextSearchDataItem;
24  ref class TextSearchDataItem;
25  ref class UIExtensionsManager;
26  }
27  }
28 }
29 
30 namespace foxit
31 {
32  namespace rdk
33  {
34  namespace uiextensions
35  {
36  public ref class SearchOnePage sealed : public ISearchOnePage
37  {
38  public:
39  SearchOnePage(int pageindex) : _PageIndex(pageindex)
40  {
41  _OnePageData = ref new Platform::Collections::Vector<ITextSearchDataItem^>();
42  }
43  property int PageIndex
44  {
45  virtual int get()
46  {
47  return _PageIndex;
48  }
49  }
50  property Windows::Foundation::Collections::IVector<ITextSearchDataItem^>^ OnePageData
51  {
52  virtual Windows::Foundation::Collections::IVector<ITextSearchDataItem^>^ get()
53  {
54  return _OnePageData;
55  }
56  }
57 
58  private:
59  Platform::Collections::Vector<ITextSearchDataItem^>^ _OnePageData;
60  int _PageIndex;
61  };
62 
64  {
65  public:
66  TextHandleContext(int pageindex, foxit::pdf::PDFDoc^ doc);
67 
68  bool LoadTextPageHandle();
69  void ReleaseTextHandle();
70  void LoadTextPageRects();
71  bool IsValid();
72  void AddRef();
73  void RemoveRef();
74  static void ReleaseTextHandleContext(TextHandleContext* val);
75  bool IsPageHandleInitByExternalModule;
76  bool IsInit;
77  foxit::pdf::PDFPage^ pageHandle;
78  foxit::pdf::TextPage^ textpageHandle;
79  bool IsInitTextRect;
80  Platform::Array<Windows::Foundation::Rect>^ TextRect;
81  int GetPageIndex();
82  void CheckPageIndex();
83 
84  private:
85  int m_PageIndex;
86  Platform::WeakReference m_DocumentWeakRef;
87  int m_TextPageRefCount;
88  };
89 
90  public ref class TextSelectContext sealed
91  {
92  public:
93  TextSelectContext() {};
94 
95  public:
96  property int SelectMode;
97  property int StartIndex;
98  property Windows::Foundation::Point StartPoint;
99  property int EndIndex;
100  property Windows::Foundation::Point EndPoint;
101 
102  void ResetContext();
103  };
104 
105  [Windows::Foundation::Metadata::WebHostHidden]
106  public ref class PDFTextManager sealed : public IPDFTextManager
107  {
108  ref class TextSelectOptContext sealed
109  {
110  public:
112 
113  public:
114  property int StartIndex;
115  property int StartCharIndex;
116  property int EndIndex;
117  property int EndCharIndex;
118  };
119 
120  public:
123  virtual ~PDFTextManager();
124 
125  public:
127  property Platform::String^ FindTextString
128  {
129  virtual Platform::String^ get()
130  {
131  return m_SearchTextString;
132  }
133  }
135  virtual bool GetIsSingleSearching();
137  virtual bool GetIsFoundText();
139  virtual void StartSearchString(int pageindex, Platform::String^ pwsFindwhat);
141  virtual void StopSearchString();
143  virtual void SearchPrev();
145  virtual void SearchNext();
146  virtual void NotifyByTextSearchDataItem(ITextSearchDataItem^ item);
147  property SingleSearchOnePage^ CurSearchTextInfo
148  {
149  virtual SingleSearchOnePage^ get()
150  {
151  return m_CurSearchOnePage;
152  }
153  }
154  property Windows::Foundation::Collections::IObservableVector<ITextSearchDataItem^>^ SearchData
155  {
156  virtual Windows::Foundation::Collections::IObservableVector<ITextSearchDataItem^>^ get()
157  {
158  return _SearchData;
159  }
160  }
161  virtual event SearchResultEventHandler^ SearchResult;
162 
163  virtual bool IsInitText(int pageindex);
165  virtual Platform::String^ GetTextByPosition(int pageindex, int start, int count);
167  virtual Platform::String^ GetTextByBounded(int pageindex, Windows::Foundation::Rect rect);
168  virtual Platform::String^ GetTextByBoundedSegments(int pageindex, Windows::Foundation::Rect rect);\
170  virtual Platform::String^ GetWordsByPoint(int pageindex, Windows::Foundation::Point point);
172  virtual bool IsHitText(int pageindex, Windows::Foundation::Point pt);
174  virtual bool IsHitSelectedText(int pageindex, Windows::Foundation::Point pt);
176  virtual bool AddSelectText(int startindex, Windows::Foundation::Point startpt, int endindex, Windows::Foundation::Point endpt);
177  property Platform::String^ SelectedTextString
178  {
179  virtual Platform::String^ get()
180  {
181  return _SelectedTextString;
182  }
183  }
184  property Windows::Foundation::Collections::IObservableVector<IPageSelectText^>^ SelectedText
185  {
186  virtual Windows::Foundation::Collections::IObservableVector<IPageSelectText^>^ get()
187  {
188  return _SelectedText;
189  }
190  }
191  property double TextSelectTolerance
192  {
193  virtual double get();
194  virtual void set(double value);
195  }
196  virtual event TextSelectChangedEventHandler^ TextSelectChanged;
197 
198  virtual void SetOption(ITextSelectOption^ opt);
199  ITextSelectOption^ GetOption();
200  void UpdateTextSelectOption();
201 
202  virtual bool OnCreate(foxit::rdk::PDFViewCtrl^ pageview);
203  virtual bool OnLoaded();
204  virtual void OnDelete();
205  virtual property foxit::rdk::PDFViewCtrl^ PDFViewCtrl
206  {
207  virtual foxit::rdk::PDFViewCtrl^ get();
208  }
209 
210  virtual bool LoadPdfTextResource(int pageindex);
211  virtual Platform::Array<Windows::Foundation::Rect>^ GetPageCoordinateRects(int pageindex);
212 
213  virtual foxit::pdf::PDFPage^ GetPageHandle(int pageindex);
214  virtual bool IsResourcesReleased();
215  virtual void ReleaseExtraResources();
216  virtual void ForceReleaseResources();
218  virtual void ClearTextSelect();
220  virtual Windows::Foundation::Rect GetHitTextRect(int pageindex, Windows::Foundation::Point pt);
221  virtual IPageSelectText^ GetTextRect(int startindex, Windows::Foundation::Point startpt);
222 
223  private:
224  void AddTextSelect(Windows::Foundation::Collections::IVector<IPageSelectText^>^ pageTextVect);
225  bool InitPageTextArry(int pageindex);
226  bool PointInRectangleByPageCoordiation(Windows::Foundation::Point pt, Windows::Foundation::Rect rc);
227 
228  private:
229  Windows::Foundation::IAsyncOperationWithProgress<int, SearchOnePage^>^ GetSearchResultAsync(Platform::String^ pwsFindwhat);
230  void Lock();
231  void Unlock();
232 
233  bool LoadPageHandle(int pageIndex, foxit::pdf::PDFPage^ pPage = nullptr, foxit::pdf::TextPage^ pTextPage = nullptr);
234  std::shared_ptr<TextHandleContext> LoadPageHandle_Sp(int pageIndex);
235  bool SearchLoadHandle(int pageIndex, foxit::pdf::PDFPage^ pPage, foxit::pdf::TextPage^ pTextPage, foxit::pdf::TextSearch^& pSearchHandle, Platform::String^ pwsFindwhat, int findOption = 0, int findMode = 0);
236  Platform::String^ GetShowTextFromPage(int page, int count, int mode);
237  bool GetSearchItemData(int pageIndex, foxit::pdf::TextPage^ pTextPage, foxit::pdf::TextSearch^ pSeachHandle, TextSearchDataItem^ item, int findMode = 0);
238  void GetSearchItemContextString(int pageIndex, foxit::pdf::TextPage^ pTextPage, TextSearchDataItem^ item);
239  bool SearchCheckStringValid(Platform::String^ findstr);
240 
241  bool IsHasFinded(int pageindex);
242  Concurrency::task<SingleSearchOnePage^> SingleSearchString();
243  void NotifyToView(SingleSearchOnePage^ data);
244 
245  private:
246  std::shared_ptr<CritSec> m_Critsec;
247  int m_LockCount;
248  bool m_bPopupMenu;
249  Platform::WeakReference m_WeakfpdfDocument;
250  Platform::WeakReference m_PageViewWeakRef;
251  Platform::WeakReference m_UIViewWeakRef;
252  std::map<int, std::shared_ptr<TextHandleContext>> m_PageHandleVect;
253  HANDLE m_EventCancelFind;
254  Windows::Foundation::IAsyncOperationWithProgress<int, SearchOnePage^>^ m_AsyncOperation;
255 
257  bool m_IsHadReleasedResources;
259  bool m_IsForceReleaseResources;
260  // Whether end of search
261  bool m_IsSearching;
262  // Pages already searched
263  std::vector<int> m_HasSearchedPage;
264  std::map<int, ISearchOnePage^> m_SearchOnePageData;
265  std::shared_ptr<CritSec> m_MapCritsec;
266  SingleSearchOnePage^ m_CurSearchOnePage;
267 
268  Platform::String^ m_SearchTextString;
269  int m_CurSearchIndex;
270  foxit::pdf::PDFPage^ m_pCurPageHandle;
271  foxit::pdf::TextPage^ m_pCurTextPageHandle;
272  foxit::pdf::TextSearch^ m_pCurSeachHandle;
273  bool m_IsSingleSearching;
274  int m_SearchMode;
275  Concurrency::cancellation_token_source m_SingleSearchCts;
276  bool m_IsFound;
277 
278  ITextSelectOption^ m_Option;
279  std::vector<int> m_RefPageIndexVector;
280  std::vector<int> m_PrevOpraRefPageIndexVector;
281  std::shared_ptr<CritSec> m_PageIndexVectorCritsec;
282 
283  Windows::Foundation::Collections::IObservableVector<ITextSearchDataItem^>^ _SearchData;
284  Windows::Foundation::Collections::IObservableVector<IPageSelectText^>^ _SelectedText;
285  Platform::String^ _SelectedTextString;
286  double _TextSelectTolerance;
287  Windows::Foundation::EventRegistrationToken m_textRenderToken;
288  private:
289  void UpdateSelectContext();
290 
291  private:
292  bool m_IsHitText;
293  bool m_IsPressed;
294  TextSelectOptContext^m_pTextSelectOptContext;
295  TextSelectContext^ m_pTextSelectContext;
296  bool m_IsShowSelHandleBtn;
297  bool m_IsHitSelHandleBtn;
298  bool m_IsHitStartSelHandleBtn;
299 
300  bool m_IsPointerOverText;
301  Windows::UI::Xaml::DispatcherTimer^ m_PointerOverTextTimer;
302 
303  public:
304  virtual void OnRender(foxit::rdk::PDFViewCtrl^ sender, foxit::rdk::RenderCanvasEventArgs^ e);
305  virtual void OnPointerPressed(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
306  virtual void OnPointerReleased(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
307  virtual void OnPointerMoved(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
308  virtual void OnPointerEntered(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
309  virtual void OnPointerExited(Platform::Object^ sender, Windows::UI::Xaml::Input::PointerRoutedEventArgs^ e);
310  virtual void OnTapped(Platform::Object^ sender, Windows::UI::Xaml::Input::TappedRoutedEventArgs^ e);
311  virtual void OnHolding(Platform::Object^ sender, Windows::UI::Xaml::Input::HoldingRoutedEventArgs^ e);
312  virtual void OnSelHandleClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
313  virtual bool GetIsShowSelHandleBtn();
314  virtual void SetIsShowSelHandleBtn(bool bIsShow);
315 
316  public:
317  void ClearSelectedText();
318  property UIExtensionsManager^ UIExtMgr
319  {
320  UIExtensionsManager^ get();
321  }
322 
323  private:
324  void OutputCompositeTransformInfo(Windows::UI::Xaml::FrameworkElement^ framework);
325  bool IsSelectedPageIndex(int pageindex, unsigned int* index);
326  void OnClearTextSelect();
327 
328  bool IsHadRefPageIndex(int pageindex);
329  bool IsPrevRefPageIndex(int pageindex);
330  void AddPageIndexRef(int pageindex);
331  void RemovePageIndexRef(int pageindex);
332  void AddPageIndexRef(int startindex, int endindex);
333  void RemovePageIndexRef(int startindex, int endindex);
334 
335  private:
336  Platform::String^ StandardizationDealWithString(Platform::String^ source);
337  Platform::String^ LimitDealWithString(Platform::String^ source);
338  void OnPointerOverTick(Platform::Object ^sender, Platform::Object ^args);
339  bool IsSpaceCharacter(unsigned short unicode);
340 
341  public:
342  virtual void ChangePageIndex(int srcIndex, int dstIndex);
343  virtual void ChangePageIndex(Windows::Foundation::Collections::IVector<int>^ srcIndexs, int dstIndex);
344  virtual void PageDeleteBefore(Windows::Foundation::Collections::IVector<int>^ pageIndexs);
345  virtual void PageDeleteAfter(Windows::Foundation::Collections::IVector<int>^ pageIndexs);
346  virtual void CheckPageIndex(int startIndex);
347  void GotoExactlyPage(SingleSearchOnePage^ pageinfo);
348  };
349  }
350  }
351 }
Definition: PDFTextManager.h:90
The PDF view control, which is able to open/display/save/...etc the PDF document. ...
Definition: FoxitRdkComponentViewCtrl.h:95
Definition: PDFTextManager.h:36
Definition: UIExtensions.h:113
Definition: PDFTextManager.h:106
Definition: PDFTextManager.h:63
Definition: FoxitRdkComponentViewCtrl.h:3

Foxit Software Corporation Logo
@2017 Foxit Software Incorporated. All rights reserved.