summaryrefslogtreecommitdiff
path: root/xfa/fde/tto/fde_textout.h
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fde/tto/fde_textout.h')
-rw-r--r--xfa/fde/tto/fde_textout.h205
1 files changed, 145 insertions, 60 deletions
diff --git a/xfa/fde/tto/fde_textout.h b/xfa/fde/tto/fde_textout.h
index e20c00a2e0..e3e87a780a 100644
--- a/xfa/fde/tto/fde_textout.h
+++ b/xfa/fde/tto/fde_textout.h
@@ -9,7 +9,10 @@
#include "core/fxge/include/fx_dib.h"
#include "core/fxge/include/fx_ge.h"
+#include "xfa/fde/fde_object.h"
+#include "xfa/fgas/crt/fgas_utils.h"
#include "xfa/fgas/font/fgas_font.h"
+#include "xfa/fgas/layout/fgas_textbreak.h"
#define FDE_TTOSTYLE_Underline 0x0001
#define FDE_TTOSTYLE_Strikeout 0x0002
@@ -36,67 +39,149 @@
#define FDE_TTOALIGNMENT_BottomRight 10
#define FDE_TTOALIGNMENT_BottomAuto 11
-class IFDE_TextOut {
+class CFDE_RenderDevice;
+class CFX_TxtBreak;
+
+struct FDE_TTOPIECE {
+ int32_t iStartChar;
+ int32_t iChars;
+ uint32_t dwCharStyles;
+ CFX_RectF rtPiece;
+};
+typedef CFX_MassArrayTemplate<FDE_TTOPIECE> CFDE_TTOPieceArray;
+
+class CFDE_TTOLine : public CFX_Target {
+ public:
+ CFDE_TTOLine();
+ CFDE_TTOLine(const CFDE_TTOLine& ttoLine);
+ ~CFDE_TTOLine();
+ int32_t AddPiece(int32_t index, const FDE_TTOPIECE& ttoPiece);
+ int32_t GetSize() const;
+ FDE_TTOPIECE* GetPtrAt(int32_t index);
+ void RemoveLast(int32_t iCount);
+ void RemoveAll(FX_BOOL bLeaveMemory);
+
+ FX_BOOL m_bNewReload;
+ CFDE_TTOPieceArray m_pieces;
+
+ protected:
+ int32_t m_iPieceCount;
+};
+typedef CFX_ObjectMassArrayTemplate<CFDE_TTOLine> CFDE_TTOLineArray;
+
+class CFDE_TextOut : public CFX_Target {
public:
- static IFDE_TextOut* Create();
- virtual ~IFDE_TextOut() {}
- virtual void Release() = 0;
- virtual void SetFont(IFX_Font* pFont) = 0;
- virtual void SetFontSize(FX_FLOAT fFontSize) = 0;
- virtual void SetTextColor(FX_ARGB color) = 0;
- virtual void SetStyles(uint32_t dwStyles) = 0;
- virtual void SetTabWidth(FX_FLOAT fTabWidth) = 0;
- virtual void SetEllipsisString(const CFX_WideString& wsEllipsis) = 0;
- virtual void SetParagraphBreakChar(FX_WCHAR wch) = 0;
- virtual void SetAlignment(int32_t iAlignment) = 0;
- virtual void SetLineSpace(FX_FLOAT fLineSpace) = 0;
- virtual void SetDIBitmap(CFX_DIBitmap* pDIB) = 0;
- virtual void SetRenderDevice(CFX_RenderDevice* pDevice) = 0;
- virtual void SetClipRect(const CFX_Rect& rtClip) = 0;
- virtual void SetClipRect(const CFX_RectF& rtClip) = 0;
- virtual void SetMatrix(const CFX_Matrix& matrix) = 0;
- virtual void SetLineBreakTolerance(FX_FLOAT fTolerance) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_Size& size) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_SizeF& size) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_Rect& rect) = 0;
- virtual void CalcSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_RectF& rect) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- int32_t x,
- int32_t y) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- FX_FLOAT x,
- FX_FLOAT y) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_Rect& rect) = 0;
- virtual void DrawText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect) = 0;
- virtual void SetLogicClipRect(const CFX_RectF& rtClip) = 0;
- virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_SizeF& size) = 0;
- virtual void CalcLogicSize(const FX_WCHAR* pwsStr,
- int32_t iLength,
- CFX_RectF& rect) = 0;
- virtual void DrawLogicText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- FX_FLOAT x,
- FX_FLOAT y) = 0;
- virtual void DrawLogicText(const FX_WCHAR* pwsStr,
- int32_t iLength,
- const CFX_RectF& rect) = 0;
- virtual int32_t GetTotalLines() = 0;
+ CFDE_TextOut();
+ ~CFDE_TextOut();
+
+ void Release() { delete this; }
+ void SetFont(IFX_Font* pFont);
+ void SetFontSize(FX_FLOAT fFontSize);
+ void SetTextColor(FX_ARGB color);
+ void SetStyles(uint32_t dwStyles);
+ void SetTabWidth(FX_FLOAT fTabWidth);
+ void SetEllipsisString(const CFX_WideString& wsEllipsis);
+ void SetParagraphBreakChar(FX_WCHAR wch);
+ void SetAlignment(int32_t iAlignment);
+ void SetLineSpace(FX_FLOAT fLineSpace);
+ void SetDIBitmap(CFX_DIBitmap* pDIB);
+ void SetRenderDevice(CFX_RenderDevice* pDevice);
+ void SetClipRect(const CFX_Rect& rtClip);
+ void SetClipRect(const CFX_RectF& rtClip);
+ void SetMatrix(const CFX_Matrix& matrix);
+ void SetLineBreakTolerance(FX_FLOAT fTolerance);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Size& size);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_Rect& rect);
+ void CalcSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
+
+ void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, int32_t x, int32_t y);
+ void DrawText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ FX_FLOAT x,
+ FX_FLOAT y);
+ void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_Rect& rect);
+ void DrawText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
+
+ void SetLogicClipRect(const CFX_RectF& rtClip);
+ void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_SizeF& size);
+ void CalcLogicSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
+ void DrawLogicText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ FX_FLOAT x,
+ FX_FLOAT y);
+ void DrawLogicText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ const CFX_RectF& rect);
+ int32_t GetTotalLines();
+
+ protected:
+ void CalcTextSize(const FX_WCHAR* pwsStr, int32_t iLength, CFX_RectF& rect);
+ FX_BOOL RetrieveLineWidth(uint32_t dwBreakStatus,
+ FX_FLOAT& fStartPos,
+ FX_FLOAT& fWidth,
+ FX_FLOAT& fHeight);
+ void SetLineWidth(CFX_RectF& rect);
+ void DrawText(const FX_WCHAR* pwsStr,
+ int32_t iLength,
+ const CFX_RectF& rect,
+ const CFX_RectF& rtClip);
+ void LoadText(const FX_WCHAR* pwsStr, int32_t iLength, const CFX_RectF& rect);
+ void LoadEllipsis();
+ void ExpandBuffer(int32_t iSize, int32_t iType);
+ void RetrieveEllPieces(int32_t*& pCharWidths);
+
+ void Reload(const CFX_RectF& rect);
+ void ReloadLinePiece(CFDE_TTOLine* pLine, const CFX_RectF& rect);
+ FX_BOOL RetriecePieces(uint32_t dwBreakStatus,
+ int32_t& iStartChar,
+ int32_t& iPieceWidths,
+ FX_BOOL bReload,
+ const CFX_RectF& rect);
+ void AppendPiece(const FDE_TTOPIECE& ttoPiece,
+ FX_BOOL bNeedReload,
+ FX_BOOL bEnd);
+ void ReplaceWidthEllipsis();
+ void DoAlignment(const CFX_RectF& rect);
+ void OnDraw(const CFX_RectF& rtClip);
+ int32_t GetDisplayPos(FDE_TTOPIECE* pPiece);
+ int32_t GetCharRects(const FDE_TTOPIECE* pPiece);
+
+ FX_TXTRUN ToTextRun(const FDE_TTOPIECE* pPiece);
+ void DrawLine(const FDE_TTOPIECE* pPiece, CFDE_Pen*& pPen);
+
+ CFX_TxtBreak* m_pTxtBreak;
+ IFX_Font* m_pFont;
+ FX_FLOAT m_fFontSize;
+ FX_FLOAT m_fLineSpace;
+ FX_FLOAT m_fLinePos;
+ FX_FLOAT m_fTolerance;
+ int32_t m_iAlignment;
+ int32_t m_iTxtBkAlignment;
+ int32_t* m_pCharWidths;
+ int32_t m_iChars;
+ int32_t* m_pEllCharWidths;
+ int32_t m_iEllChars;
+ FX_WCHAR m_wParagraphBkChar;
+ FX_ARGB m_TxtColor;
+ uint32_t m_dwStyles;
+ uint32_t m_dwTxtBkStyles;
+ CFX_WideString m_wsEllipsis;
+ FX_BOOL m_bElliChanged;
+ int32_t m_iEllipsisWidth;
+ CFX_WideString m_wsText;
+ CFX_RectF m_rtClip;
+ CFX_RectF m_rtLogicClip;
+ CFX_Matrix m_Matrix;
+ CFDE_TTOLineArray m_ttoLines;
+ int32_t m_iCurLine;
+ int32_t m_iCurPiece;
+ int32_t m_iTotalLines;
+ FXTEXT_CHARPOS* m_pCharPos;
+ int32_t m_iCharPosSize;
+ CFDE_RenderDevice* m_pRenderDevice;
+ CFX_Int32Array m_hotKeys;
+ CFX_RectFArray m_rectArray;
};
#endif // XFA_FDE_TTO_FDE_TEXTOUT_H_