[Libreoffice-commits] core.git: include/vcl vcl/source

Chris Sherlock chris.sherlock79 at gmail.com
Fri Mar 21 13:04:29 PDT 2014


 include/vcl/outdev.hxx     |    7 +-
 include/vcl/print.hxx      |    3 +
 vcl/source/gdi/outdev2.cxx |  119 +++------------------------------------------
 vcl/source/gdi/print.cxx   |   89 +++++++++++++++++++++++++++++++++
 4 files changed, 105 insertions(+), 113 deletions(-)

New commits:
commit c30fd602521986348ef952b7173ea37a064ee82b
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Sat Mar 15 02:45:53 2014 +1100

    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 at gmail.com>
    Tested-by: Norbert Thiebaud <nthiebaud at gmail.com>

diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 67b7a1f..117ddb7 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -762,9 +762,6 @@ public:
     SAL_DLLPRIVATE void         ImplPrintTransparent ( const Bitmap& rBmp, const Bitmap& rMask,
                                                        const Point& rDestPt, const Size& rDestSize,
                                                        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;
     ///@}
 
@@ -802,6 +799,10 @@ public:
 protected:
                                 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 );
 
 private:
diff --git a/include/vcl/print.hxx b/include/vcl/print.hxx
index 0f5897d..408ec66 100644
--- a/include/vcl/print.hxx
+++ b/include/vcl/print.hxx
@@ -282,6 +282,9 @@ protected:
 
     void                        SetSelfAsQueuePrinter( bool bQueuePrinter ) { mbIsQueuePrinter = bQueuePrinter; }
     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:
                                 Printer();
diff --git a/vcl/source/gdi/outdev2.cxx b/vcl/source/gdi/outdev2.cxx
index 235a0c8..2ff2dd1 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 3f1acd1..f33037c 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 )


More information about the Libreoffice-commits mailing list