diff options
Diffstat (limited to 'core/include/fpdfdoc')
-rw-r--r-- | core/include/fpdfdoc/fpdf_ap.h | 138 | ||||
-rw-r--r-- | core/include/fpdfdoc/fpdf_doc.h | 2082 | ||||
-rw-r--r-- | core/include/fpdfdoc/fpdf_tagged.h | 120 | ||||
-rw-r--r-- | core/include/fpdfdoc/fpdf_vt.h | 603 |
4 files changed, 1265 insertions, 1678 deletions
diff --git a/core/include/fpdfdoc/fpdf_ap.h b/core/include/fpdfdoc/fpdf_ap.h index 7cfaed4685..43452fdb47 100644 --- a/core/include/fpdfdoc/fpdf_ap.h +++ b/core/include/fpdfdoc/fpdf_ap.h @@ -10,86 +10,98 @@ #include "../fpdfapi/fpdf_parser.h" #include "fpdf_vt.h" -class IPVT_FontMap -{ -public: - virtual ~IPVT_FontMap() { } - virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0; - virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0; +class IPVT_FontMap { + public: + virtual ~IPVT_FontMap() {} + virtual CPDF_Font* GetPDFFont(int32_t nFontIndex) = 0; + virtual CFX_ByteString GetPDFFontAlias(int32_t nFontIndex) = 0; }; struct CPVT_Dash { + CPVT_Dash(int32_t dash, int32_t gap, int32_t phase) + : nDash(dash), nGap(gap), nPhase(phase) {} - CPVT_Dash(int32_t dash, int32_t gap, int32_t phase) : nDash(dash), nGap(gap), nPhase(phase) - {} + int32_t nDash; - int32_t nDash; + int32_t nGap; - int32_t nGap; - - int32_t nPhase; + int32_t nPhase; }; -#define CT_TRANSPARENT 0 -#define CT_GRAY 1 -#define CT_RGB 2 -#define CT_CMYK 3 +#define CT_TRANSPARENT 0 +#define CT_GRAY 1 +#define CT_RGB 2 +#define CT_CMYK 3 struct CPVT_Color { - - CPVT_Color(int32_t type = 0, FX_FLOAT color1 = 0.0f, FX_FLOAT color2 = 0.0f, FX_FLOAT color3 = 0.0f, FX_FLOAT color4 = 0.0f) - : nColorType(type), fColor1(color1), fColor2(color2), fColor3(color3), fColor4(color4) - {} - - int32_t nColorType; - FX_FLOAT fColor1; - FX_FLOAT fColor2; - FX_FLOAT fColor3; - FX_FLOAT fColor4; + CPVT_Color(int32_t type = 0, + FX_FLOAT color1 = 0.0f, + FX_FLOAT color2 = 0.0f, + FX_FLOAT color3 = 0.0f, + FX_FLOAT color4 = 0.0f) + : nColorType(type), + fColor1(color1), + fColor2(color2), + fColor3(color3), + fColor4(color4) {} + + int32_t nColorType; + FX_FLOAT fColor1; + FX_FLOAT fColor2; + FX_FLOAT fColor3; + FX_FLOAT fColor4; }; -class CPVT_Provider : public IPDF_VariableText_Provider -{ -public: +class CPVT_Provider : public IPDF_VariableText_Provider { + public: + CPVT_Provider(IPVT_FontMap* pFontMap); - CPVT_Provider(IPVT_FontMap * pFontMap); + virtual ~CPVT_Provider(); - virtual ~CPVT_Provider(); + int32_t GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle); - int32_t GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle); + int32_t GetTypeAscent(int32_t nFontIndex); - int32_t GetTypeAscent(int32_t nFontIndex); + int32_t GetTypeDescent(int32_t nFontIndex); - int32_t GetTypeDescent(int32_t nFontIndex); + int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); - int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex); + FX_BOOL IsLatinWord(FX_WORD word); - FX_BOOL IsLatinWord(FX_WORD word); + int32_t GetDefaultFontIndex(); - int32_t GetDefaultFontIndex(); -private: - - IPVT_FontMap * m_pFontMap; + private: + IPVT_FontMap* m_pFontMap; }; -#define PBS_SOLID 0 -#define PBS_DASH 1 -#define PBS_BEVELED 2 -#define PBS_INSET 3 -#define PBS_UNDERLINED 4 -class CPVT_GenerateAP -{ -public: - - static FX_BOOL GenerateTextFieldAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); - - static FX_BOOL GenerateComboBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); - - static FX_BOOL GenerateListBoxAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); - - static CFX_ByteString GenerateEditAP(IPVT_FontMap * pFontMap, IPDF_VariableText_Iterator * pIterator, - const CPDF_Point & ptOffset, FX_BOOL bContinuous, FX_WORD SubWord = 0, const CPVT_WordRange * pVisible = NULL); - - static CFX_ByteString GenerateBorderAP(const CPDF_Rect & rect, FX_FLOAT fWidth, - const CPVT_Color & color, const CPVT_Color & crLeftTop, const CPVT_Color & crRightBottom, - int32_t nStyle, const CPVT_Dash & dash); - - static CFX_ByteString GenerateColorAP(const CPVT_Color & color, const FX_BOOL & bFillOrStroke); +#define PBS_SOLID 0 +#define PBS_DASH 1 +#define PBS_BEVELED 2 +#define PBS_INSET 3 +#define PBS_UNDERLINED 4 +class CPVT_GenerateAP { + public: + static FX_BOOL GenerateTextFieldAP(CPDF_Document* pDoc, + CPDF_Dictionary* pAnnotDict); + + static FX_BOOL GenerateComboBoxAP(CPDF_Document* pDoc, + CPDF_Dictionary* pAnnotDict); + + static FX_BOOL GenerateListBoxAP(CPDF_Document* pDoc, + CPDF_Dictionary* pAnnotDict); + + static CFX_ByteString GenerateEditAP(IPVT_FontMap* pFontMap, + IPDF_VariableText_Iterator* pIterator, + const CPDF_Point& ptOffset, + FX_BOOL bContinuous, + FX_WORD SubWord = 0, + const CPVT_WordRange* pVisible = NULL); + + static CFX_ByteString GenerateBorderAP(const CPDF_Rect& rect, + FX_FLOAT fWidth, + const CPVT_Color& color, + const CPVT_Color& crLeftTop, + const CPVT_Color& crRightBottom, + int32_t nStyle, + const CPVT_Dash& dash); + + static CFX_ByteString GenerateColorAP(const CPVT_Color& color, + const FX_BOOL& bFillOrStroke); }; #endif // CORE_INCLUDE_FPDFDOC_FPDF_AP_H_ diff --git a/core/include/fpdfdoc/fpdf_doc.h b/core/include/fpdfdoc/fpdf_doc.h index 57d1790377..22fdf546da 100644 --- a/core/include/fpdfdoc/fpdf_doc.h +++ b/core/include/fpdfdoc/fpdf_doc.h @@ -42,1664 +42,1226 @@ class CPDF_TextObject; class CPDF_ViewerPreferences; class CXML_Element; -class CPDF_NameTree -{ -public: +class CPDF_NameTree { + public: + CPDF_NameTree(CPDF_Dictionary* pRoot) { m_pRoot = pRoot; } - CPDF_NameTree(CPDF_Dictionary* pRoot) - { - m_pRoot = pRoot; - } + CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteStringC& category); - CPDF_NameTree(CPDF_Document* pDoc, const CFX_ByteStringC& category); + CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; - CPDF_Object* LookupValue(int nIndex, CFX_ByteString& csName) const; + CPDF_Object* LookupValue(const CFX_ByteString& csName) const; - CPDF_Object* LookupValue(const CFX_ByteString& csName) const; + CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, + const CFX_ByteStringC& sName); - CPDF_Array* LookupNamedDest(CPDF_Document* pDoc, const CFX_ByteStringC& sName); + int GetIndex(const CFX_ByteString& csName) const; - int GetIndex(const CFX_ByteString& csName) const; + int GetCount() const; - int GetCount() const; + CPDF_Dictionary* GetRoot() const { return m_pRoot; } - - CPDF_Dictionary* GetRoot() const - { - return m_pRoot; - } - -protected: - - CPDF_Dictionary* m_pRoot; + protected: + CPDF_Dictionary* m_pRoot; }; -class CPDF_BookmarkTree -{ -public: - CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} +class CPDF_BookmarkTree { + public: + CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {} - CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; + CPDF_Bookmark GetFirstChild(const CPDF_Bookmark& parent) const; - CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; + CPDF_Bookmark GetNextSibling(const CPDF_Bookmark& bookmark) const; - CPDF_Document* GetDocument() const { return m_pDocument; } + CPDF_Document* GetDocument() const { return m_pDocument; } -protected: - CPDF_Document* m_pDocument; + protected: + CPDF_Document* m_pDocument; }; -#define PDFBOOKMARK_ITALIC 1 -#define PDFBOOKMARK_BOLD 2 -class CPDF_Bookmark -{ -public: - - CPDF_Bookmark() : m_pDict(NULL) {} +#define PDFBOOKMARK_ITALIC 1 +#define PDFBOOKMARK_BOLD 2 +class CPDF_Bookmark { + public: + CPDF_Bookmark() : m_pDict(NULL) {} - explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {} + explicit CPDF_Bookmark(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - CPDF_Dictionary* GetDict() const { return m_pDict; } + CPDF_Dictionary* GetDict() const { return m_pDict; } - operator bool() const { return m_pDict != NULL; } + operator bool() const { return m_pDict != NULL; } - FX_DWORD GetColorRef() const; + FX_DWORD GetColorRef() const; - FX_DWORD GetFontStyle() const; + FX_DWORD GetFontStyle() const; - CFX_WideString GetTitle() const; + CFX_WideString GetTitle() const; - CPDF_Dest GetDest(CPDF_Document* pDocument) const; + CPDF_Dest GetDest(CPDF_Document* pDocument) const; - CPDF_Action GetAction() const; + CPDF_Action GetAction() const; - CPDF_Dictionary* m_pDict; + CPDF_Dictionary* m_pDict; }; -#define PDFZOOM_XYZ 1 -#define PDFZOOM_FITPAGE 2 -#define PDFZOOM_FITHORZ 3 -#define PDFZOOM_FITVERT 4 -#define PDFZOOM_FITRECT 5 -#define PDFZOOM_FITBBOX 6 -#define PDFZOOM_FITBHORZ 7 -#define PDFZOOM_FITBVERT 8 -class CPDF_Dest -{ -public: - CPDF_Dest() : m_pObj(nullptr) { } - explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) { } - - operator bool () const { return m_pObj != NULL; } - CPDF_Object* GetObject() const { return m_pObj; } - - CFX_ByteString GetRemoteName(); - int GetPageIndex(CPDF_Document* pDoc); - FX_DWORD GetPageObjNum(); - int GetZoomMode(); - FX_FLOAT GetParam(int index); - -protected: - CPDF_Object* m_pObj; +#define PDFZOOM_XYZ 1 +#define PDFZOOM_FITPAGE 2 +#define PDFZOOM_FITHORZ 3 +#define PDFZOOM_FITVERT 4 +#define PDFZOOM_FITRECT 5 +#define PDFZOOM_FITBBOX 6 +#define PDFZOOM_FITBHORZ 7 +#define PDFZOOM_FITBVERT 8 +class CPDF_Dest { + public: + CPDF_Dest() : m_pObj(nullptr) {} + explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) {} + + operator bool() const { return m_pObj != NULL; } + CPDF_Object* GetObject() const { return m_pObj; } + + CFX_ByteString GetRemoteName(); + int GetPageIndex(CPDF_Document* pDoc); + FX_DWORD GetPageObjNum(); + int GetZoomMode(); + FX_FLOAT GetParam(int index); + + protected: + CPDF_Object* m_pObj; }; -class CPDF_OCContext : public IPDF_OCContext -{ -public: +class CPDF_OCContext : public IPDF_OCContext { + public: + enum UsageType { View = 0, Design, Print, Export }; - enum UsageType { - View = 0, - Design, - Print, - Export - }; + CPDF_OCContext(CPDF_Document* pDoc, UsageType eUsageType = View); - CPDF_OCContext(CPDF_Document *pDoc, UsageType eUsageType = View); + virtual ~CPDF_OCContext(); - virtual ~CPDF_OCContext(); + CPDF_Document* GetDocument() const { return m_pDocument; } - CPDF_Document* GetDocument() const - { - return m_pDocument; - } + UsageType GetUsageType() const { return m_eUsageType; } - UsageType GetUsageType() const - { - return m_eUsageType; - } + FX_BOOL CheckOCGVisible(const CPDF_Dictionary* pOCGDict); - FX_BOOL CheckOCGVisible(const CPDF_Dictionary *pOCGDict); + void ResetOCContext(); - void ResetOCContext(); -protected: + protected: + FX_BOOL LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, + const CPDF_Dictionary* pOCGDict, + FX_BOOL& bValidConfig) const; - FX_BOOL LoadOCGStateFromConfig(const CFX_ByteStringC& csConfig, const CPDF_Dictionary *pOCGDict, FX_BOOL &bValidConfig) const; + FX_BOOL LoadOCGState(const CPDF_Dictionary* pOCGDict) const; - FX_BOOL LoadOCGState(const CPDF_Dictionary *pOCGDict) const; + FX_BOOL GetOCGVisible(const CPDF_Dictionary* pOCGDict); - FX_BOOL GetOCGVisible(const CPDF_Dictionary *pOCGDict); + FX_BOOL GetOCGVE(CPDF_Array* pExpression, + FX_BOOL bFromConfig, + int nLevel = 0); - FX_BOOL GetOCGVE(CPDF_Array *pExpression, FX_BOOL bFromConfig, int nLevel = 0); + FX_BOOL LoadOCMDState(const CPDF_Dictionary* pOCMDDict, FX_BOOL bFromConfig); - FX_BOOL LoadOCMDState(const CPDF_Dictionary *pOCMDDict, FX_BOOL bFromConfig); + CPDF_Document* m_pDocument; - CPDF_Document *m_pDocument; + UsageType m_eUsageType; - UsageType m_eUsageType; - - std::map<const CPDF_Dictionary*, FX_BOOL> m_OCGStates; + std::map<const CPDF_Dictionary*, FX_BOOL> m_OCGStates; }; -class CPDF_LWinParam -{ -public: - - CPDF_LWinParam(CPDF_Dictionary* pDict) - { - m_pDict = pDict; - } - - operator CPDF_Dictionary* () const - { - return m_pDict; - } - - inline CFX_ByteString GetFileName() - { - return m_pDict->GetString("F"); - } +class CPDF_LWinParam { + public: + CPDF_LWinParam(CPDF_Dictionary* pDict) { m_pDict = pDict; } + operator CPDF_Dictionary*() const { return m_pDict; } - inline CFX_ByteString GetDefaultDirectory() - { - return m_pDict->GetString("D"); - } + inline CFX_ByteString GetFileName() { return m_pDict->GetString("F"); } + inline CFX_ByteString GetDefaultDirectory() { + return m_pDict->GetString("D"); + } - inline CFX_ByteString GetOperation() - { - return m_pDict->GetString("O"); - } + inline CFX_ByteString GetOperation() { return m_pDict->GetString("O"); } + inline CFX_ByteString GetParameter() { return m_pDict->GetString("P"); } - inline CFX_ByteString GetParameter() - { - return m_pDict->GetString("P"); - } - - CPDF_Dictionary* m_pDict; + CPDF_Dictionary* m_pDict; }; -class CPDF_ActionFields -{ -public: - - CPDF_ActionFields(const CPDF_Action* pAction) - { - m_pAction = (CPDF_Action*)pAction; - } - - operator CPDF_Action*() const - { - return m_pAction; - } - - FX_DWORD GetFieldsCount() const; +class CPDF_ActionFields { + public: + CPDF_ActionFields(const CPDF_Action* pAction) { + m_pAction = (CPDF_Action*)pAction; + } - void GetAllFields(CFX_PtrArray& fieldObjects) const; - - CPDF_Object* GetField(FX_DWORD iIndex) const; - - CPDF_Action* m_pAction; -}; + operator CPDF_Action*() const { return m_pAction; } -#define PDFNAMED_NEXTPAGE 1 -#define PDFNAMED_PREVPAGE 2 -#define PDFNAMED_FIRSTPAGE 3 -#define PDFNAMED_LASTPAGE 4 -#define PDFJS_MAXLENGTH 64 -class CPDF_Action -{ -public: - enum ActionType { - Unknown = 0, - GoTo, - GoToR, - GoToE, - Launch, - Thread, - URI, - Sound, - Movie, - Hide, - Named, - SubmitForm, - ResetForm, - ImportData, - JavaScript, - SetOCGState, - Rendition, - Trans, - GoTo3DView - }; - - CPDF_Action() : m_pDict(nullptr) { } - explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) { } - - operator bool () const { return m_pDict != NULL; } - - CPDF_Dictionary* GetDict() const { return m_pDict; } - - CFX_ByteString GetTypeName() const - { - return m_pDict->GetString("S"); - } - - ActionType GetType() const; - - CPDF_Dest GetDest(CPDF_Document* pDoc) const; - - CFX_WideString GetFilePath() const; - - FX_BOOL GetNewWindow() const - { - return m_pDict->GetBoolean("NewWindow"); - } - - CPDF_LWinParam GetWinParam() const; - - CFX_ByteString GetURI(CPDF_Document* pDoc) const; - - FX_BOOL GetMouseMap() const - { - return m_pDict->GetBoolean("IsMap"); - } - - CPDF_ActionFields GetWidgets() const - { - return this; - } - - FX_BOOL GetHideStatus() const - { - return m_pDict->GetBoolean("H", TRUE); - } - - CFX_ByteString GetNamedAction() const - { - return m_pDict->GetString("N"); - } - - FX_DWORD GetFlags() const - { - return m_pDict->GetInteger("Flags"); - } - - CFX_WideString GetJavaScript() const; - - CPDF_Dictionary* GetAnnot() const; - - int32_t GetOperationType() const; - - CPDF_Stream* GetSoundStream() const - { - return m_pDict->GetStream("Sound"); - } - - FX_FLOAT GetVolume() const - { - return m_pDict->GetNumber("Volume"); - } - - FX_BOOL IsSynchronous() const - { - return m_pDict->GetBoolean("Synchronous"); - } - - FX_BOOL IsRepeat() const - { - return m_pDict->GetBoolean("Repeat"); - } - - FX_BOOL IsMixPlay() const - { - return m_pDict->GetBoolean("Mix"); - } + FX_DWORD GetFieldsCount() const; - FX_DWORD GetSubActionsCount() const; + void GetAllFields(CFX_PtrArray& fieldObjects) const; - CPDF_Action GetSubAction(FX_DWORD iIndex) const; + CPDF_Object* GetField(FX_DWORD iIndex) const; -protected: - CPDF_Dictionary* m_pDict; + CPDF_Action* m_pAction; }; -class CPDF_AAction -{ -public: - - CPDF_AAction(CPDF_Dictionary* pDict = NULL) - { - m_pDict = pDict; - } - - operator CPDF_Dictionary*() const - { - return m_pDict; - } - - enum AActionType { - CursorEnter = 0, - CursorExit, - ButtonDown, - ButtonUp, - GetFocus, - LoseFocus, - PageOpen, - PageClose, - PageVisible, - PageInvisible, - OpenPage, - ClosePage, - KeyStroke, - Format, - Validate, - Calculate, - CloseDocument, - SaveDocument, - DocumentSaved, - PrintDocument, - DocumentPrinted - }; - - FX_BOOL ActionExist(AActionType eType) const; - - CPDF_Action GetAction(AActionType eType) const; - - FX_POSITION GetStartPos() const; - - CPDF_Action GetNextAction(FX_POSITION& pos, AActionType& eType) const; - - CPDF_Dictionary* m_pDict; -}; -class CPDF_DocJSActions -{ -public: - CPDF_DocJSActions(CPDF_Document* pDoc); +#define PDFNAMED_NEXTPAGE 1 +#define PDFNAMED_PREVPAGE 2 +#define PDFNAMED_FIRSTPAGE 3 +#define PDFNAMED_LASTPAGE 4 +#define PDFJS_MAXLENGTH 64 +class CPDF_Action { + public: + enum ActionType { + Unknown = 0, + GoTo, + GoToR, + GoToE, + Launch, + Thread, + URI, + Sound, + Movie, + Hide, + Named, + SubmitForm, + ResetForm, + ImportData, + JavaScript, + SetOCGState, + Rendition, + Trans, + GoTo3DView + }; - int CountJSActions() const; + CPDF_Action() : m_pDict(nullptr) {} + explicit CPDF_Action(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const; + operator bool() const { return m_pDict != NULL; } - CPDF_Action GetJSAction(const CFX_ByteString& csName) const; + CPDF_Dictionary* GetDict() const { return m_pDict; } - int FindJSAction(const CFX_ByteString& csName) const; + CFX_ByteString GetTypeName() const { return m_pDict->GetString("S"); } + ActionType GetType() const; - CPDF_Document* GetDocument() const - { - return m_pDocument; - } + CPDF_Dest GetDest(CPDF_Document* pDoc) const; -protected: + CFX_WideString GetFilePath() const; - CPDF_Document* m_pDocument; -}; -class CPDF_FileSpec -{ -public: + FX_BOOL GetNewWindow() const { return m_pDict->GetBoolean("NewWindow"); } - CPDF_FileSpec(); + CPDF_LWinParam GetWinParam() const; - CPDF_FileSpec(CPDF_Object *pObj) - { - m_pObj = pObj; - } + CFX_ByteString GetURI(CPDF_Document* pDoc) const; - operator CPDF_Object*() const - { - return m_pObj; - } + FX_BOOL GetMouseMap() const { return m_pDict->GetBoolean("IsMap"); } - FX_BOOL IsURL() const; + CPDF_ActionFields GetWidgets() const { return this; } - FX_BOOL GetFileName(CFX_WideString &wsFileName) const; + FX_BOOL GetHideStatus() const { return m_pDict->GetBoolean("H", TRUE); } - CPDF_Stream* GetFileStream() const; + CFX_ByteString GetNamedAction() const { return m_pDict->GetString("N"); } - void SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL = FALSE); -protected: + FX_DWORD GetFlags() const { return m_pDict->GetInteger("Flags"); } - CPDF_Object *m_pObj; -}; -class CPDF_LinkList -{ -public: + CFX_WideString GetJavaScript() const; - CPDF_LinkList(CPDF_Document* pDoc) - { - m_pDocument = pDoc; - } + CPDF_Dictionary* GetAnnot() const; - ~CPDF_LinkList(); + int32_t GetOperationType() const; - CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y); + CPDF_Stream* GetSoundStream() const { return m_pDict->GetStream("Sound"); } - int CountLinks(CPDF_Page* pPage); + FX_FLOAT GetVolume() const { return m_pDict->GetNumber("Volume"); } - CPDF_Link GetLink(CPDF_Page* pPage, int index); + FX_BOOL IsSynchronous() const { return m_pDict->GetBoolean("Synchronous"); } - CPDF_Document* GetDocument() const - { - return m_pDocument; - } -protected: + FX_BOOL IsRepeat() const { return m_pDict->GetBoolean("Repeat"); } - CPDF_Document* m_pDocument; + FX_BOOL IsMixPlay() const { return m_pDict->GetBoolean("Mix"); } - CFX_MapPtrToPtr m_PageMap; + FX_DWORD GetSubActionsCount() const; - CFX_PtrArray* GetPageLinks(CPDF_Page* pPage); + CPDF_Action GetSubAction(FX_DWORD iIndex) const; - void LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList); + protected: + CPDF_Dictionary* m_pDict; }; -class CPDF_Link -{ -public: - CPDF_Link() : m_pDict(nullptr) { } - explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) { } - - CPDF_Dictionary* GetDict() const { return m_pDict; } - - CFX_FloatRect GetRect(); - CPDF_Dest GetDest(CPDF_Document* pDoc); - CPDF_Action GetAction(); - -protected: - CPDF_Dictionary* m_pDict; +class CPDF_AAction { + public: + CPDF_AAction(CPDF_Dictionary* pDict = NULL) { m_pDict = pDict; } + + operator CPDF_Dictionary*() const { return m_pDict; } + + enum AActionType { + CursorEnter = 0, + CursorExit, + ButtonDown, + ButtonUp, + GetFocus, + LoseFocus, + PageOpen, + PageClose, + PageVisible, + PageInvisible, + OpenPage, + ClosePage, + KeyStroke, + Format, + Validate, + Calculate, + CloseDocument, + SaveDocument, + DocumentSaved, + PrintDocument, + DocumentPrinted + }; + + FX_BOOL ActionExist(AActionType eType) const; + + CPDF_Action GetAction(AActionType eType) const; + + FX_POSITION GetStartPos() const; + + CPDF_Action GetNextAction(FX_POSITION& pos, AActionType& eType) const; + + CPDF_Dictionary* m_pDict; }; +class CPDF_DocJSActions { + public: + CPDF_DocJSActions(CPDF_Document* pDoc); -#define ANNOTFLAG_INVISIBLE 0x0001 -#define ANNOTFLAG_HIDDEN 0x0002 -#define ANNOTFLAG_PRINT 0x0004 -#define ANNOTFLAG_NOZOOM 0x0008 -#define ANNOTFLAG_NOROTATE 0x0010 -#define ANNOTFLAG_NOVIEW 0x0020 -#define ANNOTFLAG_READONLY 0x0040 -#define ANNOTFLAG_LOCKED 0x0080 -#define ANNOTFLAG_TOGGLENOVIEW 0x0100 - -class CPDF_Annot : public CFX_PrivateData -{ - public: - enum AppearanceMode { - Normal, - Rollover, - Down - }; - - CPDF_Annot(CPDF_Dictionary* pDict, CPDF_AnnotList* pList); - ~CPDF_Annot(); - - CFX_ByteString GetSubType() const; - - FX_DWORD GetFlags() const; - - void GetRect(CFX_FloatRect& rect) const; - - CPDF_Dictionary* GetAnnotDict(); - - FX_BOOL DrawAppearance(const CPDF_Page* pPage, - CFX_RenderDevice* pDevice, - const CFX_AffineMatrix* pUser2Device, - AppearanceMode mode, - const CPDF_RenderOptions* pOptions); - - FX_BOOL DrawInContext(const CPDF_Page* pPage, - const CPDF_RenderContext* pContext, - const CFX_AffineMatrix* pUser2Device, - AppearanceMode mode); - - void ClearCachedAP(); + int CountJSActions() const; - void DrawBorder(CFX_RenderDevice* pDevice, - const CFX_AffineMatrix* pUser2Device, - const CPDF_RenderOptions* pOptions); + CPDF_Action GetJSAction(int index, CFX_ByteString& csName) const; - CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode); + CPDF_Action GetJSAction(const CFX_ByteString& csName) const; - private: - CPDF_Dictionary* const m_pAnnotDict; + int FindJSAction(const CFX_ByteString& csName) const; - CPDF_AnnotList* const m_pList; + CPDF_Document* GetDocument() const { return m_pDocument; } - const CFX_ByteString m_sSubtype; - - CFX_MapPtrToPtr m_APMap; + protected: + CPDF_Document* m_pDocument; }; +class CPDF_FileSpec { + public: + CPDF_FileSpec(); -class CPDF_AnnotList -{ -public: - - CPDF_AnnotList(CPDF_Page* pPage); - - ~CPDF_AnnotList(); - - void GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CFX_Matrix &matrix) const; - - void GetAnnotRect(const CPDF_Dictionary* pAnnotDict, const CFX_Matrix* pUser2Device, CPDF_Rect &rtAnnot) const; - - void DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, - CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget, - CPDF_RenderOptions* pOptions); - - void DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext, - FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget, - CPDF_RenderOptions* pOptions) - { - DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, NULL); - } - - void DisplayAnnots(const CPDF_Page* pPage, CPDF_RenderContext* pContext, - FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_BOOL bShowWidget, - CPDF_RenderOptions* pOptions, FX_RECT *pClipRect) - { - DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, bShowWidget ? 3 : 1, pOptions, pClipRect); - } - - void DisplayAnnots(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, CPDF_RenderContext* pContext, - FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, FX_DWORD dwAnnotFlags, - CPDF_RenderOptions* pOptions, FX_RECT* pClipRect); - - - - CPDF_Annot* GetAt(int index) - { - return (CPDF_Annot*)m_AnnotList.GetAt(index); - } - - int Count() - { - return m_AnnotList.GetSize(); - } - - int GetIndex(CPDF_Annot* pAnnot); - + CPDF_FileSpec(CPDF_Object* pObj) { m_pObj = pObj; } - CPDF_Document* GetDocument() const - { - return m_pDocument; - } -protected: + operator CPDF_Object*() const { return m_pObj; } - CFX_PtrArray m_AnnotList; + FX_BOOL IsURL() const; - CPDF_Dictionary* m_pPageDict; + FX_BOOL GetFileName(CFX_WideString& wsFileName) const; - CPDF_Document* m_pDocument; + CPDF_Stream* GetFileStream() const; - CFX_PtrArray m_Borders; + void SetFileName(const CFX_WideStringC& wsFileName, FX_BOOL bURL = FALSE); - void DisplayPass(const CPDF_Page* pPage, CFX_RenderDevice* pDevice, - CPDF_RenderContext* pContext, FX_BOOL bPrinting, CFX_AffineMatrix* pMatrix, - FX_BOOL bWidget, CPDF_RenderOptions* pOptions, FX_RECT* clip_rect); - friend class CPDF_Annot; + protected: + CPDF_Object* m_pObj; }; -#define COLORTYPE_TRANSPARENT 0 -#define COLORTYPE_GRAY 1 -#define COLORTYPE_RGB 2 -#define COLORTYPE_CMYK 3 -class CPDF_DefaultAppearance -{ -public: - - CPDF_DefaultAppearance(const CFX_ByteString& csDA = "") - { - m_csDA = csDA; - } - - CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) - { - m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA; - } - - - operator CFX_ByteString() const - { - return m_csDA; - } - - const CPDF_DefaultAppearance& operator =(const CFX_ByteString& csDA) - { - m_csDA = csDA; - return *this; - } - - const CPDF_DefaultAppearance& operator =(const CPDF_DefaultAppearance& cDA) - { - m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA; - return *this; - } - - - - FX_BOOL HasFont(); - - CFX_ByteString GetFontString(); - - void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize); - - - - - FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE); +class CPDF_LinkList { + public: + CPDF_LinkList(CPDF_Document* pDoc) { m_pDocument = pDoc; } - CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE); + ~CPDF_LinkList(); - void GetColor(int& iColorType, FX_FLOAT fc[4], FX_BOOL bStrokingOperation = FALSE); + CPDF_Link GetLinkAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y); - void GetColor(FX_ARGB& color, int& iColorType, FX_BOOL bStrokingOperation = FALSE); + int CountLinks(CPDF_Page* pPage); + CPDF_Link GetLink(CPDF_Page* pPage, int index); + CPDF_Document* GetDocument() const { return m_pDocument; } + protected: + CPDF_Document* m_pDocument; - FX_BOOL HasTextMatrix(); + CFX_MapPtrToPtr m_PageMap; - CFX_ByteString GetTextMatrixString(); + CFX_PtrArray* GetPageLinks(CPDF_Page* pPage); - CFX_AffineMatrix GetTextMatrix(); - -protected: - - CFX_ByteString m_csDA; + void LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList); }; -#define FIELDTYPE_UNKNOWN 0 -#define FIELDTYPE_PUSHBUTTON 1 -#define FIELDTYPE_CHECKBOX 2 -#define FIELDTYPE_RADIOBUTTON 3 -#define FIELDTYPE_COMBOBOX 4 -#define FIELDTYPE_LISTBOX 5 -#define FIELDTYPE_TEXTFIELD 6 -#define FIELDTYPE_SIGNATURE 7 -class CPDF_InterForm : public CFX_PrivateData -{ -public: - - CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP); - - ~CPDF_InterForm(); - - - - static void EnableUpdateAP(FX_BOOL bUpdateAP); - - static FX_BOOL UpdatingAPEnabled(); - - - static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, const FX_CHAR* csType, int iMinLen = 2, const FX_CHAR* csPrefix = ""); - - - - static CPDF_Font* AddSystemDefaultFont(const CPDF_Document* pDocument); - - static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, CFX_ByteString csFontName, uint8_t iCharSet = 1); - - static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, CFX_WideString csFontName, uint8_t iCharSet = 1); +class CPDF_Link { + public: + CPDF_Link() : m_pDict(nullptr) {} + explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) {} - static CPDF_Font* AddStandardFont(const CPDF_Document* pDocument, CFX_ByteString csFontName); + CPDF_Dictionary* GetDict() const { return m_pDict; } - static CFX_ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont = NULL); + CFX_FloatRect GetRect(); + CPDF_Dest GetDest(CPDF_Document* pDoc); + CPDF_Action GetAction(); - static CFX_ByteString GetNativeFont(void* pLogFont = NULL); - - static uint8_t GetNativeCharSet(); - - static CPDF_Font* AddNativeFont(uint8_t iCharSet, const CPDF_Document* pDocument); - - static CPDF_Font* AddNativeFont(const CPDF_Document* pDocument); + protected: + CPDF_Dictionary* m_pDict; +}; +#define ANNOTFLAG_INVISIBLE 0x0001 +#define ANNOTFLAG_HIDDEN 0x0002 +#define ANNOTFLAG_PRINT 0x0004 +#define ANNOTFLAG_NOZOOM 0x0008 +#define ANNOTFLAG_NOROTATE 0x0010 +#define ANNOTFLAG_NOVIEW 0x0020 +#define ANNOTFLAG_READONLY 0x0040 +#define ANNOTFLAG_LOCKED 0x0080 +#define ANNOTFLAG_TOGGLENOVIEW 0x0100 +class CPDF_Annot : public CFX_PrivateData { + public: + enum AppearanceMode { Normal, Rollover, Down }; + CPDF_Annot(CPDF_Dictionary* pDict, CPDF_AnnotList* pList); + ~CPDF_Annot(); - FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType); + CFX_ByteString GetSubType() const; - FX_BOOL ValidateFieldName(const CPDF_FormField* pField, CFX_WideString& csNewFieldName); + FX_DWORD GetFlags() const; - FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, CFX_WideString& csNewFieldName); + void GetRect(CFX_FloatRect& rect) const; + CPDF_Dictionary* GetAnnotDict(); + FX_BOOL DrawAppearance(const CPDF_Page* pPage, + CFX_RenderDevice* pDevice, + const CFX_AffineMatrix* pUser2Device, + AppearanceMode mode, + const CPDF_RenderOptions* pOptions); + FX_BOOL DrawInContext(const CPDF_Page* pPage, + const CPDF_RenderContext* pContext, + const CFX_AffineMatrix* pUser2Device, + AppearanceMode mode); - FX_DWORD CountFields(const CFX_WideString &csFieldName = L""); + void ClearCachedAP(); - CPDF_FormField* GetField(FX_DWORD index, const CFX_WideString &csFieldName = L""); + void DrawBorder(CFX_RenderDevice* pDevice, + const CFX_AffineMatrix* pUser2Device, + const CPDF_RenderOptions* pOptions); - void GetAllFieldNames(CFX_WideStringArray& allFieldNames); + CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode); - FX_BOOL IsValidFormField(const void* pField); + private: + CPDF_Dictionary* const m_pAnnotDict; - CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; + CPDF_AnnotList* const m_pList; + const CFX_ByteString m_sSubtype; + CFX_MapPtrToPtr m_APMap; +}; +class CPDF_AnnotList { + public: + CPDF_AnnotList(CPDF_Page* pPage); + + ~CPDF_AnnotList(); + + void GetAnnotMatrix(const CPDF_Dictionary* pAnnotDict, + const CFX_Matrix* pUser2Device, + CFX_Matrix& matrix) const; + + void GetAnnotRect(const CPDF_Dictionary* pAnnotDict, + const CFX_Matrix* pUser2Device, + CPDF_Rect& rtAnnot) const; + + void DisplayAnnots(const CPDF_Page* pPage, + CFX_RenderDevice* pDevice, + CFX_AffineMatrix* pMatrix, + FX_BOOL bShowWidget, + CPDF_RenderOptions* pOptions); + + void DisplayAnnots(const CPDF_Page* pPage, + CPDF_RenderContext* pContext, + FX_BOOL bPrinting, + CFX_AffineMatrix* pMatrix, + FX_BOOL bShowWidget, + CPDF_RenderOptions* pOptions) { + DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, + bShowWidget ? 3 : 1, pOptions, NULL); + } + + void DisplayAnnots(const CPDF_Page* pPage, + CPDF_RenderContext* pContext, + FX_BOOL bPrinting, + CFX_AffineMatrix* pMatrix, + FX_BOOL bShowWidget, + CPDF_RenderOptions* pOptions, + FX_RECT* pClipRect) { + DisplayAnnots(pPage, NULL, pContext, bPrinting, pMatrix, + bShowWidget ? 3 : 1, pOptions, pClipRect); + } + + void DisplayAnnots(const CPDF_Page* pPage, + CFX_RenderDevice* pDevice, + CPDF_RenderContext* pContext, + FX_BOOL bPrinting, + CFX_AffineMatrix* pMatrix, + FX_DWORD dwAnnotFlags, + CPDF_RenderOptions* pOptions, + FX_RECT* pClipRect); + + CPDF_Annot* GetAt(int index) { return (CPDF_Annot*)m_AnnotList.GetAt(index); } + + int Count() { return m_AnnotList.GetSize(); } + + int GetIndex(CPDF_Annot* pAnnot); + + CPDF_Document* GetDocument() const { return m_pDocument; } + + protected: + CFX_PtrArray m_AnnotList; + + CPDF_Dictionary* m_pPageDict; + + CPDF_Document* m_pDocument; + + CFX_PtrArray m_Borders; + + void DisplayPass(const CPDF_Page* pPage, + CFX_RenderDevice* pDevice, + CPDF_RenderContext* pContext, + FX_BOOL bPrinting, + CFX_AffineMatrix* pMatrix, + FX_BOOL bWidget, + CPDF_RenderOptions* pOptions, + FX_RECT* clip_rect); + friend class CPDF_Annot; +}; +#define COLORTYPE_TRANSPARENT 0 +#define COLORTYPE_GRAY 1 +#define COLORTYPE_RGB 2 +#define COLORTYPE_CMYK 3 +class CPDF_DefaultAppearance { + public: + CPDF_DefaultAppearance(const CFX_ByteString& csDA = "") { m_csDA = csDA; } - FX_DWORD CountControls(CFX_WideString csFieldName = L""); + CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) { + m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA; + } - CPDF_FormControl* GetControl(FX_DWORD index, CFX_WideString csFieldName = L""); + operator CFX_ByteString() const { return m_csDA; } - FX_BOOL IsValidFormControl(const void* pControl); + const CPDF_DefaultAppearance& operator=(const CFX_ByteString& csDA) { + m_csDA = csDA; + return *this; + } - int CountPageControls(CPDF_Page* pPage) const; + const CPDF_DefaultAppearance& operator=(const CPDF_DefaultAppearance& cDA) { + m_csDA = (CFX_ByteString)(CPDF_DefaultAppearance&)cDA; + return *this; + } - CPDF_FormControl* GetPageControl(CPDF_Page* pPage, int index) const; + FX_BOOL HasFont(); + CFX_ByteString GetFontString(); - CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, FX_FLOAT pdf_x, FX_FLOAT pdf_y) const; + void GetFont(CFX_ByteString& csFontNameTag, FX_FLOAT& fFontSize); - CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const; + FX_BOOL HasColor(FX_BOOL bStrokingOperation = FALSE); + CFX_ByteString GetColorString(FX_BOOL bStrokingOperation = FALSE); + void GetColor(int& iColorType, + FX_FLOAT fc[4], + FX_BOOL bStrokingOperation = FALSE); + void GetColor(FX_ARGB& color, + int& iColorType, + FX_BOOL bStrokingOperation = FALSE); - FX_DWORD CountInternalFields(const CFX_WideString& csFieldName = L"") const; + FX_BOOL HasTextMatrix(); - CPDF_Dictionary* GetInternalField(FX_DWORD index, const CFX_WideString& csFieldName = L"") const; + CFX_ByteString GetTextMatrixString(); + CFX_AffineMatrix GetTextMatrix(); + protected: + CFX_ByteString m_csDA; +}; +#define FIELDTYPE_UNKNOWN 0 +#define FIELDTYPE_PUSHBUTTON 1 +#define FIELDTYPE_CHECKBOX 2 +#define FIELDTYPE_RADIOBUTTON 3 +#define FIELDTYPE_COMBOBOX 4 +#define FIELDTYPE_LISTBOX 5 +#define FIELDTYPE_TEXTFIELD 6 +#define FIELDTYPE_SIGNATURE 7 +class CPDF_InterForm : public CFX_PrivateData { + public: + CPDF_InterForm(CPDF_Document* pDocument, FX_BOOL bUpdateAP); + ~CPDF_InterForm(); + static void EnableUpdateAP(FX_BOOL bUpdateAP); - CPDF_Document* GetDocument() const - { - return m_pDocument; - } + static FX_BOOL UpdatingAPEnabled(); - CPDF_Dictionary* GetFormDict() const - { - return m_pFormDict; - } + static CFX_ByteString GenerateNewResourceName(const CPDF_Dictionary* pResDict, + const FX_CHAR* csType, + int iMinLen = 2, + const FX_CHAR* csPrefix = ""); + static CPDF_Font* AddSystemDefaultFont(const CPDF_Document* pDocument); + static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, + CFX_ByteString csFontName, + uint8_t iCharSet = 1); + static CPDF_Font* AddSystemFont(const CPDF_Document* pDocument, + CFX_WideString csFontName, + uint8_t iCharSet = 1); - FX_BOOL NeedConstructAP(); + static CPDF_Font* AddStandardFont(const CPDF_Document* pDocument, + CFX_ByteString csFontName); - void NeedConstructAP(FX_BOOL bNeedAP); + static CFX_ByteString GetNativeFont(uint8_t iCharSet, void* pLogFont = NULL); + static CFX_ByteString GetNativeFont(void* pLogFont = NULL); + static uint8_t GetNativeCharSet(); + static CPDF_Font* AddNativeFont(uint8_t iCharSet, + const CPDF_Document* pDocument); - int CountFieldsInCalculationOrder(); + static CPDF_Font* AddNativeFont(const CPDF_Document* pDocument); - CPDF_FormField* GetFieldInCalculationOrder(int index); + FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType); - int FindFieldInCalculationOrder(const CPDF_FormField* pField); + FX_BOOL ValidateFieldName(const CPDF_FormField* pField, + CFX_WideString& csNewFieldName); + FX_BOOL ValidateFieldName(const CPDF_FormControl* pControl, + CFX_WideString& csNewFieldName); + FX_DWORD CountFields(const CFX_WideString& csFieldName = L""); + CPDF_FormField* GetField(FX_DWORD index, + const CFX_WideString& csFieldName = L""); - FX_DWORD CountFormFonts(); + void GetAllFieldNames(CFX_WideStringArray& allFieldNames); - CPDF_Font* GetFormFont(FX_DWORD index, CFX_ByteString& csNameTag); + FX_BOOL IsValidFormField(const void* pField); - CPDF_Font* GetFormFont(CFX_ByteString csNameTag); + CPDF_FormField* GetFieldByDict(CPDF_Dictionary* pFieldDict) const; - CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag); + FX_DWORD CountControls(CFX_WideString csFieldName = L""); - CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); + CPDF_FormControl* GetControl(FX_DWORD index, + CFX_WideString csFieldName = L""); - CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag); + FX_BOOL IsValidFormControl(const void* pControl); - FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); + int CountPageControls(CPDF_Page* pPage) const; - FX_BOOL FindFormFont(CFX_ByteString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag); + CPDF_FormControl* GetPageControl(CPDF_Page* pPage, int index) const; - inline FX_BOOL FindFormFont(CFX_WideString csFontName, CPDF_Font*& pFont, CFX_ByteString& csNameTag) - { - return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag); - } + CPDF_FormControl* GetControlAtPoint(CPDF_Page* pPage, + FX_FLOAT pdf_x, + FX_FLOAT pdf_y) const; + CPDF_FormControl* GetControlByDict(CPDF_Dictionary* pWidgetDict) const; + FX_DWORD CountInternalFields(const CFX_WideString& csFieldName = L"") const; + CPDF_Dictionary* GetInternalField( + FX_DWORD index, + const CFX_WideString& csFieldName = L"") const; + CPDF_Document* GetDocument() const { return m_pDocument; } - void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); + CPDF_Dictionary* GetFormDict() const { return m_pFormDict; } - CPDF_Font* AddNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); + FX_BOOL NeedConstructAP(); - CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag); + void NeedConstructAP(FX_BOOL bNeedAP); - void RemoveFormFont(const CPDF_Font* pFont); + int CountFieldsInCalculationOrder(); - void RemoveFormFont(CFX_ByteString csNameTag); + CPDF_FormField* GetFieldInCalculationOrder(int index); + int FindFieldInCalculationOrder(const CPDF_FormField* pField); + FX_DWORD CountFormFonts(); + CPDF_Font* GetFormFont(FX_DWORD index, CFX_ByteString& csNameTag); - CPDF_DefaultAppearance GetDefaultAppearance(); + CPDF_Font* GetFormFont(CFX_ByteString csNameTag); - CPDF_Font* GetDefaultFormFont(); + CPDF_Font* GetFormFont(CFX_ByteString csFontName, CFX_ByteString& csNameTag); + CPDF_Font* GetNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); + CPDF_Font* GetNativeFormFont(CFX_ByteString& csNameTag); - int GetFormAlignment(); + FX_BOOL FindFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); + FX_BOOL FindFormFont(CFX_ByteString csFontName, + CPDF_Font*& pFont, + CFX_ByteString& csNameTag); + inline FX_BOOL FindFormFont(CFX_WideString csFontName, + CPDF_Font*& pFont, + CFX_ByteString& csNameTag) { + return FindFormFont(PDF_EncodeText(csFontName), pFont, csNameTag); + } + void AddFormFont(const CPDF_Font* pFont, CFX_ByteString& csNameTag); - CPDF_FormField* CheckRequiredFields(const CFX_PtrArray *fields = NULL, FX_BOOL bIncludeOrExclude = TRUE) const; + CPDF_Font* AddNativeFormFont(uint8_t iCharSet, CFX_ByteString& csNameTag); - CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, FX_BOOL bSimpleFileSpec = FALSE) const; + CPDF_Font* AddNativeFormFont(CFX_ByteString& csNameTag); - CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bSimpleFileSpec = FALSE) const; + void RemoveFormFont(const CPDF_Font* pFont); - FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); + void RemoveFormFont(CFX_ByteString csNameTag); + CPDF_DefaultAppearance GetDefaultAppearance(); + CPDF_Font* GetDefaultFormFont(); + int GetFormAlignment(); - FX_BOOL ResetForm(const CFX_PtrArray& fields, FX_BOOL bIncludeOrExclude = TRUE, FX_BOOL bNotify = FALSE); + CPDF_FormField* CheckRequiredFields(const CFX_PtrArray* fields = NULL, + FX_BOOL bIncludeOrExclude = TRUE) const; - FX_BOOL ResetForm(FX_BOOL bNotify = FALSE); + CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, + FX_BOOL bSimpleFileSpec = FALSE) const; - void ReloadForm(); + CFDF_Document* ExportToFDF(const CFX_WideStringC& pdf_path, + CFX_PtrArray& fields, + FX_BOOL bIncludeOrExclude = TRUE, + FX_BOOL bSimpleFileSpec = FALSE) const; - CPDF_FormNotify* GetFormNotify() const - { - return m_pFormNotify; - } + FX_BOOL ImportFromFDF(const CFDF_Document* pFDFDoc, FX_BOOL bNotify = FALSE); - void SetFormNotify(const CPDF_FormNotify* pNotify); + FX_BOOL ResetForm(const CFX_PtrArray& fields, + FX_BOOL bIncludeOrExclude = TRUE, + FX_BOOL bNotify = FALSE); + FX_BOOL ResetForm(FX_BOOL bNotify = FALSE); - int GetPageWithWidget(int iCurPage, FX_BOOL bNext); + void ReloadForm(); + CPDF_FormNotify* GetFormNotify() const { return m_pFormNotify; } + void SetFormNotify(const CPDF_FormNotify* pNotify); - FX_BOOL IsUpdated() - { - return m_bUpdated; - } + int GetPageWithWidget(int iCurPage, FX_BOOL bNext); - void ClearUpdatedFlag() - { - m_bUpdated = FALSE; - } + FX_BOOL IsUpdated() { return m_bUpdated; } + void ClearUpdatedFlag() { m_bUpdated = FALSE; } - FX_BOOL HasXFAForm() const; + FX_BOOL HasXFAForm() const; - void FixPageFields(const CPDF_Page* pPage); -protected: + void FixPageFields(const CPDF_Page* pPage); - static FX_BOOL m_bUpdateAP; + protected: + static FX_BOOL m_bUpdateAP; - void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); + void LoadField(CPDF_Dictionary* pFieldDict, int nLevel = 0); - CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name); + CPDF_Object* GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name); - CPDF_FormField* AddTerminalField(const CPDF_Dictionary* pFieldDict); + CPDF_FormField* AddTerminalField(const CPDF_Dictionary* pFieldDict); - CPDF_FormControl* AddControl(const CPDF_FormField* pField, const CPDF_Dictionary* pWidgetDict); + CPDF_FormControl* AddControl(const CPDF_FormField* pField, + const CPDF_Dictionary* pWidgetDict); - void FDF_ImportField(CPDF_Dictionary* pField, const CFX_WideString& parent_name, FX_BOOL bNotify = FALSE, int nLevel = 0); + void FDF_ImportField(CPDF_Dictionary* pField, + const CFX_WideString& parent_name, + FX_BOOL bNotify = FALSE, + int nLevel = 0); - FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, int iType, const CPDF_FormField* pExcludedField, const CPDF_FormControl* pExcludedControl); + FX_BOOL ValidateFieldName(CFX_WideString& csNewFieldName, + int iType, + const CPDF_FormField* pExcludedField, + const CPDF_FormControl* pExcludedControl); - int CompareFieldName(const CFX_WideString& name1, const CFX_WideString& name2); + int CompareFieldName(const CFX_WideString& name1, + const CFX_WideString& name2); - int CompareFieldName(const CFX_ByteString& name1, const CFX_ByteString& name2); + int CompareFieldName(const CFX_ByteString& name1, + const CFX_ByteString& name2); - CPDF_Document* m_pDocument; + CPDF_Document* m_pDocument; - FX_BOOL m_bGenerateAP; + FX_BOOL m_bGenerateAP; - CPDF_Dictionary* m_pFormDict; + CPDF_Dictionary* m_pFormDict; - CFX_MapPtrToPtr m_ControlMap; + CFX_MapPtrToPtr m_ControlMap; - CFieldTree *m_pFieldTree; + CFieldTree* m_pFieldTree; - CFX_ByteString m_bsEncoding; + CFX_ByteString m_bsEncoding; - CPDF_FormNotify* m_pFormNotify; + CPDF_FormNotify* m_pFormNotify; - FX_BOOL m_bUpdated; - friend class CPDF_FormControl; - friend class CPDF_FormField; + FX_BOOL m_bUpdated; + friend class CPDF_FormControl; + friend class CPDF_FormField; }; -#define FORMFIELD_READONLY 0x01 -#define FORMFIELD_REQUIRED 0x02 -#define FORMFIELD_NOEXPORT 0x04 -#define FORMRADIO_NOTOGGLEOFF 0x100 -#define FORMRADIO_UNISON 0x200 -#define FORMTEXT_MULTILINE 0x100 -#define FORMTEXT_PASSWORD 0x200 -#define FORMTEXT_NOSCROLL 0x400 -#define FORMTEXT_COMB 0x800 -#define FORMCOMBO_EDIT 0x100 -#define FORMLIST_MULTISELECT 0x100 -class CPDF_FormField -{ -public: - - enum Type { - Unknown, - PushButton, - RadioButton, - CheckBox, - Text, - RichText, - File, - ListBox, - ComboBox, - Sign - }; - - CFX_WideString GetFullName(); - - Type GetType() - { - return m_Type; - } - - FX_DWORD GetFlags() - { - return m_Flags; - } - - CPDF_InterForm* GetInterForm() const - { - return m_pForm; - } - - CPDF_Dictionary* GetFieldDict() const - { - return m_pDict; - } - - void SetFieldDict(CPDF_Dictionary* pDict) - { - m_pDict = pDict; - } - - FX_BOOL ResetField(FX_BOOL bNotify = FALSE); - - - - int CountControls() - { - return m_ControlList.GetSize(); - } - - CPDF_FormControl* GetControl(int index) - { - return (CPDF_FormControl*)m_ControlList.GetAt(index); - } - - int GetControlIndex(const CPDF_FormControl* pControl); - - - - - int GetFieldType(); - - - - - CPDF_AAction GetAdditionalAction(); - - - - - CFX_WideString GetAlternateName(); - - - - - CFX_WideString GetMappingName(); - - - - - FX_DWORD GetFieldFlags(); - - - - - CFX_ByteString GetDefaultStyle(); +#define FORMFIELD_READONLY 0x01 +#define FORMFIELD_REQUIRED 0x02 +#define FORMFIELD_NOEXPORT 0x04 +#define FORMRADIO_NOTOGGLEOFF 0x100 +#define FORMRADIO_UNISON 0x200 +#define FORMTEXT_MULTILINE 0x100 +#define FORMTEXT_PASSWORD 0x200 +#define FORMTEXT_NOSCROLL 0x400 +#define FORMTEXT_COMB 0x800 +#define FORMCOMBO_EDIT 0x100 +#define FORMLIST_MULTISELECT 0x100 +class CPDF_FormField { + public: + enum Type { + Unknown, + PushButton, + RadioButton, + CheckBox, + Text, + RichText, + File, + ListBox, + ComboBox, + Sign + }; + CFX_WideString GetFullName(); + Type GetType() { return m_Type; } + FX_DWORD GetFlags() { return m_Flags; } - CFX_WideString GetRichTextString(); + CPDF_InterForm* GetInterForm() const { return m_pForm; } + CPDF_Dictionary* GetFieldDict() const { return m_pDict; } + void SetFieldDict(CPDF_Dictionary* pDict) { m_pDict = pDict; } - CFX_WideString GetValue(); + FX_BOOL ResetField(FX_BOOL bNotify = FALSE); - CFX_WideString GetDefaultValue(); + int CountControls() { return m_ControlList.GetSize(); } - FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE); + CPDF_FormControl* GetControl(int index) { + return (CPDF_FormControl*)m_ControlList.GetAt(index); + } + int GetControlIndex(const CPDF_FormControl* pControl); + int GetFieldType(); + CPDF_AAction GetAdditionalAction(); + CFX_WideString GetAlternateName(); - int GetMaxLen(); + CFX_WideString GetMappingName(); + FX_DWORD GetFieldFlags(); + CFX_ByteString GetDefaultStyle(); + CFX_WideString GetRichTextString(); - int CountSelectedItems(); + CFX_WideString GetValue(); - int GetSelectedIndex(int index); + CFX_WideString GetDefaultValue(); - FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE); + FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bNotify = FALSE); - FX_BOOL IsItemSelected(int index); + int GetMaxLen(); - FX_BOOL SetItemSelection(int index, FX_BOOL bSelected, FX_BOOL bNotify = FALSE); + int CountSelectedItems(); - FX_BOOL IsItemDefaultSelected(int index); + int GetSelectedIndex(int index); - int GetDefaultSelectedItem(); + FX_BOOL ClearSelection(FX_BOOL bNotify = FALSE); + FX_BOOL IsItemSelected(int index); + FX_BOOL SetItemSelection(int index, + FX_BOOL bSelected, + FX_BOOL bNotify = FALSE); + FX_BOOL IsItemDefaultSelected(int index); - int CountOptions(); + int GetDefaultSelectedItem(); - CFX_WideString GetOptionLabel(int index); + int CountOptions(); - CFX_WideString GetOptionValue(int index); + CFX_WideString GetOptionLabel(int index); - int FindOption(CFX_WideString csOptLabel); + CFX_WideString GetOptionValue(int index); - int FindOptionValue(const CFX_WideString& csOptValue, int iStartIndex = 0); + int FindOption(CFX_WideString csOptLabel); + int FindOptionValue(const CFX_WideString& csOptValue, int iStartIndex = 0); + FX_BOOL CheckControl(int iControlIndex, + FX_BOOL bChecked, + FX_BOOL bNotify = FALSE); + int GetTopVisibleIndex(); - FX_BOOL CheckControl(int iControlIndex, FX_BOOL bChecked, FX_BOOL bNotify = FALSE); + int CountSelectedOptions(); + int GetSelectedOptionIndex(int index); + FX_BOOL IsOptionSelected(int iOptIndex); + FX_BOOL SelectOption(int iOptIndex, + FX_BOOL bSelected, + FX_BOOL bNotify = FALSE); - int GetTopVisibleIndex(); + FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE); + FX_BOOL ClearOptions(FX_BOOL bNotify = FALSE); + int InsertOption(CFX_WideString csOptLabel, + int index = -1, + FX_BOOL bNotify = FALSE); + FX_FLOAT GetFontSize() { return m_FontSize; } - int CountSelectedOptions(); + CPDF_Font* GetFont() { return m_pFont; } - int GetSelectedOptionIndex(int index); + protected: + CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); - FX_BOOL IsOptionSelected(int iOptIndex); + ~CPDF_FormField(); - FX_BOOL SelectOption(int iOptIndex, FX_BOOL bSelected, FX_BOOL bNotify = FALSE); + CPDF_FormField::Type m_Type; - FX_BOOL ClearSelectedOptions(FX_BOOL bNotify = FALSE); + FX_DWORD m_Flags; - FX_BOOL ClearOptions(FX_BOOL bNotify = FALSE);
+ CPDF_InterForm* m_pForm; - int InsertOption(CFX_WideString csOptLabel, int index = -1, FX_BOOL bNotify = FALSE);
+ CPDF_Dictionary* m_pDict; - FX_FLOAT GetFontSize() - { - return m_FontSize; - } + CFX_PtrArray m_ControlList; + friend class CPDF_InterForm; + friend class CPDF_FormControl; - CPDF_Font* GetFont() - { - return m_pFont; - } + CFX_WideString GetValue(FX_BOOL bDefault); -protected: + FX_BOOL SetValue(const CFX_WideString& value, + FX_BOOL bDefault, + FX_BOOL bNotify); - CPDF_FormField(CPDF_InterForm* pForm, CPDF_Dictionary* pDict); + void SyncFieldFlags(); - ~CPDF_FormField(); + int FindListSel(CPDF_String* str); - CPDF_FormField::Type m_Type; + CFX_WideString GetOptionText(int index, int sub_index); - FX_DWORD m_Flags; + void LoadDA(); - CPDF_InterForm* m_pForm; + void UpdateAP(CPDF_FormControl* pControl); - CPDF_Dictionary* m_pDict; + CFX_WideString GetCheckValue(FX_BOOL bDefault); - CFX_PtrArray m_ControlList; - friend class CPDF_InterForm; - friend class CPDF_FormControl; + FX_BOOL SetCheckValue(const CFX_WideString& value, + FX_BOOL bDefault, + FX_BOOL bNotify); + FX_FLOAT m_FontSize; - - CFX_WideString GetValue(FX_BOOL bDefault); - - FX_BOOL SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify); - - - void SyncFieldFlags(); - - int FindListSel(CPDF_String* str); - - CFX_WideString GetOptionText(int index, int sub_index); - - void LoadDA(); - - void UpdateAP(CPDF_FormControl* pControl); - - - - CFX_WideString GetCheckValue(FX_BOOL bDefault); - - FX_BOOL SetCheckValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify); - - - FX_FLOAT m_FontSize; - - CPDF_Font* m_pFont; + CPDF_Font* m_pFont; }; -CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel = 0); -class CPDF_IconFit -{ -public: +CPDF_Object* FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, + const FX_CHAR* name, + int nLevel = 0); +class CPDF_IconFit { + public: + CPDF_IconFit(CPDF_Dictionary* pDict = NULL) { m_pDict = pDict; } - CPDF_IconFit(CPDF_Dictionary* pDict = NULL) - { - m_pDict = pDict; - } + operator CPDF_Dictionary*() const { return m_pDict; } - operator CPDF_Dictionary*() const - { - return m_pDict; - } + enum ScaleMethod { Always = 0, Bigger, Smaller, Never }; + ScaleMethod GetScaleMethod(); + FX_BOOL IsProportionalScale(); + void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); - enum ScaleMethod { - Always = 0, - Bigger, - Smaller, - Never - }; + FX_BOOL GetFittingBounds(); - ScaleMethod GetScaleMethod(); - - - - - FX_BOOL IsProportionalScale(); - - - - - void GetIconPosition(FX_FLOAT& fLeft, FX_FLOAT& fBottom); - - - - - FX_BOOL GetFittingBounds(); - - - CPDF_Dictionary* m_pDict; + CPDF_Dictionary* m_pDict; }; -#define TEXTPOS_CAPTION 0 -#define TEXTPOS_ICON 1 -#define TEXTPOS_BELOW 2 -#define TEXTPOS_ABOVE 3 -#define TEXTPOS_RIGHT 4 -#define TEXTPOS_LEFT 5 -#define TEXTPOS_OVERLAID 6 -class CPDF_FormControl -{ -public: - - CPDF_FormField::Type GetType() - { - return m_pField->GetType(); - } - - CPDF_InterForm* GetInterForm() const - { - return m_pForm; - } - - CPDF_FormField* GetField() const - { - return m_pField; - } - - CPDF_Dictionary* GetWidget() const - { - return m_pWidgetDict; - } - - CFX_FloatRect GetRect(); - - void DrawControl(CFX_RenderDevice* pDevice, CFX_AffineMatrix* pMatrix, - CPDF_Page* pPage, CPDF_Annot::AppearanceMode mode, const CPDF_RenderOptions* pOptions = NULL); - - - - CFX_ByteString GetCheckedAPState(); - - CFX_WideString GetExportValue(); - - FX_BOOL IsChecked(); - - FX_BOOL IsDefaultChecked(); - - - - - enum HighlightingMode { - None = 0, - Invert, - Outline, - Push, - Toggle - }; - - HighlightingMode GetHighlightingMode(); - - - - - FX_BOOL HasMKEntry(CFX_ByteString csEntry); - - - - - int GetRotation(); - - - - - inline FX_ARGB GetBorderColor(int& iColorType) - { - return GetColor(iColorType, "BC"); - } - - inline FX_FLOAT GetOriginalBorderColor(int index) - { - return GetOriginalColor(index, "BC"); - } - - inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) - { - GetOriginalColor(iColorType, fc, "BC"); - } +#define TEXTPOS_CAPTION 0 +#define TEXTPOS_ICON 1 +#define TEXTPOS_BELOW 2 +#define TEXTPOS_ABOVE 3 +#define TEXTPOS_RIGHT 4 +#define TEXTPOS_LEFT 5 +#define TEXTPOS_OVERLAID 6 +class CPDF_FormControl { + public: + CPDF_FormField::Type GetType() { return m_pField->GetType(); } + CPDF_InterForm* GetInterForm() const { return m_pForm; } + CPDF_FormField* GetField() const { return m_pField; } + CPDF_Dictionary* GetWidget() const { return m_pWidgetDict; } - inline FX_ARGB GetBackgroundColor(int& iColorType) - { - return GetColor(iColorType, "BG"); - } + CFX_FloatRect GetRect(); - inline FX_FLOAT GetOriginalBackgroundColor(int index) - { - return GetOriginalColor(index, "BG"); - } + void DrawControl(CFX_RenderDevice* pDevice, + CFX_AffineMatrix* pMatrix, + CPDF_Page* pPage, + CPDF_Annot::AppearanceMode mode, + const CPDF_RenderOptions* pOptions = NULL); - inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) - { - GetOriginalColor(iColorType, fc, "BG"); - } + CFX_ByteString GetCheckedAPState(); + CFX_WideString GetExportValue(); + FX_BOOL IsChecked(); + FX_BOOL IsDefaultChecked(); - inline CFX_WideString GetNormalCaption() - { - return GetCaption("CA"); - } + enum HighlightingMode { None = 0, Invert, Outline, Push, Toggle }; + HighlightingMode GetHighlightingMode(); + FX_BOOL HasMKEntry(CFX_ByteString csEntry); + int GetRotation(); - inline CFX_WideString GetRolloverCaption() - { - return GetCaption("RC"); - } + inline FX_ARGB GetBorderColor(int& iColorType) { + return GetColor(iColorType, "BC"); + } + inline FX_FLOAT GetOriginalBorderColor(int index) { + return GetOriginalColor(index, "BC"); + } + inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) { + GetOriginalColor(iColorType, fc, "BC"); + } + inline FX_ARGB GetBackgroundColor(int& iColorType) { + return GetColor(iColorType, "BG"); + } - inline CFX_WideString GetDownCaption() - { - return GetCaption("AC"); - } + inline FX_FLOAT GetOriginalBackgroundColor(int index) { + return GetOriginalColor(index, "BG"); + } + inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) { + GetOriginalColor(iColorType, fc, "BG"); + } + inline CFX_WideString GetNormalCaption() { return GetCaption("CA"); } + inline CFX_WideString GetRolloverCaption() { return GetCaption("RC"); } - inline CPDF_Stream* GetNormalIcon() - { - return GetIcon("I"); - } + inline CFX_WideString GetDownCaption() { return GetCaption("AC"); } + inline CPDF_Stream* GetNormalIcon() { return GetIcon("I"); } + inline CPDF_Stream* GetRolloverIcon() { return GetIcon("RI"); } + inline CPDF_Stream* GetDownIcon() { return GetIcon("IX"); } - inline CPDF_Stream* GetRolloverIcon() - { - return GetIcon("RI"); - } + CPDF_IconFit GetIconFit(); + int GetTextPosition(); + CPDF_Action GetAction(); + CPDF_AAction GetAdditionalAction(); - inline CPDF_Stream* GetDownIcon() - { - return GetIcon("IX"); - } + CPDF_DefaultAppearance GetDefaultAppearance(); + CPDF_Font* GetDefaultControlFont(); + int GetControlAlignment(); + protected: + CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict); - CPDF_IconFit GetIconFit(); + CFX_ByteString GetOnStateName(); + void SetOnStateName(const CFX_ByteString& csOn); + void CheckControl(FX_BOOL bChecked); + FX_ARGB GetColor(int& iColorType, CFX_ByteString csEntry); - int GetTextPosition(); + FX_FLOAT GetOriginalColor(int index, CFX_ByteString csEntry); + void GetOriginalColor(int& iColorType, + FX_FLOAT fc[4], + CFX_ByteString csEntry); + CFX_WideString GetCaption(CFX_ByteString csEntry); + CPDF_Stream* GetIcon(CFX_ByteString csEntry); - CPDF_Action GetAction(); + CPDF_ApSettings GetMK(FX_BOOL bCreate); + CPDF_InterForm* m_pForm; + CPDF_FormField* m_pField; + CPDF_Dictionary* m_pWidgetDict; + friend class CPDF_InterForm; + friend class CPDF_FormField; +}; +class CPDF_FormNotify { + public: + virtual ~CPDF_FormNotify() {} - CPDF_AAction GetAdditionalAction(); - - - - - CPDF_DefaultAppearance GetDefaultAppearance(); - - CPDF_Font* GetDefaultControlFont(); - - - - - int GetControlAlignment(); - -protected: - - CPDF_FormControl(CPDF_FormField* pField, CPDF_Dictionary* pWidgetDict); - - CFX_ByteString GetOnStateName(); - - void SetOnStateName(const CFX_ByteString& csOn); - - void CheckControl(FX_BOOL bChecked); - - FX_ARGB GetColor(int& iColorType, CFX_ByteString csEntry); + virtual int BeforeValueChange(const CPDF_FormField* pField, + CFX_WideString& csValue) { + return 0; + } - FX_FLOAT GetOriginalColor(int index, CFX_ByteString csEntry); + virtual int AfterValueChange(const CPDF_FormField* pField) { return 0; } - void GetOriginalColor(int& iColorType, FX_FLOAT fc[4], CFX_ByteString csEntry); + virtual int BeforeSelectionChange(const CPDF_FormField* pField, + CFX_WideString& csValue) { + return 0; + } - CFX_WideString GetCaption(CFX_ByteString csEntry); + virtual int AfterSelectionChange(const CPDF_FormField* pField) { return 0; } - CPDF_Stream* GetIcon(CFX_ByteString csEntry); + virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, + const CFX_ByteArray& statusArray) { + return 0; + } - CPDF_ApSettings GetMK(FX_BOOL bCreate); + virtual int BeforeFormReset(const CPDF_InterForm* pForm) { return 0; } - CPDF_InterForm* m_pForm; + virtual int AfterFormReset(const CPDF_InterForm* pForm) { return 0; } - CPDF_FormField* m_pField; + virtual int BeforeFormImportData(const CPDF_InterForm* pForm) { return 0; } - CPDF_Dictionary* m_pWidgetDict; - friend class CPDF_InterForm; - friend class CPDF_FormField; -}; -class CPDF_FormNotify -{ -public: - - virtual ~CPDF_FormNotify() {} - - virtual int BeforeValueChange(const CPDF_FormField* pField, CFX_WideString& csValue) - { - return 0; - } - - virtual int AfterValueChange(const CPDF_FormField* pField) - { - return 0; - } - - virtual int BeforeSelectionChange(const CPDF_FormField* pField, CFX_WideString& csValue) - { - return 0; - } - - virtual int AfterSelectionChange(const CPDF_FormField* pField) - { - return 0; - } - - virtual int AfterCheckedStatusChange(const CPDF_FormField* pField, const CFX_ByteArray& statusArray) - { - return 0; - } - - virtual int BeforeFormReset(const CPDF_InterForm* pForm) - { - return 0; - } - - virtual int AfterFormReset(const CPDF_InterForm* pForm) - { - return 0; - } - - virtual int BeforeFormImportData(const CPDF_InterForm* pForm) - { - return 0; - } - - virtual int AfterFormImportData(const CPDF_InterForm* pForm) - { - return 0; - } + virtual int AfterFormImportData(const CPDF_InterForm* pForm) { return 0; } }; -FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); -class CPDF_PageLabel -{ -public: - - CPDF_PageLabel(CPDF_Document* pDocument) - { - m_pDocument = pDocument; - } - +FX_BOOL FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict); +class CPDF_PageLabel { + public: + CPDF_PageLabel(CPDF_Document* pDocument) { m_pDocument = pDocument; } - CFX_WideString GetLabel(int nPage) const; + CFX_WideString GetLabel(int nPage) const; - int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const; + int32_t GetPageByLabel(const CFX_ByteStringC& bsLabel) const; + int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const; - int32_t GetPageByLabel(const CFX_WideStringC& wsLabel) const; - -protected: - CPDF_Document* m_pDocument; + protected: + CPDF_Document* m_pDocument; }; -class CPDF_Metadata -{ -public: - - CPDF_Metadata(); - - - ~CPDF_Metadata(); +class CPDF_Metadata { + public: + CPDF_Metadata(); - void LoadDoc(CPDF_Document *pDoc); + ~CPDF_Metadata(); + void LoadDoc(CPDF_Document* pDoc); - int32_t GetString(const CFX_ByteStringC& bsItem, CFX_WideString &wsStr); + int32_t GetString(const CFX_ByteStringC& bsItem, CFX_WideString& wsStr); - CXML_Element* GetRoot() const; + CXML_Element* GetRoot() const; - CXML_Element* GetRDF() const; + CXML_Element* GetRDF() const; -protected: - void* m_pData; + protected: + void* m_pData; }; -class CPDF_ViewerPreferences -{ -public: +class CPDF_ViewerPreferences { + public: + CPDF_ViewerPreferences(CPDF_Document* pDoc); - CPDF_ViewerPreferences(CPDF_Document *pDoc); + ~CPDF_ViewerPreferences(); + FX_BOOL IsDirectionR2L() const; - ~CPDF_ViewerPreferences(); + FX_BOOL PrintScaling() const; + int32_t NumCopies() const; - FX_BOOL IsDirectionR2L() const; + CPDF_Array* PrintPageRange() const; - FX_BOOL PrintScaling() const; + CFX_ByteString Duplex() const; - int32_t NumCopies() const; - - CPDF_Array* PrintPageRange() const; - - CFX_ByteString Duplex() const; - -protected: - CPDF_Document* m_pDoc; + protected: + CPDF_Document* m_pDoc; }; -class CPDF_ApSettings -{ -public: - - CPDF_ApSettings(CPDF_Dictionary* pDict = NULL) - { - m_pDict = pDict; - } - - operator CPDF_Dictionary* () const - { - return m_pDict; - } - - FX_BOOL HasMKEntry(const CFX_ByteStringC& csEntry); - - - - int GetRotation(); - - - - - inline FX_ARGB GetBorderColor(int& iColorType) - { - return GetColor(iColorType, FX_BSTRC("BC")); - } - - inline FX_FLOAT GetOriginalBorderColor(int index) - { - return GetOriginalColor(index, FX_BSTRC("BC")); - } - - inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) - { - GetOriginalColor(iColorType, fc, FX_BSTRC("BC")); - } - - - - - inline FX_ARGB GetBackgroundColor(int& iColorType) - { - return GetColor(iColorType, FX_BSTRC("BG")); - } - - inline FX_FLOAT GetOriginalBackgroundColor(int index) - { - return GetOriginalColor(index, FX_BSTRC("BG")); - } - - inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) - { - GetOriginalColor(iColorType, fc, FX_BSTRC("BG")); - } - - - - - inline CFX_WideString GetNormalCaption() - { - return GetCaption(FX_BSTRC("CA")); - } - - - - - inline CFX_WideString GetRolloverCaption() - { - return GetCaption(FX_BSTRC("RC")); - } - - - - - inline CFX_WideString GetDownCaption() - { - return GetCaption(FX_BSTRC("AC")); - } - - - +class CPDF_ApSettings { + public: + CPDF_ApSettings(CPDF_Dictionary* pDict = NULL) { m_pDict = pDict; } - inline CPDF_Stream* GetNormalIcon() - { - return GetIcon(FX_BSTRC("I")); - } + operator CPDF_Dictionary*() const { return m_pDict; } + FX_BOOL HasMKEntry(const CFX_ByteStringC& csEntry); + int GetRotation(); + inline FX_ARGB GetBorderColor(int& iColorType) { + return GetColor(iColorType, FX_BSTRC("BC")); + } - inline CPDF_Stream* GetRolloverIcon() - { - return GetIcon(FX_BSTRC("RI")); - } + inline FX_FLOAT GetOriginalBorderColor(int index) { + return GetOriginalColor(index, FX_BSTRC("BC")); + } + inline void GetOriginalBorderColor(int& iColorType, FX_FLOAT fc[4]) { + GetOriginalColor(iColorType, fc, FX_BSTRC("BC")); + } + inline FX_ARGB GetBackgroundColor(int& iColorType) { + return GetColor(iColorType, FX_BSTRC("BG")); + } + inline FX_FLOAT GetOriginalBackgroundColor(int index) { + return GetOriginalColor(index, FX_BSTRC("BG")); + } - inline CPDF_Stream* GetDownIcon() - { - return GetIcon(FX_BSTRC("IX")); - } + inline void GetOriginalBackgroundColor(int& iColorType, FX_FLOAT fc[4]) { + GetOriginalColor(iColorType, fc, FX_BSTRC("BG")); + } + inline CFX_WideString GetNormalCaption() { + return GetCaption(FX_BSTRC("CA")); + } + inline CFX_WideString GetRolloverCaption() { + return GetCaption(FX_BSTRC("RC")); + } + inline CFX_WideString GetDownCaption() { return GetCaption(FX_BSTRC("AC")); } - CPDF_IconFit GetIconFit(); + inline CPDF_Stream* GetNormalIcon() { return GetIcon(FX_BSTRC("I")); } + inline CPDF_Stream* GetRolloverIcon() { return GetIcon(FX_BSTRC("RI")); } + inline CPDF_Stream* GetDownIcon() { return GetIcon(FX_BSTRC("IX")); } + CPDF_IconFit GetIconFit(); - int GetTextPosition(); + int GetTextPosition(); - CPDF_Dictionary* m_pDict; -protected: + CPDF_Dictionary* m_pDict; - FX_ARGB GetColor(int& iColorType, const CFX_ByteStringC& csEntry); + protected: + FX_ARGB GetColor(int& iColorType, const CFX_ByteStringC& csEntry); - FX_FLOAT GetOriginalColor(int index, const CFX_ByteStringC& csEntry); + FX_FLOAT GetOriginalColor(int index, const CFX_ByteStringC& csEntry); - void GetOriginalColor(int& iColorType, FX_FLOAT fc[4], const CFX_ByteStringC& csEntry); + void GetOriginalColor(int& iColorType, + FX_FLOAT fc[4], + const CFX_ByteStringC& csEntry); - CFX_WideString GetCaption(const CFX_ByteStringC& csEntry); + CFX_WideString GetCaption(const CFX_ByteStringC& csEntry); - CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry); - friend class CPDF_FormControl; + CPDF_Stream* GetIcon(const CFX_ByteStringC& csEntry); + friend class CPDF_FormControl; }; #endif // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_ diff --git a/core/include/fpdfdoc/fpdf_tagged.h b/core/include/fpdfdoc/fpdf_tagged.h index 706f5c04d7..3de6041dc1 100644 --- a/core/include/fpdfdoc/fpdf_tagged.h +++ b/core/include/fpdfdoc/fpdf_tagged.h @@ -14,89 +14,93 @@ class CPDF_StructTree; class IPDF_ReflowedPage; struct CPDF_StructKid; -class CPDF_StructTree -{ -public: +class CPDF_StructTree { + public: + static CPDF_StructTree* LoadDoc(const CPDF_Document* pDoc); - static CPDF_StructTree* LoadDoc(const CPDF_Document* pDoc); + static CPDF_StructTree* LoadPage(const CPDF_Document* pDoc, + const CPDF_Dictionary* pPageDict); - static CPDF_StructTree* LoadPage(const CPDF_Document* pDoc, const CPDF_Dictionary* pPageDict); + virtual ~CPDF_StructTree() {} - virtual ~CPDF_StructTree() {} + virtual int CountTopElements() const = 0; - virtual int CountTopElements() const = 0; - - virtual CPDF_StructElement* GetTopElement(int i) const = 0; + virtual CPDF_StructElement* GetTopElement(int i) const = 0; }; struct CPDF_StructKid { - enum { - Invalid, - Element, - PageContent, - StreamContent, - Object - } m_Type; - - union { - struct { - - CPDF_StructElement* m_pElement; - - CPDF_Dictionary* m_pDict; - } m_Element; - struct { + enum { Invalid, Element, PageContent, StreamContent, Object } m_Type; - FX_DWORD m_PageObjNum; + union { + struct { + CPDF_StructElement* m_pElement; - FX_DWORD m_ContentId; - } m_PageContent; - struct { + CPDF_Dictionary* m_pDict; + } m_Element; + struct { + FX_DWORD m_PageObjNum; - FX_DWORD m_PageObjNum; + FX_DWORD m_ContentId; + } m_PageContent; + struct { + FX_DWORD m_PageObjNum; - FX_DWORD m_ContentId; + FX_DWORD m_ContentId; - FX_DWORD m_RefObjNum; - } m_StreamContent; - struct { + FX_DWORD m_RefObjNum; + } m_StreamContent; + struct { + FX_DWORD m_PageObjNum; - FX_DWORD m_PageObjNum; - - FX_DWORD m_RefObjNum; - } m_Object; - }; + FX_DWORD m_RefObjNum; + } m_Object; + }; }; -class CPDF_StructElement -{ -public: - virtual ~CPDF_StructElement() { } - - virtual CPDF_StructTree* GetTree() const = 0; - - virtual const CFX_ByteString& GetType() const = 0; - - virtual CPDF_StructElement* GetParent() const = 0; +class CPDF_StructElement { + public: + virtual ~CPDF_StructElement() {} - virtual CPDF_Dictionary * GetDict() const = 0; + virtual CPDF_StructTree* GetTree() const = 0; - virtual int CountKids() const = 0; + virtual const CFX_ByteString& GetType() const = 0; - virtual const CPDF_StructKid& GetKid(int index) const = 0; + virtual CPDF_StructElement* GetParent() const = 0; - virtual CFX_PtrArray* GetObjectArray() = 0; + virtual CPDF_Dictionary* GetDict() const = 0; - virtual CPDF_Object* GetAttr(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_BOOL bInheritable = FALSE, FX_FLOAT fLevel = 0.0F) = 0; + virtual int CountKids() const = 0; + virtual const CPDF_StructKid& GetKid(int index) const = 0; + virtual CFX_PtrArray* GetObjectArray() = 0; - virtual CFX_ByteString GetName(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, const CFX_ByteStringC& default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0; + virtual CPDF_Object* GetAttr(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + FX_BOOL bInheritable = FALSE, + FX_FLOAT fLevel = 0.0F) = 0; - virtual FX_ARGB GetColor(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_ARGB default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0; + virtual CFX_ByteString GetName(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + const CFX_ByteStringC& default_value, + FX_BOOL bInheritable = FALSE, + int subindex = -1) = 0; - virtual FX_FLOAT GetNumber(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, FX_FLOAT default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0; + virtual FX_ARGB GetColor(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + FX_ARGB default_value, + FX_BOOL bInheritable = FALSE, + int subindex = -1) = 0; - virtual int GetInteger(const CFX_ByteStringC& owner, const CFX_ByteStringC& name, int default_value, FX_BOOL bInheritable = FALSE, int subindex = -1) = 0; + virtual FX_FLOAT GetNumber(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + FX_FLOAT default_value, + FX_BOOL bInheritable = FALSE, + int subindex = -1) = 0; + virtual int GetInteger(const CFX_ByteStringC& owner, + const CFX_ByteStringC& name, + int default_value, + FX_BOOL bInheritable = FALSE, + int subindex = -1) = 0; }; #endif // CORE_INCLUDE_FPDFDOC_FPDF_TAGGED_H_ diff --git a/core/include/fpdfdoc/fpdf_vt.h b/core/include/fpdfdoc/fpdf_vt.h index 4baba41348..62a6019793 100644 --- a/core/include/fpdfdoc/fpdf_vt.h +++ b/core/include/fpdfdoc/fpdf_vt.h @@ -20,434 +20,443 @@ struct CPVT_WordPlace; struct CPVT_WordRange; struct CPVT_WordPlace { - - CPVT_WordPlace() : nSecIndex(-1), nLineIndex(-1), nWordIndex(-1) - { + CPVT_WordPlace() : nSecIndex(-1), nLineIndex(-1), nWordIndex(-1) {} + + CPVT_WordPlace(int32_t other_nSecIndex, + int32_t other_nLineIndex, + int32_t other_nWordIndex) { + nSecIndex = other_nSecIndex; + nLineIndex = other_nLineIndex; + nWordIndex = other_nWordIndex; + } + + void Default() { nSecIndex = nLineIndex = nWordIndex = -1; } + + FX_BOOL operator==(const CPVT_WordPlace& wp) const { + return wp.nSecIndex == nSecIndex && wp.nLineIndex == nLineIndex && + wp.nWordIndex == nWordIndex; + } + + FX_BOOL operator!=(const CPVT_WordPlace& wp) const { + return wp.nSecIndex != nSecIndex || wp.nLineIndex != nLineIndex || + wp.nWordIndex != nWordIndex; + } + + inline int32_t WordCmp(const CPVT_WordPlace& wp) const { + if (nSecIndex > wp.nSecIndex) { + return 1; } - - CPVT_WordPlace(int32_t other_nSecIndex, - int32_t other_nLineIndex, - int32_t other_nWordIndex) - { - nSecIndex = other_nSecIndex; - nLineIndex = other_nLineIndex; - nWordIndex = other_nWordIndex; + if (nSecIndex < wp.nSecIndex) { + return -1; } - - void Default() - { - nSecIndex = nLineIndex = nWordIndex = -1; + if (nLineIndex > wp.nLineIndex) { + return 1; } - - FX_BOOL operator == (const CPVT_WordPlace & wp) const - { - return wp.nSecIndex == nSecIndex && wp.nLineIndex == nLineIndex && wp.nWordIndex == nWordIndex; + if (nLineIndex < wp.nLineIndex) { + return -1; } - - FX_BOOL operator != (const CPVT_WordPlace & wp) const - { - return wp.nSecIndex != nSecIndex || wp.nLineIndex != nLineIndex || wp.nWordIndex != nWordIndex; + if (nWordIndex > wp.nWordIndex) { + return 1; } - - inline int32_t WordCmp(const CPVT_WordPlace & wp) const - { - if (nSecIndex > wp.nSecIndex) { - return 1; - } - if (nSecIndex < wp.nSecIndex) { - return -1; - } - if (nLineIndex > wp.nLineIndex) { - return 1; - } - if (nLineIndex < wp.nLineIndex) { - return -1; - } - if (nWordIndex > wp.nWordIndex) { - return 1; - } - if (nWordIndex < wp.nWordIndex) { - return -1; - } - return 0; + if (nWordIndex < wp.nWordIndex) { + return -1; } + return 0; + } - inline int32_t LineCmp(const CPVT_WordPlace & wp) const - { - if (nSecIndex > wp.nSecIndex) { - return 1; - } - if (nSecIndex < wp.nSecIndex) { - return -1; - } - if (nLineIndex > wp.nLineIndex) { - return 1; - } - if (nLineIndex < wp.nLineIndex) { - return -1; - } - return 0; + inline int32_t LineCmp(const CPVT_WordPlace& wp) const { + if (nSecIndex > wp.nSecIndex) { + return 1; } - - inline int32_t SecCmp(const CPVT_WordPlace & wp) const - { - if (nSecIndex > wp.nSecIndex) { - return 1; - } - if (nSecIndex < wp.nSecIndex) { - return -1; - } - return 0; + if (nSecIndex < wp.nSecIndex) { + return -1; } - - int32_t nSecIndex; - - int32_t nLineIndex; - - int32_t nWordIndex; -}; -struct CPVT_WordRange { - - CPVT_WordRange() - { - } - - CPVT_WordRange(const CPVT_WordPlace & begin, const CPVT_WordPlace & end) - { - Set(begin, end); + if (nLineIndex > wp.nLineIndex) { + return 1; } - - void Default() - { - BeginPos.Default(); - EndPos.Default(); + if (nLineIndex < wp.nLineIndex) { + return -1; } + return 0; + } - void Set(const CPVT_WordPlace & begin, const CPVT_WordPlace & end) - { - BeginPos = begin; - EndPos = end; - SwapWordPlace(); + inline int32_t SecCmp(const CPVT_WordPlace& wp) const { + if (nSecIndex > wp.nSecIndex) { + return 1; } - - void SetBeginPos(const CPVT_WordPlace & begin) - { - BeginPos = begin; - SwapWordPlace(); + if (nSecIndex < wp.nSecIndex) { + return -1; } + return 0; + } - void SetEndPos(const CPVT_WordPlace & end) - { - EndPos = end; - SwapWordPlace(); - } + int32_t nSecIndex; - FX_BOOL IsExist() const - { - return BeginPos != EndPos; - } - - FX_BOOL operator != (const CPVT_WordRange & wr) const - { - return wr.BeginPos != BeginPos || wr.EndPos != EndPos; - } - - void SwapWordPlace() - { - if (BeginPos.WordCmp(EndPos) > 0) { - CPVT_WordPlace place = EndPos; - EndPos = BeginPos; - BeginPos = place; - } - } + int32_t nLineIndex; - CPVT_WordPlace BeginPos; - - CPVT_WordPlace EndPos; + int32_t nWordIndex; }; -struct CPVT_SecProps { - - CPVT_SecProps() : fLineLeading(0.0f), fLineIndent(0.0f), nAlignment(0) - { - } - - CPVT_SecProps(FX_FLOAT lineLeading, FX_FLOAT lineIndent, int32_t alignment) : - fLineLeading(lineLeading), fLineIndent(lineIndent), nAlignment(alignment) - { - } - - CPVT_SecProps(const CPVT_SecProps & other) : - fLineLeading(other.fLineLeading), fLineIndent(other.fLineIndent), nAlignment(other.nAlignment) - { +struct CPVT_WordRange { + CPVT_WordRange() {} + + CPVT_WordRange(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { + Set(begin, end); + } + + void Default() { + BeginPos.Default(); + EndPos.Default(); + } + + void Set(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) { + BeginPos = begin; + EndPos = end; + SwapWordPlace(); + } + + void SetBeginPos(const CPVT_WordPlace& begin) { + BeginPos = begin; + SwapWordPlace(); + } + + void SetEndPos(const CPVT_WordPlace& end) { + EndPos = end; + SwapWordPlace(); + } + + FX_BOOL IsExist() const { return BeginPos != EndPos; } + + FX_BOOL operator!=(const CPVT_WordRange& wr) const { + return wr.BeginPos != BeginPos || wr.EndPos != EndPos; + } + + void SwapWordPlace() { + if (BeginPos.WordCmp(EndPos) > 0) { + CPVT_WordPlace place = EndPos; + EndPos = BeginPos; + BeginPos = place; } + } - FX_FLOAT fLineLeading; - - FX_FLOAT fLineIndent; + CPVT_WordPlace BeginPos; - int32_t nAlignment; + CPVT_WordPlace EndPos; }; -struct CPVT_WordProps { - - CPVT_WordProps() : nFontIndex(-1), fFontSize(0.0f), dwWordColor(0), nScriptType(0), nWordStyle(0), - fCharSpace(0.0f), nHorzScale(0) - { - } - - CPVT_WordProps(int32_t fontIndex, FX_FLOAT fontSize, FX_COLORREF wordColor = 0, int32_t scriptType = 0, int32_t wordStyle = 0, - FX_FLOAT charSpace = 0, int32_t horzScale = 100) : - nFontIndex(fontIndex), fFontSize(fontSize), dwWordColor(wordColor), nScriptType(scriptType), - nWordStyle(wordStyle), fCharSpace(charSpace), nHorzScale(horzScale) - { - } - - CPVT_WordProps(const CPVT_WordProps & other) : - nFontIndex(other.nFontIndex), fFontSize(other.fFontSize), dwWordColor(other.dwWordColor), - nScriptType(other.nScriptType), nWordStyle(other.nWordStyle), fCharSpace(other.fCharSpace), - nHorzScale(other.nHorzScale) - { - } +struct CPVT_SecProps { + CPVT_SecProps() : fLineLeading(0.0f), fLineIndent(0.0f), nAlignment(0) {} - int32_t nFontIndex; + CPVT_SecProps(FX_FLOAT lineLeading, FX_FLOAT lineIndent, int32_t alignment) + : fLineLeading(lineLeading), + fLineIndent(lineIndent), + nAlignment(alignment) {} - FX_FLOAT fFontSize; + CPVT_SecProps(const CPVT_SecProps& other) + : fLineLeading(other.fLineLeading), + fLineIndent(other.fLineIndent), + nAlignment(other.nAlignment) {} - FX_COLORREF dwWordColor; + FX_FLOAT fLineLeading; - int32_t nScriptType; + FX_FLOAT fLineIndent; - int32_t nWordStyle; - - FX_FLOAT fCharSpace; - - int32_t nHorzScale; + int32_t nAlignment; +}; +struct CPVT_WordProps { + CPVT_WordProps() + : nFontIndex(-1), + fFontSize(0.0f), + dwWordColor(0), + nScriptType(0), + nWordStyle(0), + fCharSpace(0.0f), + nHorzScale(0) {} + + CPVT_WordProps(int32_t fontIndex, + FX_FLOAT fontSize, + FX_COLORREF wordColor = 0, + int32_t scriptType = 0, + int32_t wordStyle = 0, + FX_FLOAT charSpace = 0, + int32_t horzScale = 100) + : nFontIndex(fontIndex), + fFontSize(fontSize), + dwWordColor(wordColor), + nScriptType(scriptType), + nWordStyle(wordStyle), + fCharSpace(charSpace), + nHorzScale(horzScale) {} + + CPVT_WordProps(const CPVT_WordProps& other) + : nFontIndex(other.nFontIndex), + fFontSize(other.fFontSize), + dwWordColor(other.dwWordColor), + nScriptType(other.nScriptType), + nWordStyle(other.nWordStyle), + fCharSpace(other.fCharSpace), + nHorzScale(other.nHorzScale) {} + + int32_t nFontIndex; + + FX_FLOAT fFontSize; + + FX_COLORREF dwWordColor; + + int32_t nScriptType; + + int32_t nWordStyle; + + FX_FLOAT fCharSpace; + + int32_t nHorzScale; }; struct CPVT_Word { + CPVT_Word() + : Word(0), + nCharset(0), + ptWord(0, 0), + fAscent(0.0f), + fDescent(0.0f), + fWidth(0.0f), + fFontSize(0), + WordProps() {} - CPVT_Word() : Word(0), nCharset(0), ptWord(0, 0), fAscent(0.0f), fDescent(0.0f), fWidth(0.0f), - fFontSize(0), WordProps() - { - } - - FX_WORD Word; + FX_WORD Word; - int32_t nCharset; + int32_t nCharset; - CPVT_WordPlace WordPlace; + CPVT_WordPlace WordPlace; - CPDF_Point ptWord; + CPDF_Point ptWord; - FX_FLOAT fAscent; + FX_FLOAT fAscent; - FX_FLOAT fDescent; + FX_FLOAT fDescent; - FX_FLOAT fWidth; + FX_FLOAT fWidth; - int32_t nFontIndex; + int32_t nFontIndex; - FX_FLOAT fFontSize; + FX_FLOAT fFontSize; - CPVT_WordProps WordProps; + CPVT_WordProps WordProps; }; struct CPVT_Line { + CPVT_Line() + : ptLine(0, 0), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f) {} - CPVT_Line() : ptLine(0, 0), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f) - { - } + CPVT_WordPlace lineplace; - CPVT_WordPlace lineplace; + CPVT_WordPlace lineEnd; - CPVT_WordPlace lineEnd; + CPDF_Point ptLine; - CPDF_Point ptLine; + FX_FLOAT fLineWidth; - FX_FLOAT fLineWidth; + FX_FLOAT fLineAscent; - FX_FLOAT fLineAscent; - - FX_FLOAT fLineDescent; + FX_FLOAT fLineDescent; }; struct CPVT_Section { + CPVT_WordPlace secplace; - CPVT_WordPlace secplace; - - CPDF_Rect rcSection; + CPDF_Rect rcSection; - CPVT_SecProps SecProps; + CPVT_SecProps SecProps; - CPVT_WordProps WordProps; + CPVT_WordProps WordProps; }; -class IPDF_VariableText_Provider -{ -public: - virtual ~IPDF_VariableText_Provider() { } +class IPDF_VariableText_Provider { + public: + virtual ~IPDF_VariableText_Provider() {} - virtual int32_t GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle) = 0; + virtual int32_t GetCharWidth(int32_t nFontIndex, + FX_WORD word, + int32_t nWordStyle) = 0; - virtual int32_t GetTypeAscent(int32_t nFontIndex) = 0; + virtual int32_t GetTypeAscent(int32_t nFontIndex) = 0; - virtual int32_t GetTypeDescent(int32_t nFontIndex) = 0; + virtual int32_t GetTypeDescent(int32_t nFontIndex) = 0; - virtual int32_t GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex) = 0; + virtual int32_t GetWordFontIndex(FX_WORD word, + int32_t charset, + int32_t nFontIndex) = 0; - virtual FX_BOOL IsLatinWord(FX_WORD word) = 0; + virtual FX_BOOL IsLatinWord(FX_WORD word) = 0; - virtual int32_t GetDefaultFontIndex() = 0; + virtual int32_t GetDefaultFontIndex() = 0; }; -class IPDF_VariableText_Iterator -{ -public: - virtual ~IPDF_VariableText_Iterator() { } +class IPDF_VariableText_Iterator { + public: + virtual ~IPDF_VariableText_Iterator() {} - virtual FX_BOOL NextWord() = 0; + virtual FX_BOOL NextWord() = 0; - virtual FX_BOOL PrevWord() = 0; + virtual FX_BOOL PrevWord() = 0; - virtual FX_BOOL NextLine() = 0; + virtual FX_BOOL NextLine() = 0; - virtual FX_BOOL PrevLine() = 0; + virtual FX_BOOL PrevLine() = 0; - virtual FX_BOOL NextSection() = 0; + virtual FX_BOOL NextSection() = 0; - virtual FX_BOOL PrevSection() = 0; + virtual FX_BOOL PrevSection() = 0; - virtual FX_BOOL GetWord(CPVT_Word & word) const = 0; + virtual FX_BOOL GetWord(CPVT_Word& word) const = 0; - virtual FX_BOOL SetWord(const CPVT_Word & word) = 0; + virtual FX_BOOL SetWord(const CPVT_Word& word) = 0; - virtual FX_BOOL GetLine(CPVT_Line & line) const = 0; + virtual FX_BOOL GetLine(CPVT_Line& line) const = 0; - virtual FX_BOOL GetSection(CPVT_Section & section) const = 0; + virtual FX_BOOL GetSection(CPVT_Section& section) const = 0; - virtual FX_BOOL SetSection(const CPVT_Section & section) = 0; + virtual FX_BOOL SetSection(const CPVT_Section& section) = 0; - virtual void SetAt(int32_t nWordIndex) = 0; + virtual void SetAt(int32_t nWordIndex) = 0; - virtual void SetAt(const CPVT_WordPlace & place) = 0; + virtual void SetAt(const CPVT_WordPlace& place) = 0; - virtual const CPVT_WordPlace & GetAt() const = 0; + virtual const CPVT_WordPlace& GetAt() const = 0; }; -class IPDF_VariableText -{ -public: - static IPDF_VariableText* NewVariableText(); +class IPDF_VariableText { + public: + static IPDF_VariableText* NewVariableText(); - static void DelVariableText(IPDF_VariableText* pVT); + static void DelVariableText(IPDF_VariableText* pVT); - virtual IPDF_VariableText_Provider* SetProvider(IPDF_VariableText_Provider * pProvider) = 0; + virtual IPDF_VariableText_Provider* SetProvider( + IPDF_VariableText_Provider* pProvider) = 0; - virtual IPDF_VariableText_Iterator* GetIterator() = 0; + virtual IPDF_VariableText_Iterator* GetIterator() = 0; - virtual void SetPlateRect(const CPDF_Rect & rect) = 0; + virtual void SetPlateRect(const CPDF_Rect& rect) = 0; - virtual void SetAlignment(int32_t nFormat = 0) = 0; + virtual void SetAlignment(int32_t nFormat = 0) = 0; - virtual void SetPasswordChar(FX_WORD wSubWord = '*') = 0; + virtual void SetPasswordChar(FX_WORD wSubWord = '*') = 0; - virtual void SetLimitChar(int32_t nLimitChar = 0) = 0; + virtual void SetLimitChar(int32_t nLimitChar = 0) = 0; - virtual void SetCharArray(int32_t nCharArray = 0) = 0; + virtual void SetCharArray(int32_t nCharArray = 0) = 0; - virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) = 0; + virtual void SetCharSpace(FX_FLOAT fCharSpace = 0.0f) = 0; - virtual void SetHorzScale(int32_t nHorzScale = 100) = 0; + virtual void SetHorzScale(int32_t nHorzScale = 100) = 0; - virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE) = 0; + virtual void SetMultiLine(FX_BOOL bMultiLine = TRUE) = 0; - virtual void SetAutoReturn(FX_BOOL bAuto = TRUE) = 0; + virtual void SetAutoReturn(FX_BOOL bAuto = TRUE) = 0; - virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE) = 0; + virtual void SetAutoFontSize(FX_BOOL bAuto = TRUE) = 0; - virtual void SetFontSize(FX_FLOAT fFontSize) = 0; + virtual void SetFontSize(FX_FLOAT fFontSize) = 0; - virtual void SetLineLeading(FX_FLOAT fLineLeading) = 0; + virtual void SetLineLeading(FX_FLOAT fLineLeading) = 0; - virtual void SetRichText(FX_BOOL bRichText) = 0; + virtual void SetRichText(FX_BOOL bRichText) = 0; - virtual void Initialize() = 0; + virtual void Initialize() = 0; - virtual FX_BOOL IsValid() const = 0; + virtual FX_BOOL IsValid() const = 0; - virtual FX_BOOL IsRichText() const = 0; + virtual FX_BOOL IsRichText() const = 0; - virtual void RearrangeAll() = 0; + virtual void RearrangeAll() = 0; - virtual void RearrangePart(const CPVT_WordRange & PlaceRange) = 0; + virtual void RearrangePart(const CPVT_WordRange& PlaceRange) = 0; - virtual void ResetAll() = 0; + virtual void ResetAll() = 0; - virtual void SetText(const FX_WCHAR* text, int32_t charset = 1, const CPVT_SecProps * pSecProps = NULL, - const CPVT_WordProps * pWordProps = NULL) = 0; + virtual void SetText(const FX_WCHAR* text, + int32_t charset = 1, + const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL) = 0; - virtual CPVT_WordPlace InsertWord(const CPVT_WordPlace & place, FX_WORD word, int32_t charset = 1, - const CPVT_WordProps * pWordProps = NULL) = 0; + virtual CPVT_WordPlace InsertWord( + const CPVT_WordPlace& place, + FX_WORD word, + int32_t charset = 1, + const CPVT_WordProps* pWordProps = NULL) = 0; - virtual CPVT_WordPlace InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps = NULL, - const CPVT_WordProps * pWordProps = NULL) = 0; + virtual CPVT_WordPlace InsertSection( + const CPVT_WordPlace& place, + const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL) = 0; - virtual CPVT_WordPlace InsertText(const CPVT_WordPlace & place, const FX_WCHAR* text, int32_t charset = 1, - const CPVT_SecProps * pSecProps = NULL, const CPVT_WordProps * pWordProps = NULL) = 0; + virtual CPVT_WordPlace InsertText( + const CPVT_WordPlace& place, + const FX_WCHAR* text, + int32_t charset = 1, + const CPVT_SecProps* pSecProps = NULL, + const CPVT_WordProps* pWordProps = NULL) = 0; - virtual CPVT_WordPlace DeleteWords(const CPVT_WordRange & PlaceRange) = 0; + virtual CPVT_WordPlace DeleteWords(const CPVT_WordRange& PlaceRange) = 0; - virtual CPVT_WordPlace DeleteWord(const CPVT_WordPlace & place) = 0; + virtual CPVT_WordPlace DeleteWord(const CPVT_WordPlace& place) = 0; - virtual CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace & place) = 0; + virtual CPVT_WordPlace BackSpaceWord(const CPVT_WordPlace& place) = 0; - virtual const CPDF_Rect & GetPlateRect() const = 0; + virtual const CPDF_Rect& GetPlateRect() const = 0; - virtual CPDF_Rect GetContentRect() const = 0; + virtual CPDF_Rect GetContentRect() const = 0; - virtual int32_t GetTotalWords() const = 0; + virtual int32_t GetTotalWords() const = 0; - virtual FX_FLOAT GetFontSize() const = 0; + virtual FX_FLOAT GetFontSize() const = 0; - virtual int32_t GetAlignment() const = 0; + virtual int32_t GetAlignment() const = 0; - virtual FX_WORD GetPasswordChar() const = 0; + virtual FX_WORD GetPasswordChar() const = 0; - virtual int32_t GetCharArray() const = 0; + virtual int32_t GetCharArray() const = 0; - virtual int32_t GetLimitChar() const = 0; + virtual int32_t GetLimitChar() const = 0; - virtual FX_BOOL IsMultiLine() const = 0; + virtual FX_BOOL IsMultiLine() const = 0; - virtual int32_t GetHorzScale() const = 0; + virtual int32_t GetHorzScale() const = 0; - virtual FX_FLOAT GetCharSpace() const = 0; + virtual FX_FLOAT GetCharSpace() const = 0; - virtual CPVT_WordPlace GetBeginWordPlace() const = 0; + virtual CPVT_WordPlace GetBeginWordPlace() const = 0; - virtual CPVT_WordPlace GetEndWordPlace() const = 0; + virtual CPVT_WordPlace GetEndWordPlace() const = 0; - virtual CPVT_WordPlace GetPrevWordPlace(const CPVT_WordPlace & place) const = 0; + virtual CPVT_WordPlace GetPrevWordPlace( + const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace GetNextWordPlace(const CPVT_WordPlace & place) const = 0; + virtual CPVT_WordPlace GetNextWordPlace( + const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point & point) const = 0; + virtual CPVT_WordPlace SearchWordPlace(const CPDF_Point& point) const = 0; - virtual CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const = 0; + virtual CPVT_WordPlace GetUpWordPlace(const CPVT_WordPlace& place, + const CPDF_Point& point) const = 0; - virtual CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const = 0; + virtual CPVT_WordPlace GetDownWordPlace(const CPVT_WordPlace& place, + const CPDF_Point& point) const = 0; - virtual CPVT_WordPlace GetLineBeginPlace(const CPVT_WordPlace & place) const = 0; + virtual CPVT_WordPlace GetLineBeginPlace( + const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace & place) const = 0; + virtual CPVT_WordPlace GetLineEndPlace(const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace GetSectionBeginPlace(const CPVT_WordPlace & place) const = 0; + virtual CPVT_WordPlace GetSectionBeginPlace( + const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace GetSectionEndPlace(const CPVT_WordPlace & place) const = 0; + virtual CPVT_WordPlace GetSectionEndPlace( + const CPVT_WordPlace& place) const = 0; - virtual void UpdateWordPlace(CPVT_WordPlace & place) const = 0; + virtual void UpdateWordPlace(CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const = 0; + virtual CPVT_WordPlace AjustLineHeader(const CPVT_WordPlace& place, + FX_BOOL bPrevOrNext) const = 0; - virtual int32_t WordPlaceToWordIndex(const CPVT_WordPlace & place) const = 0; + virtual int32_t WordPlaceToWordIndex(const CPVT_WordPlace& place) const = 0; - virtual CPVT_WordPlace WordIndexToWordPlace(int32_t index) const = 0; + virtual CPVT_WordPlace WordIndexToWordPlace(int32_t index) const = 0; -protected: - ~IPDF_VariableText() { } + protected: + ~IPDF_VariableText() {} }; #endif // CORE_INCLUDE_FPDFDOC_FPDF_VT_H_ |