Cleanup: Make CPDF_Annot::m_pAnnotDict private.
[pdfium.git] / core / include / fpdfdoc / fpdf_doc.h
index dbcc7f4..45cdebc 100644 (file)
@@ -1,48 +1,46 @@
 // Copyright 2014 PDFium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
+
 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
 
-#ifndef _FPDF_DOC_H_
-#define _FPDF_DOC_H_
-#ifndef _FPDF_PARSER_
+#ifndef CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
+#define CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_
+
 #include "../fpdfapi/fpdf_parser.h"
-#endif
-#ifndef _FPDF_RENDER_
 #include "../fpdfapi/fpdf_render.h"
-#endif
+
+class CFieldTree;
+class CPDF_AAction;
 class CPDF_Action;
+class CPDF_ActionFields;
 class CPDF_Annot;
 class CPDF_AnnotList;
+class CPDF_ApSettings;
 class CPDF_Bookmark;
 class CPDF_BookmarkTree;
+class CPDF_DefaultAppearance;
 class CPDF_Dest;
+class CPDF_DocJSActions;
+class CPDF_FileSpec;
+class CPDF_FormControl;
+class CPDF_FormField;
+class CPDF_FormNotify;
+class CPDF_IconFit;
+class CPDF_InterForm;
 class CPDF_Link;
 class CPDF_LinkList;
+class CPDF_LWinParam;
 class CPDF_Metadata;
-class CPDF_NameTree;
 class CPDF_NumberTree;
-class CPDF_TextObject;
-class CPDF_ViewerPreferences;
+class CPDF_OCContext;
 class CPDF_Page;
 class CPDF_RenderOptions;
+class CPDF_TextObject;
+class CPDF_ViewerPreferences;
 class CXML_Element;
-class CPDF_OCContext;
-class CPDF_DocJSActions;
-class CPDF_ActionFields;
-class CPDF_AAction;
-class CPDF_FileSpec;
-class CPDF_IconFit;
-class CPDF_DefaultAppearance;
-class CPDF_InterForm;
-class CPDF_FormField;
-class CPDF_FormNotify;
-class CPDF_FormControl;
-class CPDF_LWinParam;
-class CFieldTree;
-class CPDF_ApSettings;
-class CPDF_NameTree : public CFX_Object
+
+class CPDF_NameTree
 {
 public:
 
@@ -73,7 +71,7 @@ protected:
 
     CPDF_Dictionary*           m_pRoot;
 };
-class CPDF_BookmarkTree : public CFX_Object
+class CPDF_BookmarkTree
 {
 public:
     CPDF_BookmarkTree(CPDF_Document* pDoc) : m_pDocument(pDoc) {}
@@ -89,7 +87,7 @@ protected:
 };
 #define PDFBOOKMARK_ITALIC                     1
 #define PDFBOOKMARK_BOLD                       2
-class CPDF_Bookmark : public CFX_Object
+class CPDF_Bookmark
 {
 public:
 
@@ -121,34 +119,25 @@ public:
 #define PDFZOOM_FITBBOX                                6
 #define PDFZOOM_FITBHORZ                       7
 #define PDFZOOM_FITBVERT                       8
-class CPDF_Dest : public CFX_Object
+class CPDF_Dest
 {
 public:
+    CPDF_Dest() : m_pObj(nullptr) { }
+    explicit CPDF_Dest(CPDF_Object* pObj) : m_pObj(pObj) { }
 
-    CPDF_Dest(CPDF_Object* pObj = NULL)
-    {
-        m_pObj = pObj;
-    }
-
-    operator CPDF_Object* () const
-    {
-        return m_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 CFX_Object, public IPDF_OCContext
+class CPDF_OCContext : public IPDF_OCContext
 {
 public:
 
@@ -194,7 +183,7 @@ protected:
 
     CFX_MapPtrTemplate<const CPDF_Dictionary*, void*>  m_OCGStates;
 };
-class CPDF_LWinParam : public CFX_Object
+class CPDF_LWinParam
 {
 public:
 
@@ -233,7 +222,7 @@ public:
 
     CPDF_Dictionary*           m_pDict;
 };
-class CPDF_ActionFields : public CFX_Object
+class CPDF_ActionFields
 {
 public:
 
@@ -261,7 +250,7 @@ public:
 #define PDFNAMED_FIRSTPAGE             3
 #define PDFNAMED_LASTPAGE              4
 #define PDFJS_MAXLENGTH                        64
-class CPDF_Action : public CFX_Object
+class CPDF_Action
 {
 public:
     enum ActionType {
@@ -300,92 +289,50 @@ public:
 
     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;
 
-
-
-
     FX_INT32                   GetOperationType() const;
 
-
-
-
     CPDF_Stream*               GetSoundStream() const
     {
         return m_pDict->GetStream("Sound");
@@ -411,9 +358,6 @@ public:
         return m_pDict->GetBoolean("Mix");
     }
 
-
-
-
     FX_DWORD                   GetSubActionsCount() const;
 
     CPDF_Action                        GetSubAction(FX_DWORD iIndex) const;
@@ -421,7 +365,7 @@ public:
 protected:
     CPDF_Dictionary*   m_pDict;
 };
-class CPDF_AAction : public CFX_Object
+class CPDF_AAction
 {
 public:
 
@@ -469,7 +413,7 @@ public:
 
     CPDF_Dictionary*   m_pDict;
 };
-class CPDF_DocJSActions : public CFX_Object
+class CPDF_DocJSActions
 {
 public:
     CPDF_DocJSActions(CPDF_Document* pDoc);
@@ -493,7 +437,7 @@ protected:
 
     CPDF_Document*             m_pDocument;
 };
-class CPDF_FileSpec : public CFX_Object
+class CPDF_FileSpec
 {
 public:
 
@@ -520,7 +464,7 @@ protected:
 
     CPDF_Object                *m_pObj;
 };
-class CPDF_LinkList : public CFX_Object
+class CPDF_LinkList
 {
 public:
 
@@ -551,98 +495,80 @@ protected:
 
     void                               LoadPageLinks(CPDF_Page* pPage, CFX_PtrArray* pList);
 };
-class CPDF_Link : public CFX_Object
+class CPDF_Link
 {
 public:
+    CPDF_Link() : m_pDict(nullptr) { }
+    explicit CPDF_Link(CPDF_Dictionary* pDict) : m_pDict(pDict) { }
 
-    CPDF_Link(CPDF_Dictionary* pDict = NULL)
-    {
-        m_pDict = pDict;
-    }
-
-    operator CPDF_Dictionary*() const
-    {
-        return m_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;
 };
-#define ANNOTFLAG_INVISIBLE                    1
-#define ANNOTFLAG_HIDDEN                       2
-#define ANNOTFLAG_PRINT                                4
-#define ANNOTFLAG_NOZOOM                       8
-#define ANNOTFLAG_NOROTATE                     0x10
-#define ANNOTFLAG_NOVIEW                       0x20
-#define ANNOTFLAG_READONLY                     0x40
-#define ANNOTFLAG_LOCKED                       0x80
-#define ANNOTFLAG_TOGGLENOVIEW         0x100
-class CPDF_Annot : public CFX_PrivateData, public CFX_Object
-{
-public:
-
-    CPDF_Annot(CPDF_Dictionary* pDict);
 
-    ~CPDF_Annot();
-
-    CPDF_Dictionary*   m_pAnnotDict;
-
-    CFX_ByteString             GetSubType() const;
-
-    FX_DWORD                   GetFlags() const
-    {
-        return m_pAnnotDict->GetInteger("F");
-    }
-
-    void                               GetRect(CFX_FloatRect& rect) const;
-
-    enum AppearanceMode        {
+#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
     };
 
-    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();
+    CPDF_Annot(CPDF_Dictionary* pDict, CPDF_AnnotList* pList);
+    ~CPDF_Annot();
 
+    CFX_ByteString GetSubType() const;
 
-    void                               DrawBorder(CFX_RenderDevice* pDevice, const CFX_AffineMatrix* pUser2Device,
-                                   const CPDF_RenderOptions* pOptions);
+    FX_DWORD GetFlags() const;
 
-    CPDF_PageObject*   GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions* pOptions);
+    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);
 
-    int                                        CountIRTNotes();
+    FX_BOOL DrawInContext(const CPDF_Page* pPage,
+                          const CPDF_RenderContext* pContext,
+                          const CFX_AffineMatrix* pUser2Device,
+                          AppearanceMode mode);
 
-    CPDF_Annot*                        GetIRTNote(int index);
+    void ClearCachedAP();
 
+    void DrawBorder(CFX_RenderDevice* pDevice,
+                    const CFX_AffineMatrix* pUser2Device,
+                    const CPDF_RenderOptions* pOptions);
 
-    CPDF_Form*                 GetAPForm(const CPDF_Page* pPage, AppearanceMode mode);
-private:
+    CPDF_Form* GetAPForm(const CPDF_Page* pPage, AppearanceMode mode);
 
-    CFX_MapPtrToPtr            m_APMap;
-protected:
-    friend class               CPDF_AnnotList;
+  private:
+    CPDF_Dictionary* const m_pAnnotDict;
 
-    CPDF_AnnotList*            m_pList;
+    CPDF_AnnotList* const m_pList;
 
-    CPDF_Reference*            NewAnnotRef();
+    CFX_MapPtrToPtr m_APMap;
 };
-class CPDF_AnnotList : public CFX_Object
+
+class CPDF_AnnotList
 {
 public:
 
@@ -714,7 +640,7 @@ protected:
 #define COLORTYPE_GRAY                 1
 #define COLORTYPE_RGB                  2
 #define COLORTYPE_CMYK                 3
-class CPDF_DefaultAppearance : public CFX_Object
+class CPDF_DefaultAppearance
 {
 public:
 
@@ -786,7 +712,7 @@ protected:
 #define FIELDTYPE_LISTBOX                      5
 #define FIELDTYPE_TEXTFIELD                    6
 #define FIELDTYPE_SIGNATURE                    7
-class CPDF_InterForm : public CFX_PrivateData, public CFX_Object
+class CPDF_InterForm : public CFX_PrivateData
 {
 public:
 
@@ -1044,7 +970,7 @@ protected:
 #define FORMTEXT_COMB                  0x800
 #define FORMCOMBO_EDIT                 0x100
 #define FORMLIST_MULTISELECT   0x100
-class CPDF_FormField : public CFX_Object
+class CPDF_FormField
 {
 public:
 
@@ -1181,7 +1107,7 @@ public:
 
     int                                                FindOption(CFX_WideString csOptLabel);
 
-    int                                                FindOptionValue(FX_LPCWSTR csOptValue, int iStartIndex = 0);
+    int                                                FindOptionValue(const CFX_WideString& csOptValue, int iStartIndex = 0);
 
 
 
@@ -1266,7 +1192,7 @@ protected:
     CPDF_Font*                         m_pFont;
 };
 CPDF_Object*   FPDF_GetFieldAttr(CPDF_Dictionary* pFieldDict, const FX_CHAR* name, int nLevel = 0);
-class CPDF_IconFit : public CFX_Object
+class CPDF_IconFit
 {
 public:
 
@@ -1318,7 +1244,7 @@ public:
 #define TEXTPOS_RIGHT          4
 #define TEXTPOS_LEFT           5
 #define TEXTPOS_OVERLAID       6
-class CPDF_FormControl : public CFX_Object
+class CPDF_FormControl
 {
 public:
 
@@ -1526,7 +1452,7 @@ protected:
     friend class                       CPDF_InterForm;
     friend class                       CPDF_FormField;
 };
-class CPDF_FormNotify : public CFX_Object
+class CPDF_FormNotify
 {
 public:
 
@@ -1578,7 +1504,7 @@ public:
     }
 };
 FX_BOOL                FPDF_GenerateAP(CPDF_Document* pDoc, CPDF_Dictionary* pAnnotDict);
-class CPDF_PageLabel : public CFX_Object
+class CPDF_PageLabel
 {
 public:
 
@@ -1642,7 +1568,7 @@ public:
 protected:
     CPDF_Document*     m_pDoc;
 };
-class CPDF_ApSettings : public CFX_Object
+class CPDF_ApSettings
 {
 public:
 
@@ -1770,4 +1696,5 @@ protected:
     CPDF_Stream*                       GetIcon(FX_BSTR csEntry);
     friend class                       CPDF_FormControl;
 };
-#endif
+
+#endif  // CORE_INCLUDE_FPDFDOC_FPDF_DOC_H_