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 XFA_FDE_FDE_VISUALSET_H_ 8 #define XFA_FDE_FDE_VISUALSET_H_ 9 10 #include <vector> 11 12 #include "core/fxcrt/cfx_retain_ptr.h" 13 #include "core/fxcrt/fx_coordinates.h" 14 #include "core/fxcrt/fx_system.h" 15 #include "core/fxge/fx_dib.h" 16 #include "xfa/fde/cfde_path.h" 17 #include "xfa/fde/fde_object.h" 18 #include "xfa/fgas/font/cfgas_fontmgr.h" 19 20 class FXTEXT_CHARPOS; 21 22 enum FDE_VISUALOBJTYPE { 23 FDE_VISUALOBJ_Canvas = 0x00, 24 FDE_VISUALOBJ_Text = 0x01 25 }; 26 27 struct FDE_TEXTEDITPIECE { 28 FDE_TEXTEDITPIECE(); 29 FDE_TEXTEDITPIECE(const FDE_TEXTEDITPIECE& that); 30 ~FDE_TEXTEDITPIECE(); 31 32 int32_t nStart; 33 int32_t nCount; 34 int32_t nBidiLevel; 35 CFX_RectF rtPiece; 36 uint32_t dwCharStyles; 37 }; 38 inline FDE_TEXTEDITPIECE::FDE_TEXTEDITPIECE() = default; 39 inline FDE_TEXTEDITPIECE::FDE_TEXTEDITPIECE(const FDE_TEXTEDITPIECE& that) = 40 default; 41 inline FDE_TEXTEDITPIECE::~FDE_TEXTEDITPIECE() = default; 42 43 class IFDE_VisualSet { 44 public: ~IFDE_VisualSet()45 virtual ~IFDE_VisualSet() {} 46 virtual FDE_VISUALOBJTYPE GetType() = 0; 47 virtual CFX_RectF GetRect(const FDE_TEXTEDITPIECE& hVisualObj) = 0; 48 }; 49 50 class IFDE_CanvasSet : public IFDE_VisualSet { 51 public: 52 virtual FX_POSITION GetFirstPosition() = 0; 53 virtual FDE_TEXTEDITPIECE* GetNext(FX_POSITION& pos, 54 IFDE_VisualSet*& pVisualSet) = 0; 55 }; 56 57 class IFDE_TextSet : public IFDE_VisualSet { 58 public: 59 virtual int32_t GetString(FDE_TEXTEDITPIECE* hText, 60 CFX_WideString& wsText) = 0; 61 virtual CFX_RetainPtr<CFGAS_GEFont> GetFont() = 0; 62 virtual FX_FLOAT GetFontSize() = 0; 63 virtual FX_ARGB GetFontColor() = 0; 64 virtual int32_t GetDisplayPos(const FDE_TEXTEDITPIECE& hText, 65 FXTEXT_CHARPOS* pCharPos, 66 bool bCharCode = false, 67 CFX_WideString* pWSForms = nullptr) = 0; 68 virtual std::vector<CFX_RectF> GetCharRects(const FDE_TEXTEDITPIECE* hText, 69 bool bbox) = 0; 70 }; 71 72 #endif // XFA_FDE_FDE_VISUALSET_H_ 73