diff options
Diffstat (limited to 'fpdfsdk/pdfwindow/PWL_Utils.h')
-rw-r--r-- | fpdfsdk/pdfwindow/PWL_Utils.h | 215 |
1 files changed, 6 insertions, 209 deletions
diff --git a/fpdfsdk/pdfwindow/PWL_Utils.h b/fpdfsdk/pdfwindow/PWL_Utils.h index cbf54e6a90..a4ecc19ee5 100644 --- a/fpdfsdk/pdfwindow/PWL_Utils.h +++ b/fpdfsdk/pdfwindow/PWL_Utils.h @@ -9,45 +9,12 @@ #include "core/fpdfdoc/cpvt_wordrange.h" #include "fpdfsdk/pdfwindow/PWL_Wnd.h" -#include "fpdfsdk/pdfwindow/cpwl_pathdata.h" class CFX_Edit; -class CFX_PathData; - struct CPWL_Color; -#define PWL_PDF2WIN(color) (uint8_t(color * 255)) -#define PWL_WIN2PDF(color) ((FX_FLOAT)((FX_FLOAT)color / 255.0f)) - #define PWL_MAKEDWORD(low, high) \ ((uint32_t)((uint16_t)(low) | (uint32_t)(((uint16_t)(high)) << 16))) -#define PWL_GETLOWWORD(dword) ((uint16_t)(dword)) -#define PWL_GETHIGHWORD(dword) ((uint16_t)(dword >> 16)) - -#define PWL_ICONTYPE_CHECKMARK 0 -#define PWL_ICONTYPE_CIRCLE 1 -#define PWL_ICONTYPE_COMMENT 2 -#define PWL_ICONTYPE_CROSS 3 -#define PWL_ICONTYPE_HELP 4 -#define PWL_ICONTYPE_INSERTTEXT 5 -#define PWL_ICONTYPE_KEY 6 -#define PWL_ICONTYPE_NEWPARAGRAPH 7 -#define PWL_ICONTYPE_TEXTNOTE 8 -#define PWL_ICONTYPE_PARAGRAPH 9 -#define PWL_ICONTYPE_RIGHTARROW 10 -#define PWL_ICONTYPE_RIGHTPOINTER 11 -#define PWL_ICONTYPE_STAR 12 -#define PWL_ICONTYPE_UPARROW 13 -#define PWL_ICONTYPE_UPLEFTARROW 14 - -#define PWL_ICONTYPE_GRAPH 15 -#define PWL_ICONTYPE_PAPERCLIP 16 -#define PWL_ICONTYPE_ATTACHMENT 17 -#define PWL_ICONTYPE_TAG 18 - -#define PWL_ICONTYPE_FOXIT 19 - -#define PWL_ICONTYPE_UNKNOWN -1 // checkbox & radiobutton style #define PCS_CHECK 0 @@ -66,36 +33,18 @@ struct CPWL_Color; #define PPBL_LABELLEFTICONRIGHT 5 #define PPBL_LABELOVERICON 6 -enum PWL_PATH_TYPE { PWLPT_PATHDATA, PWLPT_STREAM }; - class CPWL_Utils { public: static CFX_FloatRect InflateRect(const CFX_FloatRect& rcRect, FX_FLOAT fSize); static CFX_FloatRect DeflateRect(const CFX_FloatRect& rcRect, FX_FLOAT fSize); - static bool IntersectRect(const CFX_FloatRect& rect1, - const CFX_FloatRect& rect2); - static bool ContainsRect(const CFX_FloatRect& rcParent, - const CFX_FloatRect& rcChild); - static CFX_FloatRect ScaleRect(const CFX_FloatRect& rcRect, FX_FLOAT fScale); + static CPVT_WordRange OverlapWordRange(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2); static CFX_FloatRect GetCenterSquare(const CFX_FloatRect& rect); - static CPWL_Color SubstractColor(const CPWL_Color& sColor, - FX_FLOAT fColorSub); - static CPWL_Color DevideColor(const CPWL_Color& sColor, - FX_FLOAT fColorDevide); - static CFX_FloatRect MaxRect(const CFX_FloatRect& rect1, - const CFX_FloatRect& rect2); + static CFX_FloatRect OffsetRect(const CFX_FloatRect& rect, FX_FLOAT x, FX_FLOAT y); - static CFX_PointF OffsetPoint(const CFX_PointF& point, - FX_FLOAT x, - FX_FLOAT y); - static FX_COLORREF PWLColorToFXColor(const CPWL_Color& color, - int32_t nTransparancy = 255); - static bool IsBlackOrWhite(const CPWL_Color& color); - static CPWL_Color GetReverseColor(const CPWL_Color& color); static CFX_ByteString GetColorAppStream(const CPWL_Color& color, const bool& bFillOrStroke = true); @@ -118,7 +67,6 @@ class CPWL_Utils { const CPWL_Color& color); static CFX_ByteString GetCircleFillAppStream(const CFX_FloatRect& rect, const CPWL_Color& color); - static CFX_ByteString GetPushButtonAppStream(const CFX_FloatRect& rcBBox, IPVT_FontMap* pFontMap, CPDF_Stream* pIconStream, @@ -133,7 +81,6 @@ class CPWL_Utils { static CFX_ByteString GetRadioButtonAppStream(const CFX_FloatRect& rcBBox, int32_t nStyle, const CPWL_Color& crText); - static CFX_ByteString GetEditAppStream(CFX_Edit* pEdit, const CFX_PointF& ptOffset, const CPVT_WordRange* pRange = nullptr, @@ -143,22 +90,13 @@ class CPWL_Utils { CFX_Edit* pEdit, const CFX_PointF& ptOffset, const CPVT_WordRange* pRange = nullptr); - static CFX_ByteString GetTextAppStream(const CFX_FloatRect& rcBBox, - IPVT_FontMap* pFontMap, - const CFX_WideString& sText, - int32_t nAlignmentH, - int32_t nAlignmentV, - FX_FLOAT fFontSize, - bool bMultiLine, - bool bAutoReturn, - const CPWL_Color& crText); static CFX_ByteString GetDropButtonAppStream(const CFX_FloatRect& rcBBox); static void DrawFillRect(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, const CFX_FloatRect& rect, const CPWL_Color& color, - int32_t nTransparancy); + int32_t nTransparency); static void DrawFillRect(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, const CFX_FloatRect& rect, @@ -182,7 +120,7 @@ class CPWL_Utils { const CPWL_Color& crLeftTop, const CPWL_Color& crRightBottom, BorderStyle nStyle, - int32_t nTransparancy); + int32_t nTransparency); static void DrawFillArea(CFX_RenderDevice* pDevice, CFX_Matrix* pUser2Device, const CFX_PointF* pPts, @@ -193,72 +131,12 @@ class CPWL_Utils { bool bVertical, bool bHorizontal, CFX_FloatRect rect, - int32_t nTransparancy, + int32_t nTransparency, int32_t nStartGray, int32_t nEndGray); - public: - static void ConvertCMYK2RGB(FX_FLOAT dC, - FX_FLOAT dM, - FX_FLOAT dY, - FX_FLOAT dK, - FX_FLOAT& dR, - FX_FLOAT& dG, - FX_FLOAT& dB); - static void ConvertRGB2CMYK(FX_FLOAT dR, - FX_FLOAT dG, - FX_FLOAT dB, - FX_FLOAT& dC, - FX_FLOAT& dM, - FX_FLOAT& dY, - FX_FLOAT& dK); - - static void ConvertRGB2GRAY(FX_FLOAT dR, - FX_FLOAT dG, - FX_FLOAT dB, - FX_FLOAT& dGray); - static void ConvertGRAY2RGB(FX_FLOAT dGray, - FX_FLOAT& dR, - FX_FLOAT& dG, - FX_FLOAT& dB); - - static void ConvertCMYK2GRAY(FX_FLOAT dC, - FX_FLOAT dM, - FX_FLOAT dY, - FX_FLOAT dK, - FX_FLOAT& dGray); - static void ConvertGRAY2CMYK(FX_FLOAT dGray, - FX_FLOAT& dC, - FX_FLOAT& dM, - FX_FLOAT& dY, - FX_FLOAT& dK); - - static void PWLColorToARGB(const CPWL_Color& color, - int32_t& alpha, - FX_FLOAT& red, - FX_FLOAT& green, - FX_FLOAT& blue); - - public: - static CFX_ByteString GetIconAppStream( - int32_t nType, - const CFX_FloatRect& rect, - const CPWL_Color& crFill, - const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR); - static void DrawIconAppStream(CFX_RenderDevice* pDevice, - CFX_Matrix* pUser2Device, - int32_t nType, - const CFX_FloatRect& rect, - const CPWL_Color& crFill, - const CPWL_Color& crStroke, - const int32_t nTransparancy); - private: - static CFX_ByteString GetAppStreamFromArray(const CPWL_PathData* pPathData, - int32_t nCount); - static void GetPathDataFromArray(CFX_PathData& path, - const CPWL_PathData* pPathData, - int32_t nCount); + static CFX_FloatRect ScaleRect(const CFX_FloatRect& rcRect, FX_FLOAT fScale); static CFX_ByteString GetAppStream_Check(const CFX_FloatRect& rcBBox, const CPWL_Color& crText); @@ -281,87 +159,6 @@ class CPWL_Utils { static CFX_ByteString GetAP_Star(const CFX_FloatRect& crBBox); static CFX_ByteString GetAP_HalfCircle(const CFX_FloatRect& crBBox, FX_FLOAT fRotate); - - static void GetGraphics_Checkmark(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Circle(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Comment(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Cross(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Help(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_InsertText(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Key(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_NewParagraph(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_TextNote(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Paragraph(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_RightArrow(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_RightPointer(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Star(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_UpArrow(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Graph(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Paperclip(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Attachment(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Tag(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); - static void GetGraphics_Foxit(CFX_ByteString& sPathData, - CFX_PathData& path, - const CFX_FloatRect& crBBox, - const PWL_PATH_TYPE type); }; #endif // FPDFSDK_PDFWINDOW_PWL_UTILS_H_ |