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

Generated by: LCOV version 1.10