diff options
author | Chris Sherlock <chris.sherlock79@gmail.com> | 2014-03-15 02:45:53 +1100 |
---|---|---|
committer | Norbert Thiebaud <nthiebaud@gmail.com> | 2014-03-21 20:04:03 +0000 |
commit | c30fd602521986348ef952b7173ea37a064ee82b (patch) | |
tree | 0c7c419f6d4e6c796ad4e94722ca156156ceb570 /vcl | |
parent | 143c059ff7f69a363b3cf736a9f0197a9f25cf9c (diff) |
fdo#74702 ImplPrintMask() implemented in Printer
Printer should implement ImplPrintMask(), as a protected function. If
OutputDevice calls it, then do nothing.
Also removed commented out code.
Change-Id: If3e7d3b2057f0c89f48f81a4a7a7b2360c0a3439
Reviewed-on: https://gerrit.libreoffice.org/8593
Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com>
Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/gdi/outdev2.cxx | 119 | ||||
-rw-r--r-- | vcl/source/gdi/print.cxx | 89 |
2 files changed, 98 insertions, 110 deletions
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx index 235a0c89727b..2ff2dd14fead 100644 --- a/vcl/source/gdi/outdev2.cxx +++ b/vcl/source/gdi/outdev2.cxx @@ -2264,22 +2264,6 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask ImplDrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION); } - //Region aWorkRgn( aMask.CreateRegion( COL_BLACK, Rectangle( Point(), aMask.GetSizePixel() ) ) ); - //ImplRegionInfo aInfo; - //sal_Bool bRgnRect = aWorkRgn.ImplGetFirstRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight ); - - //while( bRgnRect ) - //{ - // Bitmap aBandBmp( aPaint ); - // const Rectangle aBandRect( Point( nWorkX, nWorkY ), Size( nWorkWidth, nWorkHeight ) ); - // const Point aMapPt( pMapX[ nWorkX ], pMapY[ nWorkY ] ); - // const Size aMapSz( pMapX[ nWorkX + nWorkWidth ] - aMapPt.X(), pMapY[ nWorkY + nWorkHeight ] - aMapPt.Y() ); - - // aBandBmp.Crop( aBandRect ); - // ImplDrawBitmap( aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION ); - // bRgnRect = aWorkRgn.ImplGetNextRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight ); - //} - mbMap = bOldMap; } } @@ -2288,100 +2272,15 @@ void OutputDevice::ImplPrintMask( const Bitmap& rMask, const Color& rMaskColor, const Point& rDestPt, const Size& rDestSize, const Point& rSrcPtPixel, const Size& rSrcSizePixel ) { - Point aPt; - Point aDestPt( LogicToPixel( rDestPt ) ); - Size aDestSz( LogicToPixel( rDestSize ) ); - Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel ); - - aSrcRect.Justify(); - - if( !rMask.IsEmpty() && aSrcRect.GetWidth() && aSrcRect.GetHeight() && aDestSz.Width() && aDestSz.Height() ) - { - Bitmap aMask( rMask ); - sal_uLong nMirrFlags = 0UL; - - if( aMask.GetBitCount() > 1 ) - aMask.Convert( BMP_CONVERSION_1BIT_THRESHOLD ); - - // mirrored horizontically - if( aDestSz.Width() < 0L ) - { - aDestSz.Width() = -aDestSz.Width(); - aDestPt.X() -= ( aDestSz.Width() - 1L ); - nMirrFlags |= BMP_MIRROR_HORZ; - } - - // mirrored vertically - if( aDestSz.Height() < 0L ) - { - aDestSz.Height() = -aDestSz.Height(); - aDestPt.Y() -= ( aDestSz.Height() - 1L ); - nMirrFlags |= BMP_MIRROR_VERT; - } - - // source cropped? - if( aSrcRect != Rectangle( aPt, aMask.GetSizePixel() ) ) - aMask.Crop( aSrcRect ); - - // destination mirrored - if( nMirrFlags ) - aMask.Mirror( nMirrFlags ); - - // do painting - const long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight(); - long nX, nY; //, nWorkX, nWorkY, nWorkWidth, nWorkHeight; - boost::scoped_array<long> pMapX(new long[ nSrcWidth + 1 ]); - boost::scoped_array<long> pMapY(new long[ nSrcHeight + 1 ]); - GDIMetaFile* pOldMetaFile = mpMetaFile; - const bool bOldMap = mbMap; - - mpMetaFile = NULL; - mbMap = false; - Push( PUSH_FILLCOLOR | PUSH_LINECOLOR ); - SetLineColor( rMaskColor ); - SetFillColor( rMaskColor ); - ImplInitLineColor(); - ImplInitFillColor(); - - // create forward mapping tables - for( nX = 0L; nX <= nSrcWidth; nX++ ) - pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth ); - - for( nY = 0L; nY <= nSrcHeight; nY++ ) - pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight ); - - // walk through all rectangles of mask - const Region aWorkRgn(aMask.CreateRegion(COL_BLACK, Rectangle(Point(), aMask.GetSizePixel()))); - RectangleVector aRectangles; - aWorkRgn.GetRegionRectangles(aRectangles); - - for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) - { - const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]); - const Size aMapSz( - pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 - pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y - - DrawRect(Rectangle(aMapPt, aMapSz)); - } - - //Region aWorkRgn( aMask.CreateRegion( COL_BLACK, Rectangle( Point(), aMask.GetSizePixel() ) ) ); - //ImplRegionInfo aInfo; - //sal_Bool bRgnRect = aWorkRgn.ImplGetFirstRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight ); - - //while( bRgnRect ) - //{ - // const Point aMapPt( pMapX[ nWorkX ], pMapY[ nWorkY ] ); - // const Size aMapSz( pMapX[ nWorkX + nWorkWidth ] - aMapPt.X(), pMapY[ nWorkY + nWorkHeight ] - aMapPt.Y() ); - - // DrawRect( Rectangle( aMapPt, aMapSz ) ); - // bRgnRect = aWorkRgn.ImplGetNextRect( aInfo, nWorkX, nWorkY, nWorkWidth, nWorkHeight ); - //} - - Pop(); - mbMap = bOldMap; - mpMetaFile = pOldMetaFile; - } + // let's leave this for Printer + (void) rMask; + (void) rMaskColor; + (void) rDestPt; + (void) rDestSize; + (void) rSrcPtPixel; + (void) rSrcSizePixel; + + return; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/source/gdi/print.cxx b/vcl/source/gdi/print.cxx index 3f1acd120daa..f33037c6d155 100644 --- a/vcl/source/gdi/print.cxx +++ b/vcl/source/gdi/print.cxx @@ -24,6 +24,7 @@ #include <tools/resary.hxx> #include <tools/stream.hxx> #include <tools/vcompat.hxx> +#include <tools/helpers.hxx> #include <vcl/unohelp.hxx> #include <vcl/svapp.hxx> @@ -683,6 +684,94 @@ void Printer::ImplInitDisplay( const Window* pWindow ) mnDPIY = mpDisplayDev->mnDPIY; } +void Printer::ImplPrintMask( const Bitmap& rMask, const Color& rMaskColor, + const Point& rDestPt, const Size& rDestSize, + const Point& rSrcPtPixel, const Size& rSrcSizePixel ) +{ + Point aPt; + Point aDestPt( LogicToPixel( rDestPt ) ); + Size aDestSz( LogicToPixel( rDestSize ) ); + Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel ); + + aSrcRect.Justify(); + + if( !rMask.IsEmpty() && aSrcRect.GetWidth() && aSrcRect.GetHeight() && aDestSz.Width() && aDestSz.Height() ) + { + Bitmap aMask( rMask ); + sal_uLong nMirrFlags = 0UL; + + if( aMask.GetBitCount() > 1 ) + aMask.Convert( BMP_CONVERSION_1BIT_THRESHOLD ); + + // mirrored horizontically + if( aDestSz.Width() < 0L ) + { + aDestSz.Width() = -aDestSz.Width(); + aDestPt.X() -= ( aDestSz.Width() - 1L ); + nMirrFlags |= BMP_MIRROR_HORZ; + } + + // mirrored vertically + if( aDestSz.Height() < 0L ) + { + aDestSz.Height() = -aDestSz.Height(); + aDestPt.Y() -= ( aDestSz.Height() - 1L ); + nMirrFlags |= BMP_MIRROR_VERT; + } + + // source cropped? + if( aSrcRect != Rectangle( aPt, aMask.GetSizePixel() ) ) + aMask.Crop( aSrcRect ); + + // destination mirrored + if( nMirrFlags ) + aMask.Mirror( nMirrFlags ); + + // do painting + const long nSrcWidth = aSrcRect.GetWidth(), nSrcHeight = aSrcRect.GetHeight(); + long nX, nY; //, nWorkX, nWorkY, nWorkWidth, nWorkHeight; + long* pMapX = new long[ nSrcWidth + 1 ]; + long* pMapY = new long[ nSrcHeight + 1 ]; + GDIMetaFile* pOldMetaFile = mpMetaFile; + const bool bOldMap = mbMap; + + mpMetaFile = NULL; + mbMap = false; + Push( PUSH_FILLCOLOR | PUSH_LINECOLOR ); + SetLineColor( rMaskColor ); + SetFillColor( rMaskColor ); + ImplInitLineColor(); + ImplInitFillColor(); + + // create forward mapping tables + for( nX = 0L; nX <= nSrcWidth; nX++ ) + pMapX[ nX ] = aDestPt.X() + FRound( (double) aDestSz.Width() * nX / nSrcWidth ); + + for( nY = 0L; nY <= nSrcHeight; nY++ ) + pMapY[ nY ] = aDestPt.Y() + FRound( (double) aDestSz.Height() * nY / nSrcHeight ); + + // walk through all rectangles of mask + const Region aWorkRgn(aMask.CreateRegion(COL_BLACK, Rectangle(Point(), aMask.GetSizePixel()))); + RectangleVector aRectangles; + aWorkRgn.GetRegionRectangles(aRectangles); + + for(RectangleVector::const_iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter) + { + const Point aMapPt(pMapX[aRectIter->Left()], pMapY[aRectIter->Top()]); + const Size aMapSz( + pMapX[aRectIter->Right() + 1] - aMapPt.X(), // pMapX[L + W] -> L + ((R - L) + 1) -> R + 1 + pMapY[aRectIter->Bottom() + 1] - aMapPt.Y()); // same for Y + + DrawRect(Rectangle(aMapPt, aMapSz)); + } + + Pop(); + delete[] pMapX; + delete[] pMapY; + mbMap = bOldMap; + mpMetaFile = pOldMetaFile; + } +} SalPrinterQueueInfo* Printer::ImplGetQueueInfo( const OUString& rPrinterName, const OUString* pDriver ) |