All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ContentTree.h
Go to the documentation of this file.
1 #ifndef PDFTRON_H_CPPContentTree
2 #define PDFTRON_H_CPPContentTree
3 
4 #include <C/Layout/TRN_ContentElement.h>
5 #include <C/Layout/TRN_ContentNode.h>
6 #include <C/Layout/TRN_ContentContainer.h>
7 #include <C/Layout/TRN_Section.h>
8 #include <C/Layout/TRN_Paragraph.h>
9 #include <C/Layout/TRN_PageNumber.h>
10 #include <C/Layout/TRN_Table.h>
11 #include <C/Layout/TRN_TableRow.h>
12 #include <C/Layout/TRN_TableCell.h>
13 #include <C/Layout/TRN_TextRun.h>
14 #include <C/Layout/TRN_TextStyledElement.h>
15 #include <C/Layout/TRN_List.h>
16 #include <C/Layout/TRN_ListItem.h>
17 #include <C/Layout/TRN_Shape.h>
18 #include <C/Layout/TRN_Chart.h>
19 #include <C/Layout/TRN_Float.h>
20 
21 #include <Common/BasicTypes.h>
22 #include <Common/UString.h>
23 #include <Filters/Filter.h>
24 
25 namespace pdftron { namespace Layout {
26 
27 class Paragraph;
28 class ContentNode;
29 class ContentContainer;
30 class Section;
31 class PageNumber;
32 class TextRun;
33 class Table;
34 class TableRow;
35 class TableCell;
36 class FlowDocument;
37 class List;
38 class ListItem;
39 class Shape;
40 class Chart;
41 class Float;
42 
50 template <typename T>
52 {
53  friend class ContentElement;
54  friend class Section;
55 
59  template <typename TImpl>
60  ElementRef(TImpl impl);
61 
62 public:
66  ElementRef();
67 
75  T& GetElement();
76 
82  bool IsValid();
83 
87  operator void*();
88 
95  T* operator->();
96 
103  T& operator*();
104 
105 private:
106  T m_element;
107 };
108 
114 {
115  friend class ContentNode;
116  friend class TextRun;
117  friend class List;
118  friend class ContentElement;
119 
123  TextStyledElement(TRN_TextStyledElement impl);
124 
125 public:
126 
130  TextStyledElement(const TextStyledElement& other);
131 
136 
141 
147  void SetFontFace(const UString& font_name);
148 
155 
161  void SetFontSize(double font_size);
162 
168  double GetFontSize();
169 
175  void SetItalic(bool val);
176 
182  bool IsItalic();
183 
189  void SetBold(bool val);
190 
196  bool IsBold();
197 
205  void SetTextColor(UInt8 red, UInt8 green, UInt8 blue);
206 
214  void SetBackgroundColor(UInt8 red, UInt8 green, UInt8 blue);
215 
216 #ifndef SWIGHIDDEN
217  TRN_TextStyledElement m_impl;
218 #endif
219 };
220 
229 {
230 protected:
234  ContentElement(TRN_ContentElement impl);
235 
236 public:
237  ~ContentElement();
238  void Destroy();
239 
247  ElementRef<List> AsList() const;
248 
257 
266 
275 
284 
292  ElementRef<Shape> AsShape() const;
293 
301  ElementRef<Float> AsFloat() const;
302 
310  ElementRef<Chart> AsChart() const;
311 
320 
328  ElementRef<Table> AsTable() const;
329 
338 
347 
355 
356 #ifndef SWIGHIDDEN
357  TRN_ContentElement m_impl;
358 #endif
359 };
360 
365 class TextRun : public ContentElement
366 {
367  friend class Paragraph;
368  friend class ElementRef<TextRun>;
369 
373  TextRun(TRN_TextRun impl);
374 
375 public:
376  ~TextRun();
377  void Destroy();
378 
384  void SetText(const UString& text);
385 
391  UString GetText();
392 
398  void SetHyperlinkTarget(const UString& target);
399 
406 };
407 
413 
419 {
420  friend class FlowDocument;
421  friend class ElementRef<TableCell>;
422  friend class ElementRef<ContentNode>;
423 
424 protected:
428  ContentNode(TRN_ContentNode impl);
429 
430 public:
431  ~ContentNode();
432  void Destroy();
433 
444 };
445 
451 {
452  friend class FlowDocument;
453  friend class Shape;
454  friend class Section;
456 
457 protected:
458  ContentContainer(TRN_ContentContainer impl);
459 
460 public:
467 
473  Paragraph AddParagraph(const UString& text);
474 
480  List AddList();
481 
487  Table AddTable();
488 };
489 
497 class Section : public ContentContainer
498 {
499  friend class FlowDocument;
500 
504  Section(TRN_Section impl);
505 
506 public:
511  {
524  };
525 
534 
545 
553  void RemoveHeader(PageGroup pages);
554 
563 
574 
582  void RemoveFooter(PageGroup pages);
583 
591  void SetPageSize(double width, double height);
592 
598  double GetPageWidth();
599 
605  double GetPageHeight();
606 
616  void SetMargins(double left, double top, double right, double bottom);
617 
623  double GetLeftMargin();
624 
630  double GetTopMargin();
631 
637  double GetRightMargin();
638 
644  double GetBottomMargin();
645 };
646 
652 class Float : public ContentContainer
653 {
654  friend class Paragraph;
655  friend class ElementRef<Float>;
656 
660  Float(TRN_Float impl);
661 
662 public:
667  {
671  };
672 
678  {
681  e_square = 3,
682  e_tight = 4,
684  };
685 
686  ~Float();
687  void Destroy();
688 
695 
702 
709 
716 
723  void SetPositionX(double x);
724 
730  double GetPositionX();
731 
738  void SetPositionY(double y);
739 
745  double GetPositionY();
746 
754 
762 };
763 
768 {
769  friend class Paragraph;
770  friend class ElementRef<PageNumber>;
771 
772  PageNumber(TRN_PageNumber impl);
773 
774 public:
776  {
779  };
780 
782  {
831  };
832 
834  void SetNumberType(NumberType type);
836  void SetNumberFormat(NumberFormat format);
837 };
838 
845 class Shape : public ContentNode
846 {
847  friend class Paragraph;
848  friend class ElementRef<Shape>;
849 
850  Shape(TRN_Shape impl);
851 
852 public:
857  {
858  e_line = 1,
863  e_oval = 6,
864  e_arrow = 7,
865  };
866 
867  ~Shape();
868  void Destroy();
869 
875  void SetType(ShapeType type);
876 
882  ShapeType GetType();
883 
889  void SetWidth(double width);
890 
896  double GetWidth();
897 
903  void SetHeight(double height);
904 
910  double GetHeight();
911 
917  void SetRotation(double angle);
918 
924  double GetRotation();
925 
931  void SetFlipHorizontal(bool value);
932 
938  bool GetFlipHorizontal();
939 
945  void SetFlipVertical(bool value);
946 
952  bool GetFlipVertical();
953 
961  void SetArrowHeadSize(double size);
962 
968  double GetArrowHeadSize();
969 
975  void SetCornerRadius(double radius);
976 
982  double GetCornerRadius();
983 
991  void SetBackgroundColor(int r, int g, int b);
992 
998  void SetBackgroundImage(const UString& file_path);
999 
1005  void SetBackgroundImage(const Filters::Filter& filter);
1006 
1014  void SetOutlineColor(int r, int g, int b);
1015 
1021  void SetOutlineThickness(double thickness);
1022 
1028  double GetOutlineThickness();
1029 
1036 };
1037 
1042 class Chart : public ContentNode
1043 {
1044  friend class Paragraph;
1045  friend class ElementRef<Chart>;
1046 
1047  Chart(TRN_Chart impl);
1048 
1049 public:
1050  ~Chart();
1051  void Destroy();
1052 
1058  void SetWidth(double width);
1059 
1065  double GetWidth();
1066 
1072  void SetHeight(double height);
1073 
1079  double GetHeight();
1080 
1091  void SetDefinition(const UString& definition);
1092 };
1093 
1097 class Paragraph : public ContentNode
1098 {
1099  friend class ContentContainer;
1100  friend class ListItem;
1101  friend class ElementRef<Paragraph>;
1102 
1103  Paragraph(TRN_Paragraph impl);
1104 
1105 public:
1107  {
1124  };
1125 
1126  ~Paragraph();
1127  void Destroy();
1128 
1135  TextRun AddText(const UString& text);
1136 
1144  TextRun AddHyperlink(const UString& text, const UString& target);
1145 
1153 
1162  Shape AddShape(Shape::ShapeType type, double width, double height);
1163 
1174  Shape AddImage(double width, double height, const UString& image_path);
1175 
1186  Shape AddImage(double width, double height, const Filters::Filter& image_filter);
1187 
1196  Chart AddChart(double width, double height, const UString& definition);
1197 
1207  Float AddFloat();
1208 
1214  void SetSpaceBefore(double val);
1215 
1221  double GetSpaceBefore();
1222 
1228  void SetSpaceAfter(double val);
1229 
1235  double GetSpaceAfter();
1236 
1243 
1250 
1256  void SetStartIndent(double val);
1257 
1263  double GetStartIndent();
1264 
1270  void SetEndIndent(double val);
1271 
1277  double GetEndIndent();
1278 
1284  void SetTextIndent(double val);
1285 
1291  double GetTextIndent();
1292 
1301  void SetBorder(double thickness, UInt8 red, UInt8 green, UInt8 blue);
1302 
1308  double GetBorderThickness();
1309 
1315  void AddTabStop(double val);
1316 
1323  double GetNextTabStop(double val);
1324 
1330  void SetDefaultTabStop(double val);
1331 
1337  double GetDefaultTabStop();
1338 
1344  void SetSpacesPerTab(UInt32 val);
1345 
1352 
1358  void SetDisplayRtl(bool val);
1359 
1365  bool IsDisplayRtl();
1366 };
1367 
1368 
1373 {
1374  friend class Table;
1375  friend class TableRow;
1376  friend class ElementRef<TableCell>;
1377 
1381  TableCell(TRN_TableCell impl);
1382 
1383 public:
1385  {
1398  };
1399 
1401  {
1414  };
1415 
1416  ~TableCell();
1417  void Destroy();
1418 
1425 
1432 
1440  void SetBackgroundColor(UInt8 red, UInt8 green, UInt8 blue);
1441 
1450  void SetBorder(double thickness, UInt8 red, UInt8 green, UInt8 blue);
1451 
1457  double GetBorderThickness();
1458 
1465 
1472 
1479 
1486 
1492  void SetHeight(double val);
1493 
1499  double GetHeight();
1500 
1506  void SetWidth(double val);
1507 
1513  double GetWidth();
1514 };
1515 
1519 class TableRow : public ContentNode
1520 {
1521  friend class Table;
1522  friend class ElementRef<TableRow>;
1523 
1527  TableRow(TRN_TableRow impl);
1528 
1529 public:
1530  ~TableRow();
1531  void Destroy();
1532 
1539 
1545  void SetRowHeight(double val);
1546 
1556 };
1557 
1561 class Table : public ContentNode
1562 {
1563  friend class ContentContainer;
1564  friend class ElementRef<Table>;
1565 
1569  Table(TRN_Table impl);
1570 
1571 public:
1572  ~Table();
1573  void Destroy();
1574 
1581 
1590  TableCell GetTableCell(UInt32 column, UInt32 row);
1591 
1597  void SetDefaultColumnWidth(double val);
1598 
1604  double GetDefaultRowHeight();
1605 
1611  void SetDefaultRowHeight(double val);
1612 
1621  void SetBorder(double thickness, UInt8 red, UInt8 green, UInt8 blue);
1622 
1628  double GetBorderThickness();
1629 
1635  UInt32 GetNumRows();
1636 
1643 };
1644 
1648 class List : public ContentNode
1649 {
1650  friend class ContentContainer;
1651  friend class ListItem;
1652  friend class ElementRef<List>;
1653 
1654  List(TRN_List impl);
1655  void Destroy();
1656  void UpdateLastItemRef(TRN_ContentElement last_item);
1657 
1658 public:
1660  {
1661  e_none = 0,
1673  };
1674 
1675  ~List();
1676 
1682  void SetNumberFormat(const NumberFormat format);
1683 
1691  void SetNumberFormat(const NumberFormat format, const UString& suffix, bool cascade);
1692 
1699 
1705  void SetStartIndex(int idx);
1706 
1712  ListItem AddItem();
1713 
1725  void ContinueList();
1726 
1732  int GetIndentationLevel();
1733 
1739  int GetListIdentifier();
1740 
1741 #ifndef SWIGHIDDEN
1742  TRN_List m_impl;
1743 #endif
1744 };
1745 
1749 class ListItem : public ContentNode
1750 {
1751  friend class List;
1752  friend class ElementRef<ListItem>;
1753 
1754  ListItem(TRN_ListItem impl);
1755  void Destroy();
1756  void UpdateLastItemRef(TRN_ContentElement last_item);
1757 
1758 public:
1759  ~ListItem();
1760 
1767 
1774  Paragraph AddParagraph(const UString& text);
1775 
1781  List AddList();
1782 
1788  int GetIndentationLevel();
1789 
1795  int GetListIdentifier();
1796 
1802  int GetItemIndex();
1803 
1804 #ifndef SWIGHIDDEN
1805  TRN_ListItem m_impl;
1806 #endif
1807 };
1808 
1809 #include <Impl/ContentElement.inl>
1810 #include <Impl/ContentNode.inl>
1811 #include <Impl/ContentContainer.inl>
1812 #include <Impl/Section.inl>
1813 #include <Impl/ElementRef.inl>
1814 #include <Impl/PageNumber.inl>
1815 #include <Impl/Paragraph.inl>
1816 #include <Impl/TextRun.inl>
1817 #include <Impl/TextStyledElement.inl>
1818 #include <Impl/TableCell.inl>
1819 #include <Impl/TableRow.inl>
1820 #include <Impl/Table.inl>
1821 #include <Impl/ListItem.inl>
1822 #include <Impl/List.inl>
1823 #include <Impl/Shape.inl>
1824 #include <Impl/Chart.inl>
1825 #include <Impl/Float.inl>
1826 
1827 } //end pdftron
1828 } //end Layout
1829 
1830 #endif // PDFTRON_H_CPPContentTree
void SetFontFace(const UString &font_name)
PageNumber AddPageNumber(PageNumber::NumberType type)
void SetDisplayRtl(bool val)
void SetMargins(double left, double top, double right, double bottom)
ElementRef< ContentContainer > GetHeader(PageGroup pages) const
void SetHyperlinkTarget(const UString &target)
CellAlignmentVertical GetVerticalAlignment()
void RemoveFooter(PageGroup pages)
void SetHorizontalAlignment(CellAlignmentHorizontal val)
void SetObstructionType(FloatObstructionType type)
void SetEndIndent(double val)
void SetDefaultColumnWidth(double val)
void SetWidth(double val)
TextStyledElement GetTextStyledElement()
TextRun AddHyperlink(const UString &text, const UString &target)
void RemoveHeader(PageGroup pages)
ContentNodeIterator GetContentNodeIterator()
void SetJustificationMode(TextJustification val)
void SetDefaultRowHeight(double val)
Common::Iterator< ContentElement > ContentNodeIterator
Definition: ContentTree.h:412
void SetVerticalAlignment(CellAlignmentVertical val)
TRN_UInt8 UInt8
Definition: BasicTypes.h:15
void SetHeight(double val)
ElementRef< TableRow > AsTableRow() const
ContentContainer GetOrCreateFooter(PageGroup pages)
void SetText(const UString &text)
ElementRef< ListItem > AsListItem() const
void SetDefinition(const UString &definition)
Chart AddChart(double width, double height, const UString &definition)
void SetArrowHeadSize(double size)
void SetOutlineThickness(double thickness)
void SetBackgroundColor(UInt8 red, UInt8 green, UInt8 blue)
void SetNumberFormat(const NumberFormat format)
void SetPageSize(double width, double height)
ElementRef< TextRun > AsTextRun() const
ElementRef< Chart > AsChart() const
TableCell MergeCellsRight(UInt32 num)
TableCell GetTableCell(UInt32 column, UInt32 row)
void SetOutlineColor(int r, int g, int b)
FloatReferencePoint GetHorizontalReferencePoint()
void SetWidth(double width)
void SetStartIndent(double val)
void SetHeight(double height)
void SetHorizontalReferencePoint(FloatReferencePoint point)
TextStyledElement GetLabelStyle()
TRN_UInt32 UInt32
Definition: BasicTypes.h:13
ElementRef< Paragraph > AsParagraph() const
TableCell MergeCellsDown(UInt32 num)
void SetBackgroundImage(const UString &file_path)
Shape AddShape(Shape::ShapeType type, double width, double height)
void SetRotation(double angle)
void SetTextColor(UInt8 red, UInt8 green, UInt8 blue)
ContentContainer GetTextBox()
ContentNode(TRN_ContentNode impl)
void SetPositionX(double x)
void SetNumberType(NumberType type)
TextRun AddText(const UString &text)
ContentContainer(TRN_ContentContainer impl)
void SetBackgroundColor(UInt8 red, UInt8 green, UInt8 blue)
void SetSpacesPerTab(UInt32 val)
void SetNumberFormat(NumberFormat format)
void SetFlipHorizontal(bool value)
FloatReferencePoint GetVerticalReferencePoint()
void SetSpaceBefore(double val)
TextStyledElement & operator=(const TextStyledElement &other)
ElementRef< ContentNode > AsContentNode() const
void SetBackgroundColor(int r, int g, int b)
void SetBorder(double thickness, UInt8 red, UInt8 green, UInt8 blue)
TRN_TextStyledElement m_impl
Definition: ContentTree.h:217
ElementRef< Float > AsFloat() const
FloatObstructionType GetObstructionType()
void SetVerticalReferencePoint(FloatReferencePoint point)
NumberFormat GetNumberFormat()
TextJustification GetJustificationMode()
ElementRef< Shape > AsShape() const
ElementRef< ContentContainer > GetFooter(PageGroup pages) const
ElementRef< List > AsList() const
void SetType(ShapeType type)
void AddTabStop(double val)
void SetFontSize(double font_size)
ContentContainer GetOrCreateHeader(PageGroup pages)
void SetBorder(double thickness, UInt8 red, UInt8 green, UInt8 blue)
void SetStartIndex(int idx)
ElementRef< Table > AsTable() const
ElementRef< PageNumber > AsPageNumber() const
void SetTextIndent(double val)
CellAlignmentHorizontal GetHorizontalAlignment()
ContentElement(TRN_ContentElement impl)
void SetSpaceAfter(double val)
void SetBorder(double thickness, UInt8 red, UInt8 green, UInt8 blue)
ElementRef< TableCell > AsTableCell() const
void SetHeight(double height)
void SetFlipVertical(bool value)
double GetNextTabStop(double val)
void SetWidth(double width)
void SetCornerRadius(double radius)
void SetPositionY(double y)
void SetDefaultTabStop(double val)
Shape AddImage(double width, double height, const UString &image_path)
void SetRowHeight(double val)