Home | History | Annotate | Download | only in pdfwindow
      1 // Copyright 2014 PDFium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
      6 
      7 #include "../../include/pdfwindow/PDFWindow.h"
      8 #include "../../include/pdfwindow/PWL_Wnd.h"
      9 #include "../../include/pdfwindow/PWL_Utils.h"
     10 #include "../../include/pdfwindow/PWL_Icon.h"
     11 
     12 #define IsFloatZero(f)						((f) < 0.0001 && (f) > -0.0001)
     13 #define IsFloatBigger(fa,fb)				((fa) > (fb) && !IsFloatZero((fa) - (fb)))
     14 #define IsFloatSmaller(fa,fb)				((fa) < (fb) && !IsFloatZero((fa) - (fb)))
     15 #define IsFloatEqual(fa,fb)					IsFloatZero((fa)-(fb))
     16 
     17 /* ---------------------------- CPWL_Utils ------------------------------ */
     18 
     19 CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, FX_INT32 nCount)
     20 {
     21 	CFX_ByteTextBuf csAP;
     22 
     23 	for (FX_INT32 i=0; i<nCount; i++)
     24 	{
     25 		switch (pPathData[i].type)
     26 		{
     27 		case PWLPT_MOVETO:
     28 			csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
     29 			break;
     30 		case PWLPT_LINETO:
     31 			csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n";
     32 			break;
     33 		case PWLPT_BEZIERTO:
     34 			csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " "
     35 				 << pPathData[i+1].point.x << " " << pPathData[i+1].point.y << " "
     36 				 << pPathData[i+2].point.x << " " << pPathData[i+2].point.y << " c\n";
     37 
     38 			i += 2;
     39 			break;
     40 		default:
     41 			break;
     42 		}
     43 	}
     44 
     45 	return csAP.GetByteString();
     46 }
     47 
     48 void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, const CPWL_PathData* pPathData, FX_INT32 nCount)
     49 {
     50 	path.SetPointCount(nCount);
     51 
     52 	for (FX_INT32 i=0; i<nCount; i++)
     53 	{
     54 		switch (pPathData[i].type)
     55 		{
     56 		case PWLPT_MOVETO:
     57 			path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_MOVETO);
     58 			break;
     59 		case PWLPT_LINETO:
     60 			path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_LINETO);
     61 			break;
     62 		case PWLPT_BEZIERTO:
     63 			path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, FXPT_BEZIERTO);
     64 			break;
     65 		default:
     66 			break;
     67 		}
     68 	}
     69 }
     70 
     71 
     72 CPDF_Rect CPWL_Utils::MaxRect(const CPDF_Rect & rect1,const CPDF_Rect & rect2)
     73 {
     74 	CPDF_Rect rcRet;
     75 
     76 	rcRet.left = PWL_MIN(rect1.left,rect2.left);
     77 	rcRet.bottom = PWL_MIN(rect1.bottom,rect2.bottom);
     78 	rcRet.right = PWL_MAX(rect1.right,rect2.right);
     79 	rcRet.top = PWL_MAX(rect1.top,rect2.top);
     80 
     81 	return rcRet;
     82 }
     83 
     84 CPDF_Rect CPWL_Utils::OffsetRect(const CPDF_Rect & rect,FX_FLOAT x,FX_FLOAT y)
     85 {
     86 	return CPDF_Rect(rect.left + x,rect.bottom + y,
     87 		rect.right + x,rect.top + y);
     88 }
     89 
     90 FX_BOOL CPWL_Utils::ContainsRect(const CPDF_Rect& rcParent, const CPDF_Rect& rcChild)
     91 {
     92 	return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom &&
     93 			rcChild.right <= rcParent.right && rcChild.top <= rcParent.top;
     94 }
     95 
     96 FX_BOOL CPWL_Utils::IntersectRect(const CPDF_Rect& rect1, const CPDF_Rect& rect2)
     97 {
     98 	FX_FLOAT left = rect1.left > rect2.left ? rect1.left : rect2.left;
     99 	FX_FLOAT right = rect1.right < rect2.right ? rect1.right : rect2.right;
    100 	FX_FLOAT bottom = rect1.bottom > rect2.bottom ? rect1.bottom : rect2.bottom;
    101 	FX_FLOAT top = rect1.top < rect2.top ? rect1.top : rect2.top;
    102 
    103 	return left < right && bottom < top;
    104 }
    105 
    106 CPDF_Point CPWL_Utils::OffsetPoint(const CPDF_Point& point,FX_FLOAT x,FX_FLOAT y)
    107 {
    108 	return CPDF_Point(point.x + x,point.y + y);
    109 }
    110 
    111 CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange & wr1, const CPVT_WordRange & wr2)
    112 {
    113 	CPVT_WordRange wrRet;
    114 
    115 	if (wr2.EndPos.WordCmp(wr1.BeginPos) < 0 || wr2.BeginPos.WordCmp(wr1.EndPos) > 0) return wrRet;
    116 	if (wr1.EndPos.WordCmp(wr2.BeginPos) < 0 || wr1.BeginPos.WordCmp(wr2.EndPos) > 0) return wrRet;
    117 
    118 	if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0)
    119 	{
    120 		wrRet.BeginPos = wr2.BeginPos;
    121 	}
    122 	else
    123 	{
    124 		wrRet.BeginPos = wr1.BeginPos;
    125 	}
    126 
    127 	if (wr1.EndPos.WordCmp(wr2.EndPos) < 0)
    128 	{
    129 		wrRet.EndPos = wr1.EndPos;
    130 	}
    131 	else
    132 	{
    133 		wrRet.EndPos = wr2.EndPos;
    134 	}
    135 
    136 	return wrRet;
    137 }
    138 
    139 CFX_ByteString CPWL_Utils::GetAP_Check(const CPDF_Rect & crBBox)
    140 {
    141 	CFX_ByteTextBuf csAP;
    142 
    143 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
    144 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
    145 
    146 	const FX_INT32 num = 8;
    147 
    148 	CPWL_Point pts[num*3] =
    149 	{
    150 		//1
    151 		CPWL_Point(0.28f, 0.52f),
    152 		CPWL_Point(0.27f, 0.48f),
    153 		CPWL_Point(0.29f, 0.40f),
    154 
    155 		//2
    156 		CPWL_Point(0.30f, 0.33f),
    157 		CPWL_Point(0.31f, 0.29f),
    158 		CPWL_Point(0.31f, 0.28f),
    159 
    160 		//3
    161 		CPWL_Point(0.39f, 0.28f),
    162 		CPWL_Point(0.49f, 0.29f),
    163 		CPWL_Point(0.77f, 0.67f),
    164 
    165 		//4
    166 		CPWL_Point(0.76f, 0.68f),
    167 		CPWL_Point(0.78f, 0.69f),
    168 		CPWL_Point(0.76f, 0.75f),
    169 
    170 		//5
    171 		CPWL_Point(0.76f, 0.75f),
    172 		CPWL_Point(0.73f, 0.80f),
    173 		CPWL_Point(0.68f, 0.75f),
    174 
    175 		//6
    176 		CPWL_Point(0.68f, 0.74f),
    177 		CPWL_Point(0.68f, 0.74f),
    178 		CPWL_Point(0.44f, 0.47f),
    179 
    180 		//7
    181 		CPWL_Point(0.43f, 0.47f),
    182 		CPWL_Point(0.40f, 0.47f),
    183 		CPWL_Point(0.41f, 0.58f),
    184 
    185 		//8
    186 		CPWL_Point(0.40f, 0.60f),
    187 		CPWL_Point(0.28f, 0.66f),
    188 		CPWL_Point(0.30f, 0.56f)
    189 	};
    190 
    191 	for (FX_INT32 j=0; j<num*3; j++)
    192 	{
    193 		pts[j].x *= fWidth;
    194 		pts[j].x += crBBox.left;
    195 
    196 		pts[j].y *= fHeight;
    197 		pts[j].y += crBBox.bottom;
    198 	}
    199 
    200 	csAP << pts[0].x << " " << pts[0].y << " m\n";
    201 
    202 	for (FX_INT32 i=0; i<num; i++)
    203 	{
    204 		FX_INT32 nCur = i*3;
    205 		FX_INT32 n1 = i*3 + 1;
    206 		FX_INT32 n2 = i*3 + 2;
    207 		FX_INT32 nNext = (i < num-1 ? (i+1)*3 : 0);
    208 
    209 		FX_FLOAT px1 = pts[n1].x - pts[nCur].x;
    210 		FX_FLOAT py1 = pts[n1].y - pts[nCur].y;
    211 		FX_FLOAT px2 = pts[n2].x - pts[nNext].x;
    212 		FX_FLOAT py2 = pts[n2].y - pts[nNext].y;
    213 
    214 		csAP << pts[nCur].x + px1 * PWL_BEZIER << " " << pts[nCur].y + py1 * PWL_BEZIER << " "
    215 			<< pts[nNext].x + px2 * PWL_BEZIER << " " << pts[nNext].y + py2 * PWL_BEZIER << " "
    216 			<< pts[nNext].x << " " << pts[nNext].y << " c\n";
    217 	}
    218 
    219 	return csAP.GetByteString();
    220 }
    221 
    222 CFX_ByteString CPWL_Utils::GetAP_Circle(const CPDF_Rect & crBBox)
    223 {
    224 	CFX_ByteTextBuf csAP;
    225 
    226 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
    227 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
    228 
    229 	CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2);
    230 	CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top);
    231 	CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2);
    232 	CPDF_Point pt4(crBBox.left + fWidth / 2,crBBox.bottom);
    233 
    234 	csAP << pt1.x << " " << pt1.y << " m\n";
    235 
    236 	FX_FLOAT px = pt2.x - pt1.x;
    237 	FX_FLOAT py = pt2.y - pt1.y;
    238 
    239 	csAP << pt1.x << " " << pt1.y + py * PWL_BEZIER << " "
    240 		<< pt2.x - px * PWL_BEZIER << " " << pt2.y << " "
    241 		<< pt2.x << " " << pt2.y << " c\n";
    242 
    243 	px = pt3.x - pt2.x;
    244 	py = pt2.y - pt3.y;
    245 
    246 	csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " "
    247 		<< pt3.x << " " << pt3.y + py * PWL_BEZIER << " "
    248 		<< pt3.x << " " << pt3.y << " c\n";
    249 
    250 	px = pt3.x - pt4.x;
    251 	py = pt3.y - pt4.y;
    252 
    253 	csAP << pt3.x << " " << pt3.y - py * PWL_BEZIER << " "
    254 		<< pt4.x + px * PWL_BEZIER << " " << pt4.y << " "
    255 		<< pt4.x << " " << pt4.y << " c\n";
    256 
    257 	px = pt4.x - pt1.x;
    258 	py = pt1.y - pt4.y;
    259 
    260 	csAP << pt4.x - px * PWL_BEZIER << " " << pt4.y << " "
    261 		<< pt1.x << " " << pt1.y - py * PWL_BEZIER << " "
    262 		<< pt1.x << " " << pt1.y << " c\n";
    263 
    264 	return csAP.GetByteString();
    265 }
    266 
    267 CFX_ByteString CPWL_Utils::GetAP_Cross(const CPDF_Rect & crBBox)
    268 {
    269 	CFX_ByteTextBuf csAP;
    270 
    271 	csAP << crBBox.left << " " << crBBox.top << " m\n";
    272 	csAP << crBBox.right << " " << crBBox.bottom << " l\n";
    273 	csAP << crBBox.left << " " << crBBox.bottom << " m\n";
    274 	csAP << crBBox.right << " " << crBBox.top << " l\n";
    275 
    276 	return csAP.GetByteString();
    277 }
    278 
    279 CFX_ByteString CPWL_Utils::GetAP_Diamond(const CPDF_Rect & crBBox)
    280 {
    281 	CFX_ByteTextBuf csAP;
    282 
    283 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
    284 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
    285 
    286 	CPDF_Point pt1(crBBox.left,crBBox.bottom + fHeight / 2);
    287 	CPDF_Point pt2(crBBox.left + fWidth / 2,crBBox.top);
    288 	CPDF_Point pt3(crBBox.right,crBBox.bottom + fHeight / 2);
    289 	CPDF_Point pt4(crBBox.left + fWidth / 2,crBBox.bottom);
    290 
    291 	csAP << pt1.x << " " << pt1.y << " m\n";
    292 	csAP << pt2.x << " " << pt2.y << " l\n";
    293 	csAP << pt3.x << " " << pt3.y << " l\n";
    294 	csAP << pt4.x << " " << pt4.y << " l\n";
    295 	csAP << pt1.x << " " << pt1.y << " l\n";
    296 
    297 	return csAP.GetByteString();
    298 }
    299 
    300 CFX_ByteString CPWL_Utils::GetAP_Square(const CPDF_Rect & crBBox)
    301 {
    302 	CFX_ByteTextBuf csAP;
    303 
    304 	csAP << crBBox.left << " " << crBBox.top << " m\n";
    305 	csAP << crBBox.right << " " << crBBox.top << " l\n";
    306 	csAP << crBBox.right << " " << crBBox.bottom << " l\n";
    307 	csAP << crBBox.left << " " << crBBox.bottom << " l\n";
    308 	csAP << crBBox.left << " " << crBBox.top << " l\n";
    309 
    310 	return csAP.GetByteString();
    311 }
    312 
    313 CFX_ByteString CPWL_Utils::GetAP_Star(const CPDF_Rect & crBBox)
    314 {
    315 	CFX_ByteTextBuf csAP;
    316 
    317 	FX_FLOAT fRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f));
    318 	CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,(crBBox.top + crBBox.bottom) / 2.0f);
    319 
    320 	FX_FLOAT px[5],py[5];
    321 
    322 	FX_FLOAT fAngel = PWL_PI/10.0f;
    323 
    324 	for (FX_INT32 i=0; i<5; i++)
    325 	{
    326 		px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
    327 		py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
    328 
    329 		fAngel += PWL_PI * 2 / 5.0f;
    330 	}
    331 
    332 	csAP << px[0] << " " << py[0] << " m\n";
    333 
    334 	FX_INT32 nNext = 0;
    335 	for (FX_INT32 j=0; j<5; j++)
    336 	{
    337 		nNext += 2;
    338 		if (nNext >= 5) nNext -= 5;
    339 		csAP << px[nNext] << " " << py[nNext] << " l\n";
    340 	}
    341 
    342 	return csAP.GetByteString();
    343 }
    344 
    345 CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CPDF_Rect & crBBox,FX_FLOAT fRotate)
    346 {
    347 	CFX_ByteTextBuf csAP;
    348 
    349 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
    350 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
    351 
    352 	CPDF_Point pt1(-fWidth/2,0);
    353 	CPDF_Point pt2(0,fHeight/2);
    354 	CPDF_Point pt3(fWidth/2,0);
    355 
    356 	FX_FLOAT px,py;
    357 
    358 	csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " " << cos(fRotate) << " "
    359 		<< crBBox.left + fWidth / 2 << " " << crBBox.bottom + fHeight / 2 << " cm\n";
    360 
    361 
    362 	csAP << pt1.x << " " << pt1.y << " m\n";
    363 
    364 	px = pt2.x - pt1.x;
    365 	py = pt2.y - pt1.y;
    366 
    367 	csAP << pt1.x << " " << pt1.y + py * PWL_BEZIER << " "
    368 		<< pt2.x - px * PWL_BEZIER << " " << pt2.y << " "
    369 		<< pt2.x << " " << pt2.y << " c\n";
    370 
    371 	px = pt3.x - pt2.x;
    372 	py = pt2.y - pt3.y;
    373 
    374 	csAP << pt2.x + px * PWL_BEZIER << " " << pt2.y << " "
    375 		<< pt3.x << " " << pt3.y + py * PWL_BEZIER << " "
    376 		<< pt3.x << " " << pt3.y << " c\n";
    377 
    378 	return csAP.GetByteString();
    379 }
    380 
    381 
    382 CPDF_Rect CPWL_Utils::InflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize)
    383 {
    384 	if (rcRect.IsEmpty()) return rcRect;
    385 
    386 	CPDF_Rect rcNew(rcRect.left - fSize,
    387 					rcRect.bottom - fSize,
    388 					rcRect.right + fSize,
    389 					rcRect.top + fSize);
    390 	rcNew.Normalize();
    391 	return rcNew;
    392 }
    393 
    394 CPDF_Rect CPWL_Utils::DeflateRect(const CPDF_Rect & rcRect, FX_FLOAT fSize)
    395 {
    396 	if (rcRect.IsEmpty()) return rcRect;
    397 
    398 	CPDF_Rect rcNew(rcRect.left + fSize,
    399 					rcRect.bottom + fSize,
    400 					rcRect.right - fSize,
    401 					rcRect.top - fSize);
    402 	rcNew.Normalize();
    403 	return rcNew;
    404 }
    405 
    406 CPDF_Rect CPWL_Utils::ScaleRect(const CPDF_Rect & rcRect,FX_FLOAT fScale)
    407 {
    408 	FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f;
    409 	FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f;
    410 
    411 	CPDF_Point ptCenter = CPDF_Point((rcRect.left + rcRect.right) / 2,(rcRect.top + rcRect.bottom) / 2);
    412 
    413 	return CPDF_Rect(ptCenter.x - fHalfWidth * fScale,
    414 				ptCenter.y - fHalfHeight * fScale,
    415 				ptCenter.x + fHalfWidth * fScale,
    416 				ptCenter.y + fHalfHeight * fScale);
    417 }
    418 
    419 CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color)
    420 {
    421 	CFX_ByteTextBuf sAppStream;
    422 
    423 	CFX_ByteString sColor = GetColorAppStream(color,TRUE);
    424 	if (sColor.GetLength() > 0)
    425 	{
    426 		sAppStream << "q\n" << sColor;
    427 		sAppStream << rect.left << " " << rect.bottom << " "
    428 			<< rect.right - rect.left << " " << rect.top - rect.bottom << " re f\nQ\n";
    429 	}
    430 
    431 	return sAppStream.GetByteString();
    432 }
    433 
    434 CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CPDF_Rect & rect,const CPWL_Color & color)
    435 {
    436 	CFX_ByteTextBuf sAppStream;
    437 
    438 	CFX_ByteString sColor = GetColorAppStream(color,TRUE);
    439 	if (sColor.GetLength() > 0)
    440 	{
    441 		sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
    442 	}
    443 
    444 	return sAppStream.GetByteString();
    445 }
    446 
    447 CPDF_Rect CPWL_Utils::GetCenterSquare(const CPDF_Rect & rect)
    448 {
    449 	FX_FLOAT fWidth = rect.right -  rect.left;
    450 	FX_FLOAT fHeight = rect.top - rect.bottom;
    451 
    452 	FX_FLOAT fCenterX = (rect.left + rect.right)/2.0f;
    453 	FX_FLOAT fCenterY = (rect.top + rect.bottom)/2.0f;
    454 
    455 	FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
    456 
    457 	return CPDF_Rect(fCenterX - fRadius,fCenterY - fRadius,fCenterX + fRadius,fCenterY + fRadius);
    458 }
    459 
    460 CFX_ByteString CPWL_Utils::GetEditAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset, const CPVT_WordRange * pRange,
    461 														FX_BOOL bContinuous, FX_WORD SubWord)
    462 {
    463 	return IFX_Edit::GetEditAppearanceStream(pEdit,ptOffset,pRange,bContinuous,SubWord);
    464 }
    465 
    466 CFX_ByteString CPWL_Utils::GetEditSelAppStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset,
    467 								const CPVT_WordRange * pRange)
    468 {
    469 	return IFX_Edit::GetSelectAppearanceStream(pEdit,ptOffset,pRange);
    470 }
    471 
    472 static CFX_ByteString GetSquigglyAppearanceStream(FX_FLOAT fStartX, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep)
    473 {
    474 	CFX_ByteTextBuf sRet;
    475 
    476 	sRet << "0 w\n" << fStartX << " " << fY << " m\n";
    477 
    478 	FX_FLOAT fx;
    479 	FX_INT32 i;
    480 
    481 	for (i=1,fx=fStartX+fStep; fx<fEndX; fx+=fStep,i++)
    482 	{
    483 		sRet << fx << " " << fY + (i&1)*fStep << " l\n";
    484 	}
    485 
    486 	sRet << "S\n";
    487 
    488 	return sRet.GetByteString();
    489 }
    490 
    491 static CFX_ByteString GetWordSpellCheckAppearanceStream(IFX_Edit_Iterator* pIterator, const CPDF_Point & ptOffset,
    492 																  const CPVT_WordRange & wrWord)
    493 {
    494 	CFX_ByteTextBuf sRet;
    495 
    496 	FX_FLOAT fStartX = 0.0f;
    497 	FX_FLOAT fEndX = 0.0f;
    498 	FX_FLOAT fY = 0.0f;
    499 	FX_FLOAT fStep = 0.0f;
    500 
    501 	FX_BOOL bBreak = FALSE;
    502 
    503 	if (pIterator)
    504 	{
    505 		pIterator->SetAt(wrWord.BeginPos);
    506 
    507 		do
    508 		{
    509 			CPVT_WordPlace place = pIterator->GetAt();
    510 
    511 			CPVT_Line line;
    512 			if (pIterator->GetLine(line))
    513 			{
    514 				fY = line.ptLine.y;
    515 				fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
    516 			}
    517 
    518 			if (place.LineCmp(wrWord.BeginPos) == 0)
    519 			{
    520 				pIterator->SetAt(wrWord.BeginPos);
    521 				CPVT_Word word;
    522 				if (pIterator->GetWord(word))
    523 				{
    524 					fStartX = word.ptWord.x;
    525 				}
    526 			}
    527 			else
    528 			{
    529 				fStartX = line.ptLine.x;
    530 			}
    531 
    532 			if (place.LineCmp(wrWord.EndPos) == 0)
    533 			{
    534 				pIterator->SetAt(wrWord.EndPos);
    535 				CPVT_Word word;
    536 				if (pIterator->GetWord(word))
    537 				{
    538 					fEndX = word.ptWord.x + word.fWidth;
    539 				}
    540 
    541 				bBreak = TRUE;
    542 			}
    543 			else
    544 			{
    545 				fEndX = line.ptLine.x + line.fLineWidth;
    546 			}
    547 
    548 			sRet << GetSquigglyAppearanceStream(fStartX + ptOffset.x, fEndX + ptOffset.x, fY + ptOffset.y,fStep);
    549 
    550 			if (bBreak) break;
    551 		}
    552 		while (pIterator->NextLine());
    553 	}
    554 
    555 	return sRet.GetByteString();
    556 }
    557 
    558 CFX_ByteString CPWL_Utils::GetSpellCheckAppStream(IFX_Edit* pEdit, IPWL_SpellCheck* pSpellCheck, const CPDF_Point & ptOffset,
    559 								const CPVT_WordRange * pRange)
    560 {
    561 	ASSERT(pEdit != NULL);
    562 	ASSERT(pSpellCheck != NULL);
    563 
    564 	CFX_ByteTextBuf sRet;
    565 
    566 	if (pRange && pRange->IsExist())
    567 	{
    568 		if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
    569 		{
    570 			pIterator->SetAt(pRange->BeginPos);
    571 
    572 			FX_BOOL bLatinWord = FALSE;
    573 			CPVT_WordPlace wpWordStart;
    574 			CFX_ByteString sWord;
    575 
    576 			CPVT_WordPlace oldplace;
    577 			while (pIterator->NextWord())
    578 			{
    579 				CPVT_WordPlace place = pIterator->GetAt();
    580 				if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
    581 
    582 				CPVT_Word word;
    583 				if (pIterator->GetWord(word))
    584 				{
    585 					if (FX_EDIT_ISLATINWORD(word.Word))
    586 					{
    587 						if (!bLatinWord)
    588 						{
    589 							wpWordStart = place;
    590 							bLatinWord = TRUE;
    591 						}
    592 
    593 						sWord += (char)word.Word;
    594 						oldplace = place;
    595 					}
    596 					else
    597 					{
    598 						if (bLatinWord)
    599 						{
    600 							if (!pSpellCheck->CheckWord(sWord))
    601 							{
    602 								sRet << GetWordSpellCheckAppearanceStream(pIterator,ptOffset,CPVT_WordRange(wpWordStart,oldplace));
    603 								pIterator->SetAt(place);
    604 							}
    605 							bLatinWord = FALSE;
    606 						}
    607 
    608 						sWord.Empty();
    609 					}
    610 				}
    611 				else
    612 				{
    613 					if (bLatinWord)
    614 					{
    615 						if (!pSpellCheck->CheckWord(sWord))
    616 							sRet << GetWordSpellCheckAppearanceStream(pIterator,ptOffset,CPVT_WordRange(wpWordStart,oldplace));
    617 						bLatinWord = FALSE;
    618 						sWord.Empty();
    619 					}
    620 				}
    621 			}
    622 
    623 			if (bLatinWord)
    624 			{
    625 				if (!pSpellCheck->CheckWord(sWord))
    626 					sRet << GetWordSpellCheckAppearanceStream(pIterator,ptOffset,CPVT_WordRange(wpWordStart,oldplace));
    627 
    628 				bLatinWord = FALSE;
    629 				sWord.Empty();
    630 			}
    631 		}
    632 	}
    633 
    634 	return sRet.GetByteString();
    635 }
    636 
    637 CFX_ByteString CPWL_Utils::GetTextAppStream(const CPDF_Rect & rcBBox,IFX_Edit_FontMap * pFontMap,
    638 														const CFX_WideString & sText, FX_INT32 nAlignmentH, FX_INT32 nAlignmentV,
    639 														FX_FLOAT fFontSize, FX_BOOL bMultiLine, FX_BOOL bAutoReturn, const CPWL_Color & crText)
    640 {
    641 	CFX_ByteTextBuf sRet;
    642 
    643 	if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
    644 	{
    645 		pEdit->SetFontMap(pFontMap);
    646 
    647 		pEdit->SetPlateRect(rcBBox);
    648 		pEdit->SetAlignmentH(nAlignmentH);
    649 		pEdit->SetAlignmentV(nAlignmentV);
    650 		pEdit->SetMultiLine(bMultiLine);
    651 		pEdit->SetAutoReturn(bAutoReturn);
    652 		if (IsFloatZero(fFontSize))
    653 			pEdit->SetAutoFontSize(TRUE);
    654 		else
    655 			pEdit->SetFontSize(fFontSize);
    656 		pEdit->Initialize();
    657 
    658 		pEdit->SetText(sText);
    659 
    660 		CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit, CPDF_Point(0.0f,0.0f));
    661 		if (sEdit.GetLength() > 0)
    662 		{
    663 			sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
    664 		}
    665 
    666 		IFX_Edit::DelEdit(pEdit);
    667 	}
    668 
    669 	return sRet.GetByteString();
    670 }
    671 
    672 CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CPDF_Rect & rcBBox,
    673 											IFX_Edit_FontMap * pFontMap,
    674 											CPDF_Stream * pIconStream,
    675 											CPDF_IconFit & IconFit,
    676 											const CFX_WideString & sLabel,
    677 											const CPWL_Color & crText,
    678 											FX_FLOAT fFontSize,
    679 											FX_INT32 nLayOut)
    680 {
    681 	const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
    682 
    683 	if (IFX_Edit * pEdit = IFX_Edit::NewEdit())
    684 	{
    685 		pEdit->SetFontMap(pFontMap);
    686 
    687 		pEdit->SetAlignmentH(1);
    688 		pEdit->SetAlignmentV(1);
    689 		pEdit->SetMultiLine(FALSE);
    690 		pEdit->SetAutoReturn(FALSE);
    691 		if (IsFloatZero(fFontSize))
    692 			pEdit->SetAutoFontSize(TRUE);
    693 		else
    694 			pEdit->SetFontSize(fFontSize);
    695 		pEdit->Initialize();
    696 		pEdit->SetText(sLabel);
    697 
    698 		CPDF_Rect rcLabelContent = pEdit->GetContentRect();
    699 
    700 		CPWL_Icon Icon;
    701 		PWL_CREATEPARAM cp;
    702 		cp.dwFlags = PWS_VISIBLE;
    703 		Icon.Create(cp);
    704 		Icon.SetIconFit(&IconFit);
    705 		Icon.SetPDFStream(pIconStream);
    706 
    707 		CPDF_Rect rcLabel = CPDF_Rect(0,0,0,0);
    708 		CPDF_Rect rcIcon = CPDF_Rect(0,0,0,0);
    709 		FX_FLOAT fWidth = 0.0f;
    710 		FX_FLOAT fHeight = 0.0f;
    711 
    712 		switch (nLayOut)
    713 		{
    714 		case PPBL_LABEL:
    715 			rcLabel = rcBBox;
    716 			rcIcon = CPDF_Rect(0,0,0,0);
    717 			break;
    718 		case PPBL_ICON:
    719 			rcIcon = rcBBox;
    720 			rcLabel = CPDF_Rect(0,0,0,0);
    721 			break;
    722 		case PPBL_ICONTOPLABELBOTTOM:
    723 
    724 			if (pIconStream)
    725 			{
    726 				if (IsFloatZero(fFontSize))
    727 				{
    728 					fHeight = rcBBox.top - rcBBox.bottom;
    729 					rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight * fAutoFontScale);
    730 					rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top);
    731 				}
    732 				else
    733 				{
    734 					fHeight = rcLabelContent.Height();
    735 
    736 					if (rcBBox.bottom + fHeight > rcBBox.top)
    737 					{
    738 						rcIcon = CPDF_Rect(0,0,0,0);
    739 						rcLabel = rcBBox;
    740 					}
    741 					else
    742 					{
    743 						rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcBBox.bottom + fHeight);
    744 						rcIcon = CPDF_Rect(rcBBox.left,rcLabel.top,rcBBox.right,rcBBox.top);
    745 					}
    746 				}
    747 			}
    748 			else
    749 			{
    750 				rcLabel = rcBBox;
    751 				rcIcon = CPDF_Rect(0,0,0,0);
    752 			}
    753 
    754 			break;
    755 		case PPBL_LABELTOPICONBOTTOM:
    756 
    757 			if (pIconStream)
    758 			{
    759 				if (IsFloatZero(fFontSize))
    760 				{
    761 					fHeight = rcBBox.top - rcBBox.bottom;
    762 					rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight * fAutoFontScale ,rcBBox.right,rcBBox.top);
    763 					rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom);
    764 				}
    765 				else
    766 				{
    767 					fHeight = rcLabelContent.Height();
    768 
    769 					if (rcBBox.bottom + fHeight > rcBBox.top)
    770 					{
    771 						rcIcon = CPDF_Rect(0,0,0,0);
    772 						rcLabel = rcBBox;
    773 					}
    774 					else
    775 					{
    776 						rcLabel = CPDF_Rect(rcBBox.left,rcBBox.top - fHeight,rcBBox.right,rcBBox.top);
    777 						rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.right,rcLabel.bottom);
    778 					}
    779 				}
    780 			}
    781 			else
    782 			{
    783 				rcLabel = rcBBox;
    784 				rcIcon = CPDF_Rect(0,0,0,0);
    785 			}
    786 
    787 			break;
    788 		case PPBL_ICONLEFTLABELRIGHT:
    789 
    790 			if (pIconStream)
    791 			{
    792 				if (IsFloatZero(fFontSize))
    793 				{
    794 					fWidth = rcBBox.right - rcBBox.left;
    795 					rcLabel = CPDF_Rect(rcBBox.right - fWidth * fAutoFontScale,rcBBox.bottom,rcBBox.right,rcBBox.top);
    796 					rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
    797 
    798 					if (rcLabelContent.Width() < fWidth * fAutoFontScale)
    799 					{
    800 					}
    801 					else
    802 					{
    803 						if (rcLabelContent.Width() < fWidth)
    804 						{
    805 							rcLabel = CPDF_Rect(rcBBox.right - rcLabelContent.Width(),rcBBox.bottom,rcBBox.right,rcBBox.top);
    806 							rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
    807 						}
    808 						else
    809 						{
    810 							rcLabel = rcBBox;
    811 							rcIcon = CPDF_Rect(0,0,0,0);
    812 						}
    813 					}
    814 				}
    815 				else
    816 				{
    817 					fWidth = rcLabelContent.Width();
    818 
    819 					if (rcBBox.left + fWidth > rcBBox.right)
    820 					{
    821 						rcLabel = rcBBox;
    822 						rcIcon = CPDF_Rect(0,0,0,0);
    823 					}
    824 					else
    825 					{
    826 						rcLabel = CPDF_Rect(rcBBox.right - fWidth,rcBBox.bottom,rcBBox.right,rcBBox.top);
    827 						rcIcon = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcLabel.left,rcBBox.top);
    828 					}
    829 				}
    830 			}
    831 			else
    832 			{
    833 				rcLabel = rcBBox;
    834 				rcIcon = CPDF_Rect(0,0,0,0);
    835 			}
    836 
    837 			break;
    838 		case PPBL_LABELLEFTICONRIGHT:
    839 
    840 			if (pIconStream)
    841 			{
    842 				if (IsFloatZero(fFontSize))
    843 				{
    844 					fWidth = rcBBox.right - rcBBox.left;
    845 					rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth * fAutoFontScale,rcBBox.top);
    846 					rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
    847 
    848 					if (rcLabelContent.Width() < fWidth * fAutoFontScale)
    849 					{
    850 					}
    851 					else
    852 					{
    853 						if (rcLabelContent.Width() < fWidth)
    854 						{
    855 							rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + rcLabelContent.Width(),rcBBox.top);
    856 							rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
    857 						}
    858 						else
    859 						{
    860 							rcLabel = rcBBox;
    861 							rcIcon = CPDF_Rect(0,0,0,0);
    862 						}
    863 					}
    864 				}
    865 				else
    866 				{
    867 					fWidth = rcLabelContent.Width();
    868 
    869 					if (rcBBox.left + fWidth > rcBBox.right)
    870 					{
    871 						rcLabel = rcBBox;
    872 						rcIcon = CPDF_Rect(0,0,0,0);
    873 					}
    874 					else
    875 					{
    876 						rcLabel = CPDF_Rect(rcBBox.left,rcBBox.bottom,rcBBox.left + fWidth,rcBBox.top);
    877 						rcIcon = CPDF_Rect(rcLabel.right,rcBBox.bottom,rcBBox.right,rcBBox.top);
    878 					}
    879 				}
    880 			}
    881 			else
    882 			{
    883 				rcLabel = rcBBox;
    884 				rcIcon = CPDF_Rect(0,0,0,0);
    885 			}
    886 
    887 			break;
    888 		case PPBL_LABELOVERICON:
    889 			rcLabel = rcBBox;
    890 			rcIcon = rcBBox;
    891 			break;
    892 		}
    893 
    894 		CFX_ByteTextBuf sAppStream,sTemp;
    895 
    896 		if (!rcIcon.IsEmpty())
    897 		{
    898 			Icon.Move(rcIcon, FALSE, FALSE);
    899 			sTemp << Icon.GetImageAppStream();
    900 		}
    901 
    902 		Icon.Destroy();
    903 
    904 		if (!rcLabel.IsEmpty())
    905 		{
    906 			pEdit->SetPlateRect(rcLabel);
    907 			CFX_ByteString sEdit = CPWL_Utils::GetEditAppStream(pEdit,CPDF_Point(0.0f,0.0f));
    908 			if (sEdit.GetLength() > 0)
    909 			{
    910 				sTemp << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
    911 			}
    912 		}
    913 
    914 		IFX_Edit::DelEdit(pEdit);
    915 
    916 		if (sTemp.GetSize() > 0)
    917 		{
    918 			sAppStream << "q\n" << rcBBox.left << " " << rcBBox.bottom << " "
    919 				<< rcBBox.right - rcBBox.left << " " << rcBBox.top - rcBBox.bottom << " re W n\n";
    920 			sAppStream << sTemp << "Q\n";
    921 		}
    922 
    923 		return sAppStream.GetByteString();
    924 	}
    925 
    926 	return "";
    927 }
    928 
    929 CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color & color,const FX_BOOL & bFillOrStroke)
    930 {
    931 	CFX_ByteTextBuf sColorStream;
    932 
    933 	switch (color.nColorType)
    934 	{
    935 	case COLORTYPE_RGB:
    936 		sColorStream << color.fColor1 << " " << color.fColor2 << " " << color.fColor3 << " "
    937 			<< (bFillOrStroke ? "rg" : "RG") << "\n";
    938 		break;
    939 	case COLORTYPE_GRAY:
    940 		sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G") << "\n";
    941 		break;
    942 	case COLORTYPE_CMYK:
    943 		sColorStream << color.fColor1 << " " << color.fColor2 << " " << color.fColor3 << " " << color.fColor4 << " "
    944 			<< (bFillOrStroke ? "k" : "K") << "\n";
    945 		break;
    946 	}
    947 
    948 	return sColorStream.GetByteString();
    949 }
    950 
    951 CFX_ByteString CPWL_Utils::GetBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth,
    952 												const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
    953 												FX_INT32 nStyle, const CPWL_Dash & dash)
    954 {
    955 	CFX_ByteTextBuf sAppStream;
    956 	CFX_ByteString sColor;
    957 
    958 	FX_FLOAT fLeft = rect.left;
    959 	FX_FLOAT fRight = rect.right;
    960 	FX_FLOAT fTop = rect.top;
    961 	FX_FLOAT fBottom = rect.bottom;
    962 
    963 	if (fWidth > 0.0f)
    964 	{
    965 		FX_FLOAT fHalfWidth = fWidth / 2.0f;
    966 
    967 		sAppStream << "q\n";
    968 
    969 		switch (nStyle)
    970 		{
    971 		default:
    972 		case PBS_SOLID:
    973 			sColor = CPWL_Utils::GetColorAppStream(color,TRUE);
    974 			if (sColor.GetLength() > 0)
    975 			{
    976 				sAppStream << sColor;
    977 				sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " " << fTop - fBottom << " re\n";
    978 				sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
    979 					<< fRight - fLeft - fWidth * 2 << " " << fTop - fBottom - fWidth * 2 << " re\n";
    980 				sAppStream << "f*\n";
    981 			}
    982 			break;
    983 		case PBS_DASH:
    984 			sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
    985 			if (sColor.GetLength() > 0)
    986 			{
    987 				sAppStream << sColor;
    988 				sAppStream << fWidth << " w" << " [" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n";
    989 				sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " m\n";
    990 				sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2 << " l\n";
    991 				sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2 << " l\n";
    992 				sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2 << " l\n";
    993 				sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2 << " l S\n";
    994 			}
    995 			break;
    996 		case PBS_BEVELED:
    997 		case PBS_INSET:
    998 			sColor = CPWL_Utils::GetColorAppStream(crLeftTop,TRUE);
    999 			if (sColor.GetLength() > 0)
   1000 			{
   1001 				sAppStream << sColor;
   1002 				sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " m\n";
   1003 				sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth << " l\n";
   1004 				sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth << " l\n";
   1005 				sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n";
   1006 				sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l\n";
   1007 				sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l f\n";
   1008 			}
   1009 
   1010 			sColor = CPWL_Utils::GetColorAppStream(crRightBottom,TRUE);
   1011 			if (sColor.GetLength() > 0)
   1012 			{
   1013 				sAppStream << sColor;
   1014 				sAppStream << fRight - fHalfWidth << " " <<	fTop - fHalfWidth << " m\n";
   1015 				sAppStream << fRight - fHalfWidth << " " <<	fBottom + fHalfWidth << " l\n";
   1016 				sAppStream << fLeft + fHalfWidth << " " << 	fBottom + fHalfWidth << " l\n";
   1017 				sAppStream << fLeft + fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n";
   1018 				sAppStream << fRight - fHalfWidth * 2 << " " << fBottom + fHalfWidth * 2 << " l\n";
   1019 				sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2 << " l f\n";
   1020 			}
   1021 
   1022 			sColor = CPWL_Utils::GetColorAppStream(color,TRUE);
   1023 			if (sColor.GetLength() > 0)
   1024 			{
   1025 				sAppStream << sColor;
   1026 				sAppStream << fLeft << " " << fBottom << " " <<	fRight - fLeft << " " << fTop - fBottom << " re\n";
   1027 				sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
   1028 					<< fRight - fLeft - fHalfWidth * 2 << " " << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
   1029 			}
   1030 			break;
   1031 		case PBS_UNDERLINED:
   1032 			sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
   1033 			if (sColor.GetLength() > 0)
   1034 			{
   1035 				sAppStream << sColor;
   1036 				sAppStream << fWidth << " w\n";
   1037 				sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
   1038 				sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
   1039 			}
   1040 			break;
   1041 		}
   1042 
   1043 		sAppStream << "Q\n";
   1044 	}
   1045 
   1046 	return sAppStream.GetByteString();
   1047 }
   1048 
   1049 CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(const CPDF_Rect & rect, FX_FLOAT fWidth,
   1050 												const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
   1051 												FX_INT32 nStyle, const CPWL_Dash & dash)
   1052 {
   1053 	CFX_ByteTextBuf sAppStream;
   1054 	CFX_ByteString sColor;
   1055 
   1056 
   1057 
   1058 
   1059 
   1060 
   1061 	if (fWidth > 0.0f)
   1062 	{
   1063 		sAppStream << "q\n";
   1064 
   1065 		switch (nStyle)
   1066 		{
   1067 		default:
   1068 		case PBS_SOLID:
   1069 		case PBS_UNDERLINED:
   1070 			{
   1071 				sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
   1072 				if (sColor.GetLength() > 0)
   1073 				{
   1074 					sAppStream << "q\n" << fWidth << " w\n" << sColor
   1075 						<< CPWL_Utils::GetAP_Circle(CPWL_Utils::DeflateRect(rect,fWidth / 2.0f))
   1076 						<< " S\nQ\n";
   1077 				}
   1078 			}
   1079 			break;
   1080 		case PBS_DASH:
   1081 			{
   1082 				sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
   1083 				if (sColor.GetLength() > 0)
   1084 				{
   1085 					sAppStream << "q\n" << fWidth << " w\n"
   1086 						<< "[" << dash.nDash << " " << dash.nGap << "] " << dash.nPhase << " d\n"
   1087 						<< sColor << CPWL_Utils::GetAP_Circle(CPWL_Utils::DeflateRect(rect,fWidth / 2.0f))
   1088 						<< " S\nQ\n";
   1089 				}
   1090 			}
   1091 			break;
   1092 		case PBS_BEVELED:
   1093 			{
   1094 				FX_FLOAT fHalfWidth = fWidth / 2.0f;
   1095 
   1096 				sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
   1097 				if (sColor.GetLength() > 0)
   1098 				{
   1099 					sAppStream << "q\n" << fHalfWidth << " w\n"
   1100 						<< sColor << CPWL_Utils::GetAP_Circle(rect)
   1101 						<< " S\nQ\n";
   1102 				}
   1103 
   1104 				sColor = CPWL_Utils::GetColorAppStream(crLeftTop,FALSE);
   1105 				if (sColor.GetLength() > 0)
   1106 				{
   1107 					sAppStream << "q\n" << fHalfWidth << " w\n"
   1108 						<< sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI/4.0f)
   1109 						<< " S\nQ\n";
   1110 				}
   1111 
   1112 				sColor = CPWL_Utils::GetColorAppStream(crRightBottom,FALSE);
   1113 				if (sColor.GetLength() > 0)
   1114 				{
   1115 					sAppStream << "q\n" << fHalfWidth << " w\n"
   1116 						<< sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI*5/4.0f)
   1117 						<< " S\nQ\n";
   1118 				}
   1119 			}
   1120 			break;
   1121 		case PBS_INSET:
   1122 			{
   1123 				FX_FLOAT fHalfWidth = fWidth / 2.0f;
   1124 
   1125 				sColor = CPWL_Utils::GetColorAppStream(color,FALSE);
   1126 				if (sColor.GetLength() > 0)
   1127 				{
   1128 					sAppStream << "q\n" << fHalfWidth << " w\n"
   1129 						<< sColor << CPWL_Utils::GetAP_Circle(rect)
   1130 						<< " S\nQ\n";
   1131 				}
   1132 
   1133 				sColor = CPWL_Utils::GetColorAppStream(crLeftTop,FALSE);
   1134 				if (sColor.GetLength() > 0)
   1135 				{
   1136 					sAppStream << "q\n" << fHalfWidth << " w\n"
   1137 						<< sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI/4.0f)
   1138 						<< " S\nQ\n";
   1139 				}
   1140 
   1141 				sColor = CPWL_Utils::GetColorAppStream(crRightBottom,FALSE);
   1142 				if (sColor.GetLength() > 0)
   1143 				{
   1144 					sAppStream << "q\n" << fHalfWidth << " w\n"
   1145 						<< sColor << CPWL_Utils::GetAP_HalfCircle(CPWL_Utils::DeflateRect(rect,fHalfWidth * 0.75f),PWL_PI*5/4.0f)
   1146 						<< " S\nQ\n";
   1147 				}
   1148 			}
   1149 			break;
   1150 		}
   1151 
   1152 		sAppStream << "Q\n";
   1153 	}
   1154 
   1155 	return sAppStream.GetByteString();
   1156 }
   1157 
   1158 CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color & sColor,FX_FLOAT fColorSub)
   1159 {
   1160 	CPWL_Color sRet;
   1161 	sRet.nColorType = sColor.nColorType;
   1162 
   1163 	switch (sColor.nColorType)
   1164 	{
   1165 	case COLORTYPE_TRANSPARENT:
   1166 		sRet.nColorType = COLORTYPE_RGB;
   1167 		sRet.fColor1 = PWL_MAX(1 - fColorSub,0.0f);
   1168 		sRet.fColor2 = PWL_MAX(1 - fColorSub,0.0f);
   1169 		sRet.fColor3 = PWL_MAX(1 - fColorSub,0.0f);
   1170 		break;
   1171 	case COLORTYPE_RGB:
   1172 	case COLORTYPE_GRAY:
   1173 	case COLORTYPE_CMYK:
   1174 		sRet.fColor1 = PWL_MAX(sColor.fColor1 - fColorSub,0.0f);
   1175 		sRet.fColor2 = PWL_MAX(sColor.fColor2 - fColorSub,0.0f);
   1176 		sRet.fColor3 = PWL_MAX(sColor.fColor3 - fColorSub,0.0f);
   1177 		sRet.fColor4 = PWL_MAX(sColor.fColor4 - fColorSub,0.0f);
   1178 		break;
   1179 	}
   1180 
   1181 	return sRet;
   1182 }
   1183 
   1184 CPWL_Color CPWL_Utils::DevideColor(const CPWL_Color & sColor,FX_FLOAT fColorDevide)
   1185 {
   1186 	CPWL_Color sRet;
   1187 	sRet.nColorType = sColor.nColorType;
   1188 
   1189 	switch (sColor.nColorType)
   1190 	{
   1191 	case COLORTYPE_TRANSPARENT:
   1192 		sRet.nColorType = COLORTYPE_RGB;
   1193 		sRet.fColor1 = 1 / fColorDevide;
   1194 		sRet.fColor2 = 1 / fColorDevide;
   1195 		sRet.fColor3 = 1 / fColorDevide;
   1196 		break;
   1197 	case COLORTYPE_RGB:
   1198 	case COLORTYPE_GRAY:
   1199 	case COLORTYPE_CMYK:
   1200 		sRet = sColor;
   1201 		sRet.fColor1 /= fColorDevide;
   1202 		sRet.fColor2 /= fColorDevide;
   1203 		sRet.fColor3 /= fColorDevide;
   1204 		sRet.fColor4 /= fColorDevide;
   1205 		break;
   1206 	}
   1207 
   1208 	return sRet;
   1209 }
   1210 
   1211 CFX_ByteString CPWL_Utils::GetAppStream_Check(const CPDF_Rect & rcBBox, const CPWL_Color & crText)
   1212 {
   1213 	CFX_ByteTextBuf sAP;
   1214 	sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
   1215 	return sAP.GetByteString();
   1216 }
   1217 
   1218 CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CPDF_Rect & rcBBox, const CPWL_Color & crText)
   1219 {
   1220 	CFX_ByteTextBuf sAP;
   1221 	sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
   1222 	return sAP.GetByteString();
   1223 }
   1224 
   1225 CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CPDF_Rect & rcBBox, const CPWL_Color & crText)
   1226 {
   1227 	CFX_ByteTextBuf sAP;
   1228 	sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,FALSE) << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
   1229 	return sAP.GetByteString();
   1230 }
   1231 
   1232 CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CPDF_Rect & rcBBox, const CPWL_Color & crText)
   1233 {
   1234 	CFX_ByteTextBuf sAP;
   1235 	sAP << "q\n1 w\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
   1236 	return sAP.GetByteString();
   1237 }
   1238 
   1239 CFX_ByteString CPWL_Utils::GetAppStream_Square(const CPDF_Rect & rcBBox, const CPWL_Color & crText)
   1240 {
   1241 	CFX_ByteTextBuf sAP;
   1242 	sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
   1243 	return sAP.GetByteString();
   1244 }
   1245 
   1246 CFX_ByteString CPWL_Utils::GetAppStream_Star(const CPDF_Rect & rcBBox, const CPWL_Color & crText)
   1247 {
   1248 	CFX_ByteTextBuf sAP;
   1249 	sAP << "q\n" << CPWL_Utils::GetColorAppStream(crText,TRUE) << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
   1250 	return sAP.GetByteString();
   1251 }
   1252 
   1253 CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CPDF_Rect & rcBBox,
   1254 													FX_INT32 nStyle,
   1255 													const CPWL_Color & crText)
   1256 {
   1257 	CPDF_Rect rcCenter = GetCenterSquare(rcBBox);
   1258 	switch (nStyle)
   1259 	{
   1260 	default:
   1261 	case PCS_CHECK:
   1262 		return GetAppStream_Check(rcCenter,crText);
   1263 	case PCS_CIRCLE:
   1264 		return GetAppStream_Circle(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1265 	case PCS_CROSS:
   1266 		return GetAppStream_Cross(rcCenter,crText);
   1267 	case PCS_DIAMOND:
   1268 		return GetAppStream_Diamond(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1269 	case PCS_SQUARE:
   1270 		return GetAppStream_Square(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1271 	case PCS_STAR:
   1272 		return GetAppStream_Star(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1273 	}
   1274 }
   1275 
   1276 CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CPDF_Rect & rcBBox,
   1277 													FX_INT32 nStyle,
   1278 													const CPWL_Color & crText)
   1279 {
   1280 	CPDF_Rect rcCenter = GetCenterSquare(rcBBox);
   1281 	switch (nStyle)
   1282 	{
   1283 	default:
   1284 	case PCS_CHECK:
   1285 		return GetAppStream_Check(rcCenter,crText);
   1286 	case PCS_CIRCLE:
   1287 		return GetAppStream_Circle(ScaleRect(rcCenter,1.0f/2.0f),crText);
   1288 	case PCS_CROSS:
   1289 		return GetAppStream_Cross(rcCenter,crText);
   1290 	case PCS_DIAMOND:
   1291 		return GetAppStream_Diamond(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1292 	case PCS_SQUARE:
   1293 		return GetAppStream_Square(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1294 	case PCS_STAR:
   1295 		return GetAppStream_Star(ScaleRect(rcCenter,2.0f/3.0f),crText);
   1296 	}
   1297 }
   1298 
   1299 CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CPDF_Rect & rcBBox)
   1300 {
   1301 	CFX_ByteTextBuf sAppStream;
   1302 
   1303 	if (!rcBBox.IsEmpty())
   1304 	{
   1305 		sAppStream << "q\n" << CPWL_Utils::GetColorAppStream(CPWL_Color(COLORTYPE_RGB,220.0f/255.0f,220.0f/255.0f,220.0f/255.0f),TRUE);
   1306 		sAppStream << rcBBox.left << " " << rcBBox.bottom << " "
   1307 				<< rcBBox.right - rcBBox.left << " " << rcBBox.top - rcBBox.bottom << " re f\n";
   1308 		sAppStream << "Q\n";
   1309 
   1310 		sAppStream << "q\n" <<
   1311 			CPWL_Utils::GetBorderAppStream(rcBBox,2,CPWL_Color(COLORTYPE_GRAY,0),CPWL_Color(COLORTYPE_GRAY,1),CPWL_Color(COLORTYPE_GRAY,0.5),PBS_BEVELED,CPWL_Dash(3,0,0))
   1312 			<< "Q\n";
   1313 
   1314 		CPDF_Point ptCenter = CPDF_Point((rcBBox.left + rcBBox.right)/2,(rcBBox.top + rcBBox.bottom)/2);
   1315 		if (IsFloatBigger(rcBBox.right - rcBBox.left,6) && IsFloatBigger(rcBBox.top - rcBBox.bottom,6))
   1316 		{
   1317 			sAppStream << "q\n" << " 0 g\n";
   1318 			sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
   1319 			sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
   1320 			sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
   1321 			sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
   1322 			sAppStream << "Q\n";
   1323 		}
   1324 	}
   1325 
   1326 	return sAppStream.GetByteString();
   1327 }
   1328 
   1329 void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dGray)
   1330 {
   1331 	if (dC<0 || dC>1 || dM<0 || dM>1 || dY < 0 || dY >1 || dK < 0 || dK >1)
   1332 		return;
   1333 	dGray = 1.0f - FX_MIN(1.0f,0.3f*dC+0.59f * dM + 0.11f*dY+dK);
   1334 }
   1335 
   1336 void CPWL_Utils::ConvertGRAY2CMYK(FX_FLOAT dGray,FX_FLOAT  &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK)
   1337 {
   1338 	if (dGray <0 || dGray >1)
   1339 		return;
   1340 	dC = 0.0f;
   1341 	dM = 0.0f;
   1342 	dY = 0.0f;
   1343 	dK = 1.0f-dGray;
   1344 }
   1345 
   1346 void CPWL_Utils::ConvertGRAY2RGB(FX_FLOAT dGray,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB)
   1347 {
   1348 	if (dGray <0 || dGray >1)
   1349 		return;
   1350 	dR = dGray;
   1351 	dG = dGray;
   1352 	dB = dGray;
   1353 }
   1354 
   1355 void CPWL_Utils::ConvertRGB2GRAY(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dGray)
   1356 {
   1357 	if (dR<0 || dR>1 || dG<0 || dG > 0 || dB < 0 || dB >1)
   1358 		return;
   1359 	dGray = 0.3f*dR+0.59f*dG+0.11f*dB;
   1360 }
   1361 
   1362 void CPWL_Utils::ConvertCMYK2RGB(FX_FLOAT dC,FX_FLOAT dM,FX_FLOAT dY,FX_FLOAT dK,FX_FLOAT &dR,FX_FLOAT &dG,FX_FLOAT &dB)
   1363 {
   1364 	if (dC <0 || dC>1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 || dK > 1 )
   1365 		return;
   1366 	dR = 1.0f - FX_MIN(1.0f, dC + dK);
   1367 	dG = 1.0f - FX_MIN(1.0f, dM + dK);
   1368 	dB = 1.0f - FX_MIN(1.0f, dY + dK);
   1369 }
   1370 
   1371 void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR,FX_FLOAT dG,FX_FLOAT dB,FX_FLOAT &dC,FX_FLOAT &dM,FX_FLOAT &dY,FX_FLOAT &dK)
   1372 {
   1373 	if (dR<0 || dR>1 || dG<0 || dG>1 || dB<0 || dB>1)
   1374 		return;
   1375 
   1376 	dC = 1.0f - dR;
   1377 	dM = 1.0f - dG;
   1378 	dY = 1.0f - dB;
   1379 	dK = FX_MIN(dC, FX_MIN(dM, dY));
   1380 }
   1381 
   1382 void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color, FX_INT32& alpha, FX_FLOAT& red, FX_FLOAT& green, FX_FLOAT& blue)
   1383 {
   1384 	switch (color.nColorType)
   1385 	{
   1386 	case COLORTYPE_TRANSPARENT:
   1387 		{
   1388 			alpha = 0;
   1389 		}
   1390 		break;
   1391 	case COLORTYPE_GRAY:
   1392 		{
   1393 			ConvertGRAY2RGB(color.fColor1, red, green, blue);
   1394 		}
   1395 		break;
   1396 	case COLORTYPE_RGB:
   1397 		{
   1398 			red = color.fColor1;
   1399 			green = color.fColor2;
   1400 			blue = color.fColor3;
   1401 		}
   1402 		break;
   1403 	case COLORTYPE_CMYK:
   1404 		{
   1405 			ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3, color.fColor4,
   1406 				red, green, blue);
   1407 		}
   1408 		break;
   1409 	}
   1410 }
   1411 
   1412 FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color, FX_INT32 nTransparancy)
   1413 {
   1414 	FX_INT32 nAlpha = nTransparancy;
   1415 	FX_FLOAT dRed = 0;
   1416 	FX_FLOAT dGreen = 0;
   1417 	FX_FLOAT dBlue = 0;
   1418 
   1419 	PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
   1420 
   1421 	return ArgbEncode(nAlpha, (FX_INT32)(dRed*255), (FX_INT32)(dGreen*255), (FX_INT32)(dBlue*255));
   1422 }
   1423 
   1424 void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
   1425 							  const FX_COLORREF & color)
   1426 {
   1427 	CFX_PathData path;
   1428 	CPDF_Rect rcTemp(rect);
   1429 	path.AppendRect(rcTemp.left,rcTemp.bottom,rcTemp.right,rcTemp.top);
   1430 	pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_WINDING);
   1431 }
   1432 
   1433 void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
   1434 							const CPDF_Point* pPts, FX_INT32 nCount, const FX_COLORREF& color)
   1435 {
   1436 	CFX_PathData path;
   1437 	path.SetPointCount(nCount);
   1438 
   1439 	path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_MOVETO);
   1440 	for (FX_INT32 i=1; i<nCount; i++)
   1441 		path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_LINETO);
   1442 
   1443 	pDevice->DrawPath(&path, pUser2Device, NULL, color, 0, FXFILL_ALTERNATE);
   1444 }
   1445 
   1446 void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
   1447 							  const FX_COLORREF & color, FX_FLOAT fWidth)
   1448 {
   1449 	CFX_PathData path;
   1450 	CPDF_Rect rcTemp(rect);
   1451 	path.AppendRect(rcTemp.left,rcTemp.bottom,rcTemp.right,rcTemp.top);
   1452 
   1453 	CFX_GraphStateData gsd;
   1454 	gsd.m_LineWidth = fWidth;
   1455 
   1456 	pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
   1457 }
   1458 
   1459 void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
   1460 							const CPDF_Point & ptMoveTo, const CPDF_Point & ptLineTo, const FX_COLORREF & color, FX_FLOAT fWidth)
   1461 {
   1462 	CFX_PathData path;
   1463 	path.SetPointCount(2);
   1464 	path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_MOVETO);
   1465 	path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_LINETO);
   1466 
   1467 	CFX_GraphStateData gsd;
   1468 	gsd.m_LineWidth = fWidth;
   1469 
   1470 	pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
   1471 }
   1472 
   1473 void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,const CPDF_Rect & rect,
   1474 							  const CPWL_Color & color, FX_INT32 nTransparancy)
   1475 {
   1476 	CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rect,PWLColorToFXColor(color,nTransparancy));
   1477 }
   1478 
   1479 void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
   1480 														FX_BOOL bVertical, FX_BOOL bHorizontal, CPDF_Rect rect,
   1481 														FX_INT32 nTransparancy, FX_INT32 nStartGray, FX_INT32 nEndGray)
   1482 {
   1483 	FX_FLOAT fStepGray = 1.0f;
   1484 
   1485 	if (bVertical)
   1486 	{
   1487 		fStepGray = (nEndGray - nStartGray) / rect.Height();
   1488 
   1489 		for (FX_FLOAT fy=rect.bottom+0.5f; fy<=rect.top-0.5f; fy+=1.0f)
   1490 		{
   1491 			FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fy-rect.bottom));
   1492 			CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(rect.left, fy),
   1493 				CPDF_Point(rect.right, fy), ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
   1494 		}
   1495 	}
   1496 
   1497 	if (bHorizontal)
   1498 	{
   1499 		fStepGray = (nEndGray - nStartGray) / rect.Width();
   1500 
   1501 		for (FX_FLOAT fx=rect.left+0.5f; fx<=rect.right-0.5f; fx+=1.0f)
   1502 		{
   1503 			FX_INT32 nGray = nStartGray + (FX_INT32)(fStepGray * (fx-rect.left));
   1504 			CPWL_Utils::DrawStrokeLine(pDevice, pUser2Device, CPDF_Point(fx, rect.bottom),
   1505 				CPDF_Point(fx, rect.top), ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
   1506 		}
   1507 	}
   1508 }
   1509 
   1510 void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
   1511 												const CPDF_Rect & rect, FX_FLOAT fWidth,
   1512 												const CPWL_Color & color, const CPWL_Color & crLeftTop, const CPWL_Color & crRightBottom,
   1513 												FX_INT32 nStyle, const CPWL_Dash & dash, FX_INT32 nTransparancy)
   1514 {
   1515 	FX_FLOAT fLeft = rect.left;
   1516 	FX_FLOAT fRight = rect.right;
   1517 	FX_FLOAT fTop = rect.top;
   1518 	FX_FLOAT fBottom = rect.bottom;
   1519 
   1520 	if (fWidth > 0.0f)
   1521 	{
   1522 		FX_FLOAT fHalfWidth = fWidth / 2.0f;
   1523 
   1524 		switch (nStyle)
   1525 		{
   1526 		default:
   1527 		case PBS_SOLID:
   1528 			{
   1529 				CFX_PathData path;
   1530 				path.AppendRect(fLeft, fBottom, fRight, fTop);
   1531 				path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth);
   1532 				pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color,nTransparancy), 0, FXFILL_ALTERNATE);
   1533 			}
   1534 			break;
   1535 		case PBS_DASH:
   1536 			{
   1537 				CFX_PathData path;
   1538 
   1539 				path.SetPointCount(5);
   1540 				path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_MOVETO);
   1541 				path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, FXPT_LINETO);
   1542 				path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, FXPT_LINETO);
   1543 				path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_LINETO);
   1544 				path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, FXPT_LINETO);
   1545 
   1546 				CFX_GraphStateData gsd;
   1547 				gsd.SetDashCount(2);
   1548 				gsd.m_DashArray[0] = 3.0f;
   1549 				gsd.m_DashArray[1] = 3.0f;
   1550 				gsd.m_DashPhase = 0;
   1551 
   1552 				gsd.m_LineWidth = fWidth;
   1553 				pDevice->DrawPath(&path, pUser2Device, &gsd, 0, PWLColorToFXColor(color,nTransparancy), FXFILL_WINDING);
   1554 			}
   1555 			break;
   1556 		case PBS_BEVELED:
   1557 		case PBS_INSET:
   1558 			{
   1559 				CFX_GraphStateData gsd;
   1560 				gsd.m_LineWidth = fHalfWidth;
   1561 
   1562 				CFX_PathData pathLT;
   1563 
   1564 				pathLT.SetPointCount(7);
   1565 				pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_MOVETO);
   1566 				pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
   1567 				pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
   1568 				pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO);
   1569 				pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO);
   1570 				pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO);
   1571 				pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO);
   1572 
   1573 				pDevice->DrawPath(&pathLT, pUser2Device, &gsd, PWLColorToFXColor(crLeftTop,nTransparancy), 0, FXFILL_ALTERNATE);
   1574 
   1575 				CFX_PathData pathRB;
   1576 
   1577 				pathRB.SetPointCount(7);
   1578 				pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_MOVETO);
   1579 				pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO);
   1580 				pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, FXPT_LINETO);
   1581 				pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO);
   1582 				pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, FXPT_LINETO);
   1583 				pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, FXPT_LINETO);
   1584 				pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, FXPT_LINETO);
   1585 
   1586 				pDevice->DrawPath(&pathRB, pUser2Device, &gsd, PWLColorToFXColor(crRightBottom,nTransparancy), 0, FXFILL_ALTERNATE);
   1587 
   1588 				CFX_PathData path;
   1589 
   1590 				path.AppendRect(fLeft, fBottom, fRight, fTop);
   1591 				path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth, fRight - fHalfWidth, fTop - fHalfWidth);
   1592 
   1593 				pDevice->DrawPath(&path, pUser2Device, &gsd, PWLColorToFXColor(color,nTransparancy), 0, FXFILL_ALTERNATE);
   1594 			}
   1595 			break;
   1596 		case PBS_UNDERLINED:
   1597 			{
   1598 				CFX_PathData path;
   1599 
   1600 				path.SetPointCount(2);
   1601 				path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_MOVETO);
   1602 				path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_LINETO);
   1603 
   1604 				CFX_GraphStateData gsd;
   1605 				gsd.m_LineWidth = fWidth;
   1606 
   1607 				pDevice->DrawPath(&path, pUser2Device, &gsd,0,  PWLColorToFXColor(color,nTransparancy), FXFILL_ALTERNATE);
   1608 			}
   1609 			break;
   1610 		case PBS_SHADOW:
   1611 			{
   1612 				CFX_PathData path;
   1613 				path.AppendRect(fLeft, fBottom, fRight, fTop);
   1614 				path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, fTop - fWidth);
   1615 				pDevice->DrawPath(&path, pUser2Device, NULL, PWLColorToFXColor(color,nTransparancy/2), 0, FXFILL_ALTERNATE);
   1616 			}
   1617 			break;
   1618 		}
   1619 	}
   1620 }
   1621 
   1622 static void AddSquigglyPath(CFX_PathData & PathData, FX_FLOAT fStartX, FX_FLOAT fEndX, FX_FLOAT fY, FX_FLOAT fStep)
   1623 {
   1624 	PathData.AddPointCount(1);
   1625 	PathData.SetPoint(PathData.GetPointCount() - 1, fStartX, fY, FXPT_MOVETO);
   1626 
   1627 	FX_FLOAT fx;
   1628 	FX_INT32 i;
   1629 
   1630 	for (i=1,fx=fStartX+fStep; fx<fEndX; fx+=fStep,i++)
   1631 	{
   1632 		PathData.AddPointCount(1);
   1633 		PathData.SetPoint(PathData.GetPointCount() - 1, fx, fY + (i&1)*fStep, FXPT_LINETO);
   1634 	}
   1635 }
   1636 
   1637 static void AddSpellCheckObj(CFX_PathData & PathData, IFX_Edit* pEdit, const CPVT_WordRange& wrWord)
   1638 {
   1639 	FX_FLOAT fStartX = 0.0f;
   1640 	FX_FLOAT fEndX = 0.0f;
   1641 	FX_FLOAT fY = 0.0f;
   1642 	FX_FLOAT fStep = 0.0f;
   1643 
   1644 	FX_BOOL bBreak = FALSE;
   1645 
   1646 	if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
   1647 	{
   1648 		pIterator->SetAt(wrWord.BeginPos);
   1649 
   1650 		do
   1651 		{
   1652 			CPVT_WordPlace place = pIterator->GetAt();
   1653 
   1654 			CPVT_Line line;
   1655 			if (pIterator->GetLine(line))
   1656 			{
   1657 				fY = line.ptLine.y;
   1658 				fStep = (line.fLineAscent - line.fLineDescent) / 16.0f;
   1659 			}
   1660 
   1661 			if (place.LineCmp(wrWord.BeginPos) == 0)
   1662 			{
   1663 				pIterator->SetAt(wrWord.BeginPos);
   1664 				CPVT_Word word;
   1665 				if (pIterator->GetWord(word))
   1666 				{
   1667 					fStartX = word.ptWord.x;
   1668 				}
   1669 			}
   1670 			else
   1671 			{
   1672 				fStartX = line.ptLine.x;
   1673 			}
   1674 
   1675 			if (place.LineCmp(wrWord.EndPos) == 0)
   1676 			{
   1677 				pIterator->SetAt(wrWord.EndPos);
   1678 				CPVT_Word word;
   1679 				if (pIterator->GetWord(word))
   1680 				{
   1681 					fEndX = word.ptWord.x + word.fWidth;
   1682 				}
   1683 
   1684 				bBreak = TRUE;
   1685 			}
   1686 			else
   1687 			{
   1688 				fEndX = line.ptLine.x + line.fLineWidth;
   1689 			}
   1690 
   1691 			AddSquigglyPath(PathData, fStartX, fEndX, fY, fStep);
   1692 
   1693 			if (bBreak) break;
   1694 		}
   1695 		while (pIterator->NextLine());
   1696 	}
   1697 }
   1698 
   1699 void CPWL_Utils::DrawEditSpellCheck(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit,
   1700 						const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange,
   1701 						IPWL_SpellCheck * pSpellCheck)
   1702 {
   1703 	const FX_COLORREF crSpell = ArgbEncode(255,255,0,0);
   1704 
   1705 	//for spellcheck
   1706 	FX_BOOL bLatinWord = FALSE;
   1707 	CPVT_WordPlace wpWordStart;
   1708 	CFX_ByteString sLatinWord;
   1709 
   1710 	CFX_PathData pathSpell;
   1711 
   1712 	pDevice->SaveState();
   1713 
   1714 	if (!rcClip.IsEmpty())
   1715 	{
   1716 		CPDF_Rect rcTemp = rcClip;
   1717 		pUser2Device->TransformRect(rcTemp);
   1718 		FX_RECT rcDevClip;
   1719 		rcDevClip.left = (FX_INT32)rcTemp.left;
   1720 		rcDevClip.right = (FX_INT32)rcTemp.right;
   1721 		rcDevClip.top = (FX_INT32)rcTemp.top;
   1722 		rcDevClip.bottom = (FX_INT32)rcTemp.bottom;
   1723 		pDevice->SetClip_Rect(&rcDevClip);
   1724 	}
   1725 
   1726 	if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
   1727 	{
   1728 		if (pEdit->GetFontMap())
   1729 		{
   1730 			if (pRange)
   1731 				pIterator->SetAt(pRange->BeginPos);
   1732 			else
   1733 				pIterator->SetAt(0);
   1734 
   1735 			CPVT_WordPlace oldplace;
   1736 
   1737 			while (pIterator->NextWord())
   1738 			{
   1739 				CPVT_WordPlace place = pIterator->GetAt();
   1740 				if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
   1741 
   1742 				CPVT_Word word;
   1743 				if (pIterator->GetWord(word))
   1744 				{
   1745 					if (FX_EDIT_ISLATINWORD(word.Word))
   1746 					{
   1747 						if (!bLatinWord)
   1748 						{
   1749 							wpWordStart = place;
   1750 							bLatinWord = TRUE;
   1751 						}
   1752 
   1753 						sLatinWord += (char)word.Word;
   1754 					}
   1755 					else
   1756 					{
   1757 						if (bLatinWord)
   1758 						{
   1759 							if (!sLatinWord.IsEmpty())
   1760 							{
   1761 								if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord))
   1762 								{
   1763 									AddSpellCheckObj(pathSpell,pEdit,CPVT_WordRange(wpWordStart,oldplace));
   1764 									pIterator->SetAt(place);
   1765 								}
   1766 							}
   1767 							bLatinWord = FALSE;
   1768 						}
   1769 
   1770 						sLatinWord.Empty();
   1771 					}
   1772 
   1773 					oldplace = place;
   1774 				}
   1775 				else
   1776 				{
   1777 					if (bLatinWord)
   1778 					{
   1779 						if (!sLatinWord.IsEmpty())
   1780 						{
   1781 							if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord))
   1782 							{
   1783 								AddSpellCheckObj(pathSpell,pEdit,CPVT_WordRange(wpWordStart,oldplace));
   1784 								pIterator->SetAt(place);
   1785 							}
   1786 						}
   1787 						bLatinWord = FALSE;
   1788 					}
   1789 
   1790 					sLatinWord.Empty();
   1791 				}
   1792 			}
   1793 
   1794 			if (!sLatinWord.IsEmpty())
   1795 			{
   1796 				if (pSpellCheck && !pSpellCheck->CheckWord(sLatinWord))
   1797 				{
   1798 					AddSpellCheckObj(pathSpell,pEdit,CPVT_WordRange(wpWordStart,oldplace));
   1799 				}
   1800 			}
   1801 		}
   1802 	}
   1803 
   1804 	CFX_GraphStateData gsd;
   1805 	gsd.m_LineWidth = 0;
   1806 	if (pathSpell.GetPointCount() > 0)
   1807 		pDevice->DrawPath(&pathSpell, pUser2Device, &gsd, 0, crSpell, FXFILL_ALTERNATE);
   1808 
   1809 	pDevice->RestoreState();
   1810 }
   1811 
   1812 FX_BOOL CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color)
   1813 {
   1814 	switch (color.nColorType)
   1815 	{
   1816 	case COLORTYPE_TRANSPARENT:
   1817 		return FALSE;
   1818 	case COLORTYPE_GRAY:
   1819 		return color.fColor1 < 0.5f;
   1820 	case COLORTYPE_RGB:
   1821 		return color.fColor1 + color.fColor2 + color.fColor3 < 1.5f;
   1822 	case COLORTYPE_CMYK:
   1823 		return color.fColor1 + color.fColor2 + color.fColor3 + color.fColor4 > 2.0f;
   1824 	}
   1825 
   1826 	return TRUE;
   1827 }
   1828 
   1829 CPWL_Color CPWL_Utils::GetReverseColor(const CPWL_Color& color)
   1830 {
   1831 	CPWL_Color crRet = color;
   1832 
   1833 	switch (color.nColorType)
   1834 	{
   1835 	case COLORTYPE_GRAY:
   1836 		crRet.fColor1 = 1.0f - crRet.fColor1;
   1837 		break;
   1838 	case COLORTYPE_RGB:
   1839 		crRet.fColor1 = 1.0f - crRet.fColor1;
   1840 		crRet.fColor2 = 1.0f - crRet.fColor2;
   1841 		crRet.fColor3 = 1.0f - crRet.fColor3;
   1842 		break;
   1843 	case COLORTYPE_CMYK:
   1844 		crRet.fColor1 = 1.0f - crRet.fColor1;
   1845 		crRet.fColor2 = 1.0f - crRet.fColor2;
   1846 		crRet.fColor3 = 1.0f - crRet.fColor3;
   1847 		crRet.fColor4 = 1.0f - crRet.fColor4;
   1848 		break;
   1849 	}
   1850 
   1851 	return crRet;
   1852 }
   1853 
   1854 CFX_ByteString CPWL_Utils::GetIconAppStream(FX_INT32 nType, const CPDF_Rect& rect, const CPWL_Color& crFill,
   1855 												const CPWL_Color& crStroke)
   1856 {
   1857 	CFX_ByteString sAppStream = CPWL_Utils::GetColorAppStream(crStroke, FALSE);
   1858 	sAppStream += CPWL_Utils::GetColorAppStream(crFill, TRUE);
   1859 
   1860 	CFX_ByteString sPath;
   1861 	CFX_PathData path;
   1862 
   1863 	switch (nType)
   1864 	{
   1865 	case PWL_ICONTYPE_CHECKMARK:
   1866 		GetGraphics_Checkmark(sPath, path, rect, PWLPT_STREAM);
   1867 		break;
   1868 	case PWL_ICONTYPE_CIRCLE:
   1869 		GetGraphics_Circle(sPath, path, rect, PWLPT_STREAM);
   1870 		break;
   1871 	case PWL_ICONTYPE_COMMENT:
   1872 		GetGraphics_Comment(sPath, path, rect, PWLPT_STREAM);
   1873 		break;
   1874 	case PWL_ICONTYPE_CROSS:
   1875 		GetGraphics_Cross(sPath, path, rect, PWLPT_STREAM);
   1876 		break;
   1877 	case PWL_ICONTYPE_HELP:
   1878 		GetGraphics_Help(sPath, path, rect, PWLPT_STREAM);
   1879 		break;
   1880 	case PWL_ICONTYPE_INSERTTEXT:
   1881 		GetGraphics_InsertText(sPath, path, rect, PWLPT_STREAM);
   1882 		break;
   1883 	case PWL_ICONTYPE_KEY:
   1884 		GetGraphics_Key(sPath, path, rect, PWLPT_STREAM);
   1885 		break;
   1886 	case PWL_ICONTYPE_NEWPARAGRAPH:
   1887 		GetGraphics_NewParagraph(sPath, path, rect, PWLPT_STREAM);
   1888 		break;
   1889 	case PWL_ICONTYPE_TEXTNOTE:
   1890 		GetGraphics_TextNote(sPath, path, rect, PWLPT_STREAM);
   1891 		break;
   1892 	case PWL_ICONTYPE_PARAGRAPH:
   1893 		GetGraphics_Paragraph(sPath, path, rect, PWLPT_STREAM);
   1894 		break;
   1895 	case PWL_ICONTYPE_RIGHTARROW:
   1896 		GetGraphics_RightArrow(sPath, path, rect, PWLPT_STREAM);
   1897 		break;
   1898 	case PWL_ICONTYPE_RIGHTPOINTER:
   1899 		GetGraphics_RightPointer(sPath, path, rect, PWLPT_STREAM);
   1900 		break;
   1901 	case PWL_ICONTYPE_STAR:
   1902 		GetGraphics_Star(sPath, path, rect, PWLPT_STREAM);
   1903 		break;
   1904 	case PWL_ICONTYPE_UPARROW:
   1905 		GetGraphics_UpArrow(sPath, path, rect, PWLPT_STREAM);
   1906 		break;
   1907 	case PWL_ICONTYPE_UPLEFTARROW:
   1908 		GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_STREAM);
   1909 		break;
   1910 	case PWL_ICONTYPE_GRAPH:
   1911 		GetGraphics_Graph(sPath, path, rect, PWLPT_STREAM);
   1912 		break;
   1913 	case PWL_ICONTYPE_PAPERCLIP:
   1914 		GetGraphics_Paperclip(sPath, path, rect, PWLPT_STREAM);
   1915 		break;
   1916 	case PWL_ICONTYPE_ATTACHMENT:
   1917 		GetGraphics_Attachment(sPath, path, rect, PWLPT_STREAM);
   1918 		break;
   1919 	case PWL_ICONTYPE_TAG:
   1920 		GetGraphics_Tag(sPath, path, rect, PWLPT_STREAM);
   1921 		break;
   1922 	case PWL_ICONTYPE_FOXIT:
   1923 		GetGraphics_Foxit(sPath, path, rect, PWLPT_STREAM);
   1924 		break;
   1925 	}
   1926 
   1927 	sAppStream += sPath;
   1928 	if (crStroke.nColorType != COLORTYPE_TRANSPARENT)
   1929 		sAppStream += "B*\n";
   1930 	else
   1931 		sAppStream += "f*\n";
   1932 
   1933 	return sAppStream;
   1934 }
   1935 
   1936 void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device,
   1937 						FX_INT32 nType, const CPDF_Rect & rect, const CPWL_Color& crFill, const CPWL_Color& crStroke, const FX_INT32 nTransparancy)
   1938 {
   1939 	CFX_GraphStateData gsd;
   1940 	gsd.m_LineWidth = 1.0f;
   1941 
   1942 	CFX_ByteString sPath;
   1943 	CFX_PathData path;
   1944 
   1945 	switch (nType)
   1946 	{
   1947 	case PWL_ICONTYPE_CHECKMARK:
   1948 		GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA);
   1949 		break;
   1950 	case PWL_ICONTYPE_CIRCLE:
   1951 		GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA);
   1952 		break;
   1953 	case PWL_ICONTYPE_COMMENT:
   1954 		GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA);
   1955 		break;
   1956 	case PWL_ICONTYPE_CROSS:
   1957 		GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA);
   1958 		break;
   1959 	case PWL_ICONTYPE_HELP:
   1960 		GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA);
   1961 		break;
   1962 	case PWL_ICONTYPE_INSERTTEXT:
   1963 		GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA);
   1964 		break;
   1965 	case PWL_ICONTYPE_KEY:
   1966 		GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA);
   1967 		break;
   1968 	case PWL_ICONTYPE_NEWPARAGRAPH:
   1969 		GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA);
   1970 		break;
   1971 	case PWL_ICONTYPE_TEXTNOTE:
   1972 		GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA);
   1973 		break;
   1974 	case PWL_ICONTYPE_PARAGRAPH:
   1975 		GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA);
   1976 		break;
   1977 	case PWL_ICONTYPE_RIGHTARROW:
   1978 		GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA);
   1979 		break;
   1980 	case PWL_ICONTYPE_RIGHTPOINTER:
   1981 		GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA);
   1982 		break;
   1983 	case PWL_ICONTYPE_STAR:
   1984 		GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA);
   1985 		break;
   1986 	case PWL_ICONTYPE_UPARROW:
   1987 		GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA);
   1988 		break;
   1989 	case PWL_ICONTYPE_UPLEFTARROW:
   1990 		GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA);
   1991 		break;
   1992 	case PWL_ICONTYPE_GRAPH:
   1993 		GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA);
   1994 		break;
   1995 	case PWL_ICONTYPE_PAPERCLIP:
   1996 		GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA);
   1997 		break;
   1998 	case PWL_ICONTYPE_ATTACHMENT:
   1999 		GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA);
   2000 		break;
   2001 	case PWL_ICONTYPE_TAG:
   2002 		GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA);
   2003 		break;
   2004 	case PWL_ICONTYPE_FOXIT:
   2005 		GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA);
   2006 		break;
   2007 	default:
   2008 		return;
   2009 	}
   2010 
   2011 	pDevice->DrawPath(&path, pUser2Device, &gsd,
   2012 		PWLColorToFXColor(crFill,nTransparancy), PWLColorToFXColor(crStroke,nTransparancy), FXFILL_ALTERNATE);
   2013 }
   2014 
   2015 void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2016 {
   2017 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2018 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2019 
   2020 	CPWL_PathData PathArray[] =
   2021 	{
   2022 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth / 15.0f, crBBox.bottom + fHeight * 2 / 5.0f),PWLPT_MOVETO),
   2023 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth / 15.0f + PWL_BEZIER*(fWidth / 7.0f - fWidth / 15.0f),
   2024 					  crBBox.bottom + fHeight * 2 / 5.0f + PWL_BEZIER*(fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)), PWLPT_BEZIERTO),
   2025 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f + PWL_BEZIER*(fWidth / 5.0f - fWidth / 4.5f),
   2026 					  crBBox.bottom + fHeight / 16.0f + PWL_BEZIER*(fHeight / 5.0f - fHeight / 16.0f)), PWLPT_BEZIERTO),
   2027 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f, crBBox.bottom + fHeight / 16.0f), PWLPT_BEZIERTO),
   2028 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f + PWL_BEZIER*(fWidth / 4.4f - fWidth / 4.5f),
   2029 		              crBBox.bottom + fHeight / 16.0f - PWL_BEZIER*fHeight / 16.0f), PWLPT_BEZIERTO),
   2030 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + PWL_BEZIER*(fWidth / 4.0f - fWidth / 3.0f),
   2031 		              crBBox.bottom), PWLPT_BEZIERTO),
   2032 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f, crBBox.bottom), PWLPT_BEZIERTO),
   2033 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + PWL_BEZIER*fWidth*(1/7.0f + 2/15.0f),
   2034 		              crBBox.bottom + PWL_BEZIER*fHeight * 4 / 5.0f), PWLPT_BEZIERTO),
   2035 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth * 14 / 15.0f + PWL_BEZIER*fWidth*(1/7.0f - 7/15.0f),
   2036 		              crBBox.bottom + fHeight * 15/16.0f + PWL_BEZIER*(fHeight * 4/5.0f - fHeight * 15/16.0f)), PWLPT_BEZIERTO),
   2037 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth * 14 / 15.0f,crBBox.bottom + fHeight * 15 / 16.0f), PWLPT_BEZIERTO),
   2038 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth * 14 / 15.0f + PWL_BEZIER*(fWidth * 7 / 15.0f - fWidth * 14 / 15.0f),
   2039 		              crBBox.bottom + fHeight * 15 / 16.0f + PWL_BEZIER*(fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)), PWLPT_BEZIERTO),
   2040 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f + PWL_BEZIER*(fWidth / 3.4f - fWidth / 3.6f),
   2041 		              crBBox.bottom + fHeight / 3.5f + PWL_BEZIER*(fHeight / 3.5f - fHeight / 3.5f)), PWLPT_BEZIERTO),
   2042 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f,crBBox.bottom + fHeight / 3.5f), PWLPT_BEZIERTO),
   2043 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f,
   2044 		              crBBox.bottom + fHeight / 3.5f + PWL_BEZIER*(fHeight / 4.0f - fHeight / 3.5f)), PWLPT_BEZIERTO),
   2045 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth / 15.0f + PWL_BEZIER*(fWidth / 3.5f - fWidth / 15.0f),
   2046 		              crBBox.bottom + fHeight * 2 / 5.0f + PWL_BEZIER*(fHeight * 3.5f / 5.0f - fHeight * 2 / 5.0f)), PWLPT_BEZIERTO),
   2047 		CPWL_PathData(CPWL_Point(crBBox.left  + fWidth / 15.0f,crBBox.bottom + fHeight * 2 / 5.0f), PWLPT_BEZIERTO)
   2048 	};
   2049 
   2050 	if(type == PWLPT_STREAM)
   2051 		sPathData = GetAppStreamFromArray(PathArray, 16);
   2052 	else
   2053 		GetPathDataFromArray(path, PathArray, 16);
   2054 }
   2055 
   2056 void CPWL_Utils::GetGraphics_Circle(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2057 {
   2058 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2059 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2060 
   2061 	CPWL_PathData PathArray[] =
   2062 	{
   2063 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f,crBBox.bottom + fHeight/2.0f), PWLPT_MOVETO),
   2064 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f,
   2065 		              crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*14/15.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2066 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth/15.0f), crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO),
   2067 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f,crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO),
   2068 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*14/15.0f - fWidth/2.0f), crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO),
   2069 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*14/15.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2070 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO),
   2071 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight/2.0f - fHeight/15.0f)), PWLPT_BEZIERTO),
   2072 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*14/15.0f - fWidth/2.0f), crBBox.bottom + fHeight/15.0f), PWLPT_BEZIERTO),
   2073 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/15.0f), PWLPT_BEZIERTO),
   2074 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth/15.0f), crBBox.bottom + fHeight/15.0f), PWLPT_BEZIERTO),
   2075 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight/2.0f - fHeight/15.0f)), PWLPT_BEZIERTO),
   2076 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f,crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO),
   2077 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_MOVETO),
   2078 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2079 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth*3/15.0f), crBBox.top - fHeight*3/15.0f), PWLPT_BEZIERTO),
   2080 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight*3/15.0f), PWLPT_BEZIERTO),
   2081 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*4/5.0f - fWidth/2.0f), crBBox.top - fHeight*3/15.0f), PWLPT_BEZIERTO),
   2082 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2083 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO),
   2084 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2085 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*(fWidth*4/5.0f - fWidth/2.0f), crBBox.bottom + fHeight*3/15.0f), PWLPT_BEZIERTO),
   2086 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight*3/15.0f), PWLPT_BEZIERTO),
   2087 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth*4/5.0f - fWidth/2.0f), crBBox.bottom + fHeight*3/15.0f), PWLPT_BEZIERTO),
   2088 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f - PWL_BEZIER*(fHeight*4/5.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2089 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*3/15.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO)
   2090 	};
   2091 
   2092 	if(type == PWLPT_STREAM)
   2093 		sPathData = GetAppStreamFromArray(PathArray, 26);
   2094 	else
   2095 		GetPathDataFromArray(path, PathArray, 26);
   2096 }
   2097 
   2098 void CPWL_Utils::GetGraphics_Comment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2099 {
   2100 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2101 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2102 
   2103 	CPWL_PathData PathArray[] =
   2104 	{
   2105 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.top - fHeight/6.0f), PWLPT_MOVETO),
   2106 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.top - fHeight/6.0f + PWL_BEZIER*(fHeight/6.0f - fHeight/10.0f)), PWLPT_BEZIERTO),
   2107 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f - PWL_BEZIER*fWidth/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO),
   2108 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO),
   2109 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.top - fHeight/10.0f), PWLPT_LINETO),
   2110 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f + PWL_BEZIER*fWidth/15.0f, crBBox.top - fHeight/10.0f), PWLPT_BEZIERTO),
   2111 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/6 + PWL_BEZIER*(fHeight/6.0f - fHeight/10.0f)), PWLPT_BEZIERTO),
   2112 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/6.0f), PWLPT_BEZIERTO),
   2113 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight/3.0f), PWLPT_LINETO),
   2114 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.bottom + fHeight*4/15.0f + PWL_BEZIER*fHeight/15.0f), PWLPT_BEZIERTO),
   2115 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f + PWL_BEZIER*fWidth/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO),
   2116 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO),
   2117 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2118 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f, crBBox.bottom + fHeight*2/15 + PWL_BEZIER*fHeight*2/15.0f), PWLPT_BEZIERTO),
   2119 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*5/15.0f - PWL_BEZIER*fWidth*2/15.0f, crBBox.bottom + fHeight*2/15.0f), PWLPT_BEZIERTO),
   2120 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*6/30.0f, crBBox.bottom + fHeight*2/15.0f), PWLPT_BEZIERTO),
   2121 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/30.0f + PWL_BEZIER*fWidth/30.0f, crBBox.bottom + fHeight*2/15.0f), PWLPT_BEZIERTO),
   2122 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/30.0f, crBBox.bottom + fHeight*2/15.0f + PWL_BEZIER*fHeight*2/15.0f), PWLPT_BEZIERTO),
   2123 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/30.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO),
   2124 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2125 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f - PWL_BEZIER*fWidth/15.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_BEZIERTO),
   2126 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.bottom + fHeight/3.0f - PWL_BEZIER*fHeight/15.0f), PWLPT_BEZIERTO),
   2127 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.bottom + fHeight/3.0f), PWLPT_BEZIERTO),
   2128 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/15.0f, crBBox.top - fHeight/6.0f), PWLPT_LINETO),
   2129 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.top - fHeight*8/30.0f), PWLPT_MOVETO),
   2130 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.top - fHeight*8/30.0f), PWLPT_LINETO),
   2131 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15, crBBox.top - fHeight*25/60.0f), PWLPT_MOVETO),
   2132 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*2/15.0f, crBBox.top - fHeight*25/60.0f), PWLPT_LINETO),
   2133 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*2/15.0f, crBBox.top - fHeight*17/30.0f), PWLPT_MOVETO),
   2134 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*4/15.0f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO)
   2135 	};
   2136 
   2137 	if(type == PWLPT_STREAM)
   2138 		sPathData = GetAppStreamFromArray(PathArray, 30);
   2139 	else
   2140 		GetPathDataFromArray(path, PathArray, 30);
   2141 }
   2142 
   2143 void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2144 {
   2145 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2146 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2147 	//FX_FLOAT fcatercorner = (FX_FLOAT)sqrt(fWidth*fWidth + fHeight*fHeight);
   2148 	CPWL_Point center_point(crBBox.left + fWidth/2, crBBox.bottom + fHeight/2);
   2149 
   2150 	CPWL_PathData PathArray[] =
   2151 	{
   2152 		CPWL_PathData(CPWL_Point(center_point.x, center_point.y + fHeight/10.0f), PWLPT_MOVETO),
   2153 		CPWL_PathData(CPWL_Point(center_point.x + fWidth*0.3f, center_point.y + fHeight/10.0f + fWidth*0.3f), PWLPT_LINETO),
   2154 		CPWL_PathData(CPWL_Point(center_point.x + fWidth/10.0f + fWidth*0.3f, center_point.y + fHeight*0.3f), PWLPT_LINETO),
   2155 		CPWL_PathData(CPWL_Point(center_point.x + fWidth/10.0f, center_point.y), PWLPT_LINETO),
   2156 		CPWL_PathData(CPWL_Point(center_point.x + fWidth/10.0f + fWidth*0.3f, center_point.y - fHeight*0.3f), PWLPT_LINETO),
   2157 		CPWL_PathData(CPWL_Point(center_point.x + fWidth*0.3f, center_point.y - fHeight/10.0f - fHeight*0.3f), PWLPT_LINETO),
   2158 		CPWL_PathData(CPWL_Point(center_point.x, center_point.y - fHeight/10.0f), PWLPT_LINETO),
   2159 		CPWL_PathData(CPWL_Point(center_point.x - fWidth*0.3f, center_point.y - fHeight/10 - fHeight*0.3f), PWLPT_LINETO),
   2160 		CPWL_PathData(CPWL_Point(center_point.x - fWidth/10.0f - fWidth*0.3f, center_point.y - fHeight*0.3f), PWLPT_LINETO),
   2161 		CPWL_PathData(CPWL_Point(center_point.x - fWidth/10, center_point.y), PWLPT_LINETO),
   2162 		CPWL_PathData(CPWL_Point(center_point.x - fWidth/10 - fWidth*0.3f, center_point.y + fHeight*0.3f), PWLPT_LINETO),
   2163 		CPWL_PathData(CPWL_Point(center_point.x - fWidth*0.3f, center_point.y + fHeight/10.0f + fHeight*0.3f), PWLPT_LINETO),
   2164 		CPWL_PathData(CPWL_Point(center_point.x, center_point.y + fHeight/10.0f), PWLPT_LINETO)
   2165 	};
   2166 
   2167 	if(type == PWLPT_STREAM)
   2168 		sPathData = GetAppStreamFromArray(PathArray, 13);
   2169 	else
   2170 		GetPathDataFromArray(path, PathArray, 13);
   2171 }
   2172 
   2173 void CPWL_Utils::GetGraphics_Help(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2174 {
   2175 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2176 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2177 
   2178 	CPWL_PathData PathArray[] =
   2179 	{
   2180 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f), PWLPT_MOVETO),
   2181 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight/60.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2182 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*(fWidth/2.0f - fWidth/60.0f), crBBox.bottom + fHeight/60.0f), PWLPT_BEZIERTO),
   2183 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/60.0f), PWLPT_BEZIERTO),
   2184 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*fWidth*29/60.0f, crBBox.bottom + fHeight/60.0f), PWLPT_BEZIERTO),
   2185 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*(fHeight/60.0f - fHeight/2.0f)), PWLPT_BEZIERTO),
   2186 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/60.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO),
   2187 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/60.0f, crBBox.bottom + fHeight/2.0f + PWL_BEZIER*fHeight*29/60.0f), PWLPT_BEZIERTO),
   2188 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + PWL_BEZIER*fWidth*29/60.0f, crBBox.top - fHeight/60.0f), PWLPT_BEZIERTO),
   2189 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/60.0f), PWLPT_BEZIERTO),
   2190 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f - PWL_BEZIER*fWidth*29/60.0f, crBBox.top - fHeight/60.0f), PWLPT_BEZIERTO),
   2191 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f  + PWL_BEZIER*fHeight*29/60.0f), PWLPT_BEZIERTO),
   2192 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60.0f, crBBox.bottom + fHeight/2.0f), PWLPT_BEZIERTO),
   2193 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f), PWLPT_MOVETO),
   2194 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.23f), PWLPT_BEZIERTO),
   2195 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f - PWL_BEZIER*fWidth*0.23f, crBBox.bottom + fHeight*0.87f), PWLPT_BEZIERTO),
   2196 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.87f), PWLPT_BEZIERTO),
   2197 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f + PWL_BEZIER*fWidth*0.23f, crBBox.bottom + fHeight*0.87f), PWLPT_BEZIERTO),
   2198 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.27f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.23f), PWLPT_BEZIERTO),
   2199 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.27f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO),
   2200 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.27f - fWidth*0.08f*0.2f, crBBox.top - fHeight*0.36f - fHeight*0.15f*0.7f), PWLPT_BEZIERTO),
   2201 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.35f + fWidth*0.08f*0.2f, crBBox.top - fHeight*0.51f + fHeight*0.15f*0.2f), PWLPT_BEZIERTO),
   2202 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.35f, crBBox.top - fHeight*0.51f), PWLPT_BEZIERTO),
   2203 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.35f - fWidth*0.1f*0.5f, crBBox.top - fHeight*0.51f - fHeight*0.15f*0.3f), PWLPT_BEZIERTO),
   2204 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f - fWidth*0.1f*0.5f, crBBox.top - fHeight*0.68f + fHeight*0.15f*0.5f), PWLPT_BEZIERTO),
   2205 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.top - fHeight*0.68f), PWLPT_BEZIERTO),
   2206 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.bottom + fHeight*0.30f), PWLPT_LINETO),
   2207 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.bottom + fHeight*0.30f - fWidth*0.1f*0.7f), PWLPT_BEZIERTO),
   2208 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f, crBBox.bottom + fHeight*0.30f - fWidth*0.1f*0.7f), PWLPT_BEZIERTO),
   2209 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f, crBBox.bottom + fHeight*0.30f), PWLPT_BEZIERTO),
   2210 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f, crBBox.top - fHeight*0.66f), PWLPT_LINETO),
   2211 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.55f - fWidth*0.1f*0.05f, crBBox.top - fHeight*0.66f + fHeight*0.18f*0.5f), PWLPT_BEZIERTO),
   2212 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f - fWidth*0.1f*0.05f, crBBox.top - fHeight*0.48f - fHeight*0.18f*0.3f), PWLPT_BEZIERTO),
   2213 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f, crBBox.top - fHeight*0.48f), PWLPT_BEZIERTO),
   2214 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.45f + fWidth*0.08f*0.2f, crBBox.top - fHeight*0.48f + fHeight*0.18f*0.2f), PWLPT_BEZIERTO),
   2215 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.37f - fWidth*0.08f*0.2f, crBBox.top - fHeight*0.36f - fHeight*0.18f*0.7f), PWLPT_BEZIERTO),
   2216 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.37f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO),
   2217 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.37f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.13f), PWLPT_BEZIERTO),
   2218 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f + PWL_BEZIER*fWidth*0.13f, crBBox.bottom + fHeight*0.77f), PWLPT_BEZIERTO),
   2219 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.77f), PWLPT_BEZIERTO),
   2220 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f - PWL_BEZIER*fWidth*0.13f, crBBox.bottom + fHeight*0.77f), PWLPT_BEZIERTO),
   2221 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.37f, crBBox.top - fHeight*0.36f + PWL_BEZIER*fHeight*0.13f), PWLPT_BEZIERTO),
   2222 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.37f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO),
   2223 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.37f, crBBox.top - fHeight*0.36f - fWidth*0.1f*0.6f), PWLPT_BEZIERTO),
   2224 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f - fWidth*0.1f*0.6f), PWLPT_BEZIERTO),
   2225 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.27f, crBBox.top - fHeight*0.36f), PWLPT_BEZIERTO),
   2226 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f), PWLPT_MOVETO),
   2227 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f + PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
   2228 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f - PWL_BEZIER*fWidth*0.095f, crBBox.bottom + fHeight*0.185f), PWLPT_BEZIERTO),
   2229 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f, crBBox.bottom + fHeight*0.185f), PWLPT_BEZIERTO),
   2230 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f + PWL_BEZIER*fWidth*0.065f, crBBox.bottom + fHeight*0.185f), PWLPT_BEZIERTO),
   2231 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.44f, crBBox.bottom + fHeight*0.13f + PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
   2232 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.44f, crBBox.bottom + fHeight*0.13f), PWLPT_BEZIERTO),
   2233 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.44f, crBBox.bottom + fHeight*0.13f - PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
   2234 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f + PWL_BEZIER*fWidth*0.065f, crBBox.bottom + fHeight*0.075f), PWLPT_BEZIERTO),
   2235 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f, crBBox.bottom + fHeight*0.075f), PWLPT_BEZIERTO),
   2236 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.505f - PWL_BEZIER*fWidth*0.065f, crBBox.bottom + fHeight*0.075f), PWLPT_BEZIERTO),
   2237 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f - PWL_BEZIER*fHeight*0.055f), PWLPT_BEZIERTO),
   2238 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.56f, crBBox.bottom + fHeight*0.13f), PWLPT_BEZIERTO)
   2239 	};
   2240 
   2241 	if(type == PWLPT_STREAM)
   2242 		sPathData = GetAppStreamFromArray(PathArray, 59);
   2243 	else
   2244 		GetPathDataFromArray(path, PathArray, 59);
   2245 }
   2246 
   2247 void CPWL_Utils::GetGraphics_InsertText(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2248 {
   2249 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2250 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2251 
   2252 	CPWL_PathData PathArray[] =
   2253 	{
   2254 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10, crBBox.bottom + fHeight/10), PWLPT_MOVETO),
   2255 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2, crBBox.top - fHeight*2/15), PWLPT_LINETO),
   2256 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10, crBBox.bottom + fHeight/10), PWLPT_LINETO),
   2257 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10, crBBox.bottom + fHeight/10), PWLPT_LINETO)
   2258 	};
   2259 
   2260 	if(type == PWLPT_STREAM)
   2261 		sPathData = GetAppStreamFromArray(PathArray, 4);
   2262 	else
   2263 		GetPathDataFromArray(path, PathArray, 4);
   2264 }
   2265 
   2266 void CPWL_Utils::GetGraphics_Key(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2267 {
   2268 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2269 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2270 	FX_FLOAT k = -fHeight/fWidth;
   2271 	CPWL_Point tail;
   2272 	CPWL_Point CicleCenter;
   2273 	tail.x = crBBox.left + fWidth*0.9f;
   2274 	tail.y = k*(tail.x - crBBox.right) + crBBox.bottom;
   2275 	CicleCenter.x = crBBox.left + fWidth*0.15f;
   2276 	CicleCenter.y = k*(CicleCenter.x - crBBox.right) + crBBox.bottom;
   2277 
   2278 	CPWL_PathData PathArray[] =
   2279 	{
   2280 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30.0f, -fWidth/30.0f/k + tail.y), PWLPT_MOVETO),
   2281 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30.0f - fWidth*0.18f, -k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2282 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f + fWidth*0.07f,
   2283 		              -fWidth*0.07f/k - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2284 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 + fWidth*0.07f,
   2285 		              -fWidth*0.07f/k - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2286 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20,
   2287 		              -k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2288 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15,
   2289 		              -k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2290 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15 + fWidth*0.07f,
   2291 		              -fWidth*0.07f/k - k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2292 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15 - fWidth/20 + fWidth*0.07f,
   2293 		              -fWidth*0.07f/k + -k*fWidth/20 + -k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2294 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.18f - fWidth/20 - fWidth/15 - fWidth/20,
   2295 		              -k*fWidth/20 + -k*fWidth/15 - k*fWidth/20 - k*fWidth*0.18f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2296 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.45f, -k*fWidth*0.45f - fWidth/30/k + tail.y), PWLPT_LINETO),
   2297 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30 - fWidth*0.45f + fWidth*0.2f,
   2298 		              -fWidth*0.4f/k - k*fWidth*0.45f - fWidth/30/k + tail.y), PWLPT_BEZIERTO),
   2299 		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.2f, - fWidth*0.1f/k + CicleCenter.y), PWLPT_BEZIERTO),
   2300 		CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
   2301 		CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth/60.0f, -k*fWidth/60 + CicleCenter.y), PWLPT_BEZIERTO),
   2302 		CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth/60, -k*fWidth/60 + CicleCenter.y), PWLPT_BEZIERTO),
   2303 		CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
   2304 		CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth*0.22f, fWidth*0.35f/k + CicleCenter.y - fHeight*0.05f), PWLPT_BEZIERTO),
   2305 		CPWL_PathData(CPWL_Point(tail.x - fWidth/30 - fWidth*0.45f - fWidth*0.18f, fWidth*0.05f/k - k*fWidth*0.45f + fWidth/30/k + tail.y - fHeight*0.05f), PWLPT_BEZIERTO),
   2306 		CPWL_PathData(CPWL_Point(tail.x - fWidth/30.0f - fWidth*0.45f, -k*fWidth*0.45f + fWidth/30.0f/k + tail.y), PWLPT_BEZIERTO),
   2307 		CPWL_PathData(CPWL_Point(tail.x - fWidth/30.0f, fWidth/30.0f/k + tail.y), PWLPT_LINETO),
   2308 		CPWL_PathData(CPWL_Point(tail.x + fWidth/30, -fWidth/30/k + tail.y), PWLPT_LINETO),
   2309  		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f, k*fWidth*0.08f + CicleCenter.y), PWLPT_MOVETO),
   2310  		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f + fWidth*0.1f, -fWidth*0.1f/k + k*fWidth*0.08f + CicleCenter.y), PWLPT_BEZIERTO),
   2311  		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.22f + fWidth*0.1f, k*fWidth*0.22f + CicleCenter.y - fWidth*0.1f/k), PWLPT_BEZIERTO),
   2312  		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.22f, k*fWidth*0.22f + CicleCenter.y), PWLPT_BEZIERTO),
   2313  		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.22f - fWidth*0.1f, fWidth*0.1f/k + k*fWidth*0.22f + CicleCenter.y), PWLPT_BEZIERTO),
   2314 		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f - fWidth*0.1f, fWidth*0.1f/k + k*fWidth*0.08f + CicleCenter.y), PWLPT_BEZIERTO),
   2315  		CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth*0.08f, k*fWidth*0.08f + CicleCenter.y), PWLPT_BEZIERTO)
   2316 	};
   2317 
   2318 	if(type == PWLPT_STREAM)
   2319 		sPathData = GetAppStreamFromArray(PathArray, 28);
   2320 	else
   2321 		GetPathDataFromArray(path, PathArray, 28);
   2322 }
   2323 
   2324 void CPWL_Utils::GetGraphics_NewParagraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2325 {
   2326 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2327 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2328 
   2329 	CPWL_PathData PathArray[] =
   2330 	{
   2331 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/20.0f), PWLPT_MOVETO),
   2332 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO),
   2333 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO),
   2334 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/20.0f), PWLPT_LINETO),
   2335 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.12f, crBBox.top - fHeight*17/30.0f), PWLPT_MOVETO),
   2336 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.12f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO),
   2337 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.22f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO),
   2338 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.22f, crBBox.top - fHeight*17/30.0f - fWidth*0.14f), PWLPT_LINETO),
   2339 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.38f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO),
   2340 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.48f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO),
   2341 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.48f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO),
   2342 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.38f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO),
   2343 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.38f, crBBox.bottom + fWidth*0.24f), PWLPT_LINETO),
   2344 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.22f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO),
   2345 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.12f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO),
   2346 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.bottom + fHeight/10.0f), PWLPT_MOVETO),
   2347 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO),
   2348 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/10.0f + fHeight/7.0f), PWLPT_LINETO),
   2349 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.97f, crBBox.bottom + fHeight/10.0f + fHeight/7.0f), PWLPT_BEZIERTO),
   2350 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.97f, crBBox.top - fHeight*17/30.0f), PWLPT_BEZIERTO),
   2351 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight*17/30.0f), PWLPT_BEZIERTO),
   2352 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*17/30.0f), PWLPT_LINETO),
   2353 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.bottom + fHeight/10.0f), PWLPT_LINETO),
   2354 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/7 + fHeight*0.18f), PWLPT_MOVETO),
   2355 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.85f, crBBox.bottom + fHeight/7 + fHeight*0.18f), PWLPT_BEZIERTO),
   2356 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.85f, crBBox.top - fHeight*17/30.0f - fHeight*0.08f), PWLPT_BEZIERTO),
   2357 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight*17/30.0f - fHeight*0.08f), PWLPT_BEZIERTO),
   2358 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/7 + fHeight*0.18f), PWLPT_LINETO)
   2359 	};
   2360 
   2361 	if(type == PWLPT_STREAM)
   2362 		sPathData = GetAppStreamFromArray(PathArray, 28);
   2363 	else
   2364 		GetPathDataFromArray(path, PathArray, 28);
   2365 }
   2366 
   2367 void CPWL_Utils::GetGraphics_TextNote(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2368 {
   2369 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2370 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2371 
   2372 	CPWL_PathData PathArray[] =
   2373 	{
   2374 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_MOVETO),
   2375 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*7/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2376 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2377 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.top - fHeight/15.0f), PWLPT_LINETO),
   2378 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10.0f, crBBox.top - fHeight/15.0f), PWLPT_LINETO),
   2379 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2380 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2381 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2382 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2383 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2384 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.bottom + fHeight*4/15.0f), PWLPT_LINETO),
   2385 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/5.0f, crBBox.top - fHeight*4/15.0f), PWLPT_MOVETO),
   2386 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/5.0f, crBBox.top - fHeight*4/15.0f), PWLPT_LINETO),
   2387 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/5.0f, crBBox.top - fHeight*7/15.0f), PWLPT_MOVETO),
   2388 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/5.0f, crBBox.top - fHeight*7/15.0f), PWLPT_LINETO),
   2389 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/5.0f, crBBox.top - fHeight*10/15.0f), PWLPT_MOVETO),
   2390 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*3/10.0f, crBBox.top - fHeight*10/15.0f), PWLPT_LINETO)
   2391 	};
   2392 
   2393 	if(type == PWLPT_STREAM)
   2394 		sPathData = GetAppStreamFromArray(PathArray, 17);
   2395 	else
   2396 		GetPathDataFromArray(path, PathArray, 17);
   2397 }
   2398 
   2399 void CPWL_Utils::GetGraphics_Paragraph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2400 {
   2401 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2402 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2403 
   2404 	CPWL_PathData PathArray[] =
   2405 	{
   2406 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_MOVETO),
   2407 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight/15.0f), PWLPT_LINETO),
   2408 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2409 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.634f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2410 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.634f, crBBox.top - fHeight*2/15.0f), PWLPT_LINETO),
   2411 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.566f, crBBox.top - fHeight*2/15.0f), PWLPT_LINETO),
   2412 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.566f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2413 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2414 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f - fHeight*0.4f), PWLPT_LINETO),
   2415 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.2f, crBBox.top - fHeight/15.0f - fHeight*0.4f), PWLPT_BEZIERTO),
   2416 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.2f, crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO),
   2417 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_BEZIERTO)
   2418 	};
   2419 
   2420 	if(type == PWLPT_STREAM)
   2421 		sPathData = GetAppStreamFromArray(PathArray, 12);
   2422 	else
   2423 		GetPathDataFromArray(path, PathArray, 12);
   2424 }
   2425 
   2426 void CPWL_Utils::GetGraphics_RightArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2427 {
   2428 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2429 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2430 
   2431 	CPWL_PathData PathArray[] =
   2432 	{
   2433 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/2.0f), PWLPT_MOVETO),
   2434 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + fWidth/8.0f, crBBox.bottom + fHeight/5.0f), PWLPT_LINETO),
   2435 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.bottom + fHeight/5.0f), PWLPT_LINETO),
   2436 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f - fWidth*0.15f, crBBox.top - fHeight/2.0f - fWidth/25.0f), PWLPT_LINETO),
   2437 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.1f, crBBox.top - fHeight/2.0f - fWidth/25.0f), PWLPT_LINETO),
   2438 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.1f, crBBox.top - fHeight/2.0f + fWidth/25.0f), PWLPT_LINETO),
   2439 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f - fWidth*0.15f, crBBox.top - fHeight/2.0f + fWidth/25.0f), PWLPT_LINETO),
   2440 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/5.0f), PWLPT_LINETO),
   2441 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f + fWidth/8.0f, crBBox.top - fHeight/5.0f), PWLPT_LINETO),
   2442 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO)
   2443 	};
   2444 
   2445 	if(type == PWLPT_STREAM)
   2446 		sPathData = GetAppStreamFromArray(PathArray, 10);
   2447 	else
   2448 		GetPathDataFromArray(path, PathArray, 10);
   2449 }
   2450 
   2451 void CPWL_Utils::GetGraphics_RightPointer(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2452 {
   2453 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2454 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2455 
   2456 	CPWL_PathData PathArray[] =
   2457 	{
   2458 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30.0f, crBBox.top - fHeight/2.0f), PWLPT_MOVETO),
   2459 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/30.0f, crBBox.bottom + fHeight/6.0f), PWLPT_LINETO),
   2460 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*4/15.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO),
   2461 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/30.0f, crBBox.top - fHeight/6.0f), PWLPT_LINETO),
   2462 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30.0f, crBBox.top - fHeight/2.0f), PWLPT_LINETO)
   2463 	};
   2464 
   2465 	if(type == PWLPT_STREAM)
   2466 		sPathData = GetAppStreamFromArray(PathArray, 5);
   2467 	else
   2468 		GetPathDataFromArray(path, PathArray, 5);
   2469 }
   2470 
   2471 void CPWL_Utils::GetGraphics_Star(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2472 {
   2473 	FX_FLOAT fLongRadius = (crBBox.top - crBBox.bottom)/(1+(FX_FLOAT)cos(PWL_PI/5.0f));
   2474 	fLongRadius = fLongRadius * 0.7f;
   2475 	FX_FLOAT fShortRadius = fLongRadius * 0.55f;
   2476 	CPDF_Point ptCenter = CPDF_Point((crBBox.left + crBBox.right) / 2.0f,(crBBox.top + crBBox.bottom) / 2.0f);
   2477 
   2478 	FX_FLOAT px1[5], py1[5];
   2479 	FX_FLOAT px2[5], py2[5];
   2480 
   2481 	FX_FLOAT fAngel = PWL_PI/10.0f;
   2482 
   2483 	for (FX_INT32 i=0; i<5; i++)
   2484 	{
   2485 		px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
   2486 		py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
   2487 
   2488 		fAngel += PWL_PI * 2 / 5.0f;
   2489 	}
   2490 
   2491 	fAngel = PWL_PI/5.0f + PWL_PI/10.0f;
   2492 
   2493 	for (FX_INT32 j=0; j<5; j++)
   2494 	{
   2495 		px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
   2496 		py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
   2497 
   2498 		fAngel += PWL_PI * 2 / 5.0f;
   2499 	}
   2500 
   2501 	CPWL_PathData PathArray[11];
   2502 	PathArray[0] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_MOVETO);
   2503 	PathArray[1] = CPWL_PathData(CPWL_Point(px2[0], py2[0]), PWLPT_LINETO);
   2504 
   2505 	for(FX_INT32 k = 0; k < 4; k++)
   2506 	{
   2507 		PathArray[(k+1)*2] = CPWL_PathData(CPWL_Point(px1[k+1], py1[k+1]), PWLPT_LINETO);
   2508 		PathArray[(k+1)*2 + 1] = CPWL_PathData(CPWL_Point(px2[k+1], py2[k+1]), PWLPT_LINETO);
   2509 	}
   2510 
   2511 	PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO);
   2512 
   2513 	if(type == PWLPT_STREAM)
   2514 		sPathData = GetAppStreamFromArray(PathArray, 11);
   2515 	else
   2516 		GetPathDataFromArray(path, PathArray, 11);
   2517 }
   2518 
   2519 void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2520 {
   2521 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2522 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2523 
   2524 	CPWL_PathData PathArray[] =
   2525 	{
   2526 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_MOVETO),
   2527 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/10.0f, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO),
   2528 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO),
   2529 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2530 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.bottom + fHeight/15.0f), PWLPT_LINETO),
   2531 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO),
   2532 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/10, crBBox.top - fWidth*3/5.0f), PWLPT_LINETO),
   2533 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/2.0f, crBBox.top - fHeight/15.0f), PWLPT_LINETO)
   2534 	};
   2535 
   2536 	if(type == PWLPT_STREAM)
   2537 		sPathData = GetAppStreamFromArray(PathArray, 8);
   2538 	else
   2539 		GetPathDataFromArray(path, PathArray, 8);
   2540 }
   2541 
   2542 void CPWL_Utils::GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2543 {
   2544 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2545 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2546 	CPWL_Point leftup(crBBox.left, crBBox.top);
   2547 	CPWL_Point rightdown(crBBox.right, crBBox.bottom);
   2548 	FX_FLOAT k = -fHeight/fWidth;
   2549 	CPWL_Point tail;
   2550 	tail.x = crBBox.left + fWidth*4/5.0f;
   2551 	tail.y = k*(tail.x - crBBox.right) + rightdown.y;
   2552 
   2553 	CPWL_PathData PathArray[] =
   2554 	{
   2555 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/20.0f, k*(crBBox.left + fWidth/20.0f - rightdown.x) + rightdown.y), PWLPT_MOVETO),
   2556 		CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x + fWidth/10.0f + fWidth/5.0f,
   2557 		              -fWidth/5.0f/k + tail.y - fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO),
   2558 		CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x + fWidth/10.0f,
   2559 		              tail.y - fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO),
   2560 		CPWL_PathData(CPWL_Point(tail.x + fWidth/10.0f, tail.y - fWidth/10.0f/k), PWLPT_LINETO),
   2561 		CPWL_PathData(CPWL_Point(tail.x - fWidth/10.0f, tail.y + fWidth/10.0f/k), PWLPT_LINETO),
   2562 		CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x - fWidth/10.0f, tail.y + fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO),
   2563 		CPWL_PathData(CPWL_Point(fHeight*17/60.0f/k + tail.x - fWidth/10.0f - fWidth/5.0f,
   2564 		              fWidth/5.0f/k + tail.y + fWidth/10.0f/k + fHeight*17/60.0f), PWLPT_LINETO),
   2565 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/20.0f, k*(crBBox.left + fWidth/20.0f - rightdown.x) + rightdown.y), PWLPT_LINETO)
   2566 	};
   2567 
   2568 	if(type == PWLPT_STREAM)
   2569 		sPathData = GetAppStreamFromArray(PathArray, 8);
   2570 	else
   2571 		GetPathDataFromArray(path, PathArray, 8);
   2572 }
   2573 
   2574 void CPWL_Utils::GetGraphics_Graph(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2575 {
   2576 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2577 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2578 
   2579 	CPWL_PathData PathArray[] =
   2580 	{
   2581 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.05f, crBBox.top - fWidth*0.15f), PWLPT_MOVETO),
   2582 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.25f, crBBox.top - fHeight*0.15f), PWLPT_LINETO),
   2583 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2584 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.05f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2585 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.05f, crBBox.top - fWidth*0.15f), PWLPT_LINETO),
   2586 
   2587 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.top - fWidth*0.45f), PWLPT_MOVETO),
   2588 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.475f, crBBox.top - fWidth*0.45f), PWLPT_LINETO),
   2589 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.475f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2590 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2591 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.275f, crBBox.top - fWidth*0.45f), PWLPT_LINETO),
   2592 
   2593 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.top - fHeight*0.05f), PWLPT_MOVETO),
   2594 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.top - fHeight*0.05f), PWLPT_LINETO),
   2595 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.7f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2596 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2597 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.top - fHeight*0.05f), PWLPT_LINETO),
   2598 
   2599 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.725f, crBBox.top - fWidth*0.35f), PWLPT_MOVETO),
   2600 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.925f, crBBox.top - fWidth*0.35f), PWLPT_LINETO),
   2601 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.925f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2602 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.725f, crBBox.bottom + fHeight*0.08f), PWLPT_LINETO),
   2603 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.725f, crBBox.top - fWidth*0.35f), PWLPT_LINETO)
   2604 	};
   2605 
   2606 	if(type == PWLPT_STREAM)
   2607 		sPathData = GetAppStreamFromArray(PathArray, 20);
   2608 	else
   2609 		GetPathDataFromArray(path, PathArray, 20);
   2610 }
   2611 
   2612 void CPWL_Utils::GetGraphics_Paperclip(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2613 {
   2614 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2615 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2616 
   2617 	CPWL_PathData PathArray[] =
   2618 	{
   2619 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.top - fHeight*0.25f), PWLPT_MOVETO),
   2620 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.bottom + fHeight*0.25f), PWLPT_LINETO),
   2621 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.bottom + fHeight*0.25f - fWidth*57/60.0f*0.35f), PWLPT_BEZIERTO),
   2622 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.bottom + fHeight*0.25f - fWidth*57/60.0f*0.35f), PWLPT_BEZIERTO),
   2623 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.bottom + fHeight*0.25f), PWLPT_BEZIERTO),
   2624 
   2625 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.top - fHeight*0.33f), PWLPT_LINETO),
   2626 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30, crBBox.top - fHeight*0.33f + fHeight/15*0.5f), PWLPT_BEZIERTO),
   2627 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.top - fHeight*0.33f + fHeight/15*0.5f), PWLPT_BEZIERTO),
   2628 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.top - fHeight*0.33f), PWLPT_BEZIERTO),
   2629 
   2630 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.bottom + fHeight*0.2f), PWLPT_LINETO),
   2631 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/30 - fWidth*0.12f, crBBox.bottom + fHeight*0.2f - (fWidth*57/60.0f - fWidth*0.24f)*0.25f), PWLPT_BEZIERTO),
   2632 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.bottom + fHeight*0.2f - (fWidth*57/60.0f - fWidth*0.24f)*0.25f), PWLPT_BEZIERTO),
   2633 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.bottom + fHeight*0.2f), PWLPT_BEZIERTO),
   2634 
   2635 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.top - fHeight*0.2f), PWLPT_LINETO),
   2636 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60 + fWidth*0.12f, crBBox.top - fHeight*0.2f + (fWidth*11/12.0f - fWidth*0.36f)*0.25f), PWLPT_BEZIERTO),
   2637 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.top - fHeight*0.2f + (fWidth*11/12.0f - fWidth*0.36f)*0.25f), PWLPT_BEZIERTO),
   2638 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.top - fHeight*0.2f), PWLPT_BEZIERTO),
   2639 
   2640 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.bottom + fHeight*0.25f), PWLPT_LINETO),
   2641 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.24f, crBBox.bottom + fHeight*0.25f - (fWidth*14/15.0f - fWidth*0.53f)*0.25f), PWLPT_BEZIERTO),
   2642 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.bottom + fHeight*0.25f - (fWidth*14/15.0f - fWidth*0.53f)*0.25f), PWLPT_BEZIERTO),
   2643 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.bottom + fHeight*0.25f), PWLPT_BEZIERTO),
   2644 
   2645 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.top - fHeight*0.33f), PWLPT_LINETO),
   2646 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.29f, crBBox.top - fHeight*0.33f + fWidth*0.12f*0.35f), PWLPT_BEZIERTO),
   2647 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.top - fHeight*0.33f + fWidth*0.12f*0.35f), PWLPT_BEZIERTO),
   2648 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.top - fHeight*0.33f), PWLPT_BEZIERTO),
   2649 
   2650 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.bottom + fHeight*0.3f), PWLPT_LINETO),
   2651 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.17f, crBBox.bottom + fHeight*0.3f - fWidth*(14/15.0f - 0.29f)*0.35f), PWLPT_BEZIERTO),
   2652 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.bottom + fHeight*0.3f - fWidth*(14/15.0f - 0.29f)*0.35f), PWLPT_BEZIERTO),
   2653 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.bottom + fHeight*0.3f), PWLPT_BEZIERTO),
   2654 
   2655 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.top - fHeight*0.25f), PWLPT_LINETO),
   2656 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth/15 - fWidth*0.12f, crBBox.top - fHeight*0.25f + fWidth*0.35f*(11/12.0f - 0.12f)), PWLPT_BEZIERTO),
   2657 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.top - fHeight*0.25f + fWidth*0.35f*(11/12.0f - 0.12f)), PWLPT_BEZIERTO),
   2658 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth/60, crBBox.top - fHeight*0.25f), PWLPT_BEZIERTO)
   2659 	};
   2660 
   2661 	if(type == PWLPT_STREAM)
   2662 		sPathData = GetAppStreamFromArray(PathArray, 33);
   2663 	else
   2664 		GetPathDataFromArray(path, PathArray, 33);
   2665 }
   2666 
   2667 void CPWL_Utils::GetGraphics_Attachment(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2668 {
   2669 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2670 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2671 
   2672 	CPWL_PathData PathArray[] =
   2673 	{
   2674 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.25f, crBBox.top - fHeight*0.1f), PWLPT_MOVETO),
   2675 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.23f), PWLPT_LINETO),
   2676 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_LINETO),
   2677 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO),
   2678 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO),
   2679 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO),
   2680 
   2681 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.23f), PWLPT_LINETO),
   2682 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.25f, crBBox.top - fHeight*0.1f), PWLPT_LINETO),
   2683 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.25f, crBBox.top - fHeight*0.1f), PWLPT_LINETO),
   2684 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.23f), PWLPT_LINETO),
   2685 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.23f), PWLPT_LINETO),
   2686 
   2687 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_MOVETO),
   2688 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f - fWidth*0.25f*0.4f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO),
   2689 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.15f, crBBox.top - fHeight*0.65f + fHeight*0.15f*0.4f), PWLPT_BEZIERTO),
   2690 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.15f, crBBox.top - fHeight*0.65f), PWLPT_BEZIERTO),
   2691 
   2692 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.15f, crBBox.top - fHeight*0.65f), PWLPT_LINETO),
   2693 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.15f, crBBox.top - fHeight*0.65f + fHeight*0.15f*0.4f), PWLPT_BEZIERTO),
   2694 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f + fWidth*0.25f*0.4f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO),
   2695 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO),
   2696 
   2697 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.6f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO),
   2698 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f + fWidth*0.04f), PWLPT_BEZIERTO),
   2699 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_BEZIERTO),
   2700 
   2701 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.top - fHeight*0.65f), PWLPT_MOVETO),
   2702 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.5f, crBBox.bottom + fHeight*0.1f), PWLPT_LINETO)
   2703 	};
   2704 
   2705 	if(type == PWLPT_STREAM)
   2706 		sPathData = GetAppStreamFromArray(PathArray, 24);
   2707 	else
   2708 		GetPathDataFromArray(path, PathArray, 24);
   2709 }
   2710 
   2711 void CPWL_Utils::GetGraphics_Tag(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2712 {
   2713 	FX_FLOAT fWidth = crBBox.right - crBBox.left;
   2714 	FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
   2715 
   2716 	CPWL_PathData PathArray[] =
   2717 	{
   2718 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.1f), PWLPT_MOVETO),
   2719 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.1f, crBBox.top - fHeight*0.5f), PWLPT_LINETO),
   2720 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.3f, crBBox.bottom + fHeight*0.1f), PWLPT_LINETO),
   2721 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.1f, crBBox.bottom + fHeight*0.1f), PWLPT_LINETO),
   2722 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.1f, crBBox.top - fHeight*0.1f), PWLPT_LINETO),
   2723 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.1f), PWLPT_LINETO),
   2724 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.3f), PWLPT_MOVETO),
   2725 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.2f, crBBox.top - fHeight*0.3f), PWLPT_LINETO),
   2726 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.5f), PWLPT_MOVETO),
   2727 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.2f, crBBox.top - fHeight*0.5f), PWLPT_LINETO),
   2728 		CPWL_PathData(CPWL_Point(crBBox.left + fWidth*0.4f, crBBox.top - fHeight*0.7f), PWLPT_MOVETO),
   2729 		CPWL_PathData(CPWL_Point(crBBox.right - fWidth*0.2f, crBBox.top - fHeight*0.7f), PWLPT_LINETO)
   2730 	};
   2731 
   2732 	if(type == PWLPT_STREAM)
   2733 		sPathData = GetAppStreamFromArray(PathArray, 12);
   2734 	else
   2735 		GetPathDataFromArray(path, PathArray, 12);
   2736 }
   2737 
   2738 void CPWL_Utils::GetGraphics_Foxit(CFX_ByteString& sPathData, CFX_PathData& path, const CPDF_Rect& crBBox, const PWL_PATH_TYPE type)
   2739 {
   2740 	FX_FLOAT fOutWidth = crBBox.right - crBBox.left;
   2741 	FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom;
   2742 
   2743 	CPDF_Rect crInBox = crBBox;
   2744 	crInBox.left = crBBox.left + fOutWidth*0.08f;
   2745 	crInBox.right = crBBox.right - fOutWidth*0.08f;
   2746 	crInBox.top = crBBox.top - fOutHeight*0.08f;
   2747 	crInBox.bottom = crBBox.bottom + fOutHeight*0.08f;
   2748 
   2749 	FX_FLOAT fWidth = crInBox.right - crInBox.left;
   2750 	FX_FLOAT fHeight = crInBox.top - crInBox.bottom;
   2751 
   2752 	CPWL_PathData PathArray[] =
   2753 	{
   2754 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_MOVETO),
   2755 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f, crInBox.top), PWLPT_LINETO),
   2756 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f, crInBox.top - PWL_BEZIER * fHeight * 0.4f), PWLPT_BEZIERTO),
   2757 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.45f  - PWL_BEZIER * fWidth * 0.45f, crInBox.top - fHeight*0.4f), PWLPT_BEZIERTO),
   2758 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.4f), PWLPT_BEZIERTO),
   2759 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_LINETO),
   2760 
   2761 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.60f, crInBox.top), PWLPT_MOVETO),
   2762 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f, crInBox.top), PWLPT_LINETO),
   2763 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f, crInBox.top - PWL_BEZIER * fHeight * 0.7f), PWLPT_BEZIERTO),
   2764 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.75f  - PWL_BEZIER * fWidth * 0.75f, crInBox.top - fHeight*0.7f), PWLPT_BEZIERTO),
   2765 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.7f), PWLPT_BEZIERTO),
   2766 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.55f), PWLPT_LINETO),
   2767 		CPWL_PathData(CPWL_Point(crInBox.left + PWL_BEZIER * fWidth*0.60f, crInBox.top - fHeight*0.55f), PWLPT_BEZIERTO),
   2768 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top - PWL_BEZIER * fHeight * 0.55f), PWLPT_BEZIERTO),
   2769 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top), PWLPT_BEZIERTO),
   2770 
   2771 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f, crInBox.top), PWLPT_MOVETO),
   2772 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f, crInBox.top - PWL_BEZIER * fHeight * 0.85f), PWLPT_BEZIERTO),
   2773 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f  - PWL_BEZIER * fWidth * 0.90f, crInBox.top - fHeight*0.85f), PWLPT_BEZIERTO),
   2774 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight*0.85f), PWLPT_BEZIERTO),
   2775 		CPWL_PathData(CPWL_Point(crInBox.left, crInBox.bottom), PWLPT_LINETO),
   2776 		CPWL_PathData(CPWL_Point(crInBox.right, crInBox.bottom), PWLPT_LINETO),
   2777 		CPWL_PathData(CPWL_Point(crInBox.right, crInBox.top), PWLPT_LINETO),
   2778 		CPWL_PathData(CPWL_Point(crInBox.left + fWidth*0.90f, crInBox.top), PWLPT_LINETO),
   2779 
   2780 		/*
   2781 		CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_MOVETO),
   2782 		CPWL_PathData(CPWL_Point(crBBox.right, crBBox.top), PWLPT_LINETO),
   2783 		CPWL_PathData(CPWL_Point(crBBox.right, crBBox.bottom), PWLPT_LINETO),
   2784 		CPWL_PathData(CPWL_Point(crBBox.left, crBBox.bottom), PWLPT_LINETO),
   2785 		CPWL_PathData(CPWL_Point(crBBox.left, crBBox.top), PWLPT_LINETO),
   2786 
   2787 		CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_MOVETO),
   2788 		CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO),
   2789 		CPWL_PathData(CPWL_Point(crBBox.right-fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO),
   2790 		CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.bottom+fOutHeight*0.04f), PWLPT_LINETO),
   2791 		CPWL_PathData(CPWL_Point(crBBox.left+fOutWidth*0.04f, crBBox.top-fOutHeight*0.04f), PWLPT_LINETO),
   2792 		*/
   2793 	};
   2794 
   2795 	if(type == PWLPT_STREAM)
   2796 		sPathData = GetAppStreamFromArray(PathArray, 23);
   2797 	else
   2798 		GetPathDataFromArray(path, PathArray, 23);
   2799 }
   2800 
   2801 void CPWL_Color::ConvertColorType(FX_INT32 nColorType)
   2802 {
   2803 	switch (this->nColorType)
   2804 	{
   2805 	case COLORTYPE_TRANSPARENT:
   2806 		break;
   2807 	case COLORTYPE_GRAY:
   2808 		switch (nColorType)
   2809 		{
   2810 		case COLORTYPE_RGB:
   2811 			CPWL_Utils::ConvertGRAY2RGB(this->fColor1, this->fColor1, this->fColor2, this->fColor3);
   2812 			break;
   2813 		case COLORTYPE_CMYK:
   2814 			CPWL_Utils::ConvertGRAY2CMYK(this->fColor1, this->fColor1, this->fColor2, this->fColor3, this->fColor4);
   2815 			break;
   2816 		}
   2817 		break;
   2818 	case COLORTYPE_RGB:
   2819 		switch (nColorType)
   2820 		{
   2821 		case COLORTYPE_GRAY:
   2822 			CPWL_Utils::ConvertRGB2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor1);
   2823 			break;
   2824 		case COLORTYPE_CMYK:
   2825 			CPWL_Utils::ConvertRGB2CMYK(this->fColor1, this->fColor2, this->fColor3, this->fColor1, this->fColor2, this->fColor3, this->fColor4);
   2826 			break;
   2827 		}
   2828 		break;
   2829 	case COLORTYPE_CMYK:
   2830 		switch (nColorType)
   2831 		{
   2832 		case COLORTYPE_GRAY:
   2833 			CPWL_Utils::ConvertCMYK2GRAY(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1);
   2834 			break;
   2835 		case COLORTYPE_RGB:
   2836 			CPWL_Utils::ConvertCMYK2RGB(this->fColor1, this->fColor2, this->fColor3, this->fColor4, this->fColor1, this->fColor2, this->fColor3);
   2837 			break;
   2838 		}
   2839 		break;
   2840 	}
   2841 	this->nColorType = nColorType;
   2842 }
   2843 
   2844 
   2845