OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ | 7 #ifndef FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ |
8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ | 8 #define FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ |
9 | 9 |
10 #include "../../../core/include/fpdfapi/fpdf_parser.h" // For CPDF_Point. | 10 #include "../../../core/include/fpdfapi/fpdf_parser.h" // For CPDF_Point. |
11 #include "../../../core/include/fpdfdoc/fpdf_vt.h" // For CPVT_WordRange. | 11 #include "../../../core/include/fpdfdoc/fpdf_vt.h" // For CPVT_WordRange. |
12 #include "../fxedit/fx_edit.h" | 12 #include "../fxedit/fx_edit.h" |
13 #include "PWL_Wnd.h" | 13 #include "PWL_Wnd.h" |
14 | 14 |
15 class CFX_PathData; | 15 class CFX_PathData; |
16 struct CPWL_Color; | 16 struct CPWL_Color; |
17 | 17 |
18 template<class T> T PWL_MIN (const T & i, const T & j) { return ((i < j) ? i : j
); } | 18 template <class T> |
19 template<class T> T PWL_MAX (const T & i, const T & j) { return ((i > j) ? i : j
); } | 19 T PWL_MIN(const T& i, const T& j) { |
20 | 20 return ((i < j) ? i : j); |
21 #define PWL_PDF2WIN(color)» » » » » (uint8_t(color*2
55)) | 21 } |
22 #define PWL_WIN2PDF(color)» » » » » ((FX_FLOAT)((FX_
FLOAT)color/255.0f)) | 22 template <class T> |
23 | 23 T PWL_MAX(const T& i, const T& j) { |
24 #define PWL_MAKEDWORD(low,high)»» » » ((FX_DWORD)((FX_WORD)(lo
w) | (FX_DWORD)(((FX_WORD)(high))<<16))) | 24 return ((i > j) ? i : j); |
25 #define PWL_GETLOWWORD(dword)» » » » ((FX_WORD)(dword)) | 25 } |
26 #define PWL_GETHIGHWORD(dword)» » » » ((FX_WORD)(dword>>16)) | 26 |
27 | 27 #define PWL_PDF2WIN(color) (uint8_t(color * 255)) |
28 #define PWL_ICONTYPE_CHECKMARK» » » » 0 | 28 #define PWL_WIN2PDF(color) ((FX_FLOAT)((FX_FLOAT)color / 255.0f)) |
29 #define PWL_ICONTYPE_CIRCLE» » » » » 1 | 29 |
30 #define PWL_ICONTYPE_COMMENT» » » » 2 | 30 #define PWL_MAKEDWORD(low, high) \ |
31 #define PWL_ICONTYPE_CROSS» » » » » 3 | 31 ((FX_DWORD)((FX_WORD)(low) | (FX_DWORD)(((FX_WORD)(high)) << 16))) |
32 #define PWL_ICONTYPE_HELP» » » » » 4 | 32 #define PWL_GETLOWWORD(dword) ((FX_WORD)(dword)) |
33 #define PWL_ICONTYPE_INSERTTEXT»» » » 5 | 33 #define PWL_GETHIGHWORD(dword) ((FX_WORD)(dword >> 16)) |
34 #define PWL_ICONTYPE_KEY» » » » » 6 | 34 |
35 #define PWL_ICONTYPE_NEWPARAGRAPH» » » 7 | 35 #define PWL_ICONTYPE_CHECKMARK 0 |
36 #define PWL_ICONTYPE_TEXTNOTE» » » » 8 | 36 #define PWL_ICONTYPE_CIRCLE 1 |
37 #define PWL_ICONTYPE_PARAGRAPH» » » » 9 | 37 #define PWL_ICONTYPE_COMMENT 2 |
38 #define PWL_ICONTYPE_RIGHTARROW»» » » 10 | 38 #define PWL_ICONTYPE_CROSS 3 |
39 #define PWL_ICONTYPE_RIGHTPOINTER» » » 11 | 39 #define PWL_ICONTYPE_HELP 4 |
40 #define PWL_ICONTYPE_STAR» » » » » 12 | 40 #define PWL_ICONTYPE_INSERTTEXT 5 |
41 #define PWL_ICONTYPE_UPARROW» » » » 13 | 41 #define PWL_ICONTYPE_KEY 6 |
42 #define PWL_ICONTYPE_UPLEFTARROW» » » 14 | 42 #define PWL_ICONTYPE_NEWPARAGRAPH 7 |
43 | 43 #define PWL_ICONTYPE_TEXTNOTE 8 |
44 #define PWL_ICONTYPE_GRAPH» » » » » 15 | 44 #define PWL_ICONTYPE_PARAGRAPH 9 |
45 #define PWL_ICONTYPE_PAPERCLIP» » » » 16 | 45 #define PWL_ICONTYPE_RIGHTARROW 10 |
46 #define PWL_ICONTYPE_ATTACHMENT»» » » 17 | 46 #define PWL_ICONTYPE_RIGHTPOINTER 11 |
47 #define PWL_ICONTYPE_TAG» » » » » 18 | 47 #define PWL_ICONTYPE_STAR 12 |
48 | 48 #define PWL_ICONTYPE_UPARROW 13 |
49 #define PWL_ICONTYPE_FOXIT» » » » » 19 | 49 #define PWL_ICONTYPE_UPLEFTARROW 14 |
50 | 50 |
51 #define PWL_ICONTYPE_UNKNOWN» » » » -1 | 51 #define PWL_ICONTYPE_GRAPH 15 |
52 | 52 #define PWL_ICONTYPE_PAPERCLIP 16 |
53 //checkbox & radiobutton style | 53 #define PWL_ICONTYPE_ATTACHMENT 17 |
54 #define PCS_CHECK» » » » » » » 0 | 54 #define PWL_ICONTYPE_TAG 18 |
55 #define PCS_CIRCLE» » » » » » » 1 | 55 |
56 #define PCS_CROSS» » » » » » » 2 | 56 #define PWL_ICONTYPE_FOXIT 19 |
57 #define PCS_DIAMOND» » » » » » » 3 | 57 |
58 #define PCS_SQUARE» » » » » » » 4 | 58 #define PWL_ICONTYPE_UNKNOWN -1 |
59 #define PCS_STAR» » » » » » » 5 | 59 |
60 | 60 // checkbox & radiobutton style |
61 #define»PWL_PI» » » » » » » » 3.141592
65358979f | 61 #define PCS_CHECK 0 |
62 #define PWL_BEZIER» » » » » » » 0.552284
7498308f | 62 #define PCS_CIRCLE 1 |
63 | 63 #define PCS_CROSS 2 |
64 //pushbutton layout style | 64 #define PCS_DIAMOND 3 |
65 #define PPBL_LABEL» » » » » » » 0 | 65 #define PCS_SQUARE 4 |
66 #define PPBL_ICON» » » » » » » 1 | 66 #define PCS_STAR 5 |
67 #define PPBL_ICONTOPLABELBOTTOM»» » » 2 | 67 |
68 #define»PPBL_LABELTOPICONBOTTOM»» » » 3 | 68 #define PWL_PI 3.14159265358979f |
69 #define»PPBL_ICONLEFTLABELRIGHT»» » » 4 | 69 #define PWL_BEZIER 0.5522847498308f |
70 #define PPBL_LABELLEFTICONRIGHT»» » » 5 | 70 |
71 #define PPBL_LABELOVERICON» » » » » 6 | 71 // pushbutton layout style |
72 | 72 #define PPBL_LABEL 0 |
73 class CPWL_Point : public CPDF_Point | 73 #define PPBL_ICON 1 |
74 { | 74 #define PPBL_ICONTOPLABELBOTTOM 2 |
75 public: | 75 #define PPBL_LABELTOPICONBOTTOM 3 |
76 » CPWL_Point() : CPDF_Point(0.0f,0.0f){} | 76 #define PPBL_ICONLEFTLABELRIGHT 4 |
77 » CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CPDF_Point(fx,fy) {} | 77 #define PPBL_LABELLEFTICONRIGHT 5 |
78 » CPWL_Point(const CPWL_Point& point) : CPDF_Point(point.x, point.y) {} | 78 #define PPBL_LABELOVERICON 6 |
| 79 |
| 80 class CPWL_Point : public CPDF_Point { |
| 81 public: |
| 82 CPWL_Point() : CPDF_Point(0.0f, 0.0f) {} |
| 83 CPWL_Point(FX_FLOAT fx, FX_FLOAT fy) : CPDF_Point(fx, fy) {} |
| 84 CPWL_Point(const CPWL_Point& point) : CPDF_Point(point.x, point.y) {} |
79 }; | 85 }; |
80 | 86 |
81 enum PWL_PATHDATA_TYPE | 87 enum PWL_PATHDATA_TYPE { |
82 { | 88 PWLPT_MOVETO, |
83 » PWLPT_MOVETO, | 89 PWLPT_LINETO, |
84 » PWLPT_LINETO, | 90 PWLPT_BEZIERTO, |
85 » PWLPT_BEZIERTO, | 91 PWLPT_UNKNOWN |
86 » PWLPT_UNKNOWN | |
87 }; | 92 }; |
88 | 93 |
89 enum PWL_PATH_TYPE | 94 enum PWL_PATH_TYPE { PWLPT_PATHDATA, PWLPT_STREAM }; |
90 { | 95 |
91 » PWLPT_PATHDATA, | 96 class CPWL_PathData { |
92 » PWLPT_STREAM | 97 public: |
| 98 CPWL_PathData() : point(), type(PWLPT_UNKNOWN) {} |
| 99 CPWL_PathData(const CPWL_Point& pt, PWL_PATHDATA_TYPE tp) |
| 100 : point(pt), type(tp) {} |
| 101 |
| 102 CPWL_Point point; |
| 103 PWL_PATHDATA_TYPE type; |
93 }; | 104 }; |
94 | 105 |
95 class CPWL_PathData | 106 class IPWL_SpellCheck; |
96 { | 107 |
97 public: | 108 class CPWL_Utils { |
98 CPWL_PathData() : point(), type(PWLPT_UNKNOWN){} | 109 public: |
99 CPWL_PathData(const CPWL_Point& pt, PWL_PATHDATA_TYPE tp) : point(pt), t
ype(tp) {} | 110 static CPDF_Rect InflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); |
100 | 111 static CPDF_Rect DeflateRect(const CPDF_Rect& rcRect, FX_FLOAT fSize); |
101 CPWL_Point
point; | 112 static FX_BOOL IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); |
102 PWL_PATHDATA_TYPE type; | 113 static FX_BOOL ContainsRect(const CPDF_Rect& rcParent, |
| 114 const CPDF_Rect& rcChild); |
| 115 static CPDF_Rect ScaleRect(const CPDF_Rect& rcRect, FX_FLOAT fScale); |
| 116 static CPVT_WordRange OverlapWordRange(const CPVT_WordRange& wr1, |
| 117 const CPVT_WordRange& wr2); |
| 118 static CPDF_Rect GetCenterSquare(const CPDF_Rect& rect); |
| 119 static CPWL_Color SubstractColor(const CPWL_Color& sColor, |
| 120 FX_FLOAT fColorSub); |
| 121 static CPWL_Color DevideColor(const CPWL_Color& sColor, |
| 122 FX_FLOAT fColorDevide); |
| 123 static CPDF_Rect MaxRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); |
| 124 static CPDF_Rect OffsetRect(const CPDF_Rect& rect, FX_FLOAT x, FX_FLOAT y); |
| 125 static CPDF_Point OffsetPoint(const CPDF_Point& point, |
| 126 FX_FLOAT x, |
| 127 FX_FLOAT y); |
| 128 static FX_COLORREF PWLColorToFXColor(const CPWL_Color& color, |
| 129 int32_t nTransparancy = 255); |
| 130 static FX_BOOL IsBlackOrWhite(const CPWL_Color& color); |
| 131 static CPWL_Color GetReverseColor(const CPWL_Color& color); |
| 132 |
| 133 static CFX_ByteString GetColorAppStream(const CPWL_Color& color, |
| 134 const FX_BOOL& bFillOrStroke = TRUE); |
| 135 static CFX_ByteString GetBorderAppStream(const CPDF_Rect& rect, |
| 136 FX_FLOAT fWidth, |
| 137 const CPWL_Color& color, |
| 138 const CPWL_Color& crLeftTop, |
| 139 const CPWL_Color& crRightBottom, |
| 140 int32_t nStyle, |
| 141 const CPWL_Dash& dash); |
| 142 static CFX_ByteString GetCircleBorderAppStream( |
| 143 const CPDF_Rect& rect, |
| 144 FX_FLOAT fWidth, |
| 145 const CPWL_Color& color, |
| 146 const CPWL_Color& crLeftTop, |
| 147 const CPWL_Color& crRightBottom, |
| 148 int32_t nStyle, |
| 149 const CPWL_Dash& dash); |
| 150 static CFX_ByteString GetRectFillAppStream(const CPDF_Rect& rect, |
| 151 const CPWL_Color& color); |
| 152 static CFX_ByteString GetCircleFillAppStream(const CPDF_Rect& rect, |
| 153 const CPWL_Color& color); |
| 154 |
| 155 static CFX_ByteString GetPushButtonAppStream(const CPDF_Rect& rcBBox, |
| 156 IFX_Edit_FontMap* pFontMap, |
| 157 CPDF_Stream* pIconStream, |
| 158 CPDF_IconFit& IconFit, |
| 159 const CFX_WideString& sLabel, |
| 160 const CPWL_Color& crText, |
| 161 FX_FLOAT fFontSize, |
| 162 int32_t nLayOut); |
| 163 static CFX_ByteString GetCheckBoxAppStream(const CPDF_Rect& rcBBox, |
| 164 int32_t nStyle, |
| 165 const CPWL_Color& crText); |
| 166 static CFX_ByteString GetRadioButtonAppStream(const CPDF_Rect& rcBBox, |
| 167 int32_t nStyle, |
| 168 const CPWL_Color& crText); |
| 169 |
| 170 static CFX_ByteString GetEditAppStream(IFX_Edit* pEdit, |
| 171 const CPDF_Point& ptOffset, |
| 172 const CPVT_WordRange* pRange = NULL, |
| 173 FX_BOOL bContinuous = TRUE, |
| 174 FX_WORD SubWord = 0); |
| 175 static CFX_ByteString GetEditSelAppStream( |
| 176 IFX_Edit* pEdit, |
| 177 const CPDF_Point& ptOffset, |
| 178 const CPVT_WordRange* pRange = NULL); |
| 179 static CFX_ByteString GetSpellCheckAppStream( |
| 180 IFX_Edit* pEdit, |
| 181 IPWL_SpellCheck* pSpellCheck, |
| 182 const CPDF_Point& ptOffset, |
| 183 const CPVT_WordRange* pRange = NULL); |
| 184 static CFX_ByteString GetTextAppStream(const CPDF_Rect& rcBBox, |
| 185 IFX_Edit_FontMap* pFontMap, |
| 186 const CFX_WideString& sText, |
| 187 int32_t nAlignmentH, |
| 188 int32_t nAlignmentV, |
| 189 FX_FLOAT fFontSize, |
| 190 FX_BOOL bMultiLine, |
| 191 FX_BOOL bAutoReturn, |
| 192 const CPWL_Color& crText); |
| 193 static CFX_ByteString GetDropButtonAppStream(const CPDF_Rect& rcBBox); |
| 194 |
| 195 static void DrawFillRect(CFX_RenderDevice* pDevice, |
| 196 CPDF_Matrix* pUser2Device, |
| 197 const CPDF_Rect& rect, |
| 198 const CPWL_Color& color, |
| 199 int32_t nTransparancy); |
| 200 static void DrawFillRect(CFX_RenderDevice* pDevice, |
| 201 CPDF_Matrix* pUser2Device, |
| 202 const CPDF_Rect& rect, |
| 203 const FX_COLORREF& color); |
| 204 static void DrawStrokeRect(CFX_RenderDevice* pDevice, |
| 205 CPDF_Matrix* pUser2Device, |
| 206 const CPDF_Rect& rect, |
| 207 const FX_COLORREF& color, |
| 208 FX_FLOAT fWidth); |
| 209 static void DrawStrokeLine(CFX_RenderDevice* pDevice, |
| 210 CPDF_Matrix* pUser2Device, |
| 211 const CPDF_Point& ptMoveTo, |
| 212 const CPDF_Point& ptLineTo, |
| 213 const FX_COLORREF& color, |
| 214 FX_FLOAT fWidth); |
| 215 static void DrawBorder(CFX_RenderDevice* pDevice, |
| 216 CPDF_Matrix* pUser2Device, |
| 217 const CPDF_Rect& rect, |
| 218 FX_FLOAT fWidth, |
| 219 const CPWL_Color& color, |
| 220 const CPWL_Color& crLeftTop, |
| 221 const CPWL_Color& crRightBottom, |
| 222 int32_t nStyle, |
| 223 const CPWL_Dash& dash, |
| 224 int32_t nTransparancy); |
| 225 static void DrawFillArea(CFX_RenderDevice* pDevice, |
| 226 CPDF_Matrix* pUser2Device, |
| 227 const CPDF_Point* pPts, |
| 228 int32_t nCount, |
| 229 const FX_COLORREF& color); |
| 230 static void DrawShadow(CFX_RenderDevice* pDevice, |
| 231 CPDF_Matrix* pUser2Device, |
| 232 FX_BOOL bVertical, |
| 233 FX_BOOL bHorizontal, |
| 234 CPDF_Rect rect, |
| 235 int32_t nTransparancy, |
| 236 int32_t nStartGray, |
| 237 int32_t nEndGray); |
| 238 static void DrawEditSpellCheck(CFX_RenderDevice* pDevice, |
| 239 CPDF_Matrix* pUser2Device, |
| 240 IFX_Edit* pEdit, |
| 241 const CPDF_Rect& rcClip, |
| 242 const CPDF_Point& ptOffset, |
| 243 const CPVT_WordRange* pRange, |
| 244 IPWL_SpellCheck* pSpellCheck); |
| 245 |
| 246 public: |
| 247 static void ConvertCMYK2RGB(FX_FLOAT dC, |
| 248 FX_FLOAT dM, |
| 249 FX_FLOAT dY, |
| 250 FX_FLOAT dK, |
| 251 FX_FLOAT& dR, |
| 252 FX_FLOAT& dG, |
| 253 FX_FLOAT& dB); |
| 254 static void ConvertRGB2CMYK(FX_FLOAT dR, |
| 255 FX_FLOAT dG, |
| 256 FX_FLOAT dB, |
| 257 FX_FLOAT& dC, |
| 258 FX_FLOAT& dM, |
| 259 FX_FLOAT& dY, |
| 260 FX_FLOAT& dK); |
| 261 |
| 262 static void ConvertRGB2GRAY(FX_FLOAT dR, |
| 263 FX_FLOAT dG, |
| 264 FX_FLOAT dB, |
| 265 FX_FLOAT& dGray); |
| 266 static void ConvertGRAY2RGB(FX_FLOAT dGray, |
| 267 FX_FLOAT& dR, |
| 268 FX_FLOAT& dG, |
| 269 FX_FLOAT& dB); |
| 270 |
| 271 static void ConvertCMYK2GRAY(FX_FLOAT dC, |
| 272 FX_FLOAT dM, |
| 273 FX_FLOAT dY, |
| 274 FX_FLOAT dK, |
| 275 FX_FLOAT& dGray); |
| 276 static void ConvertGRAY2CMYK(FX_FLOAT dGray, |
| 277 FX_FLOAT& dC, |
| 278 FX_FLOAT& dM, |
| 279 FX_FLOAT& dY, |
| 280 FX_FLOAT& dK); |
| 281 |
| 282 static void PWLColorToARGB(const CPWL_Color& color, |
| 283 int32_t& alpha, |
| 284 FX_FLOAT& red, |
| 285 FX_FLOAT& green, |
| 286 FX_FLOAT& blue); |
| 287 |
| 288 public: |
| 289 static CFX_ByteString GetIconAppStream( |
| 290 int32_t nType, |
| 291 const CPDF_Rect& rect, |
| 292 const CPWL_Color& crFill, |
| 293 const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR); |
| 294 static void DrawIconAppStream(CFX_RenderDevice* pDevice, |
| 295 CPDF_Matrix* pUser2Device, |
| 296 int32_t nType, |
| 297 const CPDF_Rect& rect, |
| 298 const CPWL_Color& crFill, |
| 299 const CPWL_Color& crStroke, |
| 300 const int32_t nTransparancy); |
| 301 |
| 302 private: |
| 303 static CFX_ByteString GetAppStreamFromArray(const CPWL_PathData* pPathData, |
| 304 int32_t nCount); |
| 305 static void GetPathDataFromArray(CFX_PathData& path, |
| 306 const CPWL_PathData* pPathData, |
| 307 int32_t nCount); |
| 308 |
| 309 static CFX_ByteString GetAppStream_Check(const CPDF_Rect& rcBBox, |
| 310 const CPWL_Color& crText); |
| 311 static CFX_ByteString GetAppStream_Circle(const CPDF_Rect& rcBBox, |
| 312 const CPWL_Color& crText); |
| 313 static CFX_ByteString GetAppStream_Cross(const CPDF_Rect& rcBBox, |
| 314 const CPWL_Color& crText); |
| 315 static CFX_ByteString GetAppStream_Diamond(const CPDF_Rect& rcBBox, |
| 316 const CPWL_Color& crText); |
| 317 static CFX_ByteString GetAppStream_Square(const CPDF_Rect& rcBBox, |
| 318 const CPWL_Color& crText); |
| 319 static CFX_ByteString GetAppStream_Star(const CPDF_Rect& rcBBox, |
| 320 const CPWL_Color& crText); |
| 321 |
| 322 static CFX_ByteString GetAP_Check(const CPDF_Rect& crBBox); |
| 323 static CFX_ByteString GetAP_Circle(const CPDF_Rect& crBBox); |
| 324 static CFX_ByteString GetAP_Cross(const CPDF_Rect& crBBox); |
| 325 static CFX_ByteString GetAP_Diamond(const CPDF_Rect& crBBox); |
| 326 static CFX_ByteString GetAP_Square(const CPDF_Rect& crBBox); |
| 327 static CFX_ByteString GetAP_Star(const CPDF_Rect& crBBox); |
| 328 static CFX_ByteString GetAP_HalfCircle(const CPDF_Rect& crBBox, |
| 329 FX_FLOAT fRotate); |
| 330 |
| 331 static void GetGraphics_Checkmark(CFX_ByteString& sPathData, |
| 332 CFX_PathData& path, |
| 333 const CPDF_Rect& crBBox, |
| 334 const PWL_PATH_TYPE type); |
| 335 static void GetGraphics_Circle(CFX_ByteString& sPathData, |
| 336 CFX_PathData& path, |
| 337 const CPDF_Rect& crBBox, |
| 338 const PWL_PATH_TYPE type); |
| 339 static void GetGraphics_Comment(CFX_ByteString& sPathData, |
| 340 CFX_PathData& path, |
| 341 const CPDF_Rect& crBBox, |
| 342 const PWL_PATH_TYPE type); |
| 343 static void GetGraphics_Cross(CFX_ByteString& sPathData, |
| 344 CFX_PathData& path, |
| 345 const CPDF_Rect& crBBox, |
| 346 const PWL_PATH_TYPE type); |
| 347 static void GetGraphics_Help(CFX_ByteString& sPathData, |
| 348 CFX_PathData& path, |
| 349 const CPDF_Rect& crBBox, |
| 350 const PWL_PATH_TYPE type); |
| 351 static void GetGraphics_InsertText(CFX_ByteString& sPathData, |
| 352 CFX_PathData& path, |
| 353 const CPDF_Rect& crBBox, |
| 354 const PWL_PATH_TYPE type); |
| 355 static void GetGraphics_Key(CFX_ByteString& sPathData, |
| 356 CFX_PathData& path, |
| 357 const CPDF_Rect& crBBox, |
| 358 const PWL_PATH_TYPE type); |
| 359 static void GetGraphics_NewParagraph(CFX_ByteString& sPathData, |
| 360 CFX_PathData& path, |
| 361 const CPDF_Rect& crBBox, |
| 362 const PWL_PATH_TYPE type); |
| 363 static void GetGraphics_TextNote(CFX_ByteString& sPathData, |
| 364 CFX_PathData& path, |
| 365 const CPDF_Rect& crBBox, |
| 366 const PWL_PATH_TYPE type); |
| 367 static void GetGraphics_Paragraph(CFX_ByteString& sPathData, |
| 368 CFX_PathData& path, |
| 369 const CPDF_Rect& crBBox, |
| 370 const PWL_PATH_TYPE type); |
| 371 static void GetGraphics_RightArrow(CFX_ByteString& sPathData, |
| 372 CFX_PathData& path, |
| 373 const CPDF_Rect& crBBox, |
| 374 const PWL_PATH_TYPE type); |
| 375 static void GetGraphics_RightPointer(CFX_ByteString& sPathData, |
| 376 CFX_PathData& path, |
| 377 const CPDF_Rect& crBBox, |
| 378 const PWL_PATH_TYPE type); |
| 379 static void GetGraphics_Star(CFX_ByteString& sPathData, |
| 380 CFX_PathData& path, |
| 381 const CPDF_Rect& crBBox, |
| 382 const PWL_PATH_TYPE type); |
| 383 static void GetGraphics_UpArrow(CFX_ByteString& sPathData, |
| 384 CFX_PathData& path, |
| 385 const CPDF_Rect& crBBox, |
| 386 const PWL_PATH_TYPE type); |
| 387 static void GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, |
| 388 CFX_PathData& path, |
| 389 const CPDF_Rect& crBBox, |
| 390 const PWL_PATH_TYPE type); |
| 391 static void GetGraphics_Graph(CFX_ByteString& sPathData, |
| 392 CFX_PathData& path, |
| 393 const CPDF_Rect& crBBox, |
| 394 const PWL_PATH_TYPE type); |
| 395 static void GetGraphics_Paperclip(CFX_ByteString& sPathData, |
| 396 CFX_PathData& path, |
| 397 const CPDF_Rect& crBBox, |
| 398 const PWL_PATH_TYPE type); |
| 399 static void GetGraphics_Attachment(CFX_ByteString& sPathData, |
| 400 CFX_PathData& path, |
| 401 const CPDF_Rect& crBBox, |
| 402 const PWL_PATH_TYPE type); |
| 403 static void GetGraphics_Tag(CFX_ByteString& sPathData, |
| 404 CFX_PathData& path, |
| 405 const CPDF_Rect& crBBox, |
| 406 const PWL_PATH_TYPE type); |
| 407 static void GetGraphics_Foxit(CFX_ByteString& sPathData, |
| 408 CFX_PathData& path, |
| 409 const CPDF_Rect& crBBox, |
| 410 const PWL_PATH_TYPE type); |
103 }; | 411 }; |
104 | 412 |
105 class IPWL_SpellCheck; | |
106 | |
107 class CPWL_Utils | |
108 { | |
109 public: | |
110 static CPDF_Rect InflateR
ect(const CPDF_Rect& rcRect, FX_FLOAT fSize); | |
111 static CPDF_Rect DeflateR
ect(const CPDF_Rect& rcRect, FX_FLOAT fSize); | |
112 static FX_BOOL Intersec
tRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2); | |
113 static FX_BOOL Contains
Rect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild); | |
114 static CPDF_Rect ScaleRec
t(const CPDF_Rect& rcRect,FX_FLOAT fScale); | |
115 static CPVT_WordRange OverlapWordRange
(const CPVT_WordRange& wr1, const CPVT_WordRange& wr2); | |
116 static CPDF_Rect GetCente
rSquare(const CPDF_Rect & rect); | |
117 static CPWL_Color Substrac
tColor(const CPWL_Color & sColor,FX_FLOAT fColorSub); | |
118 static CPWL_Color DevideCo
lor(const CPWL_Color & sColor,FX_FLOAT fColorDevide); | |
119 static CPDF_Rect MaxRect(
const CPDF_Rect & rect1,const CPDF_Rect & rect2); | |
120 static CPDF_Rect OffsetRe
ct(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y); | |
121 static CPDF_Point OffsetPo
int(const CPDF_Point & point,FX_FLOAT x,FX_FLOAT y); | |
122 static FX_COLORREF PWLColor
ToFXColor(const CPWL_Color& color, int32_t nTransparancy = 255); | |
123 static FX_BOOL IsBlackO
rWhite(const CPWL_Color& color); | |
124 static CPWL_Color GetRever
seColor(const CPWL_Color& color); | |
125 | |
126 static CFX_ByteString GetColorAppStrea
m(const CPWL_Color & color,const FX_BOOL & bFillOrStroke = TRUE); | |
127 static CFX_ByteString GetBorderAppStre
am(const CPDF_Rect & rect, FX_FLOAT fWidth, | |
128
const CPWL_Color & color, const CPWL_Color & crLeftTop, const CP
WL_Color & crRightBottom, | |
129
int32_t nStyle, const CPWL_Dash & dash); | |
130 static CFX_ByteString GetCircleBorderA
ppStream(const CPDF_Rect & rect, FX_FLOAT fWidth, | |
131
const CPWL_Color & color, const CPWL_Color & crLeftTop, const CP
WL_Color & crRightBottom, | |
132
int32_t nStyle, const CPWL_Dash & dash); | |
133 static CFX_ByteString GetRectFillAppSt
ream(const CPDF_Rect & rect,const CPWL_Color & color); | |
134 static CFX_ByteString GetCircleFillApp
Stream(const CPDF_Rect & rect,const CPWL_Color & color); | |
135 | |
136 static CFX_ByteString GetPushButtonApp
Stream(const CPDF_Rect & rcBBox, | |
137
IFX_Edit_FontMap * pFontMap, | |
138
CPDF_Stream * pIconStream, | |
139
CPDF_IconFit & IconFit, | |
140
const CFX_WideString & sLabel, | |
141
const CPWL_Color & crText, | |
142
FX_FLOAT fFontSize, | |
143
int32_t nLayOut); | |
144 static CFX_ByteString GetCheckBoxAppSt
ream(const CPDF_Rect & rcBBox, | |
145
int32_t nStyle, | |
146
const CPWL_Color & crText); | |
147 static CFX_ByteString GetRadioButtonAp
pStream(const CPDF_Rect & rcBBox, | |
148
int32_t nStyle, | |
149
const CPWL_Color & crText); | |
150 | |
151 static CFX_ByteString GetEditAppStream
(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange * pRange = N
ULL, | |
152
FX_BOOL bContinuous = TRUE, FX_WORD SubWord = 0)
; | |
153 static CFX_ByteString GetEditSelAppStr
eam(IFX_Edit* pEdit, const CPDF_Point & ptOffset, | |
154
const CPVT_WordRange * pRange = NULL); | |
155 static CFX_ByteString GetSpellCheckApp
Stream(IFX_Edit* pEdit, IPWL_SpellCheck* pSpellCheck, | |
156
const CPDF_Point & ptOffset, | |
157
const CPVT_WordRange * pRange = NULL); | |
158 static CFX_ByteString GetTextAppStream
(const CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap, | |
159
const CFX_WideString & sText, int32_t nAlignment
H, int32_t nAlignmentV, | |
160
FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL
bAutoReturn, const CPWL_Color & crText); | |
161 static CFX_ByteString GetDropButtonApp
Stream(const CPDF_Rect & rcBBox); | |
162 | |
163 static void
DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rec
t & rect, | |
164
const CPWL_Color & color, int32_t nTransparancy)
; | |
165 static void
DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | |
166
const CPDF_Rect & rect,const FX_COLORREF & color
); | |
167 static void
DrawStrokeRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_R
ect & rect, | |
168
const FX_COLORREF & color, FX_FLOAT fWidth); | |
169 static void
DrawStrokeLine(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | |
170
const CPDF_Point & ptMoveTo, const CPDF_Point &
ptLineTo, const FX_COLORREF & color, FX_FLOAT fWidth); | |
171 static void
DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | |
172
const CPDF_Rect & rect, FX_FLOAT fWidth, | |
173
const CPWL_Color & color, const CPWL_Color & crLeftTop, const CP
WL_Color & crRightBottom, | |
174
int32_t nStyle, const CPWL_Dash & dash, int32_t nTransparancy); | |
175 static void
DrawFillArea(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | |
176
const CPDF_Point* pPts, int32_t nCount, const FX
_COLORREF& color); | |
177 static void
DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | |
178
FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rec
t rect, | |
179
int32_t nTransparancy, int32_t nStartGray, int32
_t nEndGray); | |
180 static void
DrawEditSpellCheck(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edi
t* pEdit, | |
181
const CPDF_Rect& rcClip, const CPDF_Point& ptOff
set, const CPVT_WordRange* pRange, | |
182
IPWL_SpellCheck* pSpellCheck); | |
183 public: | |
184 static void
ConvertCMYK2RGB(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dR,FX_
FLOAT &dG,FX_FLOAT &dB); | |
185 static void
ConvertRGB2CMYK(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dC,FX_FLOAT &dM,FX
_FLOAT &dY,FX_FLOAT &dK); | |
186 | |
187 static void
ConvertRGB2GRAY(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dGray); | |
188 static void
ConvertGRAY2RGB(FX_FLOAT dGray,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB); | |
189 | |
190 static void
ConvertCMYK2GRAY(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dGray
); | |
191 static void
ConvertGRAY2CMYK(FX_FLOAT dGray,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT
&dK); | |
192 | |
193 static void
PWLColorToARGB(const CPWL_Color& color, int32_t& alpha, FX_FLOAT& red, FX_FLOAT&
green, FX_FLOAT& blue); | |
194 | |
195 public: | |
196 static CFX_ByteString GetIconAppStream
(int32_t nType, const CPDF_Rect& rect, const CPWL_Color& crFill, | |
197
const CPWL_Color& crStroke = PWL_DEFAULT_BLACKCOLOR); | |
198 static void
DrawIconAppStream(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, | |
199
int32_t nType, const CPDF_Rect & rect, const CPWL_Color& crFill, | |
200
const CPWL_Color& crStroke, const int32_t nTransparancy); | |
201 | |
202 private: | |
203 static CFX_ByteString GetAppStreamFrom
Array(const CPWL_PathData* pPathData, int32_t nCount); | |
204 static void
GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, int32_t
nCount); | |
205 | |
206 static CFX_ByteString GetAppStream_Che
ck(const CPDF_Rect & rcBBox, const CPWL_Color & crText); | |
207 static CFX_ByteString GetAppStream_Cir
cle(const CPDF_Rect & rcBBox, const CPWL_Color & crText); | |
208 static CFX_ByteString GetAppStream_Cro
ss(const CPDF_Rect & rcBBox, const CPWL_Color & crText); | |
209 static CFX_ByteString GetAppStream_Dia
mond(const CPDF_Rect & rcBBox, const CPWL_Color & crText); | |
210 static CFX_ByteString GetAppStream_Squ
are(const CPDF_Rect & rcBBox, const CPWL_Color & crText); | |
211 static CFX_ByteString GetAppStream_Sta
r(const CPDF_Rect & rcBBox, const CPWL_Color & crText); | |
212 | |
213 static CFX_ByteString GetAP_Check(cons
t CPDF_Rect & crBBox); | |
214 static CFX_ByteString GetAP_Circle(con
st CPDF_Rect & crBBox); | |
215 static CFX_ByteString GetAP_Cross(cons
t CPDF_Rect & crBBox); | |
216 static CFX_ByteString GetAP_Diamond(co
nst CPDF_Rect & crBBox); | |
217 static CFX_ByteString GetAP_Square(con
st CPDF_Rect & crBBox); | |
218 static CFX_ByteString GetAP_Star(const
CPDF_Rect & crBBox); | |
219 static CFX_ByteString GetAP_HalfCircle
(const CPDF_Rect & crBBox,FX_FLOAT fRotate); | |
220 | |
221 static void
GetGraphics_Checkmark(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_
Rect& crBBox, const PWL_PATH_TYPE type); | |
222 static void
GetGraphics_Circle(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rec
t& crBBox, const PWL_PATH_TYPE type); | |
223 static void
GetGraphics_Comment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Re
ct& crBBox, const PWL_PATH_TYPE type); | |
224 static void
GetGraphics_Cross(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect
& crBBox, const PWL_PATH_TYPE type); | |
225 static void
GetGraphics_Help(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect&
crBBox, const PWL_PATH_TYPE type); | |
226 static void
GetGraphics_InsertText(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF
_Rect& crBBox, const PWL_PATH_TYPE type); | |
227 static void
GetGraphics_Key(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect&
crBBox, const PWL_PATH_TYPE type); | |
228 static void
GetGraphics_NewParagraph(CFX_ByteString& sPathData, CFX_PathData& path, const CP
DF_Rect& crBBox, const PWL_PATH_TYPE type); | |
229 static void
GetGraphics_TextNote(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_R
ect& crBBox, const PWL_PATH_TYPE type); | |
230 static void
GetGraphics_Paragraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_
Rect& crBBox, const PWL_PATH_TYPE type); | |
231 static void
GetGraphics_RightArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF
_Rect& crBBox, const PWL_PATH_TYPE type); | |
232 static void
GetGraphics_RightPointer(CFX_ByteString& sPathData, CFX_PathData& path, const CP
DF_Rect& crBBox, const PWL_PATH_TYPE type); | |
233 static void
GetGraphics_Star(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect&
crBBox, const PWL_PATH_TYPE type); | |
234 static void
GetGraphics_UpArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Re
ct& crBBox, const PWL_PATH_TYPE type); | |
235 static void
GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPD
F_Rect& crBBox, const PWL_PATH_TYPE type); | |
236 static void
GetGraphics_Graph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect
& crBBox, const PWL_PATH_TYPE type); | |
237 static void
GetGraphics_Paperclip(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_
Rect& crBBox, const PWL_PATH_TYPE type); | |
238 static void
GetGraphics_Attachment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF
_Rect& crBBox, const PWL_PATH_TYPE type); | |
239 static void
GetGraphics_Tag(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect&
crBBox, const PWL_PATH_TYPE type); | |
240 static void
GetGraphics_Foxit(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect
& crBBox, const PWL_PATH_TYPE type); | |
241 }; | |
242 | |
243 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ | 413 #endif // FPDFSDK_INCLUDE_PDFWINDOW_PWL_UTILS_H_ |
OLD | NEW |