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 _FDE_PARSER 8 #define _FDE_PARSER 9 enum FDE_VISUALOBJTYPE { 10 FDE_VISUALOBJ_Canvas = 0x00, 11 FDE_VISUALOBJ_Text = 0x01, 12 FDE_VISUALOBJ_Image = 0x02, 13 FDE_VISUALOBJ_Path = 0x04, 14 FDE_VISUALOBJ_Widget = 0x08, 15 }; 16 typedef struct _FDE_HVISUALOBJ { void* pData; } const* FDE_HVISUALOBJ; 17 class IFDE_VisualSet { 18 public: 19 virtual ~IFDE_VisualSet() {} 20 virtual FDE_VISUALOBJTYPE GetType() = 0; 21 virtual FX_BOOL GetBBox(FDE_HVISUALOBJ hVisualObj, CFX_RectF& bbox) = 0; 22 virtual FX_BOOL GetMatrix(FDE_HVISUALOBJ hVisualObj, CFX_Matrix& matrix) = 0; 23 virtual FX_BOOL GetRect(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0; 24 virtual FX_BOOL GetClip(FDE_HVISUALOBJ hVisualObj, CFX_RectF& rt) = 0; 25 }; 26 class IFDE_CanvasSet : public IFDE_VisualSet { 27 public: 28 virtual FX_POSITION GetFirstPosition(FDE_HVISUALOBJ hCanvas) = 0; 29 virtual FDE_HVISUALOBJ GetNext(FDE_HVISUALOBJ hCanvas, 30 FX_POSITION& pos, 31 IFDE_VisualSet*& pVisualSet) = 0; 32 virtual FDE_HVISUALOBJ GetParentCanvas(FDE_HVISUALOBJ hCanvas, 33 IFDE_VisualSet*& pVisualSet) = 0; 34 }; 35 class IFDE_TextSet : public IFDE_VisualSet { 36 public: 37 virtual int32_t GetString(FDE_HVISUALOBJ hText, CFX_WideString& wsText) = 0; 38 virtual IFX_Font* GetFont(FDE_HVISUALOBJ hText) = 0; 39 virtual FX_FLOAT GetFontSize(FDE_HVISUALOBJ hText) = 0; 40 virtual FX_ARGB GetFontColor(FDE_HVISUALOBJ hText) = 0; 41 virtual int32_t GetDisplayPos(FDE_HVISUALOBJ hText, 42 FXTEXT_CHARPOS* pCharPos, 43 FX_BOOL bCharCode = FALSE, 44 CFX_WideString* pWSForms = NULL) = 0; 45 virtual int32_t GetCharRects(FDE_HVISUALOBJ hText, 46 CFX_RectFArray& rtArray) = 0; 47 }; 48 class IFDE_ImageSet : public IFDE_VisualSet { 49 public: 50 virtual IFDE_Image* GetImage(FDE_HVISUALOBJ hImage) = 0; 51 virtual FX_POSITION GetFirstFilterPosition(FDE_HVISUALOBJ hImage) = 0; 52 virtual FDE_LPCIMAGEFILTERPARAMS GetNextFilter(FDE_HVISUALOBJ hImage, 53 FX_POSITION& pos) = 0; 54 }; 55 #define FDE_FILLMODE_Alternate 1 56 #define FDE_FILLMODE_Winding 2 57 #define FDE_PATHRENDER_Stroke 1 58 #define FDE_PATHRENDER_Fill 2 59 #define FDE_PATHRENDER_FillStroke 3 60 class IFDE_PathSet : public IFDE_VisualSet { 61 public: 62 virtual IFDE_Path* GetPath(FDE_HVISUALOBJ hPath) = 0; 63 virtual int32_t GetFillMode(FDE_HVISUALOBJ hPath) = 0; 64 virtual int32_t GetRenderMode(FDE_HVISUALOBJ hPath) = 0; 65 virtual IFDE_Pen* GetPen(FDE_HVISUALOBJ hPath) = 0; 66 virtual FX_FLOAT GetPenWidth(FDE_HVISUALOBJ hPath) = 0; 67 virtual IFDE_Brush* GetBrush(FDE_HVISUALOBJ hPath) = 0; 68 }; 69 enum FDE_WIDGETOBJ { 70 FDE_WIDGETOBJ_Unknown = 0x0000, 71 FDE_WIDGETOBJ_Anchor = 0x0100, 72 FDE_WIDGETOBJ_NamedDest = 0x0200, 73 FDE_WIDGETOBJ_HyperLink = 0x0400, 74 }; 75 #define FDE_WIDGETPARAM_Uri 1 76 #define FDE_WIDGETPARAM_Rects 2 77 class IFDE_WidgetSet : public IFDE_VisualSet { 78 public: 79 virtual FDE_WIDGETOBJ GetWidgetType(FDE_HVISUALOBJ hWidget) = 0; 80 virtual FX_FLOAT GetFloat(FDE_HVISUALOBJ hWidget, 81 int32_t iParameter, 82 FX_FLOAT fDefVal = 0.0f) = 0; 83 virtual int32_t GetInteger(FDE_HVISUALOBJ hWidget, 84 int32_t iParameter, 85 int32_t iDefVal = 0) = 0; 86 virtual FX_BOOL GetString(FDE_HVISUALOBJ hWidget, 87 int32_t iParameter, 88 CFX_WideString& wsValue) = 0; 89 virtual FX_BOOL GetRects(FDE_HVISUALOBJ hWidget, 90 int32_t iParameter, 91 CFX_RectFArray& rects) = 0; 92 }; 93 class IFDE_VisualSetIterator { 94 public: 95 static IFDE_VisualSetIterator* Create(); 96 virtual ~IFDE_VisualSetIterator() {} 97 virtual void Release() = 0; 98 virtual FX_BOOL AttachCanvas(IFDE_CanvasSet* pCanvas) = 0; 99 virtual FX_BOOL FilterObjects(FX_DWORD dwObjects = 0xFFFFFFFF) = 0; 100 virtual void Reset() = 0; 101 virtual FDE_HVISUALOBJ GetNext(IFDE_VisualSet*& pVisualSet, 102 FDE_HVISUALOBJ* phCanvasObj = NULL, 103 IFDE_CanvasSet** ppCanvasSet = NULL) = 0; 104 }; 105 #endif 106