Foxit PDF SDK
fs_readingorder.h
浏览该文件的文档.
1 
15 #ifndef FS_READINGORDER_H_
16 #define FS_READINGORDER_H_
17 
18 #include "common/fs_common.h"
19 #include "pdf/fs_pdfdoc.h"
20 #include "pdf/fs_pdfpage.h"
21 
27 namespace foxit {
31 namespace addon {
35 namespace accessibility {
42 typedef enum _ContentType {
69 } ContentType;
70 
71 
75 class TableCellAttribute FS_FINAL : public Object {
76  public:
82  typedef enum _TableCellType {
87  } TableCellType;
88 
91  : row_span(1)
92  , column_span(1)
94 
101  row_span = other.row_span;
102  column_span = other.column_span;
103  type = other.type;
104  scope = other.scope;
105  cell_id = other.cell_id;
107  }
108 
117  row_span = other.row_span;
118  column_span = other.column_span;
119  type = other.type;
120  scope = other.scope;
121  cell_id = other.cell_id;
123  return *this;
124  }
125 
140  this->row_span = row_span;
141  this->column_span = column_span;
142  this->type = type;
143  this->scope = scope;
144  this->cell_id = cell_id;
145  this->associated_array = associated_array;
146  }
147 
149  int row_span;
160 };
161 
164 
165 
166 class SelectItemInfo FS_FINAL : public Object {
167  public:
170  : page_index(-1)
171  , order_index(-1) {}
172 
181  SelectItemInfo(int page_index, int order_index, const foxit::RectF& rect)
182  : page_index(page_index)
183  , order_index(order_index)
184  , rect(rect) {}
185 
192  this->page_index = other.page_index;
193  this->order_index = other.order_index;
194  this->rect = other.rect;
195  }
196 
205  this->page_index = other.page_index;
206  this->order_index = other.order_index;
207  this->rect = other.rect;
208  return (*this);
209  }
210 
220  void Set(int page_index, int order_index, const foxit::RectF& rect) {
221  this->page_index = page_index;
222  this->order_index = order_index;
223  this->rect = rect;
224  }
225 
232 };
233 
236 
237 
238 class TreeItemInfo FS_FINAL : public Object {
239  public:
251  : type(e_ContentTypeUnknown)
252  , order_index(-1)
253  , page_index(-1) {}
254 
265  TreeItemInfo(ContentType type, int order_index, int page_index,
266  const wchar_t* text, foxit::RectF rect)
267  : type(type)
268  , order_index(order_index)
269  , page_index(page_index)
270  , text(text)
271  , rect(rect) {}
272 
278  TreeItemInfo(const TreeItemInfo& other) {
279  this->type = other.type;
280  this->order_index = other.order_index;
281  this->page_index = other.page_index;
282  this->text = other.text;
283  this->rect = other.rect;
284  }
285 
294  this->type = other.type;
295  this->order_index = other.order_index;
296  this->page_index = other.page_index;
297  this->text = other.text;
298  this->rect = other.rect;
299  return (*this);
300  }
301 
313  void Set(ContentType type, int order_index, int page_index,
314  const wchar_t* text, foxit::RectF rect) {
315  this->type = type;
316  this->order_index = order_index;
317  this->page_index = page_index;
318  this->text = text;
319  this->rect = rect;
320  }
321 
332 };
333 
335 FSDK_DEFINE_ARRAY(TreeItemInfoArray, TreeItemInfo)
336 
337 
338 class TreeItem FS_FINAL : public Object {
339  public:
341  TreeItem() {}
342 
344  TreeItem(TreeItemInfo item_info, TreeItemInfoArray children_items_info)
345  : item_info(item_info)
346  , children_items_info(children_items_info) {}
347 
353  TreeItem(const TreeItem& other) {
354  this->item_info = other.item_info;
355  this->children_items_info = other.children_items_info;
356  }
357 
365  TreeItem& operator=(const TreeItem& other) {
366  this->item_info = other.item_info;
367  this->children_items_info = other.children_items_info;
368  return (*this);
369  }
370 
379  void Set(TreeItemInfo item_info, TreeItemInfoArray children_items_info) {
380  this->item_info = item_info;
381  this->children_items_info = children_items_info;
382  }
383 
388 };
389 
391 FSDK_DEFINE_ARRAY(TreeItemArray, TreeItem)
392 
393 
394 class ReadingOrderOptions FS_FINAL : public Object {
395  public:
401  typedef enum _ReadingOrderShowType {
403  e_ReadingOrderShowTypeOrder = 0,
405  e_ReadingOrderShowTypeStruct = 1,
407  e_ReadingOrderShowTypeNone = 2
408  } ReadingOrderShowType;
409 
410 
413  : reading_order_show_type(e_ReadingOrderShowTypeStruct)
414  , is_show_table_figure(true)
415  , is_display_like_element(false)
416  , is_show_table_cells(true) {}
417 
419  ReadingOrderOptions(ReadingOrderShowType reading_order_show_type, bool is_show_table_figure,
420  bool is_display_like_element, bool is_show_table_cells)
421  : reading_order_show_type(reading_order_show_type)
422  , is_show_table_figure(is_show_table_figure)
423  , is_display_like_element(is_display_like_element)
424  , is_show_table_cells(is_show_table_cells) {}
425 
432  this->reading_order_show_type = other.reading_order_show_type;
433  this->is_show_table_figure = other.is_show_table_figure;
434  this->is_display_like_element = other.is_display_like_element;
435  this->is_show_table_cells = other.is_show_table_cells;
436  }
437 
446  this->reading_order_show_type = other.reading_order_show_type;
447  this->is_show_table_figure = other.is_show_table_figure;
448  this->is_display_like_element = other.is_display_like_element;
449  this->is_show_table_cells = other.is_show_table_cells;
450  return (*this);
451  }
452 
463  void Set(ReadingOrderShowType reading_order_show_type, bool is_show_table_figure,
464  bool is_display_like_element, bool is_show_table_cells) {
465  this->reading_order_show_type = reading_order_show_type;
466  this->is_show_table_figure = is_show_table_figure;
467  this->is_display_like_element = is_display_like_element;
468  this->is_show_table_cells = is_show_table_cells;
469  }
470 
479 };
480 
484 class ContentTreeItemData FS_FINAL : public Object {
485  public:
488  : page_index(-1)
490 
502  : name(name)
503  , id(id)
506  , type(type) {}
507 
514  this->name = other.name;
515  this->id = other.id;
516  this->rect_array = other.rect_array;
517  this->page_index = other.page_index;
518  this->type = other.type;
519  }
520 
529  this->name = other.name;
530  this->id = other.id;
531  this->rect_array = other.rect_array;
532  this->page_index = other.page_index;
533  this->type = other.type;
534  return *this;
535  }
536 
549  this->name = name;
550  this->id = id;
551  this->rect_array = rect_array;
552  this->page_index = page_index;
553  this->type = type;
554  }
555 
566 };
567 
568 FSDK_DEFINE_ARRAY(ContentTreeItemDataArray, ContentTreeItemData)
569 
570 
573 class ContentTreeItem FS_FINAL : public Object {
574  public:
577 
585  const ContentTreeItemDataArray& children_items_data)
586  : item_data(item_data)
587  , children_items_data(children_items_data) {}
588 
595  this->item_data = other.item_data;
596  this->children_items_data = other.children_items_data;
597  }
598 
607  this->item_data = other.item_data;
608  this->children_items_data = other.children_items_data;
609  return (*this);
610  }
611 
620  void Set(const ContentTreeItemData& item_data, const ContentTreeItemDataArray& children_items_data) {
621  this->item_data = item_data;
622  this->children_items_data = children_items_data;
623  }
624 
628  ContentTreeItemDataArray children_items_data;
629 };
630 
631 FSDK_DEFINE_ARRAY(ContentTreeItemArray, ContentTreeItem)
632 
633 
640 class ReadingOrder FS_FINAL : public Base {
641  public:
647  typedef enum _TableSelectResult {
649  e_TableSelectResultNone = 0,
651  e_TableSelectResultNotStarted = 1,
653  e_TableSelectResultNotSamePage = 2,
655  e_TableSelectResultNoTableExist = 3,
657  e_TableSelectResultNotInTable = 4
658  } TableSelectResult;
659 
665  typedef enum _StructureType {
667  e_StructureTypeText = 0,
669  e_StructureTypeFigure = 1,
671  e_StructureTypeFormfield = 2,
673  e_StructureTypeFigureOrCaption = 3,
675  e_StructureTypeCaption = 4,
677  e_StructureTypeH1 = 5,
679  e_StructureTypeH2 = 6,
681  e_StructureTypeH3 = 7,
683  e_StructureTypeH4 = 8,
685  e_StructureTypeH5 = 9,
687  e_StructureTypeH6 = 10,
689  e_StructureTypeTable = 11,
691  e_StructureTypeCell = 12,
693  e_StructureTypeFormula = 13,
695  e_StructureTypeReference = 14,
697  e_StructureTypeNote = 15,
699  e_StructureTypeBackgroundOrArtifact = 16
700  } StructureType;
701 
702 
708  ReadingOrder(const foxit::pdf::PDFDoc& pdf_doc);
709 
710  explicit ReadingOrder(FS_HANDLE handle);
711 
713  ~ReadingOrder();
714 
720  ReadingOrder(const ReadingOrder& other);
721 
729  ReadingOrder& operator=(const ReadingOrder& other);
730 
738  bool operator==(const ReadingOrder& other) const;
739 
747  bool operator!=(const ReadingOrder& other) const;
748 
754  bool IsEmpty() const;
755 
763  void SetReadingOrderOptions(const ReadingOrderOptions& options);
764 
770  TreeItemArray GetReadingOrderTreeItems();
771 
779  bool DrawReadingOrderItems(int page_index);
780 
789  bool SetOrderTypeForSelectedTreeItems(StructureType structure_type, const TreeItemInfoArray& select_info_array);
790 
799  bool SetOrderTypeForSelectedContent(StructureType structure_type);
800 
809  RectFArray AddOrderDataForRect(int page_index, foxit::RectF rect);
810 
819  RectFArray RemoveOrderDataForRect(int page_index, foxit::RectF rect);
820 
830  bool CanMoveDataOrder(int page_index, const TreeItemInfoArray& select_info_array,
831  const TreeItemInfo& dest_move_item);
832 
842  int MoveOrderData(int page_index, Int32Array src_order_index_array, int dest_order_index);
843 
853  int DeleteOrderDataStructInfo(foxit::pdf::PDFPage page, Int32Array src_order_index_array, bool is_loaded);
854 
862  void ClearPageStructInfo(foxit::pdf::PDFPage page);
863 
872  bool ApplyReadingOrder(int page_index, const RectFArray& selected_rect);
873 
882  bool SelectTableAtPoint(int page_index, const PointF& point);
883 
891  bool StartEditTable(foxit::pdf::PDFPage page);
892 
901  bool StartEditTableAtPoint(foxit::pdf::PDFPage page, foxit::PointF point);
902 
908  bool EndEditTable();
909 
915  bool IsEditingTable();
916 
922  WStringArray GetCurrentTableHeaderIDs();
923 
929  bool HasMissingHeaderIDs();
930 
936  bool GenerateTableHeaderIDs();
937 
945  bool HasHeaderID(WString header_id);
946 
952  TableCellAttributeArray GetSelectedTableCellAttributes();
953 
963  bool SetSelectedTableCellAttributes(TableCellAttribute cell_attribute, bool change_id_enabled,
964  bool need_change_ids);
965 
974  ReadingOrder::TableSelectResult CanSelectTableCellAtPoint(foxit::pdf::PDFPage page, foxit::PointF point);
975 
986  ReadingOrder::TableSelectResult SelectTableCellAtPoint(foxit::pdf::PDFPage page, foxit::PointF point,
987  foxit::RectFArray& region_selected, bool appended);
988 
999  ReadingOrder::TableSelectResult SelectTableCellAtRect(foxit::pdf::PDFPage page, foxit::RectF rect,
1000  foxit::RectFArray& region_selected, bool appended);
1001 
1009  WString GetTableSummary(foxit::pdf::PDFPage page);
1010 
1019  bool SetTableSummary(foxit::pdf::PDFPage page, const wchar_t* table_summary);
1020 
1026  void SynchronizeTable();
1027 
1033  ContentTreeItemArray GetContentTree();
1034 
1043  StringArray GetAllLeafChildrenByContentItemID(const ContentTreeItemArray& content_tree,
1044  const String& content_item_id);
1045 };
1046 
1047 } // namespace accessibility
1048 } // namespace addon
1049 } // namespace foxit
1050 #endif // FS_READINGORDER_H_
SelectItemInfo(const SelectItemInfo &other)
构造函数,使用另一个阅读顺序选中项信息对象。
Definition: fs_readingorder.h:191
int order_index
选中项的顺序索引。
Definition: fs_readingorder.h:229
Definition: fs_readingorder.h:391
WStringArray associated_array
关联表格单元格的 ID 数组。
Definition: fs_readingorder.h:159
TableCellType
表格单元格类型的枚举。
Definition: fs_readingorder.h:82
图像对象项类型。
Definition: fs_readingorder.h:60
void Set(ReadingOrderShowType reading_order_show_type, bool is_show_table_figure, bool is_display_like_element, bool is_show_table_cells)
设置值。
Definition: fs_readingorder.h:463
CFX_Object Object
对象类型。
Definition: fs_basictypes.h:220
ContentTreeItem & operator=(const ContentTreeItem &other)
赋值操作符。
Definition: fs_readingorder.h:606
TreeItem(const TreeItem &other)
构造函数,使用另一个阅读顺序树项对象。
Definition: fs_readingorder.h:353
TreeItemInfo()
构造函数。
Definition: fs_readingorder.h:250
PDF文档相关定义和类的头文件。
Definition: fs_basictypes.h:227
void Set(int row_span, int column_span, TableCellType type, String scope, WString cell_id, WStringArray associated_array)
设置值。
Definition: fs_readingorder.h:138
注释项类型。
Definition: fs_readingorder.h:64
注释组项类型。
Definition: fs_readingorder.h:62
TreeItem(TreeItemInfo item_info, TreeItemInfoArray children_items_info)
构造函数。
Definition: fs_readingorder.h:344
路径对象项类型。
Definition: fs_readingorder.h:56
Definition: fx_coordinates.h:30
TreeItem()
构造函数。
Definition: fs_readingorder.h:341
ContentType
内容类型的枚举。
Definition: fs_readingorder.h:42
void Set(int page_index, int order_index, const foxit::RectF &rect)
设置值。
Definition: fs_readingorder.h:220
TreeItemInfo item_info
项的信息。
Definition: fs_readingorder.h:385
宽字符串类
Definition: fx_string.h:1457
ContentTreeItemData(WString name, String id, RectFArray rect_array, int page_index, ContentType type)
构造函数,带参数。
Definition: fs_readingorder.h:500
Definition: fs_readingorder.h:235
ContentTreeItem(const ContentTreeItem &other)
构造函数,使用另一个内容树项对象。
Definition: fs_readingorder.h:594
Definition: fs_pdfdoc.h:768
int row_span
表格单元格跨行数。
Definition: fs_readingorder.h:149
foxit::RectF rect
页面内容项的矩形区域。
Definition: fs_readingorder.h:331
ContentType type
内容类型。请参见 ContentType。
Definition: fs_readingorder.h:565
ContentType type
项内容类型。请参见从 foxit::addon::accessibility::e_ContentTypeUnknown 开始的值。
Definition: fs_readingorder.h:323
int page_index
选中项的页面索引。有效取值范围为 0 到 (count - 1),其中 count 为函数 pdf::PDFDoc::GetPageCount 返回的页面总数。
Definition: fs_readingorder.h:227
TreeItemInfo(const TreeItemInfo &other)
构造函数,使用另一个阅读顺序树项信息对象。
Definition: fs_readingorder.h:278
Definition: fs_readingorder.h:640
ContentTreeItemData item_data
项的信息。
Definition: fs_readingorder.h:626
SelectItemInfo()
构造函数。
Definition: fs_readingorder.h:169
Definition: fs_readingorder.h:484
TreeItem & operator=(const TreeItem &other)
赋值操作符。
Definition: fs_readingorder.h:365
TreeItemInfo(ContentType type, int order_index, int page_index, const wchar_t *text, foxit::RectF rect)
构造函数。
Definition: fs_readingorder.h:265
bool operator==(const char *str1, const CFX_ByteString &str2)
检查两个字节字符串是否相等。
Definition: fs_basictypes.h:128
ContentTreeItem()
构造函数。
Definition: fs_readingorder.h:576
ContentTreeItemData & operator=(const ContentTreeItemData &other)
赋值操作符。
Definition: fs_readingorder.h:528
TableCellAttribute()
构造函数。
Definition: fs_readingorder.h:90
文本段对象项类型。
Definition: fs_readingorder.h:54
int column_span
表格单元格跨列数。
Definition: fs_readingorder.h:151
int page_index
选中项的页面索引。有效取值范围为 0 到 (count - 1),其中 count 为函数 pdf::PDFDoc::GetPageCount 返回的页面总数。
Definition: fs_readingorder.h:327
ReadingOrderOptions()
构造函数。
Definition: fs_readingorder.h:412
表单 XObject 项类型。
Definition: fs_readingorder.h:68
Definition: fs_readingorder.h:238
ContentTreeItemDataArray children_items_data
子项信息。
Definition: fs_readingorder.h:628
WString name
项名称。
Definition: fs_readingorder.h:557
ReadingOrderOptions(ReadingOrderShowType reading_order_show_type, bool is_show_table_figure, bool is_display_like_element, bool is_show_table_cells)
构造函数。
Definition: fs_readingorder.h:419
int page_index
页面索引。有效取值范围为 0 到 (count - 1),其中 count 为函数 pdf::PDFDoc::GetPageCount 返回的页面总数。
Definition: fs_readingorder.h:563
ReadingOrderShowType
阅读顺序显示类型的枚举。
Definition: fs_readingorder.h:401
bool is_show_table_cells
是否显示表格单元格。
Definition: fs_readingorder.h:478
SelectItemInfo & operator=(const SelectItemInfo &other)
赋值操作符。
Definition: fs_readingorder.h:204
文档项类型。
Definition: fs_readingorder.h:46
void Set(TreeItemInfo item_info, TreeItemInfoArray children_items_info)
设置值。
Definition: fs_readingorder.h:379
Definition: fs_pdfpage.h:417
void * FS_HANDLE
句柄类型。
Definition: fs_basictypes.h:213
TableCellType type
表格单元格类型。请参见从 TableCellAttribute::e_TableCellTypeHeader 开始的值。
Definition: fs_readingorder.h:153
通用定义和类的头文件。
String scope
表格单元格作用域。
Definition: fs_readingorder.h:155
容器项类型。
Definition: fs_readingorder.h:66
Definition: fs_readingorder.h:75
ReadingOrderOptions(const ReadingOrderOptions &other)
构造函数,使用另一个阅读顺序选项对象。
Definition: fs_readingorder.h:431
TreeItemInfoArray children_items_info
子项信息。
Definition: fs_readingorder.h:387
ReadingOrderShowType reading_order_show_type
阅读顺序类型。
Definition: fs_readingorder.h:472
ReadingOrderOptions & operator=(const ReadingOrderOptions &other)
赋值操作符。
Definition: fs_readingorder.h:445
页面项类型。
Definition: fs_readingorder.h:48
Definition: fs_basictypes.h:471
Definition: fs_basictypes.h:229
渐变对象项类型。
Definition: fs_readingorder.h:58
String id
项 ID。
Definition: fs_readingorder.h:559
TableCellAttribute & operator=(const TableCellAttribute &other)
赋值操作符。
Definition: fs_readingorder.h:116
PDF页面相关定义和类的头文件。
Definition: fs_readingorder.h:394
int order_index
项的顺序索引,从 0 开始。
Definition: fs_readingorder.h:325
TableCellAttribute(const TableCellAttribute &other)
构造函数,使用另一个辅助功能单元格属性对象。
Definition: fs_readingorder.h:100
Foxit 命名空间。
Definition: fs_accessibility.h:28
Definition: fs_readingorder.h:573
TreeItemInfo & operator=(const TreeItemInfo &other)
赋值操作符。
Definition: fs_readingorder.h:293
WString cell_id
表格单元格 ID。
Definition: fs_readingorder.h:157
字节字符串类
Definition: fx_string.h:317
Definition: fs_readingorder.h:338
ContentTreeItemData(const ContentTreeItemData &other)
构造函数,使用另一个内容树项数据对象。
Definition: fs_readingorder.h:513
文本组项类型。
Definition: fs_readingorder.h:52
表格单元格类型:数据。
Definition: fs_readingorder.h:86
SelectItemInfo(int page_index, int order_index, const foxit::RectF &rect)
构造函数。
Definition: fs_readingorder.h:181
bool is_display_like_element
是否将相似元素显示在同一个框中。
Definition: fs_readingorder.h:476
bool operator!=(const char *str1, const CFX_ByteString &str2)
检查两个字节字符串是否不相等。
Definition: fs_basictypes.h:140
未知内容。
Definition: fs_readingorder.h:44
TableSelectResult
表格选择结果的枚举。
Definition: fs_readingorder.h:647
空对象项类型。
Definition: fs_readingorder.h:50
foxit::RectF rect
PDF 页面上选中项的矩形坐标。
Definition: fs_readingorder.h:231
bool is_show_table_figure
是否显示表格和图形。
Definition: fs_readingorder.h:474
ContentTreeItem(const ContentTreeItemData &item_data, const ContentTreeItemDataArray &children_items_data)
构造函数,带参数。
Definition: fs_readingorder.h:584
表格单元格类型:表头。
Definition: fs_readingorder.h:84
Definition: fs_readingorder.h:335
WString text
项文本,用于在 UI 中显示。
Definition: fs_readingorder.h:329
void Set(WString name, String id, RectFArray rect_array, int page_index, ContentType type)
设置值。
Definition: fs_readingorder.h:548
ContentTreeItemData()
构造函数。
Definition: fs_readingorder.h:487
Definition: fs_readingorder.h:166
void Set(ContentType type, int order_index, int page_index, const wchar_t *text, foxit::RectF rect)
设置值。
Definition: fs_readingorder.h:313
Definition: fx_coordinates.h:771
RectFArray rect_array
项矩形数组。
Definition: fs_readingorder.h:561
void Set(const ContentTreeItemData &item_data, const ContentTreeItemDataArray &children_items_data)
设置值。
Definition: fs_readingorder.h:620