LCOV - code coverage report
Current view: top level - libreoffice/vcl/source/gdi - salgdilayout.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 83 373 22.3 %
Date: 2012-12-27 Functions: 22 42 52.4 %
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 <tools/debug.hxx>
      21             : #include <tools/poly.hxx>
      22             : 
      23             : #include <vcl/svapp.hxx>
      24             : #include <vcl/region.hxx>
      25             : #include <vcl/virdev.hxx>
      26             : #include <vcl/window.hxx>
      27             : #include <vcl/metaact.hxx>
      28             : #include <vcl/gdimtf.hxx>
      29             : #include <vcl/print.hxx>
      30             : #include <vcl/outdev.hxx>
      31             : #include <vcl/unowrap.hxx>
      32             : 
      33             : #include <window.h>
      34             : #include <region.h>
      35             : #include <outdev.h>
      36             : #include <sallayout.hxx>
      37             : #include <salgdi.hxx>
      38             : #include <salframe.hxx>
      39             : #include <salvd.hxx>
      40             : #include <salprn.hxx>
      41             : #include <svdata.hxx>
      42             : #include <outdata.hxx>
      43             : 
      44             : #include <boost/scoped_ptr.hpp>
      45             : 
      46             : #include "basegfx/polygon/b2dpolygon.hxx"
      47             : 
      48             : // ----------------------------------------------------------------------------
      49             : // The only common SalFrame method
      50             : // ----------------------------------------------------------------------------
      51             : 
      52        5825 : SalFrameGeometry SalFrame::GetGeometry()
      53             : {
      54             :     // mirror frame coordinates at parent
      55        5825 :     SalFrame *pParent = GetParent();
      56        5825 :     if( pParent && Application::GetSettings().GetLayoutRTL() )
      57             :     {
      58           0 :         SalFrameGeometry aGeom = maGeometry;
      59           0 :         int parent_x = aGeom.nX - pParent->maGeometry.nX;
      60           0 :         aGeom.nX = pParent->maGeometry.nX + pParent->maGeometry.nWidth - maGeometry.nWidth - parent_x;
      61           0 :         return aGeom;
      62             :     }
      63             :     else
      64        5825 :         return maGeometry;
      65             : }
      66             : 
      67             : // ----------------------------------------------------------------------------
      68             : 
      69       16560 : SalGraphics::SalGraphics()
      70             : :   m_nLayout( 0 ),
      71       16560 :     m_bAntiAliasB2DDraw(false)
      72             : {
      73             :     // read global RTL settings
      74       16560 :     if( Application::GetSettings().GetLayoutRTL() )
      75           0 :         m_nLayout = SAL_LAYOUT_BIDI_RTL;
      76       16560 : }
      77             : 
      78        8840 : SalGraphics::~SalGraphics()
      79             : {
      80        8840 : }
      81             : 
      82             : // ----------------------------------------------------------------------------
      83             : 
      84           0 : void SalGraphics::mirror( long& x, const OutputDevice *pOutDev, bool bBack ) const
      85             : {
      86             :     long w;
      87           0 :     if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
      88           0 :         w = pOutDev->GetOutputWidthPixel();
      89             :     else
      90           0 :         w = GetGraphicsWidth();
      91             : 
      92           0 :     if( w )
      93             :     {
      94           0 :         if( pOutDev && pOutDev->ImplIsAntiparallel() )
      95             :         {
      96           0 :             OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
      97             :             // mirror this window back
      98           0 :             if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
      99             :             {
     100           0 :                 long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     101           0 :                 if( bBack )
     102           0 :                     x = x - devX + pOutDevRef->GetOutOffXPixel();
     103             :                 else
     104           0 :                     x = devX + (x - pOutDevRef->GetOutOffXPixel());
     105             :             }
     106             :             else
     107             :             {
     108           0 :                 long devX = pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     109           0 :                 if( bBack )
     110           0 :                     x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
     111             :                 else
     112           0 :                     x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - 1;
     113             :             }
     114             :         }
     115           0 :         else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
     116           0 :             x = w-1-x;
     117             :     }
     118           0 : }
     119             : 
     120           0 : void SalGraphics::mirror( long& x, long& nWidth, const OutputDevice *pOutDev, bool bBack ) const
     121             : {
     122             :     long w;
     123           0 :     if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
     124           0 :         w = pOutDev->GetOutputWidthPixel();
     125             :     else
     126           0 :         w = GetGraphicsWidth();
     127             : 
     128           0 :     if( w )
     129             :     {
     130           0 :         if( pOutDev && pOutDev->ImplIsAntiparallel() )
     131             :         {
     132           0 :             OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
     133             :             // mirror this window back
     134           0 :             if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
     135             :             {
     136           0 :                 long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     137           0 :                 if( bBack )
     138           0 :                     x = x - devX + pOutDevRef->GetOutOffXPixel();
     139             :                 else
     140           0 :                     x = devX + (x - pOutDevRef->GetOutOffXPixel());
     141             :             }
     142             :             else
     143             :             {
     144           0 :                 long devX = pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     145           0 :                 if( bBack )
     146           0 :                     x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + nWidth;
     147             :                 else
     148           0 :                     x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - nWidth;
     149             :             }
     150             :         }
     151           0 :         else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
     152           0 :             x = w-nWidth-x;
     153             : 
     154             :     }
     155           0 : }
     156             : 
     157           0 : sal_Bool SalGraphics::mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint *pPtAry2, const OutputDevice *pOutDev, bool bBack ) const
     158             : {
     159             :     long w;
     160           0 :     if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
     161           0 :         w = pOutDev->GetOutputWidthPixel();
     162             :     else
     163           0 :         w = GetGraphicsWidth();
     164             : 
     165           0 :     if( w )
     166             :     {
     167             :         sal_uInt32 i, j;
     168             : 
     169           0 :         if( pOutDev && pOutDev->ImplIsAntiparallel() )
     170             :         {
     171           0 :             OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
     172             :             // mirror this window back
     173           0 :             if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
     174             :             {
     175           0 :                 long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     176           0 :                 if( bBack )
     177             :                 {
     178           0 :                     for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
     179             :                     {
     180             :                         //long x = w-1-pPtAry[i].mnX;
     181             :                         //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
     182           0 :                         pPtAry2[j].mnX = pOutDevRef->GetOutOffXPixel() + (pPtAry[i].mnX - devX);
     183           0 :                         pPtAry2[j].mnY = pPtAry[i].mnY;
     184             :                     }
     185             :                 }
     186             :                 else
     187             :                 {
     188           0 :                     for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
     189             :                     {
     190             :                         //long x = w-1-pPtAry[i].mnX;
     191             :                         //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
     192           0 :                         pPtAry2[j].mnX = devX + (pPtAry[i].mnX - pOutDevRef->GetOutOffXPixel());
     193           0 :                         pPtAry2[j].mnY = pPtAry[i].mnY;
     194             :                     }
     195             :                 }
     196             :             }
     197             :             else
     198             :             {
     199           0 :                 long devX = pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     200           0 :                 if( bBack )
     201             :                 {
     202           0 :                     for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
     203             :                     {
     204             :                         //long x = w-1-pPtAry[i].mnX;
     205             :                         //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
     206           0 :                         pPtAry2[j].mnX = pPtAry[i].mnX - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
     207           0 :                         pPtAry2[j].mnY = pPtAry[i].mnY;
     208             :                     }
     209             :                 }
     210             :                 else
     211             :                 {
     212           0 :                     for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
     213             :                     {
     214             :                         //long x = w-1-pPtAry[i].mnX;
     215             :                         //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
     216           0 :                         pPtAry2[j].mnX = pOutDevRef->GetOutputWidthPixel() - (pPtAry[i].mnX - devX) + pOutDevRef->GetOutOffXPixel() - 1;
     217           0 :                         pPtAry2[j].mnY = pPtAry[i].mnY;
     218             :                     }
     219             :                 }
     220             :             }
     221             :         }
     222           0 :         else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
     223             :         {
     224           0 :             for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
     225             :             {
     226           0 :                 pPtAry2[j].mnX = w-1-pPtAry[i].mnX;
     227           0 :                 pPtAry2[j].mnY = pPtAry[i].mnY;
     228             :             }
     229             :         }
     230           0 :         return sal_True;
     231             :     }
     232             :     else
     233           0 :         return sal_False;
     234             : }
     235             : 
     236           0 : void SalGraphics::mirror( Region& rRgn, const OutputDevice *pOutDev, bool bBack ) const
     237             : {
     238           0 :     if( rRgn.HasPolyPolygon() )
     239             :     {
     240           0 :         basegfx::B2DPolyPolygon aPolyPoly( rRgn.ConvertToB2DPolyPolygon() );
     241           0 :         aPolyPoly = mirror( aPolyPoly, pOutDev, bBack );
     242           0 :         rRgn = Region( aPolyPoly );
     243             :     }
     244             :     else
     245             :     {
     246             :         ImplRegionInfo      aInfo;
     247             :         bool                bRegionRect;
     248           0 :         Region              aMirroredRegion;
     249             :         long nX, nY, nWidth, nHeight;
     250             : 
     251           0 :         bRegionRect = rRgn.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
     252           0 :         while ( bRegionRect )
     253             :         {
     254           0 :             Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
     255           0 :             mirror( aRect, pOutDev, bBack );
     256           0 :             aMirroredRegion.Union( aRect );
     257           0 :             bRegionRect = rRgn.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
     258             :         }
     259           0 :         rRgn = aMirroredRegion;
     260             :     }
     261           0 : }
     262             : 
     263           0 : void SalGraphics::mirror( Rectangle& rRect, const OutputDevice *pOutDev, bool bBack ) const
     264             : {
     265           0 :     long nWidth = rRect.GetWidth();
     266           0 :     long x      = rRect.Left();
     267           0 :     long x_org = x;
     268             : 
     269           0 :     mirror( x, nWidth, pOutDev, bBack );
     270           0 :     rRect.Move( x - x_org, 0 );
     271           0 : }
     272             : 
     273           0 : basegfx::B2DPoint SalGraphics::mirror( const basegfx::B2DPoint& i_rPoint, const OutputDevice *i_pOutDev, bool i_bBack ) const
     274             : {
     275             :     long w;
     276           0 :     if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
     277           0 :         w = i_pOutDev->GetOutputWidthPixel();
     278             :     else
     279           0 :         w = GetGraphicsWidth();
     280             : 
     281             :     DBG_ASSERT( w, "missing graphics width" );
     282             : 
     283           0 :     basegfx::B2DPoint aRet( i_rPoint );
     284           0 :     if( w )
     285             :     {
     286           0 :         if( i_pOutDev && !i_pOutDev->IsRTLEnabled() )
     287             :         {
     288           0 :             OutputDevice *pOutDevRef = (OutputDevice*)i_pOutDev;
     289             :             // mirror this window back
     290           0 :             double devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel();   // re-mirrored mnOutOffX
     291           0 :             if( i_bBack )
     292           0 :                 aRet.setX( i_rPoint.getX() - devX + pOutDevRef->GetOutOffXPixel() );
     293             :             else
     294           0 :                 aRet.setX( devX + (i_rPoint.getX() - pOutDevRef->GetOutOffXPixel()) );
     295             :         }
     296             :         else
     297           0 :             aRet.setX( w-1-i_rPoint.getX() );
     298             :     }
     299           0 :     return aRet;
     300             : }
     301             : 
     302           0 : basegfx::B2DPolygon SalGraphics::mirror( const basegfx::B2DPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
     303             : {
     304             :     long w;
     305           0 :     if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
     306           0 :         w = i_pOutDev->GetOutputWidthPixel();
     307             :     else
     308           0 :         w = GetGraphicsWidth();
     309             : 
     310             :     DBG_ASSERT( w, "missing graphics width" );
     311             : 
     312           0 :     basegfx::B2DPolygon aRet;
     313           0 :     if( w )
     314             :     {
     315           0 :         sal_Int32 nPoints = i_rPoly.count();
     316           0 :         for( sal_Int32 i = 0; i < nPoints; i++ )
     317             :         {
     318           0 :             aRet.append( mirror( i_rPoly.getB2DPoint( i ), i_pOutDev, i_bBack ) );
     319           0 :             if( i_rPoly.isPrevControlPointUsed( i ) )
     320           0 :                 aRet.setPrevControlPoint( i, mirror( i_rPoly.getPrevControlPoint( i ), i_pOutDev, i_bBack ) );
     321           0 :             if( i_rPoly.isNextControlPointUsed( i ) )
     322           0 :                 aRet.setNextControlPoint( i, mirror( i_rPoly.getNextControlPoint( i ), i_pOutDev, i_bBack ) );
     323             :         }
     324           0 :         aRet.setClosed( i_rPoly.isClosed() );
     325           0 :         aRet.flip();
     326             :     }
     327             :     else
     328           0 :         aRet = i_rPoly;
     329           0 :     return aRet;
     330             : }
     331             : 
     332           0 : basegfx::B2DPolyPolygon SalGraphics::mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
     333             : {
     334             :     long w;
     335           0 :     if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
     336           0 :         w = i_pOutDev->GetOutputWidthPixel();
     337             :     else
     338           0 :         w = GetGraphicsWidth();
     339             : 
     340             :     DBG_ASSERT( w, "missing graphics width" );
     341             : 
     342           0 :     basegfx::B2DPolyPolygon aRet;
     343           0 :     if( w )
     344             :     {
     345           0 :         sal_Int32 nPoly = i_rPoly.count();
     346           0 :         for( sal_Int32 i = 0; i < nPoly; i++ )
     347           0 :             aRet.append( mirror( i_rPoly.getB2DPolygon( i ), i_pOutDev, i_bBack ) );
     348           0 :         aRet.setClosed( i_rPoly.isClosed() );
     349           0 :         aRet.flip();
     350             :     }
     351             :     else
     352           0 :         aRet = i_rPoly;
     353           0 :     return aRet;
     354             : }
     355             : 
     356             : // ----------------------------------------------------------------------------
     357             : 
     358        8851 : bool SalGraphics::SetClipRegion( const Region& i_rClip, const OutputDevice *pOutDev )
     359             : {
     360        8851 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     361             :     {
     362           0 :         Region aMirror( i_rClip );
     363           0 :         mirror( aMirror, pOutDev );
     364           0 :         return setClipRegion( aMirror );
     365             :     }
     366        8851 :     return setClipRegion( i_rClip );
     367             : }
     368             : 
     369        4241 : void    SalGraphics::DrawPixel( long nX, long nY, const OutputDevice *pOutDev )
     370             : {
     371        4241 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     372           0 :         mirror( nX, pOutDev );
     373        4241 :     drawPixel( nX, nY );
     374        4241 : }
     375       21105 : void    SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor, const OutputDevice *pOutDev )
     376             : {
     377       21105 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     378           0 :         mirror( nX, pOutDev );
     379       21105 :     drawPixel( nX, nY, nSalColor );
     380       21105 : }
     381      101150 : void    SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2, const OutputDevice *pOutDev )
     382             : {
     383      101150 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     384             :     {
     385           0 :         mirror( nX1, pOutDev );
     386           0 :         mirror( nX2, pOutDev );
     387             :     }
     388      101150 :     drawLine( nX1, nY1, nX2, nY2 );
     389      101150 : }
     390       30500 : void    SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
     391             : {
     392       30500 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     393           0 :         mirror( nX, nWidth, pOutDev );
     394       30500 :     drawRect( nX, nY, nWidth, nHeight );
     395       30500 : }
     396             : 
     397        2884 : void SalGraphics::DrawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
     398             : {
     399        2884 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     400             :     {
     401           0 :         SalPoint* pPtAry2 = new SalPoint[nPoints];
     402           0 :         sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
     403           0 :         drawPolyLine( nPoints, bCopied ? pPtAry2 : pPtAry );
     404           0 :         delete [] pPtAry2;
     405             :     }
     406             :     else
     407        2884 :         drawPolyLine( nPoints, pPtAry );
     408        2884 : }
     409             : 
     410       47265 : void SalGraphics::DrawPolygon( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
     411             : {
     412       47265 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     413             :     {
     414           0 :         SalPoint* pPtAry2 = new SalPoint[nPoints];
     415           0 :         sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
     416           0 :         drawPolygon( nPoints, bCopied ? pPtAry2 : pPtAry );
     417           0 :         delete [] pPtAry2;
     418             :     }
     419             :     else
     420       47265 :         drawPolygon( nPoints, pPtAry );
     421       47265 : }
     422             : 
     423           5 : void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry, const OutputDevice *pOutDev )
     424             : {
     425           5 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     426             :     {
     427             :         // TODO: optimize, reduce new/delete calls
     428           0 :         SalPoint **pPtAry2 = new SalPoint*[nPoly];
     429             :         sal_uLong i;
     430           0 :         for(i=0; i<nPoly; i++)
     431             :         {
     432           0 :             sal_uLong nPoints = pPoints[i];
     433           0 :             pPtAry2[i] = new SalPoint[ nPoints ];
     434           0 :             mirror( nPoints, pPtAry[i], pPtAry2[i], pOutDev );
     435             :         }
     436             : 
     437           0 :         drawPolyPolygon( nPoly, pPoints, (PCONSTSALPOINT*)pPtAry2 );
     438             : 
     439           0 :         for(i=0; i<nPoly; i++)
     440           0 :             delete [] pPtAry2[i];
     441           0 :         delete [] pPtAry2;
     442             :     }
     443             :     else
     444           5 :         drawPolyPolygon( nPoly, pPoints, pPtAry );
     445           5 : }
     446             : 
     447           0 : bool SalGraphics::DrawPolyPolygon( const ::basegfx::B2DPolyPolygon& i_rPolyPolygon, double i_fTransparency, const OutputDevice* i_pOutDev )
     448             : {
     449           0 :     bool bRet = false;
     450           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
     451             :     {
     452           0 :         basegfx::B2DPolyPolygon aMirror( mirror( i_rPolyPolygon, i_pOutDev ) );
     453           0 :         bRet = drawPolyPolygon( aMirror, i_fTransparency );
     454             :     }
     455             :     else
     456           0 :         bRet = drawPolyPolygon( i_rPolyPolygon, i_fTransparency );
     457           0 :     return bRet;
     458             : }
     459             : 
     460           0 : sal_Bool SalGraphics::DrawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev )
     461             : {
     462           0 :     sal_Bool bResult = sal_False;
     463           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     464             :     {
     465           0 :         SalPoint* pPtAry2 = new SalPoint[nPoints];
     466           0 :         sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
     467           0 :         bResult = drawPolyLineBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry );
     468           0 :         delete [] pPtAry2;
     469             :     }
     470             :     else
     471           0 :         bResult = drawPolyLineBezier( nPoints, pPtAry, pFlgAry );
     472           0 :     return bResult;
     473             : }
     474             : 
     475           6 : sal_Bool SalGraphics::DrawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev )
     476             : {
     477           6 :     sal_Bool bResult = sal_False;
     478           6 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     479             :     {
     480           0 :         SalPoint* pPtAry2 = new SalPoint[nPoints];
     481           0 :         sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
     482           0 :         bResult = drawPolygonBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry );
     483           0 :         delete [] pPtAry2;
     484             :     }
     485             :     else
     486           6 :         bResult = drawPolygonBezier( nPoints, pPtAry, pFlgAry );
     487           6 :     return bResult;
     488             : }
     489             : 
     490           5 : sal_Bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i_pPoints,
     491             :                                                    const SalPoint* const* i_pPtAry, const sal_uInt8* const* i_pFlgAry, const OutputDevice* i_pOutDev )
     492             : {
     493           5 :     sal_Bool bRet = sal_False;
     494           5 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
     495             :     {
     496             :         // TODO: optimize, reduce new/delete calls
     497           0 :         SalPoint **pPtAry2 = new SalPoint*[i_nPoly];
     498             :         sal_uLong i;
     499           0 :         for(i=0; i<i_nPoly; i++)
     500             :         {
     501           0 :             sal_uLong nPoints = i_pPoints[i];
     502           0 :             pPtAry2[i] = new SalPoint[ nPoints ];
     503           0 :             mirror( nPoints, i_pPtAry[i], pPtAry2[i], i_pOutDev );
     504             :         }
     505             : 
     506           0 :         bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, (PCONSTSALPOINT*)pPtAry2, i_pFlgAry );
     507             : 
     508           0 :         for(i=0; i<i_nPoly; i++)
     509           0 :             delete [] pPtAry2[i];
     510           0 :         delete [] pPtAry2;
     511             :     }
     512             :     else
     513           5 :         bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, i_pPtAry, i_pFlgAry );
     514           5 :     return bRet;
     515             : }
     516             : 
     517           0 : bool SalGraphics::DrawPolyLine(
     518             :     const ::basegfx::B2DPolygon& i_rPolygon,
     519             :     double i_fTransparency,
     520             :     const ::basegfx::B2DVector& i_rLineWidth,
     521             :     basegfx::B2DLineJoin i_eLineJoin,
     522             :     com::sun::star::drawing::LineCap i_eLineCap,
     523             :     const OutputDevice* i_pOutDev )
     524             : {
     525           0 :     bool bRet = false;
     526           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
     527             :     {
     528           0 :         basegfx::B2DPolygon aMirror( mirror( i_rPolygon, i_pOutDev ) );
     529           0 :         bRet = drawPolyLine( aMirror, i_fTransparency, i_rLineWidth, i_eLineJoin, i_eLineCap );
     530             :     }
     531             :     else
     532           0 :         bRet = drawPolyLine( i_rPolygon, i_fTransparency, i_rLineWidth, i_eLineJoin, i_eLineCap );
     533           0 :     return bRet;
     534             : }
     535             : 
     536           8 : void    SalGraphics::CopyArea( long nDestX, long nDestY,
     537             :                                long nSrcX, long nSrcY,
     538             :                                long nSrcWidth, long nSrcHeight,
     539             :                                sal_uInt16 nFlags, const OutputDevice *pOutDev )
     540             : {
     541           8 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     542             :     {
     543           0 :         mirror( nDestX, nSrcWidth, pOutDev );
     544           0 :         mirror( nSrcX, nSrcWidth, pOutDev );
     545             :     }
     546           8 :     copyArea( nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, nFlags );
     547           8 : }
     548        1836 : void    SalGraphics::CopyBits( const SalTwoRect* pPosAry,
     549             :                                SalGraphics* pSrcGraphics, const OutputDevice *pOutDev, const OutputDevice *pSrcOutDev )
     550             : {
     551        5490 :     if( ( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) ||
     552        3654 :         (pSrcGraphics && ( (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL)  || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) ) ) )
     553             :     {
     554           0 :         SalTwoRect pPosAry2 = *pPosAry;
     555           0 :         if( (pSrcGraphics && (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL)) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) )
     556           0 :             mirror( pPosAry2.mnSrcX, pPosAry2.mnSrcWidth, pSrcOutDev );
     557           0 :         if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     558           0 :             mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
     559           0 :         copyBits( &pPosAry2, pSrcGraphics );
     560             :     }
     561             :     else
     562        1836 :         copyBits( pPosAry, pSrcGraphics );
     563        1836 : }
     564          10 : void    SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
     565             :                                     const SalBitmap& rSalBitmap, const OutputDevice *pOutDev )
     566             : {
     567          10 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     568             :     {
     569           0 :         SalTwoRect pPosAry2 = *pPosAry;
     570           0 :         mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
     571           0 :         drawBitmap( &pPosAry2, rSalBitmap );
     572             :     }
     573             :     else
     574          10 :         drawBitmap( pPosAry, rSalBitmap );
     575          10 : }
     576           4 : void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
     577             :                               const SalBitmap& rSalBitmap,
     578             :                               const SalBitmap& rTransparentBitmap, const OutputDevice *pOutDev )
     579             : {
     580           4 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     581             :     {
     582           0 :         SalTwoRect pPosAry2 = *pPosAry;
     583           0 :         mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
     584           0 :         drawBitmap( &pPosAry2, rSalBitmap, rTransparentBitmap );
     585             :     }
     586             :     else
     587           4 :         drawBitmap( pPosAry, rSalBitmap, rTransparentBitmap );
     588           4 : }
     589           0 : void    SalGraphics::DrawMask( const SalTwoRect* pPosAry,
     590             :                                   const SalBitmap& rSalBitmap,
     591             :                                   SalColor nMaskColor, const OutputDevice *pOutDev )
     592             : {
     593           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     594             :     {
     595           0 :         SalTwoRect pPosAry2 = *pPosAry;
     596           0 :         mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
     597           0 :         drawMask( &pPosAry2, rSalBitmap, nMaskColor );
     598             :     }
     599             :     else
     600           0 :         drawMask( pPosAry, rSalBitmap, nMaskColor );
     601           0 : }
     602          69 : SalBitmap*  SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
     603             : {
     604          69 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     605           0 :         mirror( nX, nWidth, pOutDev );
     606          69 :     return getBitmap( nX, nY, nWidth, nHeight );
     607             : }
     608           0 : SalColor    SalGraphics::GetPixel( long nX, long nY, const OutputDevice *pOutDev )
     609             : {
     610           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     611           0 :         mirror( nX, pOutDev );
     612           0 :     return getPixel( nX, nY );
     613             : }
     614        1132 : void    SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags, const OutputDevice *pOutDev )
     615             : {
     616        1132 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     617           0 :         mirror( nX, nWidth, pOutDev );
     618        1132 :     invert( nX, nY, nWidth, nHeight, nFlags );
     619        1132 : }
     620           0 : void    SalGraphics::Invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags, const OutputDevice *pOutDev )
     621             : {
     622           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     623             :     {
     624           0 :         SalPoint* pPtAry2 = new SalPoint[nPoints];
     625           0 :         sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
     626           0 :         invert( nPoints, bCopied ? pPtAry2 : pPtAry, nFlags );
     627           0 :         delete [] pPtAry2;
     628             :     }
     629             :     else
     630           0 :         invert( nPoints, pPtAry, nFlags );
     631           0 : }
     632             : 
     633           0 : sal_Bool    SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize, const OutputDevice *pOutDev )
     634             : {
     635           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     636           0 :         mirror( nX, nWidth, pOutDev );
     637           0 :     return drawEPS( nX, nY, nWidth, nHeight,  pPtr, nSize );
     638             : }
     639             : 
     640           0 : sal_Bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
     641             :                                                 const Point& aPos, sal_Bool& rIsInside, const OutputDevice *pOutDev )
     642             : {
     643           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     644             :     {
     645           0 :         Point pt( aPos );
     646           0 :         Rectangle rgn( rControlRegion );
     647           0 :         mirror( pt.X(), pOutDev );
     648           0 :         mirror( rgn, pOutDev );
     649           0 :         return hitTestNativeControl( nType, nPart, rgn, pt, rIsInside );
     650             :     }
     651             :     else
     652           0 :         return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rIsInside );
     653             : }
     654             : 
     655           0 : void SalGraphics::mirror( ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const
     656             : {
     657           0 :     switch( rVal.getType() )
     658             :     {
     659             :         case CTRL_SLIDER:
     660             :         {
     661           0 :             SliderValue* pSlVal = static_cast<SliderValue*>(&rVal);
     662           0 :             mirror(pSlVal->maThumbRect,pOutDev,bBack);
     663             :         }
     664           0 :         break;
     665             :         case CTRL_SCROLLBAR:
     666             :         {
     667           0 :             ScrollbarValue* pScVal = static_cast<ScrollbarValue*>(&rVal);
     668           0 :             mirror(pScVal->maThumbRect,pOutDev,bBack);
     669           0 :             mirror(pScVal->maButton1Rect,pOutDev,bBack);
     670           0 :             mirror(pScVal->maButton2Rect,pOutDev,bBack);
     671             :         }
     672           0 :         break;
     673             :         case CTRL_SPINBOX:
     674             :         case CTRL_SPINBUTTONS:
     675             :         {
     676           0 :             SpinbuttonValue* pSpVal = static_cast<SpinbuttonValue*>(&rVal);
     677           0 :             mirror(pSpVal->maUpperRect,pOutDev,bBack);
     678           0 :             mirror(pSpVal->maLowerRect,pOutDev,bBack);
     679             :         }
     680           0 :         break;
     681             :         case CTRL_TOOLBAR:
     682             :         {
     683           0 :             ToolbarValue* pTVal = static_cast<ToolbarValue*>(&rVal);
     684           0 :             mirror(pTVal->maGripRect,pOutDev,bBack);
     685             :         }
     686           0 :         break;
     687             :     }
     688           0 : }
     689             : 
     690           0 : sal_Bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
     691             :                                                 ControlState nState, const ImplControlValue& aValue,
     692             :                                                 const OUString& aCaption, const OutputDevice *pOutDev )
     693             : {
     694           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     695             :     {
     696           0 :         Rectangle rgn( rControlRegion );
     697           0 :         mirror( rgn, pOutDev );
     698           0 :         boost::scoped_ptr< ImplControlValue > mirrorValue( aValue.clone());
     699           0 :         mirror( *mirrorValue, pOutDev );
     700           0 :         sal_Bool bRet = drawNativeControl( nType, nPart, rgn, nState, *mirrorValue, aCaption );
     701           0 :         return bRet;
     702             :     }
     703             :     else
     704           0 :         return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption );
     705             : }
     706             : 
     707        4331 : sal_Bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
     708             :                                                 const ImplControlValue& aValue, const OUString& aCaption,
     709             :                                                 Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion, const OutputDevice *pOutDev )
     710             : {
     711        4331 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     712             :     {
     713           0 :         Rectangle rgn( rControlRegion );
     714           0 :         mirror( rgn, pOutDev );
     715           0 :         boost::scoped_ptr< ImplControlValue > mirrorValue( aValue.clone());
     716           0 :         mirror( *mirrorValue, pOutDev );
     717           0 :         if( getNativeControlRegion( nType, nPart, rgn, nState, *mirrorValue, aCaption,
     718           0 :                                                 rNativeBoundingRegion, rNativeContentRegion ) )
     719             :         {
     720           0 :             mirror( rNativeBoundingRegion, pOutDev, true );
     721           0 :             mirror( rNativeContentRegion, pOutDev, true );
     722           0 :             return sal_True;
     723             :         }
     724           0 :         return sal_False;
     725             :     }
     726             :     else
     727             :         return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, aCaption,
     728        4331 :                                                 rNativeBoundingRegion, rNativeContentRegion );
     729             : }
     730             : 
     731           2 : bool SalGraphics::DrawAlphaBitmap( const SalTwoRect& rPosAry,
     732             :                                    const SalBitmap& rSourceBitmap,
     733             :                                    const SalBitmap& rAlphaBitmap,
     734             :                                    const OutputDevice *pOutDev )
     735             : {
     736           2 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     737             :     {
     738           0 :         SalTwoRect pPosAry2 = rPosAry;
     739           0 :         mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
     740           0 :         return drawAlphaBitmap( pPosAry2, rSourceBitmap, rAlphaBitmap );
     741             :     }
     742             :     else
     743           2 :         return drawAlphaBitmap( rPosAry, rSourceBitmap, rAlphaBitmap );
     744             : }
     745             : 
     746           0 : bool SalGraphics::DrawAlphaRect( long nX, long nY, long nWidth, long nHeight,
     747             :                                  sal_uInt8 nTransparency, const OutputDevice *pOutDev )
     748             : {
     749           0 :     if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
     750           0 :         mirror( nX, nWidth, pOutDev );
     751             : 
     752           0 :     return drawAlphaRect( nX, nY, nWidth, nHeight, nTransparency );
     753             : }
     754             : 
     755        7337 : bool SalGraphics::filterText( const rtl::OUString&, rtl::OUString&, xub_StrLen, xub_StrLen&, xub_StrLen&, xub_StrLen& )
     756             : {
     757        7337 :     return false;
     758             : }
     759             : 
     760             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10