• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef _FPDFAPI_LAYOUT_H_
8 #define _FPDFAPI_LAYOUT_H_
9 class IPDF_LayoutElement;
10 class IPDF_LayoutProcessor;
11 class IPDF_LayoutProvider;
12 typedef enum {
13     LayoutUnknown,
14     LayoutArifact,
15     LayoutDocument,
16     LayoutPart,
17     LayoutArt,
18     LayoutSect,
19     LayoutDiv,
20     LayoutBlockQuote,
21     LayoutCaption,
22     LayoutTOC,
23     LayoutTOCI,
24     LayoutIndex,
25     LayoutNonStruct,
26     LayoutPrivate,
27     LayoutParagraph,
28     LayoutHeading,
29     LayoutHeading1,
30     LayoutHeading2,
31     LayoutHeading3,
32     LayoutHeading4,
33     LayoutHeading5,
34     LayoutHeading6,
35     LayoutList,
36     LayoutListItem,
37     LayoutListLabel,
38     LayoutListBody,
39     LayoutTable,
40     LayoutTableRow,
41     LayoutTableHeaderCell,
42     LayoutTableDataCell,
43     LayoutTableHeaderGroup,
44     LayoutTableBodyGroup,
45     LayoutTableFootGroup,
46     LayoutSpan,
47     LayoutQuote,
48     LayoutNote,
49     LayoutReference,
50     LayoutBibEntry,
51     LayoutCode,
52     LayoutLink,
53     LayoutAnnot,
54     LayoutRuby,
55     LayoutRubyBase,
56     LayoutRubyAnnot,
57     LayoutRubyPunc,
58     LayoutWarichu,
59     LayoutWarichuText,
60     LayoutWarichuPunc,
61     LayoutFigure,
62     LayoutFormula,
63     LayoutForm,
64 } LayoutType;
65 typedef enum {
66     LayoutArtifactType,
67     LayoutArtifactAttached,
68     LayoutArtifactSubType,
69     LayoutPlacement,
70     LayoutWritingMode,
71     LayoutBackgroundColor,
72     LayoutBorderColor,
73     LayoutBorderStyle,
74     LayoutBorderThickness,
75     LayoutPadding,
76     LayoutColor,
77     LayoutSpaceBefore,
78     LayoutSpaceAfter,
79     LayoutStartIndent,
80     LayoutEndIndent,
81     LayoutTextIndent,
82     LayoutTextAlign,
83     LayoutBBox,
84     LayoutWidth,
85     LayoutHeight,
86     LayoutBlockAlign,
87     LayoutInlineAlign,
88     LayoutTBorderStyle,
89     LayoutTPadding,
90     LayoutBaselineShift,
91     LayoutLineHeight,
92     LayoutTextDecorationColor,
93     LayoutTextDecorationThickness,
94     LayoutTextDecorationType,
95     LayoutRubyAlign,
96     LayoutRubyPosition,
97     LayoutGlyphOrientationVertical,
98     LayoutColumnCount,
99     LayoutColumnGap,
100     LayoutColumnWidths,
101     LayoutListNumbering,
102     LayoutFieldRole,
103     LayoutFieldChecked,
104     LayoutFieldDesc,
105     LayoutRowSpan,
106     LayoutColSpan,
107     LayoutTableHeaders,
108     LayoutTableHeaderScope,
109     LayoutTableSummary,
110 } LayoutAttr;
111 typedef enum {
112     LayoutInvalid = 0,
113     LayoutBlock,
114     LayoutInline,
115     LayoutBefore,
116     LayoutAfter,
117     LayoutStart,
118     LayoutEnd,
119     LayoutLrTb,
120     LayoutRlTb,
121     LayoutTbRl,
122     LayoutNone,
123     LayoutHidden,
124     LayoutDotted,
125     LayoutDashed,
126     LayoutSolid,
127     LayoutDouble,
128     LayoutGroove,
129     LayoutRidge,
130     LayoutInset,
131     LayoutOutset,
132     LayoutNormal,
133     LayoutAuto,
134     LayoutCenter,
135     LayoutJustify,
136     LayoutMiddle,
137     LayoutUnderline,
138     LayoutOverline,
139     LayoutLineThrough,
140     LayoutDistribute,
141     LayoutMinus90Degree,
142     LayoutZeroDegree,
143     Layout90Degree,
144     Layout180Degree,
145     Layout270Degree,
146     LayoutDisc,
147     LayoutCircle,
148     LayoutSquare,
149     LayoutDecimal,
150     LayoutUpperRoman,
151     LayoutLowerRoman,
152     LayoutUpperAlpha,
153     LayoutLowerAlpha,
154     LayoutRB,
155     LayoutCB,
156     LayoutPB,
157     LayoutTV,
158     LayoutOn,
159     LayoutOff,
160     LayoutNeutral,
161     LayoutRow,
162     LayoutColumn,
163     LayoutBoth,
164     LayoutLeft,
165     LayoutTop,
166     LayoutBottom,
167     LayoutRight,
168     LayoutPagination,
169     LayoutLayout,
170     LayoutPage,
171     LayoutBackground,
172     LayoutHeader,
173     LayoutFooter,
174     LayoutWatermark,
175 } LayoutEnum;
176 class IPDF_LayoutElement
177 {
178 public:
179 
~IPDF_LayoutElement()180     virtual ~IPDF_LayoutElement() {};
181 
182 
183     virtual LayoutType	GetType() = 0;
184 
185     virtual int		CountAttrValues(LayoutAttr attr_type) = 0;
186 
187 
188     virtual LayoutEnum	GetEnumAttr(LayoutAttr attr_type, int index = 0) = 0;
189 
190     virtual FX_FLOAT	GetNumberAttr(LayoutAttr attr_type, int index = 0) = 0;
191 
192     virtual FX_COLORREF	GetColorAttr(LayoutAttr attr_type, int index = 0) = 0;
193 
194 
195     virtual int		CountChildren() = 0;
196 
197 
198     virtual IPDF_LayoutElement* GetChild(int index) = 0;
199 
200 
201     virtual IPDF_LayoutElement* GetParent() = 0;
202 
203 
204     virtual int		CountObjects() = 0;
205 
206     virtual CPDF_PageObject*	GetObject(int index) = 0;
207 };
208 typedef enum {
209     LayoutReady,
210     LayoutFinished,
211     LayoutToBeContinued,
212     LayoutError
213 } LayoutStatus;
214 #define RF_PARSER_IMAGE		0x1
215 #define RF_PARSER_DEBUGINFO	0x2
216 #define RF_PARSER_PAGEMODE	0x4
217 #define RF_PARSER_READERORDER	0x8
218 class IPDF_LayoutProcessor
219 {
220 public:
221 
~IPDF_LayoutProcessor()222     virtual ~IPDF_LayoutProcessor() {};
223 
224     static IPDF_LayoutProcessor* Create_LayoutProcessor_Reflow(FX_FLOAT TopIndent, FX_FLOAT fWidth, FX_FLOAT fHeight, void* pReflowedPage, int flags, FX_FLOAT lineSpace = 0);
225 
226     static IPDF_LayoutProcessor* Create_LayoutProcessor_2HTML(FX_LPCSTR fileName);
227 
228     virtual LayoutStatus	StartProcess(IPDF_LayoutElement* pElement, IFX_Pause* pPause, const CFX_AffineMatrix* pPDFMatrix = NULL) = 0;
229 
230     virtual LayoutStatus	Continue() = 0;
231     virtual int				GetPosition() = 0;
232 };
233 #define LP_Lang_Unknow	 		0x0
234 #define LP_Lang_English	 		0x1
235 #define LP_Lang_French			0x2
236 #define LP_Lang_Italian			0x4
237 #define LP_Lang_German			0x8
238 #define LP_Lang_Spanish			0x10
239 #define LP_Lang_Polish			0x20
240 #define LP_Lang_Russian			0x40
241 #define LP_Lang_ChinesePRC		0x80
242 #define LP_Lang_ChineseTaiwan	0x100
243 #define LP_Lang_Japanese		0x200
244 #define LP_Lang_Korean			0x400
245 #define LP_Lang_Portuguese		0x800
246 #define LP_Lang_Turkish			0x1000
247 #define LP_Lang_Dutch			0x2000
248 typedef struct _LayoutProviderStyle {
_LayoutProviderStyle_LayoutProviderStyle249     _LayoutProviderStyle()
250     {
251         m_Language = LP_Lang_Unknow;
252         m_bIgnoreInvisibleText = TRUE;
253     }
254     FX_INT32	m_Language;
255     FX_BOOL		m_bIgnoreInvisibleText;
256 } LAYOUTPROVIDER_STYLE;
257 class IPDF_LayoutProvider
258 {
259 public:
260 
~IPDF_LayoutProvider()261     virtual ~IPDF_LayoutProvider() {};
262 
263     static IPDF_LayoutProvider* Create_LayoutProvider_TaggedPDF(CPDF_PageObjects* pPageObjs);
264 
265     static IPDF_LayoutProvider* Create_LayoutProvider_AutoReflow(CPDF_PageObjects* pPageObjs, FX_BOOL bReadOrder);
266 
267     virtual void			SetLayoutProviderStyle(LAYOUTPROVIDER_STYLE Style) = 0;
268 
269 
270 
271 
272     virtual LayoutStatus	StartLoad(IFX_Pause* pPause = NULL) = 0;
273 
274     virtual LayoutStatus	Continue() = 0;
275     virtual int				GetPosition() = 0;
276 
277 
278     virtual IPDF_LayoutElement* GetRoot() = 0;
279 };
280 #endif
281