Kaydet (Commit) c30fd602 authored tarafından Chris Sherlock's avatar Chris Sherlock Kaydeden (comit) Norbert Thiebaud

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/8593Reviewed-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
Tested-by: 's avatarNorbert Thiebaud <nthiebaud@gmail.com>
üst 143c059f
...@@ -762,9 +762,6 @@ public: ...@@ -762,9 +762,6 @@ public:
SAL_DLLPRIVATE void ImplPrintTransparent ( const Bitmap& rBmp, const Bitmap& rMask, SAL_DLLPRIVATE void ImplPrintTransparent ( const Bitmap& rBmp, const Bitmap& rMask,
const Point& rDestPt, const Size& rDestSize, const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel ); const Point& rSrcPtPixel, const Size& rSrcSizePixel );
SAL_DLLPRIVATE void ImplPrintMask ( const Bitmap& rMask, const Color& rMaskColor,
const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel );
SAL_DLLPRIVATE Color ImplDrawModeToColor ( const Color& rColor ) const; SAL_DLLPRIVATE Color ImplDrawModeToColor ( const Color& rColor ) const;
///@} ///@}
...@@ -802,6 +799,10 @@ public: ...@@ -802,6 +799,10 @@ public:
protected: protected:
OutputDevice(); OutputDevice();
virtual void ImplPrintMask ( const Bitmap& rMask, const Color& rMaskColor,
const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel );
virtual long ImplGetGradientStepCount( long nMinRect ); virtual long ImplGetGradientStepCount( long nMinRect );
private: private:
......
...@@ -282,6 +282,9 @@ protected: ...@@ -282,6 +282,9 @@ protected:
void SetSelfAsQueuePrinter( bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; } void SetSelfAsQueuePrinter( bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; }
bool IsQueuePrinter() const { return mbIsQueuePrinter; } bool IsQueuePrinter() const { return mbIsQueuePrinter; }
virtual void ImplPrintMask ( const Bitmap& rMask, const Color& rMaskColor,
const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel );
public: public:
Printer(); Printer();
......
...@@ -2264,22 +2264,6 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask ...@@ -2264,22 +2264,6 @@ void OutputDevice::ImplPrintTransparent( const Bitmap& rBmp, const Bitmap& rMask
ImplDrawBitmap(aMapPt, aMapSz, Point(), aBandBmp.GetSizePixel(), aBandBmp, META_BMPSCALEPART_ACTION); 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; mbMap = bOldMap;
} }
} }
...@@ -2288,100 +2272,15 @@ void OutputDevice::ImplPrintMask( const Bitmap& rMask, const Color& rMaskColor, ...@@ -2288,100 +2272,15 @@ void OutputDevice::ImplPrintMask( const Bitmap& rMask, const Color& rMaskColor,
const Point& rDestPt, const Size& rDestSize, const Point& rDestPt, const Size& rDestSize,
const Point& rSrcPtPixel, const Size& rSrcSizePixel ) const Point& rSrcPtPixel, const Size& rSrcSizePixel )
{ {
Point aPt; // let's leave this for Printer
Point aDestPt( LogicToPixel( rDestPt ) ); (void) rMask;
Size aDestSz( LogicToPixel( rDestSize ) ); (void) rMaskColor;
Rectangle aSrcRect( rSrcPtPixel, rSrcSizePixel ); (void) rDestPt;
(void) rDestSize;
aSrcRect.Justify(); (void) rSrcPtPixel;
(void) rSrcSizePixel;
if( !rMask.IsEmpty() && aSrcRect.GetWidth() && aSrcRect.GetHeight() && aDestSz.Width() && aDestSz.Height() )
{ return;
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;
}
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <tools/resary.hxx> #include <tools/resary.hxx>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <tools/vcompat.hxx> #include <tools/vcompat.hxx>
#include <tools/helpers.hxx>
#include <vcl/unohelp.hxx> #include <vcl/unohelp.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
...@@ -683,6 +684,94 @@ void Printer::ImplInitDisplay( const Window* pWindow ) ...@@ -683,6 +684,94 @@ void Printer::ImplInitDisplay( const Window* pWindow )
mnDPIY = mpDisplayDev->mnDPIY; 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, SalPrinterQueueInfo* Printer::ImplGetQueueInfo( const OUString& rPrinterName,
const OUString* pDriver ) const OUString* pDriver )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment