Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this.
[pdfium.git] / core / src / fpdfdoc / pdf_vt.h
index fc1af04..8fc9c7c 100644 (file)
-// Copyright 2014 PDFium Authors. All rights reserved.\r
-// Use of this source code is governed by a BSD-style license that can be\r
-// found in the LICENSE file.\r
\r
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
-\r
-#define _PDF_VT_H_\r
-class CPVT_Size;\r
-class CPVT_FloatRect;\r
-struct CPVT_SectionInfo;\r
-struct CPVT_LineInfo;\r
-struct CPVT_WordInfo;\r
-class CLine;\r
-class CLines;\r
-class CSection;\r
-class CTypeset;\r
-class CPDF_EditContainer;\r
-class CPDF_VariableText;\r
-class CPDF_VariableText_Iterator;\r
-#define IsFloatZero(f)                                         ((f) < 0.0001 && (f) > -0.0001)\r
-#define IsFloatBigger(fa,fb)                           ((fa) > (fb) && !IsFloatZero((fa) - (fb)))\r
-#define IsFloatSmaller(fa,fb)                          ((fa) < (fb) && !IsFloatZero((fa) - (fb)))\r
-template<class T> T FPDF_MIN (const T & i, const T & j)\r
-{\r
-    return ((i < j) ? i : j);\r
-}\r
-template<class T> T FPDF_MAX (const T & i, const T & j)\r
-{\r
-    return ((i > j) ? i : j);\r
-}\r
-class CPVT_Size\r
-{\r
-public:\r
-    CPVT_Size() : x(0.0f), y(0.0f)\r
-    {\r
-    }\r
-    CPVT_Size(FX_FLOAT x, FX_FLOAT y)\r
-    {\r
-        this->x = x;\r
-        this->y = y;\r
-    }\r
-    FX_FLOAT x, y;\r
-};\r
-class CPVT_FloatRect : public CFX_FloatRect\r
-{\r
-public:\r
-    CPVT_FloatRect()\r
-    {\r
-        left = top = right = bottom = 0.0f;\r
-    }\r
-    CPVT_FloatRect(FX_FLOAT left, FX_FLOAT top,\r
-                   FX_FLOAT right, FX_FLOAT bottom)\r
-    {\r
-        this->left = left;\r
-        this->top = top;\r
-        this->right = right;\r
-        this->bottom = bottom;\r
-    }\r
-    CPVT_FloatRect(const CPDF_Rect & rect)\r
-    {\r
-        this->left = rect.left;\r
-        this->top = rect.top;\r
-        this->right = rect.right;\r
-        this->bottom = rect.bottom;\r
-    }\r
-    void Default()\r
-    {\r
-        left = top = right = bottom = 0.0f;\r
-    }\r
-    FX_FLOAT Height() const\r
-    {\r
-        if(this->top > this->bottom) {\r
-            return this->top - this->bottom;\r
-        } else {\r
-            return this->bottom - this->top;\r
-        }\r
-    }\r
-};\r
-struct CPVT_SectionInfo {\r
-    CPVT_SectionInfo() : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL)\r
-    {\r
-    }\r
-    virtual ~CPVT_SectionInfo()\r
-    {\r
-        if (pSecProps) {\r
-            delete pSecProps;\r
-        }\r
-        if (pWordProps) {\r
-            delete pWordProps;\r
-        }\r
-    }\r
-    CPVT_SectionInfo(const CPVT_SectionInfo & other): rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL)\r
-    {\r
-        operator = (other);\r
-    }\r
-    void operator = (const CPVT_SectionInfo & other)\r
-    {\r
-        if (this == &other) {\r
-            return;\r
-        }\r
-        this->rcSection = other.rcSection;\r
-        this->nTotalLine = other.nTotalLine;\r
-        if (other.pSecProps) {\r
-            if (pSecProps) {\r
-                *pSecProps = *other.pSecProps;\r
-            } else {\r
-                pSecProps = FX_NEW CPVT_SecProps(*other.pSecProps);\r
-            }\r
-        }\r
-        if (other.pWordProps) {\r
-            if (pWordProps) {\r
-                *pWordProps = *other.pWordProps;\r
-            } else {\r
-                pWordProps = FX_NEW CPVT_WordProps(*other.pWordProps);\r
-            }\r
-        }\r
-    }\r
-    CPVT_FloatRect                             rcSection;\r
-    FX_INT32                                   nTotalLine;\r
-    CPVT_SecProps*                             pSecProps;\r
-    CPVT_WordProps*                            pWordProps;\r
-};\r
-struct CPVT_LineInfo {\r
-    CPVT_LineInfo() : nTotalWord(0), nBeginWordIndex(-1), nEndWordIndex(-1),\r
-        fLineX(0.0f), fLineY(0.0f), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f)\r
-    {\r
-    }\r
-    FX_INT32                                   nTotalWord;\r
-    FX_INT32                                   nBeginWordIndex;\r
-    FX_INT32                                   nEndWordIndex;\r
-    FX_FLOAT                                   fLineX;\r
-    FX_FLOAT                                   fLineY;\r
-    FX_FLOAT                                   fLineWidth;\r
-    FX_FLOAT                                   fLineAscent;\r
-    FX_FLOAT                                   fLineDescent;\r
-};\r
-struct CPVT_WordInfo : public CFX_Object {\r
-    CPVT_WordInfo() : Word(0), nCharset(0),\r
-        fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), nFontIndex(-1), pWordProps(NULL)\r
-    {\r
-    }\r
-    CPVT_WordInfo(FX_WORD word, FX_INT32 charset, FX_INT32 fontIndex, CPVT_WordProps * pProps):\r
-        Word(word), nCharset(charset), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f),\r
-        nFontIndex(fontIndex), pWordProps(pProps)\r
-    {\r
-    }\r
-    virtual ~CPVT_WordInfo()\r
-    {\r
-        if (pWordProps) {\r
-            delete pWordProps;\r
-        }\r
-    }\r
-    CPVT_WordInfo(const CPVT_WordInfo & word): Word(0), nCharset(0),\r
-        fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), nFontIndex(-1), pWordProps(NULL)\r
-    {\r
-        operator = (word);\r
-    }\r
-    void operator = (const CPVT_WordInfo & word)\r
-    {\r
-        if (this == &word) {\r
-            return;\r
-        }\r
-        this->Word = word.Word;\r
-        this->nCharset = word.nCharset;\r
-        this->nFontIndex = word.nFontIndex;\r
-        if (word.pWordProps) {\r
-            if (pWordProps) {\r
-                *pWordProps = *word.pWordProps;\r
-            } else {\r
-                pWordProps = FX_NEW CPVT_WordProps(*word.pWordProps);\r
-            }\r
-        }\r
-    }\r
-    FX_WORD                                            Word;\r
-    FX_INT32                                   nCharset;\r
-    FX_FLOAT                                   fWordX;\r
-    FX_FLOAT                                   fWordY;\r
-    FX_FLOAT                                   fWordTail;\r
-    FX_INT32                                   nFontIndex;\r
-    CPVT_WordProps*                            pWordProps;\r
-};\r
-struct CPVT_FloatRange {\r
-    CPVT_FloatRange() : fMin(0.0f), fMax(0.0f)\r
-    {\r
-    }\r
-    CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max)\r
-    {\r
-    }\r
-    FX_FLOAT Range() const\r
-    {\r
-        return fMax - fMin;\r
-    }\r
-    FX_FLOAT fMin, fMax;\r
-};\r
-template<class TYPE> class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE>\r
-{\r
-public:\r
-    FX_BOOL IsEmpty()\r
-    {\r
-        return CFX_ArrayTemplate<TYPE>::GetSize() <= 0;\r
-    }\r
-    TYPE GetAt(int nIndex) const\r
-    {\r
-        if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {\r
-            return CFX_ArrayTemplate<TYPE>::GetAt(nIndex);\r
-        }\r
-        return NULL;\r
-    }\r
-    void RemoveAt(int nIndex)\r
-    {\r
-        if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {\r
-            CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex);\r
-        }\r
-    }\r
-};\r
-class CLine : public CFX_Object\r
-{\r
-public:\r
-    CLine();\r
-    virtual ~CLine();\r
-    CPVT_WordPlace                                                     GetBeginWordPlace() const;\r
-    CPVT_WordPlace                                                     GetEndWordPlace() const;\r
-    CPVT_WordPlace                                                     GetPrevWordPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     GetNextWordPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     LinePlace;\r
-    CPVT_LineInfo                                                      m_LineInfo;\r
-};\r
-class CLines\r
-{\r
-public:\r
-    CLines() : m_nTotal(0) {}\r
-    virtual ~CLines()\r
-    {\r
-        RemoveAll();\r
-    }\r
-    FX_INT32                                                           GetSize() const\r
-    {\r
-        return m_Lines.GetSize();\r
-    }\r
-    CLine *                                                                    GetAt(FX_INT32 nIndex) const\r
-    {\r
-        return m_Lines.GetAt(nIndex);\r
-    }\r
-    void                                                                       Empty()\r
-    {\r
-        m_nTotal = 0;\r
-    }\r
-    void                                                                       RemoveAll()\r
-    {\r
-        for (FX_INT32 i = 0, sz = GetSize(); i < sz; i++) {\r
-            delete GetAt(i);\r
-        }\r
-        m_Lines.RemoveAll();\r
-        m_nTotal = 0;\r
-    }\r
-    FX_INT32                                                           Add(const CPVT_LineInfo & lineinfo)\r
-    {\r
-        if (m_nTotal >= GetSize()) {\r
-            if (CLine * pLine = FX_NEW CLine) {\r
-                pLine->m_LineInfo = lineinfo;\r
-                m_Lines.Add(pLine);\r
-                return m_nTotal++;\r
-            }\r
-            return m_nTotal;\r
-        } else {\r
-            if (CLine * pLine = GetAt(m_nTotal)) {\r
-                pLine->m_LineInfo = lineinfo;\r
-            }\r
-            return m_nTotal++;\r
-        }\r
-    }\r
-    void                                                                       Clear()\r
-    {\r
-        for (FX_INT32 i = GetSize() - 1; i >= m_nTotal; i--) {\r
-            delete GetAt(i);\r
-            m_Lines.RemoveAt(i);\r
-        }\r
-    }\r
-private:\r
-    CPVT_ArrayTemplate<CLine*>                         m_Lines;\r
-    FX_INT32                                                           m_nTotal;\r
-};\r
-class CSection : public CFX_Object\r
-{\r
-    friend class CTypeset;\r
-public:\r
-    CSection(CPDF_VariableText * pVT);\r
-    virtual ~CSection();\r
-    void                                                                       ResetAll();\r
-    void                                                                       ResetLineArray();\r
-    void                                                                       ResetWordArray();\r
-    void                                                                       ResetLinePlace();\r
-    CPVT_WordPlace                                                     AddWord(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo);\r
-    CPVT_WordPlace                                                     AddLine(const CPVT_LineInfo & lineinfo);\r
-    void                                                                       ClearWords(const CPVT_WordRange & PlaceRange);\r
-    void                                                                       ClearWord(const CPVT_WordPlace & place);\r
-    CPVT_FloatRect                                                     Rearrange();\r
-    CPVT_Size                                                          GetSectionSize(FX_FLOAT fFontSize);\r
-    CPVT_WordPlace                                                     GetBeginWordPlace() const;\r
-    CPVT_WordPlace                                                     GetEndWordPlace() const;\r
-    CPVT_WordPlace                                                     GetPrevWordPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     GetNextWordPlace(const CPVT_WordPlace & place) const;\r
-    void                                                                       UpdateWordPlace(CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     SearchWordPlace(const CPDF_Point & point) const;\r
-    CPVT_WordPlace                                                     SearchWordPlace(FX_FLOAT fx, const CPVT_WordPlace & lineplace) const;\r
-    CPVT_WordPlace                                                     SearchWordPlace(FX_FLOAT fx, const CPVT_WordRange & range) const;\r
-public:\r
-    CPVT_WordPlace                                                     SecPlace;\r
-    CPVT_SectionInfo                                           m_SecInfo;\r
-    CLines                                                                     m_LineArray;\r
-    CPVT_ArrayTemplate<CPVT_WordInfo*>         m_WordArray;\r
-private:\r
-    void                                                                       ClearLeftWords(FX_INT32 nWordIndex);\r
-    void                                                                       ClearRightWords(FX_INT32 nWordIndex);\r
-    void                                                                       ClearMidWords(FX_INT32 nBeginIndex, FX_INT32 nEndIndex);\r
-\r
-    CPDF_VariableText                                          *m_pVT;\r
-};\r
-class CTypeset\r
-{\r
-public:\r
-    CTypeset(CSection * pSection);\r
-    virtual ~CTypeset();\r
-    CPVT_Size                                                          GetEditSize(FX_FLOAT fFontSize);\r
-    CPVT_FloatRect                                                     Typeset();\r
-    CPVT_FloatRect                                                     CharArray();\r
-private:\r
-    void                                                                       SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize);\r
-    void                                                                       OutputLines();\r
-\r
-    CPVT_FloatRect                                                     m_rcRet;\r
-    CPDF_VariableText                                          * m_pVT;\r
-    CSection                                                           * m_pSection;\r
-};\r
-class CPDF_EditContainer\r
-{\r
-public:\r
-    CPDF_EditContainer(): m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {};\r
-    virtual ~CPDF_EditContainer() {};\r
-    virtual void                                                       SetPlateRect(const CPDF_Rect & rect)\r
-    {\r
-        m_rcPlate = rect;\r
-    };\r
-    virtual const CPDF_Rect &                          GetPlateRect() const\r
-    {\r
-        return m_rcPlate;\r
-    };\r
-    virtual void                                                       SetContentRect(const CPVT_FloatRect & rect)\r
-    {\r
-        m_rcContent = rect;\r
-    };\r
-    virtual CPDF_Rect                                          GetContentRect() const\r
-    {\r
-        return m_rcContent;\r
-    };\r
-    FX_FLOAT                                                           GetPlateWidth() const\r
-    {\r
-        return m_rcPlate.right - m_rcPlate.left;\r
-    };\r
-    FX_FLOAT                                                           GetPlateHeight() const\r
-    {\r
-        return m_rcPlate.top - m_rcPlate.bottom;\r
-    };\r
-    CPVT_Size                                                          GetPlateSize() const\r
-    {\r
-        return CPVT_Size(GetPlateWidth(), GetPlateHeight());\r
-    };\r
-    CPDF_Point                                                         GetBTPoint() const\r
-    {\r
-        return CPDF_Point(m_rcPlate.left, m_rcPlate.top);\r
-    };\r
-    CPDF_Point                                                         GetETPoint() const\r
-    {\r
-        return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom);\r
-    };\r
-    inline CPDF_Point                                          InToOut(const CPDF_Point & point) const\r
-    {\r
-        return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y);\r
-    };\r
-    inline CPDF_Point                                          OutToIn(const CPDF_Point & point) const\r
-    {\r
-        return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y);\r
-    };\r
-    inline CPDF_Rect                                           InToOut(const CPVT_FloatRect & rect) const\r
-    {\r
-        CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top));\r
-        CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom));\r
-        return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, ptLeftTop.y);\r
-    };\r
-    inline CPVT_FloatRect                                      OutToIn(const CPDF_Rect & rect) const\r
-    {\r
-        CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top));\r
-        CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom));\r
-        return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, ptRightBottom.y);\r
-    };\r
-\r
-private:\r
-    CPDF_Rect                                                          m_rcPlate;\r
-    CPVT_FloatRect                                                     m_rcContent;\r
-};\r
-class CPDF_VariableText : public IPDF_VariableText, public CFX_Object, private CPDF_EditContainer\r
-{\r
-    friend class CTypeset;\r
-    friend class CSection;\r
-    friend class CPDF_VariableText_Iterator;\r
-public:\r
-    CPDF_VariableText();\r
-    virtual ~CPDF_VariableText();\r
-    IPDF_VariableText_Provider*                                SetProvider(IPDF_VariableText_Provider * pProvider);\r
-    IPDF_VariableText_Iterator*                                GetIterator();\r
-    void                                                                       SetPlateRect(const CPDF_Rect & rect)\r
-    {\r
-        CPDF_EditContainer::SetPlateRect(rect);\r
-    }\r
-    void                                                                       SetAlignment(FX_INT32 nFormat = 0)\r
-    {\r
-        m_nAlignment = nFormat;\r
-    }\r
-    void                                                                       SetPasswordChar(FX_WORD wSubWord = '*')\r
-    {\r
-        m_wSubWord = wSubWord;\r
-    }\r
-    void                                                                       SetLimitChar(FX_INT32 nLimitChar = 0)\r
-    {\r
-        m_nLimitChar = nLimitChar;\r
-    }\r
-    void                                                                       SetCharSpace(FX_FLOAT fCharSpace = 0.0f)\r
-    {\r
-        m_fCharSpace = fCharSpace;\r
-    }\r
-    void                                                                       SetHorzScale(FX_INT32 nHorzScale = 100)\r
-    {\r
-        m_nHorzScale = nHorzScale;\r
-    }\r
-    void                                                                       SetMultiLine(FX_BOOL bMultiLine = TRUE)\r
-    {\r
-        m_bMultiLine = bMultiLine;\r
-    }\r
-    void                                                                       SetAutoReturn(FX_BOOL bAuto = TRUE)\r
-    {\r
-        m_bLimitWidth = bAuto;\r
-    }\r
-    void                                                                       SetFontSize(FX_FLOAT fFontSize)\r
-    {\r
-        m_fFontSize = fFontSize;\r
-    }\r
-    void                                                                       SetCharArray(FX_INT32 nCharArray = 0)\r
-    {\r
-        m_nCharArray = nCharArray;\r
-    }\r
-    void                                                                       SetAutoFontSize(FX_BOOL bAuto = TRUE)\r
-    {\r
-        m_bAutoFontSize = bAuto;\r
-    }\r
-    void                                                                       SetRichText(FX_BOOL bRichText)\r
-    {\r
-        m_bRichText = bRichText;\r
-    }\r
-    void                                                                       SetLineLeading(FX_FLOAT fLineLeading)\r
-    {\r
-        m_fLineLeading = fLineLeading;\r
-    }\r
-    void                                                                       Initialize();\r
-    FX_BOOL                                                                    IsValid() const\r
-    {\r
-        return m_bInitial;\r
-    }\r
-    FX_BOOL                                                                    IsRichText() const\r
-    {\r
-        return m_bRichText;\r
-    }\r
-    void                                                                       RearrangeAll();\r
-    void                                                                       RearrangePart(const CPVT_WordRange & PlaceRange);\r
-    void                                                                       ResetAll();\r
-    void                                                                       SetText(FX_LPCWSTR text, FX_INT32 charset = 1, const CPVT_SecProps * pSecProps = NULL,\r
-            const CPVT_WordProps * pWordProps = NULL);\r
-    CPVT_WordPlace                                                     InsertWord(const CPVT_WordPlace & place, FX_WORD word, FX_INT32 charset = 1,\r
-            const CPVT_WordProps * pWordProps = NULL);\r
-    CPVT_WordPlace                                                     InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps = NULL,\r
-            const CPVT_WordProps * pWordProps = NULL);\r
-    CPVT_WordPlace                                                     InsertText(const CPVT_WordPlace & place, FX_LPCWSTR text, FX_INT32 charset = 1,\r
-            const CPVT_SecProps * pSecProps = NULL,    const CPVT_WordProps * pWordProps = NULL);\r
-    CPVT_WordPlace                                                     DeleteWords(const CPVT_WordRange & PlaceRange);\r
-    CPVT_WordPlace                                                     DeleteWord(const CPVT_WordPlace & place);\r
-    CPVT_WordPlace                                                     BackSpaceWord(const CPVT_WordPlace & place);\r
-    const CPDF_Rect &                                          GetPlateRect() const\r
-    {\r
-        return CPDF_EditContainer::GetPlateRect();\r
-    }\r
-    CPDF_Rect                                                          GetContentRect() const;\r
-    FX_INT32                                                           GetTotalWords() const;\r
-    FX_FLOAT                                                           GetFontSize() const\r
-    {\r
-        return m_fFontSize;\r
-    }\r
-    FX_INT32                                                           GetAlignment() const\r
-    {\r
-        return m_nAlignment;\r
-    }\r
-    FX_INT32                                                           GetCharArray() const\r
-    {\r
-        return m_nCharArray;\r
-    }\r
-    FX_INT32                                                           GetLimitChar() const\r
-    {\r
-        return m_nLimitChar;\r
-    }\r
-    FX_BOOL                                                                    IsMultiLine() const\r
-    {\r
-        return m_bMultiLine;\r
-    }\r
-    FX_INT32                                                           GetHorzScale() const\r
-    {\r
-        return m_nHorzScale;\r
-    }\r
-    FX_FLOAT                                                           GetCharSpace() const\r
-    {\r
-        return m_fCharSpace;\r
-    }\r
-\r
-    inline CPVT_WordPlace                                      GetBeginWordPlace() const;\r
-    inline CPVT_WordPlace                                      GetEndWordPlace() const;\r
-    CPVT_WordPlace                                                     GetPrevWordPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     GetNextWordPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     SearchWordPlace(const CPDF_Point & point) const;\r
-    CPVT_WordPlace                                                     GetUpWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const;\r
-    CPVT_WordPlace                                                     GetDownWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const;\r
-    CPVT_WordPlace                                                     GetLineBeginPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     GetLineEndPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     GetSectionBeginPlace(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     GetSectionEndPlace(const CPVT_WordPlace & place) const;\r
-    void                                                                       UpdateWordPlace(CPVT_WordPlace & place) const;\r
-    FX_INT32                                                           WordPlaceToWordIndex(const CPVT_WordPlace & place) const;\r
-    CPVT_WordPlace                                                     WordIndexToWordPlace(FX_INT32 index) const;\r
-    FX_WORD                                                                    GetPasswordChar() const\r
-    {\r
-        return GetSubWord();\r
-    }\r
-    FX_WORD                                                                    GetSubWord() const\r
-    {\r
-        return m_wSubWord;\r
-    }\r
-private:\r
-    FX_INT32                                                           GetCharWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_WORD SubWord, FX_INT32 nWordStyle);\r
-    FX_INT32                                                           GetTypeAscent(FX_INT32 nFontIndex);\r
-    FX_INT32                                                           GetTypeDescent(FX_INT32 nFontIndex);\r
-    FX_INT32                                                           GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex);\r
-    FX_INT32                                                           GetDefaultFontIndex();\r
-    FX_BOOL                                                                    IsLatinWord(FX_WORD word);\r
-private:\r
-\r
-    CPVT_WordPlace                                                     AddSection(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo);\r
-    CPVT_WordPlace                                                     AddLine(const CPVT_WordPlace & place, const CPVT_LineInfo & lineinfo);\r
-    CPVT_WordPlace                                                     AddWord(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo);\r
-    FX_BOOL                                                                    GetWordInfo(const CPVT_WordPlace & place, CPVT_WordInfo & wordinfo);\r
-    FX_BOOL                                                                    SetWordInfo(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo);\r
-    FX_BOOL                                                                    GetLineInfo(const CPVT_WordPlace & place, CPVT_LineInfo & lineinfo);\r
-    FX_BOOL                                                                    GetSectionInfo(const CPVT_WordPlace & place, CPVT_SectionInfo & secinfo);\r
-    FX_FLOAT                                                           GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE);\r
-    FX_FLOAT                                                           GetWordWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_WORD SubWord,\r
-            FX_FLOAT fCharSpace, FX_INT32 nHorzScale,\r
-            FX_FLOAT fFontSize, FX_FLOAT fWordTail, FX_INT32 nWordStyle);\r
-    FX_FLOAT                                                           GetWordWidth(const CPVT_WordInfo & WordInfo);\r
-    FX_FLOAT                                                           GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLOAT fFontSize);\r
-    FX_FLOAT                                                           GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FLOAT fFontSize);\r
-    FX_FLOAT                                                           GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE);\r
-    FX_FLOAT                                                           GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE);\r
-    FX_FLOAT                                                           GetLineAscent(const CPVT_SectionInfo & SecInfo);\r
-    FX_FLOAT                                                           GetLineDescent(const CPVT_SectionInfo & SecInfo);\r
-    FX_FLOAT                                                           GetFontAscent(FX_INT32 nFontIndex, FX_FLOAT fFontSize);\r
-    FX_FLOAT                                                           GetFontDescent(FX_INT32 nFontIndex, FX_FLOAT fFontSize);\r
-    FX_INT32                                                           GetWordFontIndex(const CPVT_WordInfo & WordInfo);\r
-    FX_FLOAT                                                           GetCharSpace(const CPVT_WordInfo & WordInfo);\r
-    FX_INT32                                                           GetHorzScale(const CPVT_WordInfo & WordInfo);\r
-    FX_FLOAT                                                           GetLineLeading(const CPVT_SectionInfo & SecInfo);\r
-    FX_FLOAT                                                           GetLineIndent(const CPVT_SectionInfo & SecInfo);\r
-    FX_INT32                                                           GetAlignment(const CPVT_SectionInfo& SecInfo);\r
-\r
-    void                                                                       ClearSectionRightWords(const CPVT_WordPlace & place);\r
-    CPVT_WordPlace                                                     AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const;\r
-    FX_BOOL                                                                    ClearEmptySection(const CPVT_WordPlace & place);\r
-    void                                                                       ClearEmptySections(const CPVT_WordRange & PlaceRange);\r
-    void                                                                       LinkLatterSection(const CPVT_WordPlace & place);\r
-    void                                                                       ClearWords(const CPVT_WordRange & PlaceRange);\r
-    CPVT_WordPlace                                                     ClearLeftWord(const CPVT_WordPlace & place);\r
-    CPVT_WordPlace                                                     ClearRightWord(const CPVT_WordPlace & place);\r
-private:\r
-    CPVT_FloatRect                                                     Rearrange(const CPVT_WordRange & PlaceRange);\r
-    FX_FLOAT                                                           GetAutoFontSize();\r
-    FX_BOOL                                                                    IsBigger(FX_FLOAT fFontSize);\r
-    CPVT_FloatRect                                                     RearrangeSections(const CPVT_WordRange & PlaceRange);\r
-private:\r
-    void                                                                       ResetSectionArray();\r
-private:\r
-    CPVT_ArrayTemplate<CSection*>                      m_SectionArray;\r
-    FX_INT32                                                           m_nLimitChar;\r
-    FX_INT32                                                           m_nCharArray;\r
-    FX_BOOL                                                                    m_bMultiLine;\r
-    FX_BOOL                                                                    m_bLimitWidth;\r
-    FX_BOOL                                                                    m_bAutoFontSize;\r
-    FX_INT32                                                           m_nAlignment;\r
-    FX_FLOAT                                                           m_fLineLeading;\r
-    FX_FLOAT                                                           m_fCharSpace;\r
-    FX_INT32                                                           m_nHorzScale;\r
-    FX_WORD                                                                    m_wSubWord;\r
-    FX_FLOAT                                                           m_fWordSpace;\r
-    FX_FLOAT                                                           m_fFontSize;\r
-\r
-private:\r
-    FX_BOOL                                                                    m_bInitial;\r
-    FX_BOOL                                                                    m_bRichText;\r
-    FX_FLOAT                                                           m_fCaretOriginX;\r
-    FX_INT32                                                           m_nCurFontIndex;\r
-    IPDF_VariableText_Provider *                       m_pVTProvider;\r
-    CPDF_VariableText_Iterator *                       m_pVTIterator;\r
-};\r
-class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator, public CFX_Object\r
-{\r
-public:\r
-    CPDF_VariableText_Iterator(CPDF_VariableText * pVT);\r
-    virtual ~CPDF_VariableText_Iterator();\r
-    FX_BOOL                                                                    NextWord();\r
-    FX_BOOL                                                                    PrevWord();\r
-    FX_BOOL                                                                    NextLine();\r
-    FX_BOOL                                                                    PrevLine();\r
-    FX_BOOL                                                                    NextSection();\r
-    FX_BOOL                                                                    PrevSection();\r
-    FX_BOOL                                                                    SetWord(const CPVT_Word & word);\r
-    FX_BOOL                                                                    GetWord(CPVT_Word & word) const;\r
-    FX_BOOL                                                                    GetLine(CPVT_Line & line) const;\r
-    FX_BOOL                                                                    GetSection(CPVT_Section & section) const;\r
-    FX_BOOL                                                                    SetSection(const CPVT_Section & section);\r
-    void                                                                       SetAt(FX_INT32 nWordIndex);\r
-    void                                                                       SetAt(const CPVT_WordPlace & place);\r
-    const CPVT_WordPlace &                                     GetAt() const\r
-    {\r
-        return m_CurPos;\r
-    };\r
-private:\r
-    CPVT_WordPlace                                                     m_CurPos;\r
-    CPDF_VariableText *                                                m_pVT;\r
-};\r
+// 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 _PDF_VT_H_
+#define _PDF_VT_H_
+
+class CPVT_Size;
+class CPVT_FloatRect;
+struct CPVT_SectionInfo;
+struct CPVT_LineInfo;
+struct CPVT_WordInfo;
+class CLine;
+class CLines;
+class CSection;
+class CTypeset;
+class CPDF_EditContainer;
+class CPDF_VariableText;
+class CPDF_VariableText_Iterator;
+#define IsFloatZero(f)                                         ((f) < 0.0001 && (f) > -0.0001)
+#define IsFloatBigger(fa,fb)                           ((fa) > (fb) && !IsFloatZero((fa) - (fb)))
+#define IsFloatSmaller(fa,fb)                          ((fa) < (fb) && !IsFloatZero((fa) - (fb)))
+template<class T> T FPDF_MIN (const T & i, const T & j)
+{
+    return ((i < j) ? i : j);
+}
+template<class T> T FPDF_MAX (const T & i, const T & j)
+{
+    return ((i > j) ? i : j);
+}
+class CPVT_Size
+{
+public:
+    CPVT_Size() : x(0.0f), y(0.0f)
+    {
+    }
+    CPVT_Size(FX_FLOAT x, FX_FLOAT y)
+    {
+        this->x = x;
+        this->y = y;
+    }
+    FX_FLOAT x, y;
+};
+class CPVT_FloatRect : public CFX_FloatRect
+{
+public:
+    CPVT_FloatRect()
+    {
+        left = top = right = bottom = 0.0f;
+    }
+    CPVT_FloatRect(FX_FLOAT left, FX_FLOAT top,
+                   FX_FLOAT right, FX_FLOAT bottom)
+    {
+        this->left = left;
+        this->top = top;
+        this->right = right;
+        this->bottom = bottom;
+    }
+    CPVT_FloatRect(const CPDF_Rect & rect)
+    {
+        this->left = rect.left;
+        this->top = rect.top;
+        this->right = rect.right;
+        this->bottom = rect.bottom;
+    }
+    void Default()
+    {
+        left = top = right = bottom = 0.0f;
+    }
+    FX_FLOAT Height() const
+    {
+        if(this->top > this->bottom) {
+            return this->top - this->bottom;
+        } else {
+            return this->bottom - this->top;
+        }
+    }
+};
+struct CPVT_SectionInfo {
+    CPVT_SectionInfo() : rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL)
+    {
+    }
+    virtual ~CPVT_SectionInfo()
+    {
+        if (pSecProps) {
+            delete pSecProps;
+        }
+        if (pWordProps) {
+            delete pWordProps;
+        }
+    }
+    CPVT_SectionInfo(const CPVT_SectionInfo & other): rcSection(), nTotalLine(0), pSecProps(NULL), pWordProps(NULL)
+    {
+        operator = (other);
+    }
+    void operator = (const CPVT_SectionInfo & other)
+    {
+        if (this == &other) {
+            return;
+        }
+        this->rcSection = other.rcSection;
+        this->nTotalLine = other.nTotalLine;
+        if (other.pSecProps) {
+            if (pSecProps) {
+                *pSecProps = *other.pSecProps;
+            } else {
+                pSecProps = FX_NEW CPVT_SecProps(*other.pSecProps);
+            }
+        }
+        if (other.pWordProps) {
+            if (pWordProps) {
+                *pWordProps = *other.pWordProps;
+            } else {
+                pWordProps = FX_NEW CPVT_WordProps(*other.pWordProps);
+            }
+        }
+    }
+    CPVT_FloatRect                             rcSection;
+    FX_INT32                                   nTotalLine;
+    CPVT_SecProps*                             pSecProps;
+    CPVT_WordProps*                            pWordProps;
+};
+struct CPVT_LineInfo {
+    CPVT_LineInfo() : nTotalWord(0), nBeginWordIndex(-1), nEndWordIndex(-1),
+        fLineX(0.0f), fLineY(0.0f), fLineWidth(0.0f), fLineAscent(0.0f), fLineDescent(0.0f)
+    {
+    }
+    FX_INT32                                   nTotalWord;
+    FX_INT32                                   nBeginWordIndex;
+    FX_INT32                                   nEndWordIndex;
+    FX_FLOAT                                   fLineX;
+    FX_FLOAT                                   fLineY;
+    FX_FLOAT                                   fLineWidth;
+    FX_FLOAT                                   fLineAscent;
+    FX_FLOAT                                   fLineDescent;
+};
+struct CPVT_WordInfo : public CFX_Object {
+    CPVT_WordInfo() : Word(0), nCharset(0),
+        fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), nFontIndex(-1), pWordProps(NULL)
+    {
+    }
+    CPVT_WordInfo(FX_WORD word, FX_INT32 charset, FX_INT32 fontIndex, CPVT_WordProps * pProps):
+        Word(word), nCharset(charset), fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f),
+        nFontIndex(fontIndex), pWordProps(pProps)
+    {
+    }
+    virtual ~CPVT_WordInfo()
+    {
+        if (pWordProps) {
+            delete pWordProps;
+        }
+    }
+    CPVT_WordInfo(const CPVT_WordInfo & word): Word(0), nCharset(0),
+        fWordX(0.0f), fWordY(0.0f), fWordTail(0.0f), nFontIndex(-1), pWordProps(NULL)
+    {
+        operator = (word);
+    }
+    void operator = (const CPVT_WordInfo & word)
+    {
+        if (this == &word) {
+            return;
+        }
+        this->Word = word.Word;
+        this->nCharset = word.nCharset;
+        this->nFontIndex = word.nFontIndex;
+        if (word.pWordProps) {
+            if (pWordProps) {
+                *pWordProps = *word.pWordProps;
+            } else {
+                pWordProps = FX_NEW CPVT_WordProps(*word.pWordProps);
+            }
+        }
+    }
+    FX_WORD                                            Word;
+    FX_INT32                                   nCharset;
+    FX_FLOAT                                   fWordX;
+    FX_FLOAT                                   fWordY;
+    FX_FLOAT                                   fWordTail;
+    FX_INT32                                   nFontIndex;
+    CPVT_WordProps*                            pWordProps;
+};
+struct CPVT_FloatRange {
+    CPVT_FloatRange() : fMin(0.0f), fMax(0.0f)
+    {
+    }
+    CPVT_FloatRange(FX_FLOAT min, FX_FLOAT max) : fMin(min), fMax(max)
+    {
+    }
+    FX_FLOAT Range() const
+    {
+        return fMax - fMin;
+    }
+    FX_FLOAT fMin, fMax;
+};
+template<class TYPE> class CPVT_ArrayTemplate : public CFX_ArrayTemplate<TYPE>
+{
+public:
+    FX_BOOL IsEmpty()
+    {
+        return CFX_ArrayTemplate<TYPE>::GetSize() <= 0;
+    }
+    TYPE GetAt(int nIndex) const
+    {
+        if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {
+            return CFX_ArrayTemplate<TYPE>::GetAt(nIndex);
+        }
+        return NULL;
+    }
+    void RemoveAt(int nIndex)
+    {
+        if (nIndex >= 0 && nIndex < CFX_ArrayTemplate<TYPE>::GetSize()) {
+            CFX_ArrayTemplate<TYPE>::RemoveAt(nIndex);
+        }
+    }
+};
+class CLine : public CFX_Object
+{
+public:
+    CLine();
+    virtual ~CLine();
+    CPVT_WordPlace                                                     GetBeginWordPlace() const;
+    CPVT_WordPlace                                                     GetEndWordPlace() const;
+    CPVT_WordPlace                                                     GetPrevWordPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     GetNextWordPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     LinePlace;
+    CPVT_LineInfo                                                      m_LineInfo;
+};
+class CLines
+{
+public:
+    CLines() : m_nTotal(0) {}
+    virtual ~CLines()
+    {
+        RemoveAll();
+    }
+    FX_INT32                                                           GetSize() const
+    {
+        return m_Lines.GetSize();
+    }
+    CLine *                                                                    GetAt(FX_INT32 nIndex) const
+    {
+        return m_Lines.GetAt(nIndex);
+    }
+    void                                                                       Empty()
+    {
+        m_nTotal = 0;
+    }
+    void                                                                       RemoveAll()
+    {
+        for (FX_INT32 i = 0, sz = GetSize(); i < sz; i++) {
+            delete GetAt(i);
+        }
+        m_Lines.RemoveAll();
+        m_nTotal = 0;
+    }
+    FX_INT32                                                           Add(const CPVT_LineInfo & lineinfo)
+    {
+        if (m_nTotal >= GetSize()) {
+            if (CLine * pLine = FX_NEW CLine) {
+                pLine->m_LineInfo = lineinfo;
+                m_Lines.Add(pLine);
+                return m_nTotal++;
+            }
+            return m_nTotal;
+        } else {
+            if (CLine * pLine = GetAt(m_nTotal)) {
+                pLine->m_LineInfo = lineinfo;
+            }
+            return m_nTotal++;
+        }
+    }
+    void                                                                       Clear()
+    {
+        for (FX_INT32 i = GetSize() - 1; i >= m_nTotal; i--) {
+            delete GetAt(i);
+            m_Lines.RemoveAt(i);
+        }
+    }
+private:
+    CPVT_ArrayTemplate<CLine*>                         m_Lines;
+    FX_INT32                                                           m_nTotal;
+};
+class CSection : public CFX_Object
+{
+    friend class CTypeset;
+public:
+    CSection(CPDF_VariableText * pVT);
+    virtual ~CSection();
+    void                                                                       ResetAll();
+    void                                                                       ResetLineArray();
+    void                                                                       ResetWordArray();
+    void                                                                       ResetLinePlace();
+    CPVT_WordPlace                                                     AddWord(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo);
+    CPVT_WordPlace                                                     AddLine(const CPVT_LineInfo & lineinfo);
+    void                                                                       ClearWords(const CPVT_WordRange & PlaceRange);
+    void                                                                       ClearWord(const CPVT_WordPlace & place);
+    CPVT_FloatRect                                                     Rearrange();
+    CPVT_Size                                                          GetSectionSize(FX_FLOAT fFontSize);
+    CPVT_WordPlace                                                     GetBeginWordPlace() const;
+    CPVT_WordPlace                                                     GetEndWordPlace() const;
+    CPVT_WordPlace                                                     GetPrevWordPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     GetNextWordPlace(const CPVT_WordPlace & place) const;
+    void                                                                       UpdateWordPlace(CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     SearchWordPlace(const CPDF_Point & point) const;
+    CPVT_WordPlace                                                     SearchWordPlace(FX_FLOAT fx, const CPVT_WordPlace & lineplace) const;
+    CPVT_WordPlace                                                     SearchWordPlace(FX_FLOAT fx, const CPVT_WordRange & range) const;
+public:
+    CPVT_WordPlace                                                     SecPlace;
+    CPVT_SectionInfo                                           m_SecInfo;
+    CLines                                                                     m_LineArray;
+    CPVT_ArrayTemplate<CPVT_WordInfo*>         m_WordArray;
+private:
+    void                                                                       ClearLeftWords(FX_INT32 nWordIndex);
+    void                                                                       ClearRightWords(FX_INT32 nWordIndex);
+    void                                                                       ClearMidWords(FX_INT32 nBeginIndex, FX_INT32 nEndIndex);
+
+    CPDF_VariableText                                          *m_pVT;
+};
+class CTypeset
+{
+public:
+    CTypeset(CSection * pSection);
+    virtual ~CTypeset();
+    CPVT_Size                                                          GetEditSize(FX_FLOAT fFontSize);
+    CPVT_FloatRect                                                     Typeset();
+    CPVT_FloatRect                                                     CharArray();
+private:
+    void                                                                       SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize);
+    void                                                                       OutputLines();
+
+    CPVT_FloatRect                                                     m_rcRet;
+    CPDF_VariableText                                          * m_pVT;
+    CSection                                                           * m_pSection;
+};
+class CPDF_EditContainer
+{
+public:
+    CPDF_EditContainer(): m_rcPlate(0, 0, 0, 0), m_rcContent(0, 0, 0, 0) {};
+    virtual ~CPDF_EditContainer() {};
+    virtual void                                                       SetPlateRect(const CPDF_Rect & rect)
+    {
+        m_rcPlate = rect;
+    };
+    virtual const CPDF_Rect &                          GetPlateRect() const
+    {
+        return m_rcPlate;
+    };
+    virtual void                                                       SetContentRect(const CPVT_FloatRect & rect)
+    {
+        m_rcContent = rect;
+    };
+    virtual CPDF_Rect                                          GetContentRect() const
+    {
+        return m_rcContent;
+    };
+    FX_FLOAT                                                           GetPlateWidth() const
+    {
+        return m_rcPlate.right - m_rcPlate.left;
+    };
+    FX_FLOAT                                                           GetPlateHeight() const
+    {
+        return m_rcPlate.top - m_rcPlate.bottom;
+    };
+    CPVT_Size                                                          GetPlateSize() const
+    {
+        return CPVT_Size(GetPlateWidth(), GetPlateHeight());
+    };
+    CPDF_Point                                                         GetBTPoint() const
+    {
+        return CPDF_Point(m_rcPlate.left, m_rcPlate.top);
+    };
+    CPDF_Point                                                         GetETPoint() const
+    {
+        return CPDF_Point(m_rcPlate.right, m_rcPlate.bottom);
+    };
+    inline CPDF_Point                                          InToOut(const CPDF_Point & point) const
+    {
+        return CPDF_Point(point.x + GetBTPoint().x, GetBTPoint().y - point.y);
+    };
+    inline CPDF_Point                                          OutToIn(const CPDF_Point & point) const
+    {
+        return CPDF_Point(point.x - GetBTPoint().x, GetBTPoint().y - point.y);
+    };
+    inline CPDF_Rect                                           InToOut(const CPVT_FloatRect & rect) const
+    {
+        CPDF_Point ptLeftTop = InToOut(CPDF_Point(rect.left, rect.top));
+        CPDF_Point ptRightBottom = InToOut(CPDF_Point(rect.right, rect.bottom));
+        return CPDF_Rect(ptLeftTop.x, ptRightBottom.y, ptRightBottom.x, ptLeftTop.y);
+    };
+    inline CPVT_FloatRect                                      OutToIn(const CPDF_Rect & rect) const
+    {
+        CPDF_Point ptLeftTop = OutToIn(CPDF_Point(rect.left, rect.top));
+        CPDF_Point ptRightBottom = OutToIn(CPDF_Point(rect.right, rect.bottom));
+        return CPVT_FloatRect(ptLeftTop.x, ptLeftTop.y, ptRightBottom.x, ptRightBottom.y);
+    };
+
+private:
+    CPDF_Rect                                                          m_rcPlate;
+    CPVT_FloatRect                                                     m_rcContent;
+};
+class CPDF_VariableText : public IPDF_VariableText, public CFX_Object, private CPDF_EditContainer
+{
+    friend class CTypeset;
+    friend class CSection;
+    friend class CPDF_VariableText_Iterator;
+public:
+    CPDF_VariableText();
+    virtual ~CPDF_VariableText();
+    IPDF_VariableText_Provider*                                SetProvider(IPDF_VariableText_Provider * pProvider);
+    IPDF_VariableText_Iterator*                                GetIterator();
+    void                                                                       SetPlateRect(const CPDF_Rect & rect)
+    {
+        CPDF_EditContainer::SetPlateRect(rect);
+    }
+    void                                                                       SetAlignment(FX_INT32 nFormat = 0)
+    {
+        m_nAlignment = nFormat;
+    }
+    void                                                                       SetPasswordChar(FX_WORD wSubWord = '*')
+    {
+        m_wSubWord = wSubWord;
+    }
+    void                                                                       SetLimitChar(FX_INT32 nLimitChar = 0)
+    {
+        m_nLimitChar = nLimitChar;
+    }
+    void                                                                       SetCharSpace(FX_FLOAT fCharSpace = 0.0f)
+    {
+        m_fCharSpace = fCharSpace;
+    }
+    void                                                                       SetHorzScale(FX_INT32 nHorzScale = 100)
+    {
+        m_nHorzScale = nHorzScale;
+    }
+    void                                                                       SetMultiLine(FX_BOOL bMultiLine = TRUE)
+    {
+        m_bMultiLine = bMultiLine;
+    }
+    void                                                                       SetAutoReturn(FX_BOOL bAuto = TRUE)
+    {
+        m_bLimitWidth = bAuto;
+    }
+    void                                                                       SetFontSize(FX_FLOAT fFontSize)
+    {
+        m_fFontSize = fFontSize;
+    }
+    void                                                                       SetCharArray(FX_INT32 nCharArray = 0)
+    {
+        m_nCharArray = nCharArray;
+    }
+    void                                                                       SetAutoFontSize(FX_BOOL bAuto = TRUE)
+    {
+        m_bAutoFontSize = bAuto;
+    }
+    void                                                                       SetRichText(FX_BOOL bRichText)
+    {
+        m_bRichText = bRichText;
+    }
+    void                                                                       SetLineLeading(FX_FLOAT fLineLeading)
+    {
+        m_fLineLeading = fLineLeading;
+    }
+    void                                                                       Initialize();
+    FX_BOOL                                                                    IsValid() const
+    {
+        return m_bInitial;
+    }
+    FX_BOOL                                                                    IsRichText() const
+    {
+        return m_bRichText;
+    }
+    void                                                                       RearrangeAll();
+    void                                                                       RearrangePart(const CPVT_WordRange & PlaceRange);
+    void                                                                       ResetAll();
+    void                                                                       SetText(FX_LPCWSTR text, FX_INT32 charset = 1, const CPVT_SecProps * pSecProps = NULL,
+            const CPVT_WordProps * pWordProps = NULL);
+    CPVT_WordPlace                                                     InsertWord(const CPVT_WordPlace & place, FX_WORD word, FX_INT32 charset = 1,
+            const CPVT_WordProps * pWordProps = NULL);
+    CPVT_WordPlace                                                     InsertSection(const CPVT_WordPlace & place, const CPVT_SecProps * pSecProps = NULL,
+            const CPVT_WordProps * pWordProps = NULL);
+    CPVT_WordPlace                                                     InsertText(const CPVT_WordPlace & place, FX_LPCWSTR text, FX_INT32 charset = 1,
+            const CPVT_SecProps * pSecProps = NULL,    const CPVT_WordProps * pWordProps = NULL);
+    CPVT_WordPlace                                                     DeleteWords(const CPVT_WordRange & PlaceRange);
+    CPVT_WordPlace                                                     DeleteWord(const CPVT_WordPlace & place);
+    CPVT_WordPlace                                                     BackSpaceWord(const CPVT_WordPlace & place);
+    const CPDF_Rect &                                          GetPlateRect() const
+    {
+        return CPDF_EditContainer::GetPlateRect();
+    }
+    CPDF_Rect                                                          GetContentRect() const;
+    FX_INT32                                                           GetTotalWords() const;
+    FX_FLOAT                                                           GetFontSize() const
+    {
+        return m_fFontSize;
+    }
+    FX_INT32                                                           GetAlignment() const
+    {
+        return m_nAlignment;
+    }
+    FX_INT32                                                           GetCharArray() const
+    {
+        return m_nCharArray;
+    }
+    FX_INT32                                                           GetLimitChar() const
+    {
+        return m_nLimitChar;
+    }
+    FX_BOOL                                                                    IsMultiLine() const
+    {
+        return m_bMultiLine;
+    }
+    FX_INT32                                                           GetHorzScale() const
+    {
+        return m_nHorzScale;
+    }
+    FX_FLOAT                                                           GetCharSpace() const
+    {
+        return m_fCharSpace;
+    }
+
+    CPVT_WordPlace                                                     GetBeginWordPlace() const;
+    CPVT_WordPlace                                                     GetEndWordPlace() const;
+    CPVT_WordPlace                                                     GetPrevWordPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     GetNextWordPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     SearchWordPlace(const CPDF_Point & point) const;
+    CPVT_WordPlace                                                     GetUpWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const;
+    CPVT_WordPlace                                                     GetDownWordPlace(const CPVT_WordPlace & place, const CPDF_Point & point) const;
+    CPVT_WordPlace                                                     GetLineBeginPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     GetLineEndPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     GetSectionBeginPlace(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     GetSectionEndPlace(const CPVT_WordPlace & place) const;
+    void                                                                       UpdateWordPlace(CPVT_WordPlace & place) const;
+    FX_INT32                                                           WordPlaceToWordIndex(const CPVT_WordPlace & place) const;
+    CPVT_WordPlace                                                     WordIndexToWordPlace(FX_INT32 index) const;
+    FX_WORD                                                                    GetPasswordChar() const
+    {
+        return GetSubWord();
+    }
+    FX_WORD                                                                    GetSubWord() const
+    {
+        return m_wSubWord;
+    }
+private:
+    FX_INT32                                                           GetCharWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_WORD SubWord, FX_INT32 nWordStyle);
+    FX_INT32                                                           GetTypeAscent(FX_INT32 nFontIndex);
+    FX_INT32                                                           GetTypeDescent(FX_INT32 nFontIndex);
+    FX_INT32                                                           GetWordFontIndex(FX_WORD word, FX_INT32 charset, FX_INT32 nFontIndex);
+    FX_INT32                                                           GetDefaultFontIndex();
+    FX_BOOL                                                                    IsLatinWord(FX_WORD word);
+private:
+
+    CPVT_WordPlace                                                     AddSection(const CPVT_WordPlace & place, const CPVT_SectionInfo & secinfo);
+    CPVT_WordPlace                                                     AddLine(const CPVT_WordPlace & place, const CPVT_LineInfo & lineinfo);
+    CPVT_WordPlace                                                     AddWord(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo);
+    FX_BOOL                                                                    GetWordInfo(const CPVT_WordPlace & place, CPVT_WordInfo & wordinfo);
+    FX_BOOL                                                                    SetWordInfo(const CPVT_WordPlace & place, const CPVT_WordInfo & wordinfo);
+    FX_BOOL                                                                    GetLineInfo(const CPVT_WordPlace & place, CPVT_LineInfo & lineinfo);
+    FX_BOOL                                                                    GetSectionInfo(const CPVT_WordPlace & place, CPVT_SectionInfo & secinfo);
+    FX_FLOAT                                                           GetWordFontSize(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE);
+    FX_FLOAT                                                           GetWordWidth(FX_INT32 nFontIndex, FX_WORD Word, FX_WORD SubWord,
+            FX_FLOAT fCharSpace, FX_INT32 nHorzScale,
+            FX_FLOAT fFontSize, FX_FLOAT fWordTail, FX_INT32 nWordStyle);
+    FX_FLOAT                                                           GetWordWidth(const CPVT_WordInfo & WordInfo);
+    FX_FLOAT                                                           GetWordAscent(const CPVT_WordInfo & WordInfo, FX_FLOAT fFontSize);
+    FX_FLOAT                                                           GetWordDescent(const CPVT_WordInfo & WordInfo, FX_FLOAT fFontSize);
+    FX_FLOAT                                                           GetWordAscent(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE);
+    FX_FLOAT                                                           GetWordDescent(const CPVT_WordInfo & WordInfo, FX_BOOL bFactFontSize = FALSE);
+    FX_FLOAT                                                           GetLineAscent(const CPVT_SectionInfo & SecInfo);
+    FX_FLOAT                                                           GetLineDescent(const CPVT_SectionInfo & SecInfo);
+    FX_FLOAT                                                           GetFontAscent(FX_INT32 nFontIndex, FX_FLOAT fFontSize);
+    FX_FLOAT                                                           GetFontDescent(FX_INT32 nFontIndex, FX_FLOAT fFontSize);
+    FX_INT32                                                           GetWordFontIndex(const CPVT_WordInfo & WordInfo);
+    FX_FLOAT                                                           GetCharSpace(const CPVT_WordInfo & WordInfo);
+    FX_INT32                                                           GetHorzScale(const CPVT_WordInfo & WordInfo);
+    FX_FLOAT                                                           GetLineLeading(const CPVT_SectionInfo & SecInfo);
+    FX_FLOAT                                                           GetLineIndent(const CPVT_SectionInfo & SecInfo);
+    FX_INT32                                                           GetAlignment(const CPVT_SectionInfo& SecInfo);
+
+    void                                                                       ClearSectionRightWords(const CPVT_WordPlace & place);
+    CPVT_WordPlace                                                     AjustLineHeader(const CPVT_WordPlace & place, FX_BOOL bPrevOrNext) const;
+    FX_BOOL                                                                    ClearEmptySection(const CPVT_WordPlace & place);
+    void                                                                       ClearEmptySections(const CPVT_WordRange & PlaceRange);
+    void                                                                       LinkLatterSection(const CPVT_WordPlace & place);
+    void                                                                       ClearWords(const CPVT_WordRange & PlaceRange);
+    CPVT_WordPlace                                                     ClearLeftWord(const CPVT_WordPlace & place);
+    CPVT_WordPlace                                                     ClearRightWord(const CPVT_WordPlace & place);
+private:
+    CPVT_FloatRect                                                     Rearrange(const CPVT_WordRange & PlaceRange);
+    FX_FLOAT                                                           GetAutoFontSize();
+    FX_BOOL                                                                    IsBigger(FX_FLOAT fFontSize);
+    CPVT_FloatRect                                                     RearrangeSections(const CPVT_WordRange & PlaceRange);
+private:
+    void                                                                       ResetSectionArray();
+private:
+    CPVT_ArrayTemplate<CSection*>                      m_SectionArray;
+    FX_INT32                                                           m_nLimitChar;
+    FX_INT32                                                           m_nCharArray;
+    FX_BOOL                                                                    m_bMultiLine;
+    FX_BOOL                                                                    m_bLimitWidth;
+    FX_BOOL                                                                    m_bAutoFontSize;
+    FX_INT32                                                           m_nAlignment;
+    FX_FLOAT                                                           m_fLineLeading;
+    FX_FLOAT                                                           m_fCharSpace;
+    FX_INT32                                                           m_nHorzScale;
+    FX_WORD                                                                    m_wSubWord;
+    FX_FLOAT                                                           m_fFontSize;
+
+private:
+    FX_BOOL                                                                    m_bInitial;
+    FX_BOOL                                                                    m_bRichText;
+    IPDF_VariableText_Provider *                       m_pVTProvider;
+    CPDF_VariableText_Iterator *                       m_pVTIterator;
+};
+class CPDF_VariableText_Iterator : public IPDF_VariableText_Iterator, public CFX_Object
+{
+public:
+    CPDF_VariableText_Iterator(CPDF_VariableText * pVT);
+    virtual ~CPDF_VariableText_Iterator();
+    FX_BOOL                                                                    NextWord();
+    FX_BOOL                                                                    PrevWord();
+    FX_BOOL                                                                    NextLine();
+    FX_BOOL                                                                    PrevLine();
+    FX_BOOL                                                                    NextSection();
+    FX_BOOL                                                                    PrevSection();
+    FX_BOOL                                                                    SetWord(const CPVT_Word & word);
+    FX_BOOL                                                                    GetWord(CPVT_Word & word) const;
+    FX_BOOL                                                                    GetLine(CPVT_Line & line) const;
+    FX_BOOL                                                                    GetSection(CPVT_Section & section) const;
+    FX_BOOL                                                                    SetSection(const CPVT_Section & section);
+    void                                                                       SetAt(FX_INT32 nWordIndex);
+    void                                                                       SetAt(const CPVT_WordPlace & place);
+    const CPVT_WordPlace &                                     GetAt() const
+    {
+        return m_CurPos;
+    };
+private:
+    CPVT_WordPlace                                                     m_CurPos;
+    CPDF_VariableText *                                                m_pVT;
+};
+
+#endif  // _PDF_VT_H_