Lines 535-604
PrinterGfx::DrawPolyLineBezier (sal_uInt32 nPoints, const Point* pPath, const BY
Link Here
|
535 |
const sal_uInt32 nBezString = 1024; |
535 |
const sal_uInt32 nBezString = 1024; |
536 |
sal_Char pString[nBezString]; |
536 |
sal_Char pString[nBezString]; |
537 |
|
537 |
|
538 |
if ( maLineColor.Is() && nPoints && pPath ) |
538 |
if ( nPoints > 1 && maLineColor.Is() && pPath ) |
539 |
{ |
539 |
{ |
540 |
PSSetColor (maLineColor); |
540 |
PSSetColor (maLineColor); |
541 |
PSSetColor (); |
541 |
PSSetColor (); |
542 |
PSSetLineWidth (); |
542 |
PSSetLineWidth (); |
543 |
|
543 |
|
544 |
if (pFlgAry[0] != POLY_NORMAL) //There must be a starting point to moveto |
544 |
snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y()); |
545 |
{ |
545 |
WritePS(mpPageBody, pString); |
546 |
return; |
|
|
547 |
} |
548 |
else |
549 |
{ |
550 |
snprintf(pString, nBezString, "%li %li moveto\n", pPath[0].X(), pPath[0].Y()); |
551 |
WritePS(mpPageBody, pString); |
552 |
} |
553 |
|
546 |
|
554 |
// Handle the drawing of mixed lines mixed with curves |
547 |
// Handle the drawing of mixed lines mixed with curves |
555 |
// - a normal point followed by a normal point is a line |
548 |
// - a normal point followed by a normal point is a line |
556 |
// - a normal point followed by 2 control points and a normal point is a curve |
549 |
// - a normal point followed by 2 control points and a normal point is a curve |
557 |
for (unsigned int i=1; i<nPoints;) |
550 |
for (unsigned int i=1; i<nPoints;) |
558 |
{ |
551 |
{ |
559 |
if (pFlgAry[i+1] != POLY_CONTROL) //If the next point is a POLY_NORMAL, we're drawing a line |
552 |
if (pFlgAry[i] != POLY_CONTROL) //If the next point is a POLY_NORMAL, we're drawing a line |
560 |
{ |
553 |
{ |
561 |
if (i+1 >= nPoints) return; //Make sure we don't pass the end of the array |
|
|
562 |
snprintf(pString, nBezString, "%li %li lineto\n", pPath[i].X(), pPath[i].Y()); |
554 |
snprintf(pString, nBezString, "%li %li lineto\n", pPath[i].X(), pPath[i].Y()); |
563 |
i++; |
555 |
i++; |
564 |
} |
556 |
} |
565 |
else //Otherwise we're drawing a spline |
557 |
else //Otherwise we're drawing a spline |
566 |
{ |
558 |
{ |
567 |
if (i+3 >= nPoints) return; //Make sure we don't pass the end of the array |
559 |
if (i+2 >= nPoints) |
568 |
snprintf(pString, nBezString, "%li %li %li %li %li %li curveto\n", |
560 |
return; //Error: wrong sequence of contol/normal points somehow |
569 |
pPath[i+1].X(), pPath[i+1].Y(), |
561 |
if ((pFlgAry[i] == POLY_CONTROL) && (pFlgAry[i+1] == POLY_CONTROL) && |
570 |
pPath[i+2].X(), pPath[i+2].Y(), |
562 |
(pFlgAry[i+2] != POLY_CONTROL)) |
571 |
pPath[i+3].X(), pPath[i+3].Y()); |
563 |
{ |
|
|
564 |
snprintf(pString, nBezString, "%li %li %li %li %li %li curveto\n", |
565 |
pPath[i].X(), pPath[i].Y(), |
566 |
pPath[i+1].X(), pPath[i+1].Y(), |
567 |
pPath[i+2].X(), pPath[i+2].Y()); |
568 |
} |
569 |
else |
570 |
{ |
571 |
fprintf(stderr, "Strange output\n"); |
572 |
} |
572 |
i+=3; |
573 |
i+=3; |
573 |
} |
574 |
} |
574 |
WritePS(mpPageBody, pString); |
575 |
WritePS(mpPageBody, pString); |
575 |
} |
576 |
} |
576 |
} |
|
|
577 |
|
578 |
// if eofill and stroke, save the current path |
579 |
if( maFillColor.Is() && maLineColor.Is()) |
580 |
PSGSave(); |
581 |
|
582 |
// first draw area |
583 |
if( maFillColor.Is() ) |
584 |
{ |
585 |
PSSetColor (maFillColor); |
586 |
PSSetColor (); |
587 |
WritePS (mpPageBody, "eofill\n"); |
588 |
} |
589 |
|
590 |
// restore the current path |
591 |
if( maFillColor.Is() && maLineColor.Is()) |
592 |
PSGRestore(); |
593 |
|
577 |
|
594 |
// now draw outlines |
578 |
// now draw outlines |
595 |
if( maLineColor.Is() ) |
|
|
596 |
{ |
597 |
PSSetColor (maLineColor); |
598 |
PSSetColor (); |
599 |
PSSetLineWidth (); |
600 |
WritePS (mpPageBody, "stroke\n"); |
579 |
WritePS (mpPageBody, "stroke\n"); |
601 |
} |
580 |
} |
602 |
} |
581 |
} |
603 |
|
582 |
|
604 |
void |
583 |
void |