LCOV - code coverage report
Current view: top level - canvas/source/vcl - canvashelper.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 543 0.0 %
Date: 2014-11-03 Functions: 0 39 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <canvas/debug.hxx>
      21             : #include <tools/diagnose_ex.h>
      22             : 
      23             : #include <rtl/math.hxx>
      24             : 
      25             : #include <com/sun/star/rendering/CompositeOperation.hpp>
      26             : #include <com/sun/star/util/Endianness.hpp>
      27             : #include <com/sun/star/rendering/TextDirection.hpp>
      28             : #include <com/sun/star/rendering/TexturingMode.hpp>
      29             : #include <com/sun/star/rendering/PathCapType.hpp>
      30             : #include <com/sun/star/rendering/PathJoinType.hpp>
      31             : #include <com/sun/star/drawing/LineCap.hpp>
      32             : 
      33             : #include <tools/poly.hxx>
      34             : #include <vcl/window.hxx>
      35             : #include <vcl/bitmapex.hxx>
      36             : #include <vcl/bmpacc.hxx>
      37             : #include <vcl/canvastools.hxx>
      38             : 
      39             : #include <basegfx/matrix/b2dhommatrix.hxx>
      40             : #include <basegfx/range/b2drectangle.hxx>
      41             : #include <basegfx/point/b2dpoint.hxx>
      42             : #include <basegfx/vector/b2dsize.hxx>
      43             : #include <basegfx/polygon/b2dpolygon.hxx>
      44             : #include <basegfx/polygon/b2dpolygontools.hxx>
      45             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      46             : #include <basegfx/polygon/b2dlinegeometry.hxx>
      47             : #include <basegfx/tools/canvastools.hxx>
      48             : #include <basegfx/numeric/ftools.hxx>
      49             : 
      50             : #include <utility>
      51             : 
      52             : #include <comphelper/sequence.hxx>
      53             : #include <canvas/canvastools.hxx>
      54             : 
      55             : #include "textlayout.hxx"
      56             : #include "canvashelper.hxx"
      57             : #include "canvasbitmap.hxx"
      58             : #include "impltools.hxx"
      59             : #include "canvasfont.hxx"
      60             : 
      61             : 
      62             : using namespace ::com::sun::star;
      63             : 
      64             : namespace vclcanvas
      65             : {
      66             :     namespace
      67             :     {
      68           0 :         basegfx::B2DLineJoin b2DJoineFromJoin( sal_Int8 nJoinType )
      69             :         {
      70           0 :             switch( nJoinType )
      71             :             {
      72             :                 case rendering::PathJoinType::NONE:
      73           0 :                     return basegfx::B2DLINEJOIN_NONE;
      74             : 
      75             :                 case rendering::PathJoinType::MITER:
      76           0 :                     return basegfx::B2DLINEJOIN_MITER;
      77             : 
      78             :                 case rendering::PathJoinType::ROUND:
      79           0 :                     return basegfx::B2DLINEJOIN_ROUND;
      80             : 
      81             :                 case rendering::PathJoinType::BEVEL:
      82           0 :                     return basegfx::B2DLINEJOIN_BEVEL;
      83             : 
      84             :                 default:
      85           0 :                     ENSURE_OR_THROW( false,
      86             :                                       "b2DJoineFromJoin(): Unexpected join type" );
      87             :             }
      88             : 
      89             :             return basegfx::B2DLINEJOIN_NONE;
      90             :         }
      91             : 
      92           0 :         drawing::LineCap unoCapeFromCap( sal_Int8 nCapType)
      93             :         {
      94           0 :             switch ( nCapType)
      95             :             {
      96             :                 case rendering::PathCapType::BUTT:
      97           0 :                     return drawing::LineCap_BUTT;
      98             : 
      99             :                 case rendering::PathCapType::ROUND:
     100           0 :                     return drawing::LineCap_ROUND;
     101             : 
     102             :                 case rendering::PathCapType::SQUARE:
     103           0 :                     return drawing::LineCap_SQUARE;
     104             : 
     105             :                 default:
     106           0 :                     ENSURE_OR_THROW( false,
     107             :                                       "unoCapeFromCap(): Unexpected cap type" );
     108             :             }
     109             :             return drawing::LineCap_BUTT;
     110             :         }
     111             :     }
     112             : 
     113           0 :     CanvasHelper::CanvasHelper() :
     114             :         mpDevice(),
     115             :         mpProtectedOutDev(),
     116             :         mpOutDev(),
     117             :         mp2ndOutDev(),
     118           0 :         mbHaveAlpha( false )
     119             :     {
     120           0 :     }
     121             : 
     122           0 :     void CanvasHelper::disposing()
     123             :     {
     124           0 :         mpDevice = NULL;
     125           0 :         mpProtectedOutDev.reset();
     126           0 :         mpOutDev.reset();
     127           0 :         mp2ndOutDev.reset();
     128           0 :     }
     129             : 
     130           0 :     void CanvasHelper::init( rendering::XGraphicDevice&     rDevice,
     131             :                              const OutDevProviderSharedPtr& rOutDev,
     132             :                              bool                           bProtect,
     133             :                              bool                           bHaveAlpha )
     134             :     {
     135             :         // cast away const, need to change refcount (as this is
     136             :         // ~invisible to client code, still logically const)
     137           0 :         mpDevice    = &rDevice;
     138           0 :         mbHaveAlpha = bHaveAlpha;
     139             : 
     140           0 :         setOutDev( rOutDev, bProtect );
     141           0 :     }
     142             : 
     143           0 :     void CanvasHelper::setOutDev( const OutDevProviderSharedPtr& rOutDev,
     144             :                                   bool                           bProtect )
     145             :     {
     146           0 :         if( bProtect )
     147           0 :             mpProtectedOutDev = rOutDev;
     148             :         else
     149           0 :             mpProtectedOutDev.reset();
     150             : 
     151           0 :         mpOutDev = rOutDev;
     152           0 :     }
     153             : 
     154           0 :     void CanvasHelper::setBackgroundOutDev( const OutDevProviderSharedPtr& rOutDev )
     155             :     {
     156           0 :         mp2ndOutDev = rOutDev;
     157           0 :         mp2ndOutDev->getOutDev().EnableMapMode( false );
     158           0 :         mp2ndOutDev->getOutDev().SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
     159           0 :     }
     160             : 
     161           0 :     void CanvasHelper::clear()
     162             :     {
     163             :         // are we disposed?
     164           0 :         if( mpOutDev )
     165             :         {
     166           0 :             OutputDevice& rOutDev( mpOutDev->getOutDev() );
     167           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     168             : 
     169           0 :             rOutDev.EnableMapMode( false );
     170           0 :             rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
     171           0 :             rOutDev.SetLineColor( COL_WHITE );
     172           0 :             rOutDev.SetFillColor( COL_WHITE );
     173           0 :             rOutDev.SetClipRegion();
     174             :             rOutDev.DrawRect( Rectangle( Point(),
     175           0 :                                          rOutDev.GetOutputSizePixel()) );
     176             : 
     177           0 :             if( mp2ndOutDev )
     178             :             {
     179           0 :                 OutputDevice& rOutDev2( mp2ndOutDev->getOutDev() );
     180             : 
     181           0 :                 rOutDev2.SetDrawMode( DRAWMODE_DEFAULT );
     182           0 :                 rOutDev2.EnableMapMode( false );
     183           0 :                 rOutDev2.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
     184           0 :                 rOutDev2.SetLineColor( COL_WHITE );
     185           0 :                 rOutDev2.SetFillColor( COL_WHITE );
     186           0 :                 rOutDev2.SetClipRegion();
     187             :                 rOutDev2.DrawRect( Rectangle( Point(),
     188           0 :                                               rOutDev2.GetOutputSizePixel()) );
     189             :                 rOutDev2.SetDrawMode( DRAWMODE_BLACKLINE | DRAWMODE_BLACKFILL | DRAWMODE_BLACKTEXT |
     190           0 :                                       DRAWMODE_BLACKGRADIENT | DRAWMODE_BLACKBITMAP );
     191           0 :             }
     192             :         }
     193           0 :     }
     194             : 
     195           0 :     void CanvasHelper::drawPoint( const rendering::XCanvas*     ,
     196             :                                   const geometry::RealPoint2D&  aPoint,
     197             :                                   const rendering::ViewState&   viewState,
     198             :                                   const rendering::RenderState& renderState )
     199             :     {
     200             :         // are we disposed?
     201           0 :         if( mpOutDev )
     202             :         {
     203             :             // nope, render
     204           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     205           0 :             setupOutDevState( viewState, renderState, LINE_COLOR );
     206             : 
     207             :             const Point aOutPoint( tools::mapRealPoint2D( aPoint,
     208           0 :                                                           viewState, renderState ) );
     209             :             // TODO(F1): alpha
     210           0 :             mpOutDev->getOutDev().DrawPixel( aOutPoint );
     211             : 
     212           0 :             if( mp2ndOutDev )
     213           0 :                 mp2ndOutDev->getOutDev().DrawPixel( aOutPoint );
     214             :         }
     215           0 :     }
     216             : 
     217           0 :     void CanvasHelper::drawLine( const rendering::XCanvas*      ,
     218             :                                  const geometry::RealPoint2D&   aStartRealPoint2D,
     219             :                                  const geometry::RealPoint2D&   aEndRealPoint2D,
     220             :                                  const rendering::ViewState&    viewState,
     221             :                                  const rendering::RenderState&  renderState )
     222             :     {
     223             :         // are we disposed?
     224           0 :         if( mpOutDev )
     225             :         {
     226             :             // nope, render
     227           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     228           0 :             setupOutDevState( viewState, renderState, LINE_COLOR );
     229             : 
     230             :             const Point aStartPoint( tools::mapRealPoint2D( aStartRealPoint2D,
     231           0 :                                                             viewState, renderState ) );
     232             :             const Point aEndPoint( tools::mapRealPoint2D( aEndRealPoint2D,
     233           0 :                                                           viewState, renderState ) );
     234             :             // TODO(F2): alpha
     235           0 :             mpOutDev->getOutDev().DrawLine( aStartPoint, aEndPoint );
     236             : 
     237           0 :             if( mp2ndOutDev )
     238           0 :                 mp2ndOutDev->getOutDev().DrawLine( aStartPoint, aEndPoint );
     239             :         }
     240           0 :     }
     241             : 
     242           0 :     void CanvasHelper::drawBezier( const rendering::XCanvas*            ,
     243             :                                    const geometry::RealBezierSegment2D& aBezierSegment,
     244             :                                    const geometry::RealPoint2D&         _aEndPoint,
     245             :                                    const rendering::ViewState&          viewState,
     246             :                                    const rendering::RenderState&        renderState )
     247             :     {
     248           0 :         if( mpOutDev )
     249             :         {
     250           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     251           0 :             setupOutDevState( viewState, renderState, LINE_COLOR );
     252             : 
     253             :             const Point& rStartPoint( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.Px,
     254             :                                                                                    aBezierSegment.Py),
     255           0 :                                                             viewState, renderState ) );
     256             :             const Point& rCtrlPoint1( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.C1x,
     257             :                                                                                    aBezierSegment.C1y),
     258           0 :                                                             viewState, renderState ) );
     259             :             const Point& rCtrlPoint2( tools::mapRealPoint2D( geometry::RealPoint2D(aBezierSegment.C2x,
     260             :                                                                                    aBezierSegment.C2y),
     261           0 :                                                              viewState, renderState ) );
     262             :             const Point& rEndPoint( tools::mapRealPoint2D( _aEndPoint,
     263           0 :                                                            viewState, renderState ) );
     264             : 
     265           0 :             ::Polygon aPoly(4);
     266           0 :             aPoly.SetPoint( rStartPoint, 0 );
     267           0 :             aPoly.SetFlags( 0, POLY_NORMAL );
     268           0 :             aPoly.SetPoint( rCtrlPoint1, 1 );
     269           0 :             aPoly.SetFlags( 1, POLY_CONTROL );
     270           0 :             aPoly.SetPoint( rCtrlPoint2, 2 );
     271           0 :             aPoly.SetFlags( 2, POLY_CONTROL );
     272           0 :             aPoly.SetPoint( rEndPoint, 3 );
     273           0 :             aPoly.SetFlags( 3, POLY_NORMAL );
     274             : 
     275             :             // TODO(F2): alpha
     276           0 :             mpOutDev->getOutDev().DrawPolygon( aPoly );
     277           0 :             if( mp2ndOutDev )
     278           0 :                 mp2ndOutDev->getOutDev().DrawPolygon( aPoly );
     279             :         }
     280           0 :     }
     281             : 
     282           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawPolyPolygon( const rendering::XCanvas*                          ,
     283             :                                                                                  const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
     284             :                                                                                  const rendering::ViewState&                        viewState,
     285             :                                                                                  const rendering::RenderState&                      renderState )
     286             :     {
     287           0 :         ENSURE_ARG_OR_THROW( xPolyPolygon.is(),
     288             :                          "polygon is NULL");
     289             : 
     290           0 :         if( mpOutDev )
     291             :         {
     292           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     293           0 :             setupOutDevState( viewState, renderState, LINE_COLOR );
     294             : 
     295             :             const ::basegfx::B2DPolyPolygon& rPolyPoly(
     296           0 :                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon) );
     297           0 :             const ::tools::PolyPolygon aPolyPoly( tools::mapPolyPolygon( rPolyPoly, viewState, renderState ) );
     298             : 
     299           0 :             if( rPolyPoly.isClosed() )
     300             :             {
     301           0 :                 mpOutDev->getOutDev().DrawPolyPolygon( aPolyPoly );
     302             : 
     303           0 :                 if( mp2ndOutDev )
     304           0 :                     mp2ndOutDev->getOutDev().DrawPolyPolygon( aPolyPoly );
     305             :             }
     306             :             else
     307             :             {
     308             :                 // mixed open/closed state. Cannot render open polygon
     309             :                 // via DrawPolyPolygon(), since that implicitley
     310             :                 // closed every polygon. OTOH, no need to distinguish
     311             :                 // further and render closed polygons via
     312             :                 // DrawPolygon(), and open ones via DrawPolyLine():
     313             :                 // closed polygons will simply already contain the
     314             :                 // closing segment.
     315           0 :                 sal_uInt16 nSize( aPolyPoly.Count() );
     316             : 
     317           0 :                 for( sal_uInt16 i=0; i<nSize; ++i )
     318             :                 {
     319           0 :                     mpOutDev->getOutDev().DrawPolyLine( aPolyPoly[i] );
     320             : 
     321           0 :                     if( mp2ndOutDev )
     322           0 :                         mp2ndOutDev->getOutDev().DrawPolyLine( aPolyPoly[i] );
     323             :                 }
     324           0 :             }
     325             :         }
     326             : 
     327             :         // TODO(P1): Provide caching here.
     328           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     329             :     }
     330             : 
     331           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokePolyPolygon( const rendering::XCanvas*                            ,
     332             :                                                                                    const uno::Reference< rendering::XPolyPolygon2D >&   xPolyPolygon,
     333             :                                                                                    const rendering::ViewState&                          viewState,
     334             :                                                                                    const rendering::RenderState&                        renderState,
     335             :                                                                                    const rendering::StrokeAttributes&                   strokeAttributes )
     336             :     {
     337           0 :         ENSURE_ARG_OR_THROW( xPolyPolygon.is(),
     338             :                          "polygon is NULL");
     339             : 
     340           0 :         if( mpOutDev )
     341             :         {
     342           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     343             : 
     344           0 :             ::basegfx::B2DHomMatrix aMatrix;
     345           0 :             ::canvas::tools::mergeViewAndRenderTransform(aMatrix, viewState, renderState);
     346             : 
     347             :             ::basegfx::B2DSize aLinePixelSize(strokeAttributes.StrokeWidth,
     348           0 :                                               strokeAttributes.StrokeWidth);
     349           0 :             aLinePixelSize *= aMatrix;
     350             : 
     351             :             ::basegfx::B2DPolyPolygon aPolyPoly(
     352           0 :                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon) );
     353             : 
     354           0 :             if( aPolyPoly.areControlPointsUsed() )
     355             :             {
     356             :                 // AW: Not needed for ApplyLineDashing anymore; should be removed
     357           0 :                 aPolyPoly = ::basegfx::tools::adaptiveSubdivideByAngle(aPolyPoly);
     358             :             }
     359             : 
     360             :             // apply dashing, if any
     361           0 :             if( strokeAttributes.DashArray.getLength() )
     362             :             {
     363             :                 const ::std::vector<double>& aDashArray(
     364           0 :                     ::comphelper::sequenceToContainer< ::std::vector<double> >(strokeAttributes.DashArray) );
     365             : 
     366           0 :                 ::basegfx::B2DPolyPolygon aDashedPolyPoly;
     367             : 
     368           0 :                 for( sal_uInt32 i=0; i<aPolyPoly.count(); ++i )
     369             :                 {
     370             :                     // AW: new interface; You may also get gaps in the same run now
     371           0 :                     basegfx::tools::applyLineDashing(aPolyPoly.getB2DPolygon(i), aDashArray, &aDashedPolyPoly);
     372             :                     //aDashedPolyPoly.append(
     373             :                     //    ::basegfx::tools::applyLineDashing( aPolyPoly.getB2DPolygon(i),
     374             :                     //                                        aDashArray ) );
     375             :                 }
     376             : 
     377           0 :                 aPolyPoly = aDashedPolyPoly;
     378             :             }
     379             : 
     380           0 :             ::basegfx::B2DPolyPolygon aStrokedPolyPoly;
     381           0 :             if( aLinePixelSize.getLength() < 1.42 )
     382             :             {
     383             :                 // line width < 1.0 in device pixel, thus, output as a
     384             :                 // simple hairline poly-polygon
     385           0 :                 setupOutDevState( viewState, renderState, LINE_COLOR );
     386             : 
     387           0 :                 aStrokedPolyPoly = aPolyPoly;
     388             :             }
     389             :             else
     390             :             {
     391             :                 // render as a 'thick' line
     392           0 :                 setupOutDevState( viewState, renderState, FILL_COLOR );
     393             : 
     394           0 :                 for( sal_uInt32 i=0; i<aPolyPoly.count(); ++i )
     395             :                 {
     396             :                     // TODO(F2): Use MiterLimit from StrokeAttributes,
     397             :                     // need to convert it here to angle.
     398             : 
     399             :                     // TODO(F2): Also use Cap settings from
     400             :                     // StrokeAttributes, the
     401             :                     // createAreaGeometryForLineStartEnd() method does not
     402             :                     // seem to fit very well here
     403             : 
     404             :                     // AW: New interface, will create bezier polygons now
     405             :                     aStrokedPolyPoly.append(basegfx::tools::createAreaGeometry(
     406             :                         aPolyPoly.getB2DPolygon(i),
     407             :                         strokeAttributes.StrokeWidth*0.5,
     408             :                         b2DJoineFromJoin(strokeAttributes.JoinType),
     409             :                         unoCapeFromCap(strokeAttributes.StartCapType)
     410           0 :                         ));
     411             :                     //aStrokedPolyPoly.append(
     412             :                     //    ::basegfx::tools::createAreaGeometryForPolygon( aPolyPoly.getB2DPolygon(i),
     413             :                     //                                                    strokeAttributes.StrokeWidth*0.5,
     414             :                     //                                                    b2DJoineFromJoin(strokeAttributes.JoinType) ) );
     415             :                 }
     416             :             }
     417             : 
     418             :             // transform only _now_, all the StrokeAttributes are in
     419             :             // user coordinates.
     420           0 :             aStrokedPolyPoly.transform( aMatrix );
     421             : 
     422           0 :             const ::tools::PolyPolygon aVCLPolyPoly( aStrokedPolyPoly );
     423             : 
     424             :             // TODO(F2): When using alpha here, must handle that via
     425             :             // temporary surface or somesuch.
     426             : 
     427             :             // Note: the generated stroke poly-polygon is NOT free of
     428             :             // self-intersections. Therefore, if we would render it
     429             :             // via OutDev::DrawPolyPolygon(), on/off fill would
     430             :             // generate off areas on those self-intersections.
     431           0 :             sal_uInt16 nSize( aVCLPolyPoly.Count() );
     432             : 
     433           0 :             for( sal_uInt16 i=0; i<nSize; ++i )
     434             :             {
     435           0 :                 if( aStrokedPolyPoly.getB2DPolygon( i ).isClosed() ) {
     436           0 :                     mpOutDev->getOutDev().DrawPolygon( aVCLPolyPoly[i] );
     437           0 :                     if( mp2ndOutDev )
     438           0 :                         mp2ndOutDev->getOutDev().DrawPolygon( aVCLPolyPoly[i] );
     439             :                 } else {
     440           0 :                     const sal_uInt16 nPolySize = aVCLPolyPoly[i].GetSize();
     441           0 :                     if( nPolySize ) {
     442           0 :                         Point rPrevPoint = aVCLPolyPoly[i].GetPoint( 0 );
     443           0 :                         Point rPoint;
     444             : 
     445           0 :                         for( sal_uInt16 j=1; j<nPolySize; j++ ) {
     446           0 :                             rPoint = aVCLPolyPoly[i].GetPoint( j );
     447           0 :                             mpOutDev->getOutDev().DrawLine( rPrevPoint, rPoint );
     448           0 :                             if( mp2ndOutDev )
     449           0 :                                 mp2ndOutDev->getOutDev().DrawLine( rPrevPoint, rPoint );
     450           0 :                             rPrevPoint = rPoint;
     451             :                         }
     452             :                     }
     453             :                 }
     454           0 :             }
     455             :         }
     456             : 
     457             :         // TODO(P1): Provide caching here.
     458           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     459             :     }
     460             : 
     461           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTexturedPolyPolygon( const rendering::XCanvas*                            ,
     462             :                                                                                            const uno::Reference< rendering::XPolyPolygon2D >&   ,
     463             :                                                                                            const rendering::ViewState&                          ,
     464             :                                                                                            const rendering::RenderState&                        ,
     465             :                                                                                            const uno::Sequence< rendering::Texture >&           ,
     466             :                                                                                            const rendering::StrokeAttributes&                    )
     467             :     {
     468           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     469             :     }
     470             : 
     471           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::strokeTextureMappedPolyPolygon( const rendering::XCanvas*                           ,
     472             :                                                                                                 const uno::Reference< rendering::XPolyPolygon2D >&  ,
     473             :                                                                                                 const rendering::ViewState&                         ,
     474             :                                                                                                 const rendering::RenderState&                       ,
     475             :                                                                                                 const uno::Sequence< rendering::Texture >&          ,
     476             :                                                                                                 const uno::Reference< geometry::XMapping2D >&       ,
     477             :                                                                                                 const rendering::StrokeAttributes&                   )
     478             :     {
     479           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     480             :     }
     481             : 
     482           0 :     uno::Reference< rendering::XPolyPolygon2D >   CanvasHelper::queryStrokeShapes( const rendering::XCanvas*                            ,
     483             :                                                                                    const uno::Reference< rendering::XPolyPolygon2D >&   ,
     484             :                                                                                    const rendering::ViewState&                          ,
     485             :                                                                                    const rendering::RenderState&                        ,
     486             :                                                                                    const rendering::StrokeAttributes&                    )
     487             :     {
     488           0 :         return uno::Reference< rendering::XPolyPolygon2D >(NULL);
     489             :     }
     490             : 
     491           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillPolyPolygon( const rendering::XCanvas*                          ,
     492             :                                                                                  const uno::Reference< rendering::XPolyPolygon2D >& xPolyPolygon,
     493             :                                                                                  const rendering::ViewState&                        viewState,
     494             :                                                                                  const rendering::RenderState&                      renderState )
     495             :     {
     496           0 :         ENSURE_ARG_OR_THROW( xPolyPolygon.is(),
     497             :                          "polygon is NULL");
     498             : 
     499           0 :         if( mpOutDev )
     500             :         {
     501           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     502             : 
     503           0 :             const int nTransparency( setupOutDevState( viewState, renderState, FILL_COLOR ) );
     504             :             ::basegfx::B2DPolyPolygon aB2DPolyPoly(
     505           0 :                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(xPolyPolygon));
     506           0 :             aB2DPolyPoly.setClosed(true); // ensure closed poly, otherwise VCL does not fill
     507             :             const ::tools::PolyPolygon aPolyPoly( tools::mapPolyPolygon(
     508             :                                              aB2DPolyPoly,
     509           0 :                                              viewState, renderState ) );
     510           0 :             const bool bSourceAlpha( renderState.CompositeOperation == rendering::CompositeOperation::SOURCE );
     511           0 :             if( !nTransparency || bSourceAlpha )
     512             :             {
     513           0 :                 mpOutDev->getOutDev().DrawPolyPolygon( aPolyPoly );
     514             :             }
     515             :             else
     516             :             {
     517           0 :                 const int nTransPercent( (nTransparency * 100 + 128) / 255 );  // normal rounding, no truncation here
     518           0 :                 mpOutDev->getOutDev().DrawTransparent( aPolyPoly, (sal_uInt16)nTransPercent );
     519             :             }
     520             : 
     521           0 :             if( mp2ndOutDev )
     522             :             {
     523             :                 // HACK. Normally, CanvasHelper does not care about
     524             :                 // actually what mp2ndOutDev is...  well, here we do &
     525             :                 // assume a 1bpp target - everything beyond 97%
     526             :                 // transparency is fully transparent
     527           0 :                 if( nTransparency < 253 )
     528             :                 {
     529           0 :                     mp2ndOutDev->getOutDev().SetFillColor( COL_BLACK );
     530           0 :                     mp2ndOutDev->getOutDev().DrawPolyPolygon( aPolyPoly );
     531             :                 }
     532           0 :             }
     533             :         }
     534             : 
     535             :         // TODO(P1): Provide caching here.
     536           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     537             :     }
     538             : 
     539           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::fillTextureMappedPolyPolygon( const rendering::XCanvas*                             ,
     540             :                                                                                               const uno::Reference< rendering::XPolyPolygon2D >&    ,
     541             :                                                                                               const rendering::ViewState&                           ,
     542             :                                                                                               const rendering::RenderState&                         ,
     543             :                                                                                               const uno::Sequence< rendering::Texture >&            ,
     544             :                                                                                               const uno::Reference< geometry::XMapping2D >&              )
     545             :     {
     546           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     547             :     }
     548             : 
     549           0 :     uno::Reference< rendering::XCanvasFont > CanvasHelper::createFont( const rendering::XCanvas*                        ,
     550             :                                                                        const rendering::FontRequest&                    fontRequest,
     551             :                                                                        const uno::Sequence< beans::PropertyValue >&     extraFontProperties,
     552             :                                                                        const geometry::Matrix2D&                        fontMatrix )
     553             :     {
     554           0 :         if( mpOutDev && mpDevice )
     555             :         {
     556             :             // TODO(F2): font properties and font matrix
     557             :             return uno::Reference< rendering::XCanvasFont >(
     558             :                     new CanvasFont(fontRequest, extraFontProperties, fontMatrix,
     559           0 :                                    *mpDevice, mpOutDev) );
     560             :         }
     561             : 
     562           0 :         return uno::Reference< rendering::XCanvasFont >();
     563             :     }
     564             : 
     565           0 :     uno::Sequence< rendering::FontInfo > CanvasHelper::queryAvailableFonts( const rendering::XCanvas*                       ,
     566             :                                                                             const rendering::FontInfo&                      ,
     567             :                                                                             const uno::Sequence< beans::PropertyValue >&     )
     568             :     {
     569             :         // TODO(F2)
     570           0 :         return uno::Sequence< rendering::FontInfo >();
     571             :     }
     572             : 
     573           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawText( const rendering::XCanvas*                         ,
     574             :                                                                           const rendering::StringContext&                   text,
     575             :                                                                           const uno::Reference< rendering::XCanvasFont >&   xFont,
     576             :                                                                           const rendering::ViewState&                       viewState,
     577             :                                                                           const rendering::RenderState&                     renderState,
     578             :                                                                           sal_Int8                                          textDirection )
     579             :     {
     580           0 :         ENSURE_ARG_OR_THROW( xFont.is(),
     581             :                          "font is NULL");
     582             : 
     583           0 :         if( mpOutDev )
     584             :         {
     585           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     586             : 
     587           0 :             ::Point aOutpos;
     588           0 :             if( !setupTextOutput( aOutpos, viewState, renderState, xFont ) )
     589           0 :                 return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary
     590             : 
     591             :             // change text direction and layout mode
     592           0 :             ComplexTextLayoutMode nLayoutMode(TEXT_LAYOUT_DEFAULT);
     593           0 :             switch( textDirection )
     594             :             {
     595             :                 case rendering::TextDirection::WEAK_LEFT_TO_RIGHT:
     596             :                     // FALLTHROUGH intended
     597             :                 case rendering::TextDirection::STRONG_LEFT_TO_RIGHT:
     598           0 :                     nLayoutMode |= TEXT_LAYOUT_BIDI_STRONG;
     599           0 :                     nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_LEFT;
     600           0 :                     break;
     601             : 
     602             :                 case rendering::TextDirection::WEAK_RIGHT_TO_LEFT:
     603           0 :                     nLayoutMode |= TEXT_LAYOUT_BIDI_RTL;
     604             :                     // FALLTHROUGH intended
     605             :                 case rendering::TextDirection::STRONG_RIGHT_TO_LEFT:
     606           0 :                     nLayoutMode |= TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG;
     607           0 :                     nLayoutMode |= TEXT_LAYOUT_TEXTORIGIN_RIGHT;
     608           0 :                     break;
     609             :             }
     610             : 
     611             :             // TODO(F2): alpha
     612           0 :             mpOutDev->getOutDev().SetLayoutMode( nLayoutMode );
     613           0 :             mpOutDev->getOutDev().DrawText( aOutpos,
     614             :                                             text.Text,
     615           0 :                                             ::canvas::tools::numeric_cast<sal_uInt16>(text.StartPosition),
     616           0 :                                             ::canvas::tools::numeric_cast<sal_uInt16>(text.Length) );
     617             : 
     618           0 :             if( mp2ndOutDev )
     619             :             {
     620           0 :                 mp2ndOutDev->getOutDev().SetLayoutMode( nLayoutMode );
     621           0 :                 mp2ndOutDev->getOutDev().DrawText( aOutpos,
     622             :                                                    text.Text,
     623           0 :                                                    ::canvas::tools::numeric_cast<sal_uInt16>(text.StartPosition),
     624           0 :                                                    ::canvas::tools::numeric_cast<sal_uInt16>(text.Length) );
     625           0 :             }
     626             :         }
     627             : 
     628           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     629             :     }
     630             : 
     631           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawTextLayout( const rendering::XCanvas*                       ,
     632             :                                                                                 const uno::Reference< rendering::XTextLayout >& xLayoutedText,
     633             :                                                                                 const rendering::ViewState&                     viewState,
     634             :                                                                                 const rendering::RenderState&                   renderState )
     635             :     {
     636           0 :         ENSURE_ARG_OR_THROW( xLayoutedText.is(),
     637             :                          "layout is NULL");
     638             : 
     639           0 :         TextLayout* pTextLayout = dynamic_cast< TextLayout* >( xLayoutedText.get() );
     640             : 
     641           0 :         if( pTextLayout )
     642             :         {
     643           0 :             if( mpOutDev )
     644             :             {
     645           0 :                 tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     646             : 
     647             :                 // TODO(T3): Race condition. We're taking the font
     648             :                 // from xLayoutedText, and then calling draw() at it,
     649             :                 // without exclusive access. Move setupTextOutput(),
     650             :                 // e.g. to impltools?
     651             : 
     652           0 :                 ::Point aOutpos;
     653           0 :                 if( !setupTextOutput( aOutpos, viewState, renderState, xLayoutedText->getFont() ) )
     654           0 :                     return uno::Reference< rendering::XCachedPrimitive >(NULL); // no output necessary
     655             : 
     656             :                 // TODO(F2): What about the offset scalings?
     657             :                 // TODO(F2): alpha
     658           0 :                 pTextLayout->draw( mpOutDev->getOutDev(), aOutpos, viewState, renderState );
     659             : 
     660           0 :                 if( mp2ndOutDev )
     661           0 :                     pTextLayout->draw( mp2ndOutDev->getOutDev(), aOutpos, viewState, renderState );
     662             :             }
     663             :         }
     664             :         else
     665             :         {
     666           0 :             ENSURE_ARG_OR_THROW( false,
     667             :                                  "TextLayout not compatible with this canvas" );
     668             :         }
     669             : 
     670           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     671             :     }
     672             : 
     673           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::implDrawBitmap( const rendering::XCanvas*                   pCanvas,
     674             :                                                                                 const uno::Reference< rendering::XBitmap >& xBitmap,
     675             :                                                                                 const rendering::ViewState&                 viewState,
     676             :                                                                                 const rendering::RenderState&               renderState,
     677             :                                                                                 bool                                        bModulateColors )
     678             :     {
     679           0 :         ENSURE_ARG_OR_THROW( xBitmap.is(),
     680             :                              "bitmap is NULL");
     681             : 
     682             :         ::canvas::tools::verifyInput( renderState,
     683             :                                       BOOST_CURRENT_FUNCTION,
     684             :                                       mpDevice,
     685             :                                       4,
     686           0 :                                       bModulateColors ? 3 : 0 );
     687             : 
     688           0 :         if( mpOutDev )
     689             :         {
     690           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     691           0 :             setupOutDevState( viewState, renderState, IGNORE_COLOR );
     692             : 
     693           0 :             ::basegfx::B2DHomMatrix aMatrix;
     694           0 :             ::canvas::tools::mergeViewAndRenderTransform(aMatrix, viewState, renderState);
     695             : 
     696           0 :             ::basegfx::B2DPoint aOutputPos( 0.0, 0.0 );
     697           0 :             aOutputPos *= aMatrix;
     698             : 
     699           0 :             BitmapEx aBmpEx( tools::bitmapExFromXBitmap(xBitmap) );
     700             : 
     701             :             // TODO(F2): Implement modulation again for other color
     702             :             // channels (currently, works only for alpha). Note: this
     703             :             // is already implemented in transformBitmap()
     704           0 :             if( bModulateColors &&
     705           0 :                 renderState.DeviceColor.getLength() > 3 )
     706             :             {
     707             :                 // optimize away the case where alpha modulation value
     708             :                 // is 1.0 - we then simply switch off modulation at all
     709             :                 bModulateColors = !::rtl::math::approxEqual(
     710           0 :                     renderState.DeviceColor[3], 1.0);
     711             :             }
     712             : 
     713             :             // check whether we can render bitmap as-is: must not
     714             :             // modulate colors, matrix must either be the identity
     715             :             // transform (that's clear), _or_ contain only
     716             :             // translational components.
     717           0 :             if( !bModulateColors &&
     718           0 :                 (aMatrix.isIdentity() ||
     719           0 :                  (::basegfx::fTools::equalZero( aMatrix.get(0,1) ) &&
     720           0 :                   ::basegfx::fTools::equalZero( aMatrix.get(1,0) ) &&
     721           0 :                   ::rtl::math::approxEqual(aMatrix.get(0,0), 1.0) &&
     722           0 :                   ::rtl::math::approxEqual(aMatrix.get(1,1), 1.0)) ) )
     723             :             {
     724             :                 // optimized case: identity matrix, or only
     725             :                 // translational components.
     726           0 :                 mpOutDev->getOutDev().DrawBitmapEx( ::vcl::unotools::pointFromB2DPoint( aOutputPos ),
     727           0 :                                                     aBmpEx );
     728             : 
     729           0 :                 if( mp2ndOutDev )
     730             :                 {
     731             :                     // HACK. Normally, CanvasHelper does not care about
     732             :                     // actually what mp2ndOutDev is...  well, here we do &
     733             :                     // assume a 1bpp target - everything beyond 97%
     734             :                     // transparency is fully transparent
     735           0 :                     if( aBmpEx.IsAlpha() )
     736             :                     {
     737           0 :                         Bitmap aMask( aBmpEx.GetAlpha().GetBitmap() );
     738           0 :                         aMask.MakeMono( 253 );
     739           0 :                         aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aMask );
     740             :                     }
     741           0 :                     else if( aBmpEx.IsTransparent() )
     742             :                     {
     743           0 :                         aBmpEx = BitmapEx( aBmpEx.GetBitmap(), aBmpEx.GetMask() );
     744             :                     }
     745             : 
     746           0 :                     mp2ndOutDev->getOutDev().DrawBitmapEx( ::vcl::unotools::pointFromB2DPoint( aOutputPos ),
     747           0 :                                                            aBmpEx );
     748             :                 }
     749             : 
     750             :                 // Returning a cache object is not useful, the XBitmap
     751             :                 // itself serves this purpose
     752           0 :                 return uno::Reference< rendering::XCachedPrimitive >(NULL);
     753             :             }
     754             :             else
     755             :             {
     756             :                 // Matrix contains non-trivial transformation (or
     757             :                 // color modulation is requested), decompose to check
     758             :                 // whether GraphicObject suffices
     759           0 :                 ::basegfx::B2DVector aScale;
     760             :                 double               nRotate;
     761             :                 double               nShearX;
     762           0 :                 aMatrix.decompose( aScale, aOutputPos, nRotate, nShearX );
     763             : 
     764           0 :                 GraphicAttr             aGrfAttr;
     765           0 :                 GraphicObjectSharedPtr  pGrfObj;
     766             : 
     767           0 :                 ::Size aBmpSize( aBmpEx.GetSizePixel() );
     768             : 
     769             :                 // setup alpha modulation
     770           0 :                 if( bModulateColors )
     771             :                 {
     772           0 :                     const double nAlphaModulation( renderState.DeviceColor[3] );
     773             : 
     774             :                     // TODO(F1): Note that the GraphicManager has a
     775             :                     // subtle difference in how it calculates the
     776             :                     // resulting alpha value: it's using the inverse
     777             :                     // alpha values (i.e. 'transparency'), and
     778             :                     // calculates transOrig + transModulate, instead
     779             :                     // of transOrig + transModulate -
     780             :                     // transOrig*transModulate (which would be
     781             :                     // equivalent to the origAlpha*modulateAlpha the
     782             :                     // DX canvas performs)
     783             :                     aGrfAttr.SetTransparency(
     784             :                         static_cast< sal_uInt8 >(
     785           0 :                             ::basegfx::fround( 255.0*( 1.0 - nAlphaModulation ) ) ) );
     786             :                 }
     787             : 
     788           0 :                 if( ::basegfx::fTools::equalZero( nShearX ) )
     789             :                 {
     790             :                     // no shear, GraphicObject is enough (the
     791             :                     // GraphicObject only supports scaling, rotation
     792             :                     // and translation)
     793             : 
     794             :                     // #i75339# don't apply mirror flags, having
     795             :                     // negative size values is enough to make
     796             :                     // GraphicObject flip the bitmap
     797             : 
     798             :                     // The angle has to be mapped from radian to tenths of
     799             :                     // degress with the orientation reversed: [0,2Pi) ->
     800             :                     // (3600,0].  Note that the original angle may have
     801             :                     // values outside the [0,2Pi) interval.
     802           0 :                     const double nAngleInTenthOfDegrees (3600.0 - nRotate * 3600.0 / (2*M_PI));
     803           0 :                     aGrfAttr.SetRotation( static_cast< sal_uInt16 >(::basegfx::fround(nAngleInTenthOfDegrees)) );
     804             : 
     805           0 :                     pGrfObj.reset( new GraphicObject( aBmpEx ) );
     806             :                 }
     807             :                 else
     808             :                 {
     809             :                     // modify output position, to account for the fact
     810             :                     // that transformBitmap() always normalizes its output
     811             :                     // bitmap into the smallest enclosing box.
     812           0 :                     ::basegfx::B2DRectangle aDestRect;
     813             :                     ::canvas::tools::calcTransformedRectBounds( aDestRect,
     814             :                                                                 ::basegfx::B2DRectangle(0,
     815             :                                                                                         0,
     816           0 :                                                                                         aBmpSize.Width(),
     817           0 :                                                                                         aBmpSize.Height()),
     818           0 :                                                                 aMatrix );
     819             : 
     820           0 :                     aOutputPos.setX( aDestRect.getMinX() );
     821           0 :                     aOutputPos.setY( aDestRect.getMinY() );
     822             : 
     823             :                     // complex transformation, use generic affine bitmap
     824             :                     // transformation
     825           0 :                     aBmpEx = tools::transformBitmap( aBmpEx,
     826             :                                                      aMatrix,
     827             :                                                      renderState.DeviceColor,
     828           0 :                                                      tools::MODULATE_NONE );
     829             : 
     830           0 :                     pGrfObj.reset( new GraphicObject( aBmpEx ) );
     831             : 
     832             :                     // clear scale values, generated bitmap already
     833             :                     // contains scaling
     834           0 :                     aScale.setX( 1.0 ); aScale.setY( 1.0 );
     835             : 
     836             :                     // update bitmap size, bitmap has changed above.
     837           0 :                     aBmpSize = aBmpEx.GetSizePixel();
     838             :                 }
     839             : 
     840             :                 // output GraphicObject
     841           0 :                 const ::Point aPt( ::vcl::unotools::pointFromB2DPoint( aOutputPos ) );
     842           0 :                 const ::Size  aSz( ::basegfx::fround( aScale.getX() * aBmpSize.Width() ),
     843           0 :                                    ::basegfx::fround( aScale.getY() * aBmpSize.Height() ) );
     844             : 
     845           0 :                 pGrfObj->Draw( &mpOutDev->getOutDev(),
     846             :                                aPt,
     847             :                                aSz,
     848           0 :                                &aGrfAttr );
     849             : 
     850           0 :                 if( mp2ndOutDev )
     851           0 :                     pGrfObj->Draw( &mp2ndOutDev->getOutDev(),
     852             :                                    aPt,
     853             :                                    aSz,
     854           0 :                                    &aGrfAttr );
     855             : 
     856             :                 // created GraphicObject, which possibly cached
     857             :                 // display bitmap - return cache object, to retain
     858             :                 // that information.
     859             :                 return uno::Reference< rendering::XCachedPrimitive >(
     860             :                     new CachedBitmap( pGrfObj,
     861             :                                       aPt,
     862             :                                       aSz,
     863             :                                       aGrfAttr,
     864             :                                       viewState,
     865             :                                       renderState,
     866             :                                       // cast away const, need to
     867             :                                       // change refcount (as this is
     868             :                                       // ~invisible to client code,
     869             :                                       // still logically const)
     870           0 :                                       const_cast< rendering::XCanvas* >(pCanvas)) );
     871           0 :             }
     872             :         }
     873             : 
     874             :         // Nothing rendered
     875           0 :         return uno::Reference< rendering::XCachedPrimitive >(NULL);
     876             :     }
     877             : 
     878           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmap( const rendering::XCanvas*                   pCanvas,
     879             :                                                                             const uno::Reference< rendering::XBitmap >& xBitmap,
     880             :                                                                             const rendering::ViewState&                 viewState,
     881             :                                                                             const rendering::RenderState&               renderState )
     882             :     {
     883             :         return implDrawBitmap( pCanvas,
     884             :                                xBitmap,
     885             :                                viewState,
     886             :                                renderState,
     887           0 :                                false );
     888             :     }
     889             : 
     890           0 :     uno::Reference< rendering::XCachedPrimitive > CanvasHelper::drawBitmapModulated( const rendering::XCanvas*                      pCanvas,
     891             :                                                                                      const uno::Reference< rendering::XBitmap >&    xBitmap,
     892             :                                                                                      const rendering::ViewState&                    viewState,
     893             :                                                                                      const rendering::RenderState&                  renderState )
     894             :     {
     895             :         return implDrawBitmap( pCanvas,
     896             :                                xBitmap,
     897             :                                viewState,
     898             :                                renderState,
     899           0 :                                true );
     900             :     }
     901             : 
     902           0 :     void CanvasHelper::copyRect( const rendering::XCanvas*                          ,
     903             :                                  const uno::Reference< rendering::XBitmapCanvas >&  ,
     904             :                                  const geometry::RealRectangle2D&                   ,
     905             :                                  const rendering::ViewState&                        ,
     906             :                                  const rendering::RenderState&                      ,
     907             :                                  const geometry::RealRectangle2D&                   ,
     908             :                                  const rendering::ViewState&                        ,
     909             :                                  const rendering::RenderState&                       )
     910             :     {
     911             :         // TODO(F1)
     912           0 :     }
     913             : 
     914           0 :     geometry::IntegerSize2D CanvasHelper::getSize()
     915             :     {
     916           0 :         if( !mpOutDev.get() )
     917           0 :             return geometry::IntegerSize2D(); // we're disposed
     918             : 
     919           0 :         return ::vcl::unotools::integerSize2DFromSize( mpOutDev->getOutDev().GetOutputSizePixel() );
     920             :     }
     921             : 
     922           0 :     uno::Reference< rendering::XBitmap > CanvasHelper::getScaledBitmap( const geometry::RealSize2D& newSize,
     923             :                                                                         bool                        beFast )
     924             :     {
     925           0 :         if( !mpOutDev.get() || !mpDevice )
     926           0 :             return uno::Reference< rendering::XBitmap >(); // we're disposed
     927             : 
     928           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
     929             : 
     930           0 :         tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     931           0 :         rOutDev.EnableMapMode( false );
     932           0 :         rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
     933             : 
     934             :         // TODO(F2): Support alpha vdev canvas here
     935           0 :         const Point aEmptyPoint(0,0);
     936           0 :         const Size  aBmpSize( rOutDev.GetOutputSizePixel() );
     937             : 
     938           0 :         Bitmap aBitmap( rOutDev.GetBitmap(aEmptyPoint, aBmpSize) );
     939             : 
     940             :         aBitmap.Scale( ::vcl::unotools::sizeFromRealSize2D(newSize),
     941           0 :                        beFast ? BMP_SCALE_DEFAULT : BMP_SCALE_BESTQUALITY );
     942             : 
     943             :         return uno::Reference< rendering::XBitmap >(
     944           0 :             new CanvasBitmap( aBitmap, *mpDevice, mpOutDev ) );
     945             :     }
     946             : 
     947           0 :     uno::Sequence< sal_Int8 > CanvasHelper::getData( rendering::IntegerBitmapLayout&     rLayout,
     948             :                                                      const geometry::IntegerRectangle2D& rect )
     949             :     {
     950           0 :         if( !mpOutDev.get() )
     951           0 :             return uno::Sequence< sal_Int8 >(); // we're disposed
     952             : 
     953           0 :         rLayout = getMemoryLayout();
     954             : 
     955             :         // TODO(F2): Support alpha canvas here
     956           0 :         const Rectangle aRect( ::vcl::unotools::rectangleFromIntegerRectangle2D(rect) );
     957             : 
     958           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
     959             : 
     960           0 :         tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
     961           0 :         rOutDev.EnableMapMode( false );
     962           0 :         rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
     963             : 
     964             :         Bitmap aBitmap( rOutDev.GetBitmap(aRect.TopLeft(),
     965           0 :                                           aRect.GetSize()) );
     966             : 
     967           0 :         Bitmap::ScopedReadAccess pReadAccess( aBitmap );
     968             : 
     969           0 :         ENSURE_OR_THROW( pReadAccess.get() != NULL,
     970             :                          "Could not acquire read access to OutDev bitmap" );
     971             : 
     972           0 :         const sal_Int32 nWidth( rect.X2 - rect.X1 );
     973           0 :         const sal_Int32 nHeight( rect.Y2 - rect.Y1 );
     974             : 
     975           0 :         rLayout.ScanLines = nHeight;
     976           0 :         rLayout.ScanLineBytes = nWidth*4;
     977           0 :         rLayout.ScanLineStride = rLayout.ScanLineBytes;
     978             : 
     979           0 :         uno::Sequence< sal_Int8 > aRes( 4*nWidth*nHeight );
     980           0 :         sal_Int8* pRes = aRes.getArray();
     981             : 
     982           0 :         int nCurrPos(0);
     983           0 :         for( int y=0; y<nHeight; ++y )
     984             :         {
     985           0 :             for( int x=0; x<nWidth; ++x )
     986             :             {
     987           0 :                 pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetRed();
     988           0 :                 pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetGreen();
     989           0 :                 pRes[ nCurrPos++ ] = pReadAccess->GetColor( y, x ).GetBlue();
     990           0 :                 pRes[ nCurrPos++ ] = -1;
     991             :             }
     992             :         }
     993             : 
     994           0 :         return aRes;
     995             :     }
     996             : 
     997           0 :     void CanvasHelper::setData( const uno::Sequence< sal_Int8 >&        data,
     998             :                                 const rendering::IntegerBitmapLayout&   aLayout,
     999             :                                 const geometry::IntegerRectangle2D&     rect )
    1000             :     {
    1001           0 :         if( !mpOutDev.get() )
    1002           0 :             return; // we're disposed
    1003             : 
    1004           0 :         const rendering::IntegerBitmapLayout aRefLayout( getMemoryLayout() );
    1005           0 :         ENSURE_ARG_OR_THROW( aRefLayout.PlaneStride != aLayout.PlaneStride ||
    1006             :                              aRefLayout.ColorSpace  != aLayout.ColorSpace ||
    1007             :                              aRefLayout.Palette     != aLayout.Palette ||
    1008             :                              aRefLayout.IsMsbFirst  != aLayout.IsMsbFirst,
    1009             :                              "Mismatching memory layout" );
    1010             : 
    1011           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
    1012             : 
    1013           0 :         tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
    1014           0 :         rOutDev.EnableMapMode( false );
    1015           0 :         rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
    1016             : 
    1017           0 :         const Rectangle aRect( ::vcl::unotools::rectangleFromIntegerRectangle2D(rect) );
    1018             :         const sal_uInt16    nBitCount( ::std::min( (sal_uInt16)24U,
    1019           0 :                                                (sal_uInt16)rOutDev.GetBitCount() ) );
    1020           0 :         const BitmapPalette* pPalette = NULL;
    1021             : 
    1022           0 :         if( nBitCount <= 8 )
    1023             :         {
    1024             :             // TODO(Q1): Extract this to a common place, e.g. GraphicDevice
    1025             : 
    1026             :             // try to determine palette from output device (by
    1027             :             // extracting a 1,1 bitmap, and querying it)
    1028           0 :             const Point aEmptyPoint;
    1029           0 :             const Size  aSize(1,1);
    1030             :             Bitmap aTmpBitmap( rOutDev.GetBitmap( aEmptyPoint,
    1031           0 :                                                   aSize ) );
    1032             : 
    1033           0 :             Bitmap::ScopedReadAccess pReadAccess( aTmpBitmap );
    1034             : 
    1035           0 :             pPalette = &pReadAccess->GetPalette();
    1036             :         }
    1037             : 
    1038             :         // TODO(F2): Support alpha canvas here
    1039           0 :         Bitmap aBitmap( aRect.GetSize(), nBitCount, pPalette );
    1040             : 
    1041           0 :         bool bCopyBack( false ); // only copy something back, if we
    1042             :                                  // actually changed some pixel
    1043             :         {
    1044           0 :             Bitmap::ScopedWriteAccess pWriteAccess( aBitmap );
    1045             : 
    1046           0 :             ENSURE_OR_THROW( pWriteAccess.get() != NULL,
    1047             :                              "Could not acquire write access to OutDev bitmap" );
    1048             : 
    1049             :             // for the time being, always read as RGB
    1050           0 :             const sal_Int32 nWidth( rect.X2 - rect.X1 );
    1051           0 :             const sal_Int32 nHeight( rect.Y2 - rect.Y1 );
    1052           0 :             int x, y, nCurrPos(0);
    1053           0 :             for( y=0; y<nHeight; ++y )
    1054             :             {
    1055           0 :                 switch( pWriteAccess->GetScanlineFormat() )
    1056             :                 {
    1057             :                     case BMP_FORMAT_8BIT_PAL:
    1058             :                     {
    1059           0 :                         Scanline pScan = pWriteAccess->GetScanline( y );
    1060             : 
    1061           0 :                         for( x=0; x<nWidth; ++x )
    1062             :                         {
    1063           0 :                             *pScan++ = (sal_uInt8)pWriteAccess->GetBestPaletteIndex(
    1064           0 :                                 BitmapColor( data[ nCurrPos ],
    1065           0 :                                              data[ nCurrPos+1 ],
    1066           0 :                                              data[ nCurrPos+2 ] ) );
    1067             : 
    1068           0 :                             nCurrPos += 4;
    1069             :                         }
    1070             :                     }
    1071           0 :                     break;
    1072             : 
    1073             :                     case BMP_FORMAT_24BIT_TC_BGR:
    1074             :                     {
    1075           0 :                         Scanline pScan = pWriteAccess->GetScanline( y );
    1076             : 
    1077           0 :                         for( x=0; x<nWidth; ++x )
    1078             :                         {
    1079           0 :                             *pScan++ = data[ nCurrPos+2 ];
    1080           0 :                             *pScan++ = data[ nCurrPos+1 ];
    1081           0 :                             *pScan++ = data[ nCurrPos   ];
    1082             : 
    1083           0 :                             nCurrPos += 4;
    1084             :                         }
    1085             :                     }
    1086           0 :                     break;
    1087             : 
    1088             :                     case BMP_FORMAT_24BIT_TC_RGB:
    1089             :                     {
    1090           0 :                         Scanline pScan = pWriteAccess->GetScanline( y );
    1091             : 
    1092           0 :                         for( x=0; x<nWidth; ++x )
    1093             :                         {
    1094           0 :                             *pScan++ = data[ nCurrPos   ];
    1095           0 :                             *pScan++ = data[ nCurrPos+1 ];
    1096           0 :                             *pScan++ = data[ nCurrPos+2 ];
    1097             : 
    1098           0 :                             nCurrPos += 4;
    1099             :                         }
    1100             :                     }
    1101           0 :                     break;
    1102             : 
    1103             :                     default:
    1104             :                     {
    1105           0 :                         for( x=0; x<nWidth; ++x )
    1106             :                         {
    1107           0 :                             pWriteAccess->SetPixel( y, x, BitmapColor( data[ nCurrPos   ],
    1108           0 :                                                                        data[ nCurrPos+1 ],
    1109           0 :                                                                        data[ nCurrPos+2 ] ) );
    1110           0 :                             nCurrPos += 4;
    1111             :                         }
    1112             :                     }
    1113           0 :                     break;
    1114             :                 }
    1115             :             }
    1116             : 
    1117           0 :             bCopyBack = true;
    1118             :         }
    1119             : 
    1120             :         // copy back only here, since the BitmapAccessors must be
    1121             :         // destroyed beforehand
    1122           0 :         if( bCopyBack )
    1123             :         {
    1124             :             // TODO(F2): Support alpha canvas here
    1125           0 :             rOutDev.DrawBitmap(aRect.TopLeft(), aBitmap);
    1126           0 :         }
    1127             :     }
    1128             : 
    1129           0 :     void CanvasHelper::setPixel( const uno::Sequence< sal_Int8 >&       color,
    1130             :                                  const rendering::IntegerBitmapLayout&  rLayout,
    1131             :                                  const geometry::IntegerPoint2D&        pos )
    1132             :     {
    1133           0 :         if( !mpOutDev.get() )
    1134           0 :             return; // we're disposed
    1135             : 
    1136           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
    1137             : 
    1138           0 :         tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
    1139           0 :         rOutDev.EnableMapMode( false );
    1140           0 :         rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
    1141             : 
    1142           0 :         const Size aBmpSize( rOutDev.GetOutputSizePixel() );
    1143             : 
    1144           0 :         ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
    1145             :                              "X coordinate out of bounds" );
    1146           0 :         ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
    1147             :                              "Y coordinate out of bounds" );
    1148           0 :         ENSURE_ARG_OR_THROW( color.getLength() > 3,
    1149             :                              "not enough color components" );
    1150             : 
    1151           0 :         const rendering::IntegerBitmapLayout aRefLayout( getMemoryLayout() );
    1152           0 :         ENSURE_ARG_OR_THROW( aRefLayout.PlaneStride != rLayout.PlaneStride ||
    1153             :                              aRefLayout.ColorSpace  != rLayout.ColorSpace ||
    1154             :                              aRefLayout.Palette     != rLayout.Palette ||
    1155             :                              aRefLayout.IsMsbFirst  != rLayout.IsMsbFirst,
    1156             :                              "Mismatching memory layout" );
    1157             : 
    1158             :         // TODO(F2): Support alpha canvas here
    1159             :         rOutDev.DrawPixel( ::vcl::unotools::pointFromIntegerPoint2D( pos ),
    1160           0 :                            ::canvas::tools::stdIntSequenceToColor( color ));
    1161             :     }
    1162             : 
    1163           0 :     uno::Sequence< sal_Int8 > CanvasHelper::getPixel( rendering::IntegerBitmapLayout& rLayout,
    1164             :                                                       const geometry::IntegerPoint2D& pos )
    1165             :     {
    1166           0 :         if( !mpOutDev.get() )
    1167           0 :             return uno::Sequence< sal_Int8 >(); // we're disposed
    1168             : 
    1169           0 :         rLayout = getMemoryLayout();
    1170           0 :         rLayout.ScanLines = 1;
    1171           0 :         rLayout.ScanLineBytes = 4;
    1172           0 :         rLayout.ScanLineStride = rLayout.ScanLineBytes;
    1173             : 
    1174           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
    1175             : 
    1176           0 :         tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
    1177           0 :         rOutDev.EnableMapMode( false );
    1178           0 :         rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
    1179             : 
    1180           0 :         const Size aBmpSize( rOutDev.GetOutputSizePixel() );
    1181             : 
    1182           0 :         ENSURE_ARG_OR_THROW( pos.X >= 0 && pos.X < aBmpSize.Width(),
    1183             :                              "X coordinate out of bounds" );
    1184           0 :         ENSURE_ARG_OR_THROW( pos.Y >= 0 && pos.Y < aBmpSize.Height(),
    1185             :                              "Y coordinate out of bounds" );
    1186             : 
    1187             :         // TODO(F2): Support alpha canvas here
    1188             :         return ::canvas::tools::colorToStdIntSequence(
    1189             :             rOutDev.GetPixel(
    1190           0 :                 ::vcl::unotools::pointFromIntegerPoint2D( pos )));
    1191             :     }
    1192             : 
    1193           0 :     rendering::IntegerBitmapLayout CanvasHelper::getMemoryLayout()
    1194             :     {
    1195           0 :         if( !mpOutDev.get() )
    1196           0 :             return rendering::IntegerBitmapLayout(); // we're disposed
    1197             : 
    1198           0 :         rendering::IntegerBitmapLayout xBitmapLayout( ::canvas::tools::getStdMemoryLayout(getSize()) );
    1199           0 :         if ( !mbHaveAlpha )
    1200           0 :             xBitmapLayout.ColorSpace = canvas::tools::getStdColorSpaceWithoutAlpha();
    1201             : 
    1202           0 :         return xBitmapLayout;
    1203             :     }
    1204             : 
    1205           0 :     int CanvasHelper::setupOutDevState( const rendering::ViewState&     viewState,
    1206             :                                         const rendering::RenderState&   renderState,
    1207             :                                         ColorType                       eColorType ) const
    1208             :     {
    1209           0 :         ENSURE_OR_THROW( mpOutDev.get(),
    1210             :                          "outdev null. Are we disposed?" );
    1211             : 
    1212             :         ::canvas::tools::verifyInput( renderState,
    1213             :                                       BOOST_CURRENT_FUNCTION,
    1214             :                                       mpDevice,
    1215             :                                       2,
    1216           0 :                                       eColorType == IGNORE_COLOR ? 0 : 3 );
    1217             : 
    1218           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
    1219           0 :         OutputDevice* p2ndOutDev = NULL;
    1220             : 
    1221           0 :         rOutDev.EnableMapMode( false );
    1222           0 :         rOutDev.SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW );
    1223             : 
    1224           0 :         if( mp2ndOutDev )
    1225           0 :             p2ndOutDev = &mp2ndOutDev->getOutDev();
    1226             : 
    1227           0 :         int nTransparency(0);
    1228             : 
    1229             :         // TODO(P2): Don't change clipping all the time, maintain current clip
    1230             :         // state and change only when update is necessary
    1231             : 
    1232             :         // accumulate non-empty clips into one region
    1233             :         // ==========================================
    1234             : 
    1235           0 :         vcl::Region aClipRegion(true);
    1236             : 
    1237           0 :         if( viewState.Clip.is() )
    1238             :         {
    1239             :             ::basegfx::B2DPolyPolygon aClipPoly(
    1240           0 :                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(viewState.Clip) );
    1241             : 
    1242           0 :             if( aClipPoly.count() )
    1243             :             {
    1244             :                 // setup non-empty clipping
    1245           0 :                 ::basegfx::B2DHomMatrix aMatrix;
    1246             :                 aClipPoly.transform(
    1247             :                     ::basegfx::unotools::homMatrixFromAffineMatrix( aMatrix,
    1248           0 :                                                                     viewState.AffineTransform ) );
    1249             : 
    1250           0 :                 aClipRegion = vcl::Region::GetRegionFromPolyPolygon( ::tools::PolyPolygon( aClipPoly ) );
    1251             :             }
    1252             :             else
    1253             :             {
    1254             :                 // clip polygon is empty
    1255           0 :                 aClipRegion.SetEmpty();
    1256           0 :             }
    1257             :         }
    1258             : 
    1259           0 :         if( renderState.Clip.is() )
    1260             :         {
    1261             :             ::basegfx::B2DPolyPolygon aClipPoly(
    1262           0 :                 ::basegfx::unotools::b2DPolyPolygonFromXPolyPolygon2D(renderState.Clip) );
    1263             : 
    1264           0 :             ::basegfx::B2DHomMatrix aMatrix;
    1265             :             aClipPoly.transform(
    1266             :                 ::canvas::tools::mergeViewAndRenderTransform( aMatrix,
    1267             :                                                               viewState,
    1268           0 :                                                               renderState ) );
    1269             : 
    1270           0 :             if( aClipPoly.count() )
    1271             :             {
    1272             :                 // setup non-empty clipping
    1273           0 :                 vcl::Region aRegion = vcl::Region::GetRegionFromPolyPolygon( ::tools::PolyPolygon( aClipPoly ) );
    1274           0 :                 aClipRegion.Intersect( aRegion );
    1275             :             }
    1276             :             else
    1277             :             {
    1278             :                 // clip polygon is empty
    1279           0 :                 aClipRegion.SetEmpty();
    1280           0 :             }
    1281             :         }
    1282             : 
    1283             :         // setup accumulated clip region. Note that setting an
    1284             :         // empty clip region denotes "clip everything" on the
    1285             :         // OutputDevice (which is why we translate that into
    1286             :         // SetClipRegion() here). When both view and render clip
    1287             :         // are empty, aClipRegion remains default-constructed,
    1288             :         // i.e. empty, too.
    1289           0 :         if( aClipRegion.IsNull() )
    1290             :         {
    1291           0 :             rOutDev.SetClipRegion();
    1292             : 
    1293           0 :             if( p2ndOutDev )
    1294           0 :                 p2ndOutDev->SetClipRegion();
    1295             :         }
    1296             :         else
    1297             :         {
    1298           0 :             rOutDev.SetClipRegion( aClipRegion );
    1299             : 
    1300           0 :             if( p2ndOutDev )
    1301           0 :                 p2ndOutDev->SetClipRegion( aClipRegion );
    1302             :         }
    1303             : 
    1304           0 :         Color aColor( COL_WHITE );
    1305             : 
    1306           0 :         if( renderState.DeviceColor.getLength() > 2 )
    1307             :         {
    1308             :             aColor = ::vcl::unotools::stdColorSpaceSequenceToColor(
    1309           0 :                 renderState.DeviceColor );
    1310             :         }
    1311             : 
    1312             :         // extract alpha, and make color opaque
    1313             :         // afterwards. Otherwise, OutputDevice won't draw anything
    1314           0 :         nTransparency = aColor.GetTransparency();
    1315           0 :         aColor.SetTransparency(0);
    1316             : 
    1317           0 :         if( eColorType != IGNORE_COLOR )
    1318             :         {
    1319           0 :             switch( eColorType )
    1320             :             {
    1321             :                 case LINE_COLOR:
    1322           0 :                     rOutDev.SetLineColor( aColor );
    1323           0 :                     rOutDev.SetFillColor();
    1324             : 
    1325           0 :                     if( p2ndOutDev )
    1326             :                     {
    1327           0 :                         p2ndOutDev->SetLineColor( aColor );
    1328           0 :                         p2ndOutDev->SetFillColor();
    1329             :                     }
    1330           0 :                     break;
    1331             : 
    1332             :                 case FILL_COLOR:
    1333           0 :                     rOutDev.SetFillColor( aColor );
    1334           0 :                     rOutDev.SetLineColor();
    1335             : 
    1336           0 :                     if( p2ndOutDev )
    1337             :                     {
    1338           0 :                         p2ndOutDev->SetFillColor( aColor );
    1339           0 :                         p2ndOutDev->SetLineColor();
    1340             :                     }
    1341           0 :                     break;
    1342             : 
    1343             :                 case TEXT_COLOR:
    1344           0 :                     rOutDev.SetTextColor( aColor );
    1345             : 
    1346           0 :                     if( p2ndOutDev )
    1347           0 :                         p2ndOutDev->SetTextColor( aColor );
    1348           0 :                     break;
    1349             : 
    1350             :                 default:
    1351           0 :                     ENSURE_OR_THROW( false,
    1352             :                                      "Unexpected color type");
    1353             :                     break;
    1354             :             }
    1355             :         }
    1356             : 
    1357           0 :         return nTransparency;
    1358             :     }
    1359             : 
    1360           0 :     bool CanvasHelper::setupTextOutput( ::Point&                                        o_rOutPos,
    1361             :                                         const rendering::ViewState&                     viewState,
    1362             :                                         const rendering::RenderState&                   renderState,
    1363             :                                         const uno::Reference< rendering::XCanvasFont >& xFont   ) const
    1364             :     {
    1365           0 :         ENSURE_OR_THROW( mpOutDev.get(),
    1366             :                          "outdev null. Are we disposed?" );
    1367             : 
    1368           0 :         setupOutDevState( viewState, renderState, TEXT_COLOR );
    1369             : 
    1370           0 :         OutputDevice& rOutDev( mpOutDev->getOutDev() );
    1371             : 
    1372           0 :         vcl::Font aVCLFont;
    1373             : 
    1374           0 :         CanvasFont* pFont = dynamic_cast< CanvasFont* >( xFont.get() );
    1375             : 
    1376           0 :         ENSURE_ARG_OR_THROW( pFont,
    1377             :                              "Font not compatible with this canvas" );
    1378             : 
    1379           0 :         aVCLFont = pFont->getVCLFont();
    1380             : 
    1381           0 :         Color aColor( COL_BLACK );
    1382             : 
    1383           0 :         if( renderState.DeviceColor.getLength() > 2 )
    1384             :         {
    1385             :             aColor = ::vcl::unotools::stdColorSpaceSequenceToColor(
    1386           0 :                 renderState.DeviceColor );
    1387             :         }
    1388             : 
    1389             :         // setup font color
    1390           0 :         aVCLFont.SetColor( aColor );
    1391           0 :         aVCLFont.SetFillColor( aColor );
    1392             : 
    1393             :         // no need to replicate this for mp2ndOutDev, we're modifying only aVCLFont here.
    1394           0 :         if( !tools::setupFontTransform( o_rOutPos, aVCLFont, viewState, renderState, rOutDev ) )
    1395           0 :             return false;
    1396             : 
    1397           0 :         rOutDev.SetFont( aVCLFont );
    1398             : 
    1399           0 :         if( mp2ndOutDev )
    1400           0 :             mp2ndOutDev->getOutDev().SetFont( aVCLFont );
    1401             : 
    1402           0 :         return true;
    1403             :     }
    1404             : 
    1405           0 :     bool CanvasHelper::repaint( const GraphicObjectSharedPtr&   rGrf,
    1406             :                                 const rendering::ViewState&     viewState,
    1407             :                                 const rendering::RenderState&   renderState,
    1408             :                                 const ::Point&                  rPt,
    1409             :                                 const ::Size&                   rSz,
    1410             :                                 const GraphicAttr&              rAttr ) const
    1411             :     {
    1412           0 :         ENSURE_OR_RETURN_FALSE( rGrf,
    1413             :                           "Invalid Graphic" );
    1414             : 
    1415           0 :         if( !mpOutDev )
    1416           0 :             return false; // disposed
    1417             :         else
    1418             :         {
    1419           0 :             tools::OutDevStateKeeper aStateKeeper( mpProtectedOutDev );
    1420           0 :             setupOutDevState( viewState, renderState, IGNORE_COLOR );
    1421             : 
    1422           0 :             if( !rGrf->Draw( &mpOutDev->getOutDev(), rPt, rSz, &rAttr ) )
    1423           0 :                 return false;
    1424             : 
    1425             :             // #i80779# Redraw also into mask outdev
    1426           0 :             if( mp2ndOutDev )
    1427           0 :                 return rGrf->Draw( &mp2ndOutDev->getOutDev(), rPt, rSz, &rAttr );
    1428             : 
    1429           0 :             return true;
    1430             :         }
    1431             :     }
    1432             : 
    1433           0 :     void CanvasHelper::flush() const
    1434             :     {
    1435           0 :         if( mpOutDev && mpOutDev->getOutDev().GetOutDevType() == OUTDEV_WINDOW )
    1436             :         {
    1437             :             // TODO(Q3): Evil downcast. And what's more, Window::Flush is
    1438             :             // not even const. Wah.
    1439           0 :             static_cast<vcl::Window&>(mpOutDev->getOutDev()).Flush();
    1440             :         }
    1441             : 
    1442           0 :         if( mp2ndOutDev && mp2ndOutDev->getOutDev().GetOutDevType() == OUTDEV_WINDOW )
    1443             :         {
    1444             :             // TODO(Q3): Evil downcast. And what's more, Window::Flush is
    1445             :             // not even const. Wah.
    1446           0 :             static_cast<vcl::Window&>(mp2ndOutDev->getOutDev()).Flush();
    1447             :         }
    1448           0 :     }
    1449             : 
    1450           0 : }
    1451             : 
    1452             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10