40#include <osl/diagnose.h>
41#include <com/sun/star/task/XStatusIndicator.hpp>
42#include <officecfg/Office/Common.hxx>
49#define POSTSCRIPT_BOUNDINGSEARCH 0x1000
52#define EPS_PREVIEW_TIFF 1
53#define EPS_PREVIEW_EPSI 2
63 struct StackMember * pSucc;
86 PSLZWCTreeNode* pBrother;
87 PSLZWCTreeNode* pFirstChild;
92enum NMode {PS_NONE = 0x00, PS_SPACE = 0x01, PS_RET = 0x02, PS_WRAP = 0x04};
103 sal_uInt32 mnLatestPush;
109 sal_Int32 mnTextMode;
113 std::unique_ptr<GDIMetaFile>
121 StackMember* pGDIStack;
122 sal_uInt32 mnCursorPos;
130 Color aTextFillColor;
131 Color aBackgroundColor;
143 std::unique_ptr<PSLZWCTreeNode[]> pTable;
144 PSLZWCTreeNode* pPrefix;
145 sal_uInt16 nDataSize;
146 sal_uInt16 nClearCode;
148 sal_uInt16 nTableSize;
149 sal_uInt16 nCodeSize;
153 css::uno::Reference< css::task::XStatusIndicator > xStatusIndicator;
155 void ImplWriteProlog(
const Graphic* pPreviewEPSI );
156 void ImplWriteEpilog();
161 inline void ImplExecMode( NMode nMode );
164 inline void ImplWriteLine(
const char*, NMode nMode = PS_RET );
167 void ImplWriteF( sal_Int32 nNumb,
sal_uInt8 nCount = 3, NMode nMode = PS_SPACE );
170 void ImplWriteDouble(
double );
173 void ImplWriteLong( sal_Int32 nNumb, NMode nMode = PS_SPACE );
176 void ImplWriteByte(
sal_uInt8 nNumb, NMode nMode = PS_SPACE );
179 void ImplWriteHexByte(
sal_uInt8 nNumb, NMode nMode = PS_WRAP );
184 inline void ImplWritePoint(
const Point& );
185 void ImplMoveTo(
const Point& );
186 void ImplLineTo(
const Point&, NMode nMode = PS_SPACE );
187 void ImplCurveTo(
const Point& rP1,
const Point& rP2,
const Point& rP3, NMode nMode );
188 void ImplTranslate(
const double& fX,
const double& fY );
189 void ImplScale(
const double& fX,
const double& fY );
194 void ImplWriteLineInfo(
const LineInfo& rLineInfo );
199 void ImplPolyPoly(
const tools::PolyPolygon & rPolyPolygon,
bool bTextOutline =
false );
202 void ImplSetClipRegion(
vcl::Region const & rRegion );
203 void ImplBmp(
Bitmap const *,
AlphaMask const *,
const Point &,
double nWidth,
double nHeight );
205 void ImplSetAttrForText(
const Point & rPoint );
206 void ImplWriteCharacter(
char );
208 void ImplDefineFont(
const char*,
const char* );
210 void ImplClosePathDraw();
213 inline void ImplWriteLineColor( NMode nMode );
214 inline void ImplWriteFillColor( NMode nMode );
215 inline void ImplWriteTextColor( NMode nMode );
216 void ImplWriteColor( NMode nMode );
218 static double ImplGetScaling(
const MapMode& );
219 void ImplGetMapMode(
const MapMode& );
220 static bool ImplGetBoundingBox(
double* nNumb,
sal_uInt8* pSource, sal_uInt32 nSize );
223 void StartCompression();
225 void EndCompression();
226 inline void WriteBits( sal_uInt16 nCode, sal_uInt16 nCodeLen );
240 , mbLevelWarning(false)
244 , mbCompression(false)
255 , bTextFillColor(false)
274 sal_uInt32 nStreamPosition = 0, nPSPosition = 0;
278 mbLevelWarning =
false;
279 mnLatestPush = 0xEFFFFFFE;
281 if ( pFilterConfigItem )
284 if ( xStatusIndicator.is() )
286 xStatusIndicator->start( OUString(), 100 );
290 mpPS = &rTargetStream;
291 mpPS->
SetEndian( SvStreamEndian::LITTLE );
297 mbCompression =
false;
299 mbCompression =
true;
304 if ( pFilterConfigItem )
307 mnPreview = pFilterConfigItem->
ReadInt32(
"Preview", 0 );
309 mnPreview = pFilterConfigItem->
ReadInt32(
"Preview", 1 );
314 mbGrayScale = pFilterConfigItem->
ReadInt32(
"ColorFormat", 1 ) == 2;
316 mbCompression = pFilterConfigItem->
ReadInt32(
"CompressionMode", 0 ) != 0;
318 mbCompression = pFilterConfigItem->
ReadInt32(
"CompressionMode", 1 ) == 1;
320 mnTextMode = pFilterConfigItem->
ReadInt32(
"TextMode", 0 );
321 if ( mnTextMode > 2 )
329 mbCompression =
false;
335 nStreamPosition = rTargetStream.
Tell();
349 if ( nErrCode == ERRCODE_NONE )
351 nPSPosition = rTargetStream.
TellEnd();
352 rTargetStream.
Seek( nStreamPosition + 20 );
354 rTargetStream.
Seek( nPSPosition );
358 mnPreview &=~ EPS_PREVIEW_TIFF;
359 rTargetStream.
Seek( nStreamPosition - 4 );
378 pAMTF->Record( pTmpVDev );
379 pTmpVDev->DrawBitmapEx(
Point(), aBmp );
381 pAMTF->SetPrefSize( aBmp.GetSizePixel() );
385 nBoundingX2 = pMTF->GetPrefSize().Width();
386 nBoundingY2 = pMTF->GetPrefSize().Height();
394 bTextFillColor =
true;
403 if( pMTF->GetActionSize() )
407 ImplWriteActions( *pMTF, *pVDev );
411 sal_uInt32 nPosition = rTargetStream.
Tell();
412 rTargetStream.
Seek( nStreamPosition );
414 rTargetStream.
WriteUInt32( nPosition - nPSPosition );
415 rTargetStream.
Seek( nPosition );
420 pGDIStack=pGS->pSucc;
427 if ( mbStatus && mbLevelWarning && pFilterConfigItem )
436 if ( xStatusIndicator.is() )
437 xStatusIndicator->end();
442void PSWriter::ImplWriteProlog(
const Graphic* pPreview )
444 ImplWriteLine(
"%!PS-Adobe-3.0 EPSF-3.0 " );
445 mpPS->WriteOString(
"%%BoundingBox: " );
449 pMTF->GetPrefMapMode(),
MapMode(MapUnit::MapPoint));
450 ImplWriteLong( aSizePoint.
Width() );
451 ImplWriteLong( aSizePoint.
Height() ,PS_RET );
452 ImplWriteLine(
"%%Pages: 0" );
454 OUString aCreatorOverride = officecfg::Office::Common::Save::Document::GeneratorOverride::get();
455 if( !aCreatorOverride.isEmpty())
456 aCreator = aCreatorOverride;
461 ImplWriteLine(
"%%Title: none" );
462 ImplWriteLine(
"%%CreationDate: none" );
466 mpPS->WriteOString(
"%%LanguageLevel: " );
467 ImplWriteLong( mnLevel, PS_RET );
468 if ( !mbGrayScale && mnLevel == 1 )
469 ImplWriteLine(
"%%Extensions: CMYK" );
470 ImplWriteLine(
"%%EndComments" );
471 if ( pPreview && aSizePoint.
Width() && aSizePoint.
Height() )
473 Size aSizeBitmap( ( aSizePoint.
Width() + 7 ) & ~7, aSizePoint.
Height() );
480 mpPS->WriteOString(
"%%BeginPreview: " );
481 ImplWriteLong( aSizeBitmap.Width() );
482 ImplWriteLong( aSizeBitmap.Height() );
483 mpPS->WriteOString(
"1 " );
484 sal_Int32 nLines = aSizeBitmap.Width() / 312;
485 if ( ( nLines * 312 ) != aSizeBitmap.Width() )
487 nLines *= aSizeBitmap.Height();
488 ImplWriteLong( nLines );
489 sal_Int32 nCount2,
nCount = 4;
491 for (
tools::Long nY = 0; nY < aSizeBitmap.Height(); nY++ )
496 for (
tools::Long nX = 0; nX < aSizeBitmap.Width(); nX++ )
500 ImplExecMode( PS_RET );
501 mpPS->WriteOString(
"%" );
507 if ( ! ( --nCount ) )
513 mpPS->WriteChar( nVal );
521 ImplExecMode( PS_RET );
522 ImplWriteLine(
"%%EndPreview" );
525 ImplWriteLine(
"%%BeginProlog" );
526 ImplWriteLine(
"%%BeginResource: procset SDRes-Prolog 1.0 0" );
529 ImplWriteLine(
"/b4_inc_state save def\n/dict_count countdictstack def\n/op_count count 1 sub def\nuserdict begin" );
530 ImplWriteLine(
"0 setgray 0 setlinecap 1 setlinewidth 0 setlinejoin 10 setmiterlimit[] 0 setdash newpath" );
531 ImplWriteLine(
"/languagelevel where {pop languagelevel 1 ne {false setstrokeadjust false setoverprint} if} if" );
533 ImplWriteLine(
"/bdef {bind def} bind def" );
535 ImplWriteLine(
"/c {setgray} bdef" );
537 ImplWriteLine(
"/c {setrgbcolor} bdef" );
538 ImplWriteLine(
"/l {neg lineto} bdef" );
539 ImplWriteLine(
"/rl {neg rlineto} bdef" );
540 ImplWriteLine(
"/lc {setlinecap} bdef" );
541 ImplWriteLine(
"/lj {setlinejoin} bdef" );
542 ImplWriteLine(
"/lw {setlinewidth} bdef" );
543 ImplWriteLine(
"/ml {setmiterlimit} bdef" );
544 ImplWriteLine(
"/ld {setdash} bdef" );
545 ImplWriteLine(
"/m {neg moveto} bdef" );
546 ImplWriteLine(
"/ct {6 2 roll neg 6 2 roll neg 6 2 roll neg curveto} bdef" );
547 ImplWriteLine(
"/r {rotate} bdef" );
548 ImplWriteLine(
"/t {neg translate} bdef" );
549 ImplWriteLine(
"/s {scale} bdef" );
550 ImplWriteLine(
"/sw {show} bdef" );
551 ImplWriteLine(
"/gs {gsave} bdef" );
552 ImplWriteLine(
"/gr {grestore} bdef" );
554 ImplWriteLine(
"/f {findfont dup length dict begin" );
555 ImplWriteLine(
"{1 index /FID ne {def} {pop pop} ifelse} forall /Encoding ISOLatin1Encoding def" );
556 ImplWriteLine(
"currentdict end /NFont exch definefont pop /NFont findfont} bdef" );
558 ImplWriteLine(
"/p {closepath} bdef" );
559 ImplWriteLine(
"/sf {scalefont setfont} bdef" );
561 ImplWriteLine(
"/ef {eofill}bdef" );
562 ImplWriteLine(
"/pc {closepath stroke}bdef" );
563 ImplWriteLine(
"/ps {stroke}bdef" );
564 ImplWriteLine(
"/pum {matrix currentmatrix}bdef" );
565 ImplWriteLine(
"/pom {setmatrix}bdef" );
566 ImplWriteLine(
"/bs {/aString exch def /nXOfs exch def /nWidth exch def currentpoint nXOfs 0 rmoveto pum nWidth aString stringwidth pop div 1 scale aString show pom moveto} bdef" );
567 ImplWriteLine(
"%%EndResource" );
568 ImplWriteLine(
"%%EndProlog" );
569 ImplWriteLine(
"%%BeginSetup" );
570 ImplWriteLine(
"%%EndSetup" );
571 ImplWriteLine(
"%%Page: 1 1" );
572 ImplWriteLine(
"%%BeginPageSetup" );
573 ImplWriteLine(
"%%EndPageSetup" );
574 ImplWriteLine(
"pum" );
575 ImplScale(
static_cast<double>(aSizePoint.
Width()) /
static_cast<double>(pMTF->GetPrefSize().Width()),
static_cast<double>(aSizePoint.
Height()) /
static_cast<double>(pMTF->GetPrefSize().Height()) );
576 ImplWriteDouble( 0 );
577 ImplWriteDouble( -pMTF->GetPrefSize().Height() );
578 ImplWriteLine(
"t" );
579 ImplWriteLine(
"/tm matrix currentmatrix def" );
582void PSWriter::ImplWriteEpilog()
584 ImplTranslate( 0, nBoundingY2 );
585 ImplWriteLine(
"pom" );
586 ImplWriteLine(
"count op_count sub {pop} repeat countdictstack dict_count sub {end} repeat b4_inc_state restore" );
588 ImplWriteLine(
"%%PageTrailer" );
589 ImplWriteLine(
"%%Trailer" );
591 ImplWriteLine(
"%%EOF" );
598 for(
size_t nCurAction = 0, nCount = rMtf.
GetActionSize(); nCurAction < nCount; nCurAction++ )
609 Color aOldLineColor( aLineColor );
611 ImplWriteLineColor( PS_SPACE );
615 aLineColor = aOldLineColor;
621 ImplWriteLineColor( PS_SPACE );
631 ImplWriteLineInfo( rLineInfo );
634 ImplWriteLineColor( PS_SPACE );
635 ImplMoveTo(
static_cast<const MetaLineAction*
>(pMA)->GetStartPoint() );
636 ImplLineTo(
static_cast<const MetaLineAction*
>(pMA )->GetEndPoint() );
658 ImplPolyPoly( aPolyPoly );
665 static_cast<const MetaArcAction*
>(pMA)->GetEndPoint(), PolyStyle::Arc );
667 ImplPolyPoly( aPolyPoly );
674 static_cast<const MetaPieAction*
>(pMA)->GetEndPoint(), PolyStyle::Pie );
676 ImplPolyPoly( aPolyPoly );
683 static_cast<const MetaChordAction*
>(pMA)->GetEndPoint(), PolyStyle::Chord );
685 ImplPolyPoly( aPolyPoly );
693 ImplWriteLineInfo( rLineInfo );
696 && rLineInfo.GetWidth() > 1)
699 const sal_uInt16 nPoints(aPoly.GetSize());
700 const bool bCurve(aPoly.HasFlags());
702 for(sal_uInt16
a(0);
a + 1 < nPoints;
a++)
705 && PolyFlags::Normal != aPoly.GetFlags(a + 1)
707 && PolyFlags::Normal != aPoly.GetFlags(a + 2)
711 aPoly.GetConstPointAry() + a,
712 aPoly.GetConstFlagAry() + a);
713 ImplPolyLine(aSnippet);
719 aPoly.GetConstPointAry() + a);
720 ImplPolyLine(aSnippet);
726 ImplPolyLine( aPoly );
734 ImplPolyPoly( aPolyPoly );
751 ImplText( aUniStr, aPoint, {}, {}, 0, rVDev );
757 OSL_FAIL(
"Unsupported action: TextRect...Action!" );
767 ImplText( aUniStr, aPoint, {}, {}, pA->
GetWidth(), rVDev );
788 ImplBmp( &aBitmap,
nullptr, aPoint, aSize.Width(), aSize.Height() );
799 ImplBmp( &aBitmap,
nullptr, aPoint, aSize.
Width(), aSize.
Height() );
812 ImplBmp( &aBitmap,
nullptr, aPoint, aSize.
Width(), aSize.
Height() );
819 Bitmap aBitmap( aBitmapEx.GetBitmap() );
822 AlphaMask aMask( aBitmapEx.GetAlphaMask() );
825 ImplBmp( &aBitmap, &aMask, aPoint, aSize.
Width(), aSize.
Height() );
832 Bitmap aBitmap( aBitmapEx.GetBitmap() );
835 AlphaMask aMask( aBitmapEx.GetAlphaMask() );
838 ImplBmp( &aBitmap, &aMask, aPoint, aSize.
Width(), aSize.
Height() );
847 Bitmap aBitmap( aBitmapEx.GetBitmap() );
850 AlphaMask aMask( aBitmapEx.GetAlphaMask() );
853 ImplBmp( &aBitmap, &aMask, aPoint, aSize.
Width(), aSize.
Height() );
862 OSL_FAIL(
"Unsupported action: MetaMask...Action!" );
869 ImplWriteGradient( aPolyPoly,
static_cast<const MetaGradientAction*
>(pMA)->GetGradient(), rVDev );
876 ImplWriteGradient( aPolyPoly,
static_cast<const MetaGradientExAction*
>(pMA)->GetGradient(), rVDev );
886 l_pVirDev->AddHatchActions(
static_cast<const MetaHatchAction*
>(pMA)->GetPolyPolygon(),
888 ImplWriteActions( aTmpMtf, rVDev );
928 ImplRectFill( aRect );
937 ImplSetClipRegion( aRegion );
945 ImplSetClipRegion( aRegion );
953 ImplSetClipRegion( aRegion );
997 bTextFillColor =
true;
1001 bTextFillColor =
false;
1028 StackMember* pGS =
new StackMember;
1029 pGS->pSucc = pGDIStack;
1031 pGS->aDashArray = aDashArray;
1032 pGS->eJoinType = eJoinType;
1033 pGS->eLineCap = eLineCap;
1034 pGS->fLineWidth = fLineWidth;
1035 pGS->fMiterLimit = fMiterLimit;
1036 pGS->eTextAlign = eTextAlign;
1037 pGS->aGlobalCol = aColor;
1038 pGS->bLineCol = bLineColor;
1039 pGS->aLineCol = aLineColor;
1040 pGS->bFillCol = bFillColor;
1041 pGS->aFillCol = aFillColor;
1042 pGS->aTextCol = aTextColor;
1043 pGS->bTextFillCol = bTextFillColor;
1044 pGS->aTextFillCol = aTextFillColor;
1045 pGS->aBackgroundCol = aBackgroundColor;
1046 pGS->aFont = maFont;
1047 mnLatestPush = mpPS->Tell();
1048 ImplWriteLine(
"gs" );
1057 StackMember* pGS = pGDIStack;
1058 pGDIStack = pGS->pSucc;
1059 aDashArray = pGS->aDashArray;
1060 eJoinType = pGS->eJoinType;
1061 eLineCap = pGS->eLineCap;
1062 fLineWidth = pGS->fLineWidth;
1063 fMiterLimit = pGS->fMiterLimit;
1064 eTextAlign = pGS->eTextAlign;
1065 aColor = pGS->aGlobalCol;
1066 bLineColor = pGS->bLineCol;
1067 aLineColor = pGS->aLineCol;
1068 bFillColor = pGS->bFillCol;
1069 aFillColor = pGS->aFillCol;
1070 aTextColor = pGS->aTextCol;
1071 bTextFillColor = pGS->bTextFillCol;
1072 aTextFillColor = pGS->aTextFillCol;
1073 aBackgroundColor = pGS->aBackgroundCol;
1074 maFont = pGS->aFont;
1077 sal_uInt32 nCurrentPos = mpPS->Tell();
1078 if ( nCurrentPos - 3 == mnLatestPush )
1080 mpPS->Seek( mnLatestPush );
1081 ImplWriteLine(
" " );
1082 mpPS->Seek( mnLatestPush );
1085 ImplWriteLine(
"gr" );
1095 bool bLevelConflict =
false;
1101 if ( nParseThis > nSize )
1104 if ( pSource && ( mnLevel == 1 ) )
1114 if ( ( k >
'0' ) && ( k <=
'9' ) )
1118 bLevelConflict =
true;
1119 mbLevelWarning =
true;
1126 if ( !bLevelConflict )
1128 double nBoundingBox[4];
1129 if ( pSource && ImplGetBoundingBox( nBoundingBox, pSource, nParseThis ) )
1134 MapMode aMapMode( aSubstitute.GetPrefMapMode() );
1137 aOrigin.AdjustY(aOutSize.Height() );
1138 aMapMode.SetOrigin( aOrigin );
1139 aMapMode.SetScaleX(
Fraction(aOutSize.Width() / ( nBoundingBox[ 2 ] - nBoundingBox[ 0 ] )) );
1140 aMapMode.SetScaleY(
Fraction(aOutSize.Height() / ( nBoundingBox[ 3 ] - nBoundingBox[ 1 ] )) );
1141 ImplWriteLine(
"gs" );
1142 ImplGetMapMode( aMapMode );
1143 ImplWriteLine(
"%%BeginDocument:" );
1144 mpPS->WriteBytes(pSource, aGfxLink.
GetDataSize());
1145 ImplWriteLine(
"%%EndDocument\ngr" );
1172 const double fScaleX = aSrcSize.Width() ?
static_cast<double>(aDestSize.Width()) / aSrcSize.Width() : 1.0;
1173 const double fScaleY = aSrcSize.Height() ?
static_cast<double>(aDestSize.Height()) / aSrcSize.Height() : 1.0;
1176 if( fScaleX != 1.0 || fScaleY != 1.0 )
1178 aTmpMtf.
Scale( fScaleX, fScaleY );
1179 aSrcPt.setX(
FRound( aSrcPt.X() * fScaleX ) );
1180 aSrcPt.setY(
FRound( aSrcPt.Y() * fScaleY ) );
1183 nMoveX = aDestPt.X() - aSrcPt.X();
1184 nMoveY = aDestPt.Y() - aSrcPt.Y();
1186 if( nMoveX || nMoveY )
1187 aTmpMtf.
Move( nMoveX, nMoveY );
1189 ImplWriteActions( aTmpMtf, rVDev );
1196 if ( pA->
GetComment().equalsIgnoreAsciiCase(
"XGRAD_SEQ_BEGIN") )
1199 while( ++nCurAction < nCount )
1205 (
static_cast<const MetaCommentAction*
>(pAction)->GetComment().equalsIgnoreAsciiCase(
"XGRAD_SEQ_END") ) )
1214 else if ( pA->
GetComment() ==
"XPATHFILL_SEQ_END" )
1216 if ( aFillPath.
Count() )
1219 ImplWriteLine(
"gr" );
1228 bool bSkipSequence =
false;
1231 if( pA->
GetComment() ==
"XPATHSTROKE_SEQ_BEGIN" )
1233 sSeqEnd =
"XPATHSTROKE_SEQ_END";
1250 bSkipSequence =
true;
1251 if ( l_aDashArray.size() > 11 )
1252 bSkipSequence =
false;
1253 if ( aStartArrow.
Count() || aEndArrow.
Count() )
1254 bSkipSequence =
false;
1255 if (
static_cast<sal_uInt32
>(eJT) > 2 )
1256 bSkipSequence =
false;
1257 if ( !l_aDashArray.empty() && ( fStrokeWidth != 0.0 ) )
1258 bSkipSequence =
false;
1259 if ( bSkipSequence )
1262 aStroke.
getCapType(), eJT, std::move(l_aDashArray) );
1263 ImplPolyLine( aPath );
1266 else if (pA->
GetComment() ==
"XPATHFILL_SEQ_BEGIN")
1268 sSeqEnd =
"XPATHFILL_SEQ_END";
1275 bSkipSequence =
true;
1278 sal_uInt16
i, nPolyCount = aPolyPoly.
Count();
1282 ImplWriteFillColor( PS_SPACE );
1283 for ( i = 0;
i < nPolyCount; )
1285 ImplAddPath( aPolyPoly.
GetObject( i ) );
1286 if ( ++i < nPolyCount )
1288 mpPS->WriteOString(
"p" );
1290 ImplExecMode( PS_RET );
1293 mpPS->WriteOString(
"p ef" );
1295 ImplExecMode( PS_RET );
1316 sal_uInt32 nCommentStartAction = nCurAction;
1317 sal_uInt32 nBitmapCount = 0;
1318 sal_uInt32 nBitmapAction = 0;
1321 while( bOk && ( ++nCurAction < nCount ) )
1332 nBitmapAction = nCurAction;
1337 if (
static_cast<const MetaCommentAction*
>(pAction)->GetComment() ==
"XPATHFILL_SEQ_END")
1344 if( nBitmapCount == 2 )
1346 ImplWriteLine(
"gs" );
1347 ImplIntersect( aFillPath );
1350 ImplWriteActions( aTempMtf, rVDev );
1351 ImplWriteLine(
"gr" );
1355 nCurAction = nCommentStartAction + 1;
1366 if ( aFillPath.
Count() )
1368 ImplWriteLine(
"gs" );
1369 ImplIntersect( aFillPath );
1372 if ( bSkipSequence )
1374 while( ++nCurAction < nCount )
1380 if ( sComment == sSeqEnd )
1394inline void PSWriter::ImplWritePoint(
const Point& rPoint )
1396 ImplWriteDouble( rPoint.
X() );
1397 ImplWriteDouble( rPoint.
Y() );
1400void PSWriter::ImplMoveTo(
const Point& rPoint )
1402 ImplWritePoint( rPoint );
1403 ImplWriteByte(
'm' );
1404 ImplExecMode( PS_SPACE );
1407void PSWriter::ImplLineTo(
const Point& rPoint, NMode nMode )
1409 ImplWritePoint( rPoint );
1410 ImplWriteByte(
'l' );
1411 ImplExecMode( nMode );
1414void PSWriter::ImplCurveTo(
const Point& rP1,
const Point& rP2,
const Point& rP3, NMode nMode )
1416 ImplWritePoint( rP1 );
1417 ImplWritePoint( rP2 );
1418 ImplWritePoint( rP3 );
1419 mpPS->WriteOString(
"ct " );
1420 ImplExecMode( nMode );
1423void PSWriter::ImplTranslate(
const double& fX,
const double& fY )
1425 ImplWriteDouble( fX );
1426 ImplWriteDouble( fY );
1427 ImplWriteByte(
't' );
1428 ImplExecMode( PS_RET );
1431void PSWriter::ImplScale(
const double& fX,
const double& fY )
1433 ImplWriteDouble( fX );
1434 ImplWriteDouble( fY );
1435 ImplWriteByte(
's' );
1436 ImplExecMode( PS_RET );
1442 ImplRectFill( rRect );
1448 ImplWriteLineColor( PS_SPACE );
1449 ImplMoveTo( rRect.
TopLeft() );
1450 ImplWriteDouble( nWidth );
1451 mpPS->WriteOString(
"0 rl 0 " );
1452 ImplWriteDouble( nHeight );
1453 mpPS->WriteOString(
"rl " );
1454 ImplWriteDouble( nWidth );
1455 mpPS->WriteOString(
"neg 0 rl " );
1456 ImplClosePathDraw();
1458 mpPS->WriteUChar( 10 );
1467 ImplWriteFillColor( PS_SPACE );
1468 ImplMoveTo( rRect.
TopLeft() );
1469 ImplWriteDouble( nWidth );
1470 mpPS->WriteOString(
"0 rl 0 " );
1471 ImplWriteDouble( nHeight );
1472 mpPS->WriteOString(
"rl " );
1473 ImplWriteDouble( nWidth );
1474 mpPS->WriteOString(
"neg 0 rl ef " );
1475 mpPS->WriteOString(
"p ef" );
1477 ImplExecMode( PS_RET );
1482 sal_uInt16 nPointCount = rPolygon.
GetSize();
1483 if ( nPointCount <= 1 )
1487 ImplMoveTo( rPolygon.
GetPoint( 0 ) );
1488 while ( i < nPointCount )
1490 if ( ( rPolygon.
GetFlags( i ) == PolyFlags::Control )
1491 && ( ( i + 2 ) < nPointCount )
1492 && ( rPolygon.
GetFlags( i + 1 ) == PolyFlags::Control )
1493 && ( rPolygon.
GetFlags( i + 2 ) != PolyFlags::Control ) )
1495 ImplCurveTo( rPolygon[ i ], rPolygon[ i + 1 ], rPolygon[ i + 2 ], PS_WRAP );
1499 ImplLineTo( rPolygon.
GetPoint( i++ ), PS_SPACE | PS_WRAP );
1505 sal_uInt16
i, nPolyCount = rPolyPoly.
Count();
1506 for ( i = 0;
i < nPolyCount; )
1508 ImplAddPath( rPolyPoly.
GetObject( i ) );
1509 if ( ++i < nPolyCount )
1511 mpPS->WriteOString(
"p" );
1513 ImplExecMode( PS_RET );
1516 ImplWriteLine(
"eoclip newpath" );
1525 aGradient.AddGradientActions( rPolyPoly.
GetBoundRect(), aTmpMtf );
1526 ImplWriteActions( aTmpMtf, rVDev );
1529void PSWriter::ImplPolyPoly(
const tools::PolyPolygon & rPolyPoly,
bool bTextOutline )
1531 sal_uInt16
i, nPolyCount = rPolyPoly.
Count();
1535 if ( bFillColor || bTextOutline )
1538 ImplWriteTextColor( PS_SPACE );
1540 ImplWriteFillColor( PS_SPACE );
1541 for ( i = 0;
i < nPolyCount; )
1543 ImplAddPath( rPolyPoly.
GetObject( i ) );
1544 if ( ++i < nPolyCount )
1546 mpPS->WriteOString(
"p" );
1548 ImplExecMode( PS_RET );
1551 mpPS->WriteOString(
"p ef" );
1553 ImplExecMode( PS_RET );
1557 ImplWriteLineColor( PS_SPACE );
1558 for ( i = 0;
i < nPolyCount;
i++ )
1559 ImplAddPath( rPolyPoly.
GetObject( i ) );
1560 ImplClosePathDraw();
1569 ImplWriteLineColor( PS_SPACE );
1570 sal_uInt16
i, nPointCount = rPoly.
GetSize();
1574 if ( nPointCount > 1 )
1578 while ( i < nPointCount )
1580 if ( ( rPoly.
GetFlags( i ) == PolyFlags::Control )
1581 && ( ( i + 2 ) < nPointCount )
1582 && ( rPoly.
GetFlags( i + 1 ) == PolyFlags::Control )
1583 && ( rPoly.
GetFlags( i + 2 ) != PolyFlags::Control ) )
1585 ImplCurveTo( rPoly[ i ], rPoly[ i + 1 ], rPoly[ i + 2 ], PS_WRAP );
1589 ImplLineTo( rPoly.
GetPoint( i++ ), PS_SPACE | PS_WRAP );
1594 if( rPoly[ 0 ] == rPoly[ nPointCount-1 ] )
1595 ImplClosePathDraw();
1600void PSWriter::ImplSetClipRegion(
vcl::Region const & rClipRegion )
1608 for (
auto const& rectangle : aRectangles)
1615 ImplWriteDouble( nX1 );
1616 ImplWriteDouble( nY1 );
1617 ImplWriteByte(
'm' );
1618 ImplWriteDouble( nX2 );
1619 ImplWriteDouble( nY1 );
1620 ImplWriteByte(
'l' );
1621 ImplWriteDouble( nX2 );
1622 ImplWriteDouble( nY2 );
1623 ImplWriteByte(
'l' );
1624 ImplWriteDouble( nX1 );
1625 ImplWriteDouble( nY2 );
1626 ImplWriteByte(
'l' );
1627 ImplWriteDouble( nX1 );
1628 ImplWriteDouble( nY1 );
1629 ImplWriteByte(
'l', PS_SPACE | PS_WRAP );
1632 ImplWriteLine(
"eoclip newpath" );
1644void PSWriter::ImplBmp(
Bitmap const * pBitmap,
AlphaMask const * pAlphaMaskBitmap,
const Point & rPoint,
double nXWidth,
double nYHeightOrg )
1650 sal_Int32 nHeightLeft = nHeightOrg;
1652 Point aSourcePos( rPoint );
1654 while ( nHeightLeft )
1656 Bitmap aTileBitmap( *pBitmap );
1658 double nYHeight = nYHeightOrg;
1660 bool bDoTrans =
false;
1665 if ( pAlphaMaskBitmap )
1670 if ( mnLevel == 1 && nHeight > 10 )
1673 aRegion = pAlphaMaskBitmap->
CreateRegion( COL_ALPHA_OPAQUE, aRect );
1680 if ( aRectangleVector.size() * 5 > 1000 )
1691 if ( nHeight != nHeightOrg )
1693 nYHeight = nYHeightOrg * nHeight / nHeightOrg;
1698 ImplWriteLine(
"gs\npum" );
1699 ImplTranslate( aSourcePos.X(), aSourcePos.Y() );
1700 ImplScale( nXWidth / nWidth, nYHeight / nHeight );
1704 const tools::Long nMoveVertical(nHeightLeft - nHeightOrg);
1706 for (
auto & rectangle : aRectangles)
1712 ImplWriteByte(
'm' );
1715 ImplWriteByte(
'l' );
1717 ImplWriteLong(
rectangle.Bottom() + 1 );
1718 ImplWriteByte(
'l' );
1720 ImplWriteLong(
rectangle.Bottom() + 1 );
1721 ImplWriteByte(
'l' );
1722 ImplWriteByte(
'p', PS_SPACE | PS_WRAP );
1725 ImplWriteLine(
"eoclip newpath" );
1726 ImplWriteLine(
"pom" );
1731 ImplWriteLine(
"pum" );
1733 ImplTranslate( aSourcePos.X(), aSourcePos.Y() + nYHeight );
1734 ImplScale( nXWidth, nYHeight );
1737 ImplWriteLong( nWidth );
1738 ImplWriteLong( nHeight );
1739 mpPS->WriteOString(
"8 [" );
1740 ImplWriteLong( nWidth );
1741 mpPS->WriteOString(
"0 0 " );
1742 ImplWriteLong( -nHeight );
1744 ImplWriteLong( nHeight );
1745 ImplWriteLine(
"]" );
1746 mpPS->WriteOString(
"{currentfile " );
1747 ImplWriteLong( nWidth );
1748 ImplWriteLine(
"string readhexstring pop}" );
1749 ImplWriteLine(
"image" );
1758 mpPS->WriteUChar( 10 );
1764 ImplWriteLine(
"/DeviceGray setcolorspace" );
1765 ImplWriteLine(
"<<" );
1766 ImplWriteLine(
"/ImageType 1" );
1767 mpPS->WriteOString(
"/Width " );
1768 ImplWriteLong( nWidth, PS_RET );
1769 mpPS->WriteOString(
"/Height " );
1770 ImplWriteLong( nHeight, PS_RET );
1771 ImplWriteLine(
"/BitsPerComponent 8" );
1772 ImplWriteLine(
"/Decode[0 1]" );
1773 mpPS->WriteOString(
"/ImageMatrix[" );
1774 ImplWriteLong( nWidth );
1775 mpPS->WriteOString(
"0 0 " );
1776 ImplWriteLong( -nHeight );
1778 ImplWriteLong( nHeight, PS_NONE );
1779 ImplWriteByte(
']', PS_RET );
1780 ImplWriteLine(
"/DataSource currentfile" );
1781 ImplWriteLine(
"/ASCIIHexDecode filter" );
1782 if ( mbCompression )
1783 ImplWriteLine(
"/LZWDecode filter" );
1784 ImplWriteLine(
">>" );
1785 ImplWriteLine(
"image" );
1786 if ( mbCompression )
1817 ImplWriteLine(
"[/Indexed /DeviceRGB " );
1819 ImplWriteByte(
'<', PS_NONE );
1823 ImplWriteHexByte( aBitmapColor.
GetRed(), PS_NONE );
1824 ImplWriteHexByte( aBitmapColor.
GetGreen(), PS_NONE );
1825 ImplWriteHexByte( aBitmapColor.
GetBlue(), PS_SPACE | PS_WRAP );
1827 ImplWriteByte(
'>', PS_RET );
1829 ImplWriteLine(
"] setcolorspace" );
1830 ImplWriteLine(
"<<" );
1831 ImplWriteLine(
"/ImageType 1" );
1832 mpPS->WriteOString(
"/Width " );
1833 ImplWriteLong( nWidth, PS_RET );
1834 mpPS->WriteOString(
"/Height " );
1835 ImplWriteLong( nHeight, PS_RET );
1836 ImplWriteLine(
"/BitsPerComponent 8" );
1837 ImplWriteLine(
"/Decode[0 255]" );
1838 mpPS->WriteOString(
"/ImageMatrix[" );
1839 ImplWriteLong( nWidth );
1840 mpPS->WriteOString(
"0 0 " );
1841 ImplWriteLong( -nHeight );
1843 ImplWriteLong( nHeight, PS_NONE );
1844 ImplWriteByte(
']', PS_RET );
1845 ImplWriteLine(
"/DataSource currentfile" );
1846 ImplWriteLine(
"/ASCIIHexDecode filter" );
1847 if ( mbCompression )
1848 ImplWriteLine(
"/LZWDecode filter" );
1849 ImplWriteLine(
">>" );
1850 ImplWriteLine(
"image" );
1851 if ( mbCompression )
1878 ImplWriteLine(
"/DeviceRGB setcolorspace" );
1879 ImplWriteLine(
"<<" );
1880 ImplWriteLine(
"/ImageType 1" );
1881 mpPS->WriteOString(
"/Width " );
1882 ImplWriteLong( nWidth, PS_RET );
1883 mpPS->WriteOString(
"/Height " );
1884 ImplWriteLong( nHeight, PS_RET );
1885 ImplWriteLine(
"/BitsPerComponent 8" );
1886 ImplWriteLine(
"/Decode[0 1 0 1 0 1]" );
1887 mpPS->WriteOString(
"/ImageMatrix[" );
1888 ImplWriteLong( nWidth );
1889 mpPS->WriteOString(
"0 0 " );
1890 ImplWriteLong( -nHeight );
1892 ImplWriteLong( nHeight, PS_NONE );
1893 ImplWriteByte(
']', PS_RET );
1894 ImplWriteLine(
"/DataSource currentfile" );
1895 ImplWriteLine(
"/ASCIIHexDecode filter" );
1896 if ( mbCompression )
1897 ImplWriteLine(
"/LZWDecode filter" );
1898 ImplWriteLine(
">>" );
1899 ImplWriteLine(
"image" );
1900 if ( mbCompression )
1909 Compress( aBitmapColor.
GetRed() );
1910 Compress( aBitmapColor.
GetGreen() );
1911 Compress( aBitmapColor.
GetBlue() );
1924 ImplWriteHexByte( aBitmapColor.
GetRed() );
1925 ImplWriteHexByte( aBitmapColor.
GetGreen() );
1926 ImplWriteHexByte( aBitmapColor.
GetBlue() );
1932 ImplWriteLine(
">" );
1935 ImplWriteLine(
"gr" );
1937 ImplWriteLine(
"pom" );
1940 nHeightLeft -= nHeight;
1944 aSourcePos.setY(
static_cast<tools::Long>( rPoint.
Y() + ( nYHeightOrg * ( nHeightOrg - nHeightLeft ) ) / nHeightOrg ) );
1949void PSWriter::ImplWriteCharacter(
char nChar )
1956 ImplWriteByte(
sal_uInt8(
'\\'), PS_NONE );
1958 ImplWriteByte(
static_cast<sal_uInt8>(nChar), PS_NONE );
1963 sal_Int32 nLen = rString.getLength();
1967 if ( !pDXArry.
empty() )
1971 for (sal_Int32 i = 0;
i < nLen; ++
i)
1974 nx = pDXArry[
i - 1 ];
1975 ImplWriteDouble( bStretch ? nx : rVDev.
GetTextWidth( OUString(rString[i]) ) );
1976 ImplWriteDouble( nx );
1977 ImplWriteLine(
"(", PS_NONE );
1978 ImplWriteCharacter( rString[i] );
1979 ImplWriteLine(
") bs" );
1984 ImplWriteByte(
'(', PS_NONE );
1985 for (sal_Int32 i = 0;
i < nLen; ++
i)
1986 ImplWriteCharacter( rString[i] );
1987 ImplWriteLine(
") sw" );
1993 if ( rUniString.isEmpty() )
1995 if ( mnTextMode == 0 )
1998 aNotRotatedFont.SetOrientation( 0_deg10 );
2002 pVirDev->SetFont( aNotRotatedFont );
2003 pVirDev->SetTextAlign( eTextAlign );
2005 Degree10 nRotation = maFont.GetOrientation();
2011 aPolyDummy.SetPoint( aPos, 0 );
2012 aPolyDummy.Rotate( rPos, nRotation );
2013 aPos = aPolyDummy.GetPoint( 0 );
2015 bool bOldLineColor = bLineColor;
2017 std::vector<tools::PolyPolygon> aPolyPolyVec;
2018 if ( pVirDev->GetTextOutlines( aPolyPolyVec, rUniString, 0, 0, -1, nWidth, pDXArry, pKashidaArry ) )
2021 ImplWriteLine(
"pum" );
2022 ImplWriteDouble( aPos.X() );
2023 ImplWriteDouble( aPos.Y() );
2024 ImplWriteLine(
"t" );
2027 ImplWriteF( nRotation.
get(), 1 );
2028 mpPS->WriteOString(
"r " );
2030 for (
auto const& elem : aPolyPolyVec)
2031 ImplPolyPoly( elem,
true );
2032 ImplWriteLine(
"pom" );
2034 bLineColor = bOldLineColor;
2036 else if ( ( mnTextMode == 1 ) || ( mnTextMode == 2 ) )
2038 if ( mnTextMode == 2 )
2040 ImplSetAttrForText( rPos );
2042 maFont.GetCharSet()));
2043 ImplWriteString( aStr, rVDev, pDXArry, nWidth != 0 );
2044 if ( maFont.GetOrientation() )
2045 ImplWriteLine(
"gr" );
2049void PSWriter::ImplSetAttrForText(
const Point& rPoint )
2051 Point aPoint( rPoint );
2053 Degree10 nRotation = maFont.GetOrientation();
2054 ImplWriteTextColor(PS_RET);
2056 Size aSize = maFont.GetFontSize();
2058 if ( maLastFont != maFont )
2060 if ( maFont.GetPitch() == PITCH_FIXED )
2061 ImplDefineFont(
"Courier",
"Oblique" );
2062 else if ( maFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL )
2063 ImplWriteLine(
"/Symbol findfont" );
2064 else if ( maFont.GetFamilyType() == FAMILY_SWISS )
2065 ImplDefineFont(
"Helvetica",
"Oblique" );
2067 ImplDefineFont(
"Times",
"Italic" );
2069 maLastFont = maFont;
2070 aSize = maFont.GetFontSize();
2071 ImplWriteDouble( aSize.
Height() );
2072 mpPS->WriteOString(
"sf " );
2074 if ( eTextAlign != ALIGN_BASELINE )
2076 if ( eTextAlign == ALIGN_TOP )
2078 else if ( eTextAlign == ALIGN_BOTTOM )
2081 ImplMoveTo( aPoint );
2084 mpPS->WriteOString(
"gs " );
2085 ImplWriteF( nRotation.
get(), 1 );
2086 mpPS->WriteOString(
"r " );
2090void PSWriter::ImplDefineFont(
const char* pOriginalName,
const char* pItalic )
2092 mpPS->WriteUChar(
'/' );
2093 mpPS->WriteOString( pOriginalName );
2094 switch ( maFont.GetWeight() )
2100 mpPS->WriteOString(
"-Bold" );
2101 if ( maFont.GetItalic() != ITALIC_NONE )
2102 mpPS->WriteOString( pItalic );
2105 if ( maFont.GetItalic() != ITALIC_NONE )
2106 mpPS->WriteOString( pItalic );
2109 ImplWriteLine(
" f" );
2112void PSWriter::ImplClosePathDraw()
2114 mpPS->WriteOString(
"pc" );
2116 ImplExecMode( PS_RET );
2119void PSWriter::ImplPathDraw()
2121 mpPS->WriteOString(
"ps" );
2123 ImplExecMode( PS_RET );
2127inline void PSWriter::ImplWriteLineColor( NMode nMode )
2129 if ( aColor != aLineColor )
2131 aColor = aLineColor;
2132 ImplWriteColor( nMode );
2136inline void PSWriter::ImplWriteFillColor( NMode nMode )
2138 if ( aColor != aFillColor )
2140 aColor = aFillColor;
2141 ImplWriteColor( nMode );
2145inline void PSWriter::ImplWriteTextColor( NMode nMode )
2147 if ( aColor != aTextColor )
2149 aColor = aTextColor;
2150 ImplWriteColor( nMode );
2154void PSWriter::ImplWriteColor( NMode nMode )
2160 ImplWriteF( 1000 * ( aColor.GetRed() * 77 + aColor.GetGreen() * 151 +
2161 aColor.GetBlue() * 28 + 1 ) / 65536, 3, nMode );
2165 ImplWriteB1 ( aColor.GetRed() );
2166 ImplWriteB1 ( aColor.GetGreen() );
2167 ImplWriteB1 ( aColor.GetBlue() );
2169 mpPS->WriteOString(
"c" );
2170 ImplExecMode( nMode );
2173void PSWriter::ImplGetMapMode(
const MapMode& rMapMode )
2175 ImplWriteLine(
"tm setmatrix" );
2176 double fMul = ImplGetScaling(rMapMode);
2177 double fScaleX =
static_cast<double>(rMapMode.
GetScaleX()) * fMul;
2178 double fScaleY =
static_cast<double>(rMapMode.
GetScaleY()) * fMul;
2180 ImplScale( fScaleX, fScaleY );
2183inline void PSWriter::ImplExecMode( NMode nMode )
2185 if ( nMode & PS_WRAP )
2190 mpPS->WriteUChar( 0xa );
2194 if ( nMode & PS_SPACE )
2196 mpPS->WriteUChar( 32 );
2199 if ( nMode & PS_RET )
2201 mpPS->WriteUChar( 0xa );
2206inline void PSWriter::ImplWriteLine(
const char* pString, NMode nMode )
2209 while ( pString[ i ] )
2211 mpPS->WriteUChar( pString[ i++ ] );
2214 ImplExecMode( nMode );
2217double PSWriter::ImplGetScaling(
const MapMode& rMapMode )
2222 case MapUnit::MapPixel :
2223 case MapUnit::MapSysFont :
2224 case MapUnit::MapAppFont :
2226 case MapUnit::Map100thMM :
2229 case MapUnit::Map10thMM :
2232 case MapUnit::MapMM :
2235 case MapUnit::MapCM :
2238 case MapUnit::Map1000thInch :
2241 case MapUnit::Map100thInch :
2244 case MapUnit::Map10thInch :
2247 case MapUnit::MapInch :
2250 case MapUnit::MapTwip :
2253 case MapUnit::MapPoint :
2264void PSWriter::ImplWriteLineInfo(
double fLWidth,
double fMLimit,
2269 if ( fLineWidth != fLWidth )
2271 fLineWidth = fLWidth;
2272 ImplWriteDouble( fLineWidth );
2273 ImplWriteLine(
"lw", PS_SPACE );
2275 if ( eLineCap != eLCap )
2278 ImplWriteLong(
static_cast<sal_Int32
>(eLineCap) );
2279 ImplWriteLine(
"lc", PS_SPACE );
2281 if ( eJoinType != eJoin )
2284 ImplWriteLong(
static_cast<sal_Int32
>(eJoinType) );
2285 ImplWriteLine(
"lj", PS_SPACE );
2289 if ( fMiterLimit != fMLimit )
2291 fMiterLimit = fMLimit;
2292 ImplWriteDouble( fMiterLimit );
2293 ImplWriteLine(
"ml", PS_SPACE );
2296 if ( aDashArray != rLDash )
2298 aDashArray = std::move(rLDash);
2299 sal_uInt32 j,
i = aDashArray.size();
2300 ImplWriteLine(
"[", PS_SPACE );
2301 for ( j = 0; j <
i; j++ )
2302 ImplWriteDouble( aDashArray[ j ] );
2303 ImplWriteLine(
"] 0 ld" );
2307void PSWriter::ImplWriteLineInfo(
const LineInfo& rLineInfo )
2309 std::vector< double > l_aDashArray;
2311 l_aDashArray = rLineInfo.GetDotDashArray();
2312 const double fLWidth(( ( rLineInfo.GetWidth() + 1 ) + ( rLineInfo.GetWidth() + 1 ) ) * 0.5);
2316 switch(rLineInfo.GetLineJoin())
2333 switch(rLineInfo.GetLineCap())
2340 case css::drawing::LineCap_ROUND:
2345 case css::drawing::LineCap_SQUARE:
2352 ImplWriteLineInfo( fLWidth, fMiterLimit, aCapType, aJoinType, std::move(l_aDashArray) );
2355void PSWriter::ImplWriteLong(sal_Int32 nNumber, NMode nMode)
2357 const OString aNumber(OString::number(nNumber));
2358 mnCursorPos += aNumber.getLength();
2359 mpPS->WriteOString( aNumber );
2360 ImplExecMode(nMode);
2363void PSWriter::ImplWriteDouble(
double fNumber )
2365 sal_Int32 nPTemp =
static_cast<sal_Int32
>(fNumber);
2366 sal_Int32 nATemp = std::abs(
static_cast<sal_Int32
>( ( fNumber - nPTemp ) * 100000 ) );
2368 if ( !nPTemp && nATemp && ( fNumber < 0.0 ) )
2369 mpPS->WriteChar(
'-' );
2371 const OString aNumber1(OString::number(nPTemp));
2372 mpPS->WriteOString( aNumber1 );
2373 mnCursorPos += aNumber1.getLength();
2378 mpPS->WriteUChar(
'.' );
2380 const OString aNumber2(OString::number(nATemp));
2382 sal_Int16
n, nLen = aNumber2.getLength();
2385 mnCursorPos += 6 - nLen;
2386 for ( n = 0;
n < ( 5 - nLen );
n++ )
2388 mpPS->WriteUChar(
'0' );
2391 mnCursorPos += nLen;
2392 for ( n = 0;
n < nLen;
n++ )
2394 mpPS->WriteChar( aNumber2[n] );
2396 if ( aNumber2[n] !=
'0' )
2400 mpPS->SeekRel( zCount );
2402 ImplExecMode( PS_SPACE );
2406void PSWriter::ImplWriteF( sal_Int32 nNumber,
sal_uInt8 nCount, NMode nMode )
2410 mpPS->WriteUChar(
'-' );
2414 const OString aScaleFactor(OString::number(nNumber));
2415 sal_uInt32 nLen = aScaleFactor.getLength();
2416 sal_Int32
const nStSize = (
nCount + 1) - nLen;
2417 static_assert(
sizeof(nStSize) ==
sizeof((nCount + 1) - nLen));
2420 mpPS->WriteUChar(
'0' );
2425 mpPS->WriteUChar(
'.' );
2426 for (sal_Int32 i = 1;
i < nStSize; ++
i)
2428 mpPS->WriteUChar(
'0' );
2432 mnCursorPos += nLen;
2433 for( sal_uInt32 n = 0;
n < nLen;
n++ )
2435 if ( n == nLen - nCount )
2437 mpPS->WriteUChar(
'.' );
2440 mpPS->WriteChar( aScaleFactor[n] );
2442 ImplExecMode( nMode );
2445void PSWriter::ImplWriteByte(
sal_uInt8 nNumb, NMode nMode )
2447 mpPS->WriteUChar( nNumb );
2449 ImplExecMode( nMode );
2452void PSWriter::ImplWriteHexByte(
sal_uInt8 nNumb, NMode nMode )
2454 if ( ( nNumb >> 4 ) > 9 )
2455 mpPS->WriteUChar( ( nNumb >> 4 ) +
'A' - 10 );
2457 mpPS->WriteUChar( ( nNumb >> 4 ) +
'0' );
2459 if ( ( nNumb & 0xf ) > 9 )
2460 mpPS->WriteUChar( ( nNumb & 0xf ) +
'A' - 10 );
2462 mpPS->WriteUChar( ( nNumb & 0xf ) +
'0' );
2464 ImplExecMode( nMode );
2469void PSWriter::ImplWriteB1(
sal_uInt8 nNumb )
2471 ImplWriteF( 1000 * ( nNumb + 1 ) / 256 );
2474inline void PSWriter::WriteBits( sal_uInt16 nCode, sal_uInt16 nCodeLen )
2476 dwShift |= ( nCode << ( nOffset - nCodeLen ) );
2477 nOffset -= nCodeLen;
2478 while ( nOffset < 24 )
2480 ImplWriteHexByte(
static_cast<sal_uInt8>( dwShift >> 24 ) );
2484 if ( nCode == 257 && nOffset != 32 )
2485 ImplWriteHexByte(
static_cast<sal_uInt8>( dwShift >> 24 ) );
2488void PSWriter::StartCompression()
2493 nClearCode = 1 << nDataSize;
2494 nEOICode = nClearCode + 1;
2495 nTableSize = nEOICode + 1;
2496 nCodeSize = nDataSize + 1;
2501 pTable.reset(
new PSLZWCTreeNode[ 4096 ]);
2503 for ( i = 0;
i < 4096;
i++ )
2505 pTable[
i ].pBrother = pTable[
i ].pFirstChild =
nullptr;
2506 pTable[
i ].nCode =
i;
2510 WriteBits( nClearCode, nCodeSize );
2513void PSWriter::Compress(
sal_uInt8 nCompThis )
2521 pPrefix = pTable.get() + nCompThis;
2526 for( p = pPrefix->pFirstChild; p !=
nullptr; p =
p->pBrother )
2528 if (
p->nValue == nV )
2536 WriteBits( pPrefix->nCode, nCodeSize );
2538 if ( nTableSize == 409 )
2540 WriteBits( nClearCode, nCodeSize );
2542 for ( i = 0;
i < nClearCode;
i++ )
2543 pTable[ i ].pFirstChild =
nullptr;
2545 nCodeSize = nDataSize + 1;
2546 nTableSize = nEOICode + 1;
2550 if( nTableSize ==
static_cast<sal_uInt16
>( ( 1 << nCodeSize ) - 1 ) )
2553 p = pTable.get() + ( nTableSize++ );
2554 p->pBrother = pPrefix->pFirstChild;
2555 pPrefix->pFirstChild =
p;
2557 p->pFirstChild =
nullptr;
2560 pPrefix = pTable.get() + nV;
2565void PSWriter::EndCompression()
2568 WriteBits( pPrefix->nCode, nCodeSize );
2570 WriteBits( nEOICode, nCodeSize );
2576 while ( nComp-- >= nSize )
2579 for ( i = 0;
i < nSize;
i++ )
2581 if ( ( pSource[i]&~0x20 ) != ( pDest[i]&~0x20 ) )
2591bool PSWriter::ImplGetBoundingBox(
double* nNumb,
sal_uInt8* pSource, sal_uInt32 nSize )
2593 bool bRetValue =
false;
2594 sal_uInt32 nBytesRead;
2607 int nSecurityCount = 100;
2608 nNumb[0] = nNumb[1] = nNumb[2] = nNumb[3] = 0;
2610 for (
int i = 0; (
i < 4 ) && nSecurityCount;
i++ )
2613 bool bDivision =
false;
2614 bool bNegative =
false;
2617 while ( ( --nSecurityCount ) && ( ( *pDest ==
' ' ) || ( *pDest == 0x9 ) ) )
2620 while ( nSecurityCount && ( nByte !=
' ' ) && ( nByte != 0x9 ) && ( nByte != 0xd ) && ( nByte != 0xa ) )
2634 if ( ( nByte <
'0' ) || ( nByte >
'9' ) )
2641 nNumb[
i] += nByte -
'0';
2649 nNumb[
i] = -nNumb[
i];
2650 if ( bDivision && ( nDivision != 1 ) )
2651 nNumb[i] /= nDivision;
2653 if ( nSecurityCount)
2664 return aPSWriter.WritePS(rGraphic, rStream, pFilterConfigItem);
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const AlphaMask & GetAlphaMask() const
Bitmap GetBitmap(Color aTransparentReplaceColor) const
BitmapColor GetBestMatchingColor(const BitmapColor &rBitmapColor) const
sal_uInt16 GetPaletteEntryCount() const
const BitmapColor & GetPaletteColor(sal_uInt16 nColor) const
BitmapColor GetPixelFromData(const sal_uInt8 *pData, tools::Long nX) const
sal_uInt8 GetIndexFromData(const sal_uInt8 *pData, tools::Long nX) const
Scanline GetScanline(tools::Long nY) const
bool Crop(const tools::Rectangle &rRectPixel)
Crop the bitmap.
bool Convert(BmpConversion eConversion)
Convert bitmap format.
Size GetSizePixel() const
static void ReleaseAccess(BitmapInfoAccess *pAccess)
vcl::Region CreateRegion(const Color &rColor, const tools::Rectangle &rRect) const
Create region of similar colors in a given rectangle.
sal_uInt8 GetBlue() const
sal_uInt8 GetGreen() const
css::uno::Reference< css::task::XStatusIndicator > GetStatusIndicator() const
sal_Int32 ReadInt32(const OUString &rKey, sal_Int32 nDefault)
const sal_uInt8 * GetData() const
sal_uInt32 GetDataSize() const
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
const GDIMetaFile & GetGDIMetaFile() const
GraphicType GetType() const
BitmapEx GetBitmapEx(const GraphicConversionParameters &rParameters=GraphicConversionParameters()) const
const Fraction & GetScaleX() const
MapUnit GetMapUnit() const
const Point & GetOrigin() const
const Fraction & GetScaleY() const
sal_uInt32 GetWidth() const
sal_Int32 GetIndex() const
const OUString & GetText() const
const Point & GetPoint() const
const Point & GetPoint() const
const OUString & GetText() const
sal_Int32 GetIndex() const
sal_Int32 GetIndex() const
const KernArray & GetDXArray() const
const OUString & GetText() const
const Point & GetPoint() const
const std::vector< sal_Bool > & GetKashidaArray() const
void SetFont(const vcl::Font &rNewFont)
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
const MapMode & GetMapMode() const
void Push(vcl::PushFlags nFlags=vcl::PushFlags::ALL)
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
void SetEndian(SvStreamEndian SvStreamEndian)
virtual sal_uInt64 TellEnd()
SvStream & WriteUInt16(sal_uInt16 nUInt16)
SvStream & WriteUInt32(sal_uInt32 nUInt32)
sal_uInt64 Seek(sal_uInt64 nPos)
Encapsulates geometry and associated attributes of a filled area.
FillType getFillType() const
Get fill type used.
void getPath(tools::PolyPolygon &) const
Query path to fill.
const Color & getFillColor() const
Get color used for solid fills.
@ fillSolid
Fill with a specified solid color.
@ fillHatch
Fill with the specified hatch.
@ fillGradient
Fill with the specified gradient.
@ fillTexture
Fill with the specified texture (a Graphic object)
Encapsulates geometry and associated attributes of a graphical 'pen stroke'.
double getMiterLimit() const
Get the maximum length of mitered joins.
void getPath(tools::Polygon &) const
Query path to stroke.
void getStartArrow(tools::PolyPolygon &) const
Get the polygon that is put at the start of the line.
JoinType getJoinType() const
Get the style in which the stroke segments are joined.
void getEndArrow(tools::PolyPolygon &) const
Get the polygon that is put at the end of the line.
void getDashArray(DashArray &) const
Get an array of "on" and "off" lengths for stroke dashing.
CapType
Style for open stroke ends.
@ capRound
Half-round cap at the line end, the center lying at the end point.
@ capButt
No additional cap.
@ capSquare
Half-square cap at the line end, the center lying at the end point.
CapType getCapType() const
Get the style in which open stroke ends are drawn.
double getStrokeWidth() const
Get width of the stroke.
::std::vector< double > DashArray
JoinType
Style for joins of individual stroke segments.
@ joinBevel
Connect segments by a direct straight line.
@ joinRound
Connect segments by a filled round arc.
@ joinMiter
Extend segment edges, until they cross.
reference_type * get() const
Get the body.
const BitmapEx & GetBitmap() const
const Color & GetColor() const
static OUString getProductVersion()
static OUString getProductName()
void GetRegionRectangles(RectangleVector &rTarget) const
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
constexpr ::Color COL_TRANSPARENT(ColorTransparency, 0xFF, 0xFF, 0xFF, 0xFF)
bool ExportEpsGraphic(SvStream &rStream, const Graphic &rGraphic, FilterConfigItem *pFilterConfigItem)
#define POSTSCRIPT_BOUNDINGSEARCH
tools::Long FRound(double fVal)
static const sal_uInt8 * ImplSearchEntry(const sal_uInt8 *pSource, sal_uInt8 const *pDest, size_t nComp, size_t nSize)
moOpDF operator|(moOpDF a, moOpDF b)
std::unique_ptr< sal_Int32[]> pData
std::locale Create(std::string_view aPrefixName, const LanguageTag &rLocale)
OUString get(TranslateId sContextAndId, const std::locale &loc)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
vcl::Font GetFont(vcl::Font const &rFont, DrawModeFlags nDrawMode, StyleSettings const &rStyleSettings)
std::vector< tools::Rectangle > RectangleVector
UNDERLYING_TYPE get() const