19f62ea84SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39f62ea84SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49f62ea84SAndrew Rist * or more contributor license agreements. See the NOTICE file 59f62ea84SAndrew Rist * distributed with this work for additional information 69f62ea84SAndrew Rist * regarding copyright ownership. The ASF licenses this file 79f62ea84SAndrew Rist * to you under the Apache License, Version 2.0 (the 89f62ea84SAndrew Rist * "License"); you may not use this file except in compliance 99f62ea84SAndrew Rist * with the License. You may obtain a copy of the License at 109f62ea84SAndrew Rist * 119f62ea84SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 129f62ea84SAndrew Rist * 139f62ea84SAndrew Rist * Unless required by applicable law or agreed to in writing, 149f62ea84SAndrew Rist * software distributed under the License is distributed on an 159f62ea84SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169f62ea84SAndrew Rist * KIND, either express or implied. See the License for the 179f62ea84SAndrew Rist * specific language governing permissions and limitations 189f62ea84SAndrew Rist * under the License. 199f62ea84SAndrew Rist * 209f62ea84SAndrew Rist *************************************************************/ 219f62ea84SAndrew Rist 229f62ea84SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_vcl.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <tools/ref.hxx> 28cdf0e10cSrcweir #include <tools/debug.hxx> 29cdf0e10cSrcweir #include <tools/poly.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <vcl/svapp.hxx> 32cdf0e10cSrcweir #include <vcl/region.hxx> 33cdf0e10cSrcweir #include <vcl/virdev.hxx> 34cdf0e10cSrcweir #include <vcl/window.hxx> 35cdf0e10cSrcweir #include <vcl/metaact.hxx> 36cdf0e10cSrcweir #include <vcl/gdimtf.hxx> 37cdf0e10cSrcweir #include <vcl/print.hxx> 38cdf0e10cSrcweir #include <vcl/outdev.hxx> 39cdf0e10cSrcweir #include <vcl/unowrap.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #include <window.h> 42cdf0e10cSrcweir #include <outdev.h> 43cdf0e10cSrcweir #include <sallayout.hxx> 44cdf0e10cSrcweir #include <salgdi.hxx> 45cdf0e10cSrcweir #include <salframe.hxx> 46cdf0e10cSrcweir #include <salvd.hxx> 47cdf0e10cSrcweir #include <salprn.hxx> 48cdf0e10cSrcweir #include <svdata.hxx> 49cdf0e10cSrcweir #include <outdata.hxx> 50cdf0e10cSrcweir 51cdf0e10cSrcweir 52cdf0e10cSrcweir #include "basegfx/polygon/b2dpolygon.hxx" 53cdf0e10cSrcweir 54cdf0e10cSrcweir // ---------------------------------------------------------------------------- 55cdf0e10cSrcweir // The only common SalFrame method 56cdf0e10cSrcweir // ---------------------------------------------------------------------------- 57cdf0e10cSrcweir 58cdf0e10cSrcweir SalFrameGeometry SalFrame::GetGeometry() 59cdf0e10cSrcweir { 60cdf0e10cSrcweir // mirror frame coordinates at parent 61cdf0e10cSrcweir SalFrame *pParent = GetParent(); 62cdf0e10cSrcweir if( pParent && Application::GetSettings().GetLayoutRTL() ) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir SalFrameGeometry aGeom = maGeometry; 65cdf0e10cSrcweir int parent_x = aGeom.nX - pParent->maGeometry.nX; 66cdf0e10cSrcweir aGeom.nX = pParent->maGeometry.nX + pParent->maGeometry.nWidth - maGeometry.nWidth - parent_x; 67cdf0e10cSrcweir return aGeom; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir else 70cdf0e10cSrcweir return maGeometry; 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73cdf0e10cSrcweir // ---------------------------------------------------------------------------- 74cdf0e10cSrcweir 75cdf0e10cSrcweir SalGraphics::SalGraphics() 76cdf0e10cSrcweir : m_nLayout( 0 ), 77cdf0e10cSrcweir m_bAntiAliasB2DDraw(false) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir // read global RTL settings 80cdf0e10cSrcweir if( Application::GetSettings().GetLayoutRTL() ) 81cdf0e10cSrcweir m_nLayout = SAL_LAYOUT_BIDI_RTL; 82cdf0e10cSrcweir } 83cdf0e10cSrcweir 84cdf0e10cSrcweir SalGraphics::~SalGraphics() 85cdf0e10cSrcweir { 86cdf0e10cSrcweir } 87cdf0e10cSrcweir 88cdf0e10cSrcweir // ---------------------------------------------------------------------------- 89cdf0e10cSrcweir 90cdf0e10cSrcweir bool SalGraphics::drawAlphaBitmap( const SalTwoRect&, 91cdf0e10cSrcweir const SalBitmap&, const SalBitmap& ) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir return false; 94cdf0e10cSrcweir } 95cdf0e10cSrcweir 96cdf0e10cSrcweir // ---------------------------------------------------------------------------- 97cdf0e10cSrcweir 98cdf0e10cSrcweir void SalGraphics::mirror( long& x, const OutputDevice *pOutDev, bool bBack ) const 99cdf0e10cSrcweir { 100cdf0e10cSrcweir long w; 101cdf0e10cSrcweir if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV ) 102cdf0e10cSrcweir w = pOutDev->GetOutputWidthPixel(); 103cdf0e10cSrcweir else 104cdf0e10cSrcweir w = GetGraphicsWidth(); 105cdf0e10cSrcweir 106cdf0e10cSrcweir if( w ) 107cdf0e10cSrcweir { 108cdf0e10cSrcweir if( pOutDev && pOutDev->ImplIsAntiparallel() ) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir OutputDevice *pOutDevRef = (OutputDevice*) pOutDev; 111cdf0e10cSrcweir // mirror this window back 112cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) 113cdf0e10cSrcweir { 114cdf0e10cSrcweir long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 115cdf0e10cSrcweir if( bBack ) 116cdf0e10cSrcweir x = x - devX + pOutDevRef->GetOutOffXPixel(); 117cdf0e10cSrcweir else 118cdf0e10cSrcweir x = devX + (x - pOutDevRef->GetOutOffXPixel()); 119cdf0e10cSrcweir } 120cdf0e10cSrcweir else 121cdf0e10cSrcweir { 122cdf0e10cSrcweir long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 123cdf0e10cSrcweir if( bBack ) 124cdf0e10cSrcweir x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1; 125cdf0e10cSrcweir else 126cdf0e10cSrcweir x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - 1; 127cdf0e10cSrcweir } 128cdf0e10cSrcweir } 129cdf0e10cSrcweir else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) 130cdf0e10cSrcweir x = w-1-x; 131cdf0e10cSrcweir } 132cdf0e10cSrcweir } 133cdf0e10cSrcweir 134cdf0e10cSrcweir void SalGraphics::mirror( long& x, long& nWidth, const OutputDevice *pOutDev, bool bBack ) const 135cdf0e10cSrcweir { 136cdf0e10cSrcweir long w; 137cdf0e10cSrcweir if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV ) 138cdf0e10cSrcweir w = pOutDev->GetOutputWidthPixel(); 139cdf0e10cSrcweir else 140cdf0e10cSrcweir w = GetGraphicsWidth(); 141cdf0e10cSrcweir 142cdf0e10cSrcweir if( w ) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir if( pOutDev && pOutDev->ImplIsAntiparallel() ) 145cdf0e10cSrcweir { 146cdf0e10cSrcweir OutputDevice *pOutDevRef = (OutputDevice*) pOutDev; 147cdf0e10cSrcweir // mirror this window back 148cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) 149cdf0e10cSrcweir { 150cdf0e10cSrcweir long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 151cdf0e10cSrcweir if( bBack ) 152cdf0e10cSrcweir x = x - devX + pOutDevRef->GetOutOffXPixel(); 153cdf0e10cSrcweir else 154cdf0e10cSrcweir x = devX + (x - pOutDevRef->GetOutOffXPixel()); 155cdf0e10cSrcweir } 156cdf0e10cSrcweir else 157cdf0e10cSrcweir { 158cdf0e10cSrcweir long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 159cdf0e10cSrcweir if( bBack ) 160cdf0e10cSrcweir x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + nWidth; 161cdf0e10cSrcweir else 162cdf0e10cSrcweir x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - nWidth; 163cdf0e10cSrcweir } 164cdf0e10cSrcweir } 165cdf0e10cSrcweir else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) 166cdf0e10cSrcweir x = w-nWidth-x; 167cdf0e10cSrcweir 168cdf0e10cSrcweir } 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir sal_Bool SalGraphics::mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint *pPtAry2, const OutputDevice *pOutDev, bool bBack ) const 172cdf0e10cSrcweir { 173cdf0e10cSrcweir long w; 174cdf0e10cSrcweir if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV ) 175cdf0e10cSrcweir w = pOutDev->GetOutputWidthPixel(); 176cdf0e10cSrcweir else 177cdf0e10cSrcweir w = GetGraphicsWidth(); 178cdf0e10cSrcweir 179cdf0e10cSrcweir if( w ) 180cdf0e10cSrcweir { 181cdf0e10cSrcweir sal_uInt32 i, j; 182cdf0e10cSrcweir 183cdf0e10cSrcweir if( pOutDev && pOutDev->ImplIsAntiparallel() ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir OutputDevice *pOutDevRef = (OutputDevice*) pOutDev; 186cdf0e10cSrcweir // mirror this window back 187cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) 188cdf0e10cSrcweir { 189cdf0e10cSrcweir long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 190cdf0e10cSrcweir if( bBack ) 191cdf0e10cSrcweir { 192cdf0e10cSrcweir for( i=0, j=nPoints-1; i<nPoints; i++,j-- ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir //long x = w-1-pPtAry[i].mnX; 195cdf0e10cSrcweir //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) ); 196cdf0e10cSrcweir pPtAry2[j].mnX = pOutDevRef->GetOutOffXPixel() + (pPtAry[i].mnX - devX); 197cdf0e10cSrcweir pPtAry2[j].mnY = pPtAry[i].mnY; 198cdf0e10cSrcweir } 199cdf0e10cSrcweir } 200cdf0e10cSrcweir else 201cdf0e10cSrcweir { 202cdf0e10cSrcweir for( i=0, j=nPoints-1; i<nPoints; i++,j-- ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir //long x = w-1-pPtAry[i].mnX; 205cdf0e10cSrcweir //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) ); 206cdf0e10cSrcweir pPtAry2[j].mnX = devX + (pPtAry[i].mnX - pOutDevRef->GetOutOffXPixel()); 207cdf0e10cSrcweir pPtAry2[j].mnY = pPtAry[i].mnY; 208cdf0e10cSrcweir } 209cdf0e10cSrcweir } 210cdf0e10cSrcweir } 211cdf0e10cSrcweir else 212cdf0e10cSrcweir { 213cdf0e10cSrcweir long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 214cdf0e10cSrcweir if( bBack ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir for( i=0, j=nPoints-1; i<nPoints; i++,j-- ) 217cdf0e10cSrcweir { 218cdf0e10cSrcweir //long x = w-1-pPtAry[i].mnX; 219cdf0e10cSrcweir //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) ); 220cdf0e10cSrcweir pPtAry2[j].mnX = pPtAry[i].mnX - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1; 221cdf0e10cSrcweir pPtAry2[j].mnY = pPtAry[i].mnY; 222cdf0e10cSrcweir } 223cdf0e10cSrcweir } 224cdf0e10cSrcweir else 225cdf0e10cSrcweir { 226cdf0e10cSrcweir for( i=0, j=nPoints-1; i<nPoints; i++,j-- ) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir //long x = w-1-pPtAry[i].mnX; 229cdf0e10cSrcweir //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) ); 230cdf0e10cSrcweir pPtAry2[j].mnX = pOutDevRef->GetOutputWidthPixel() - (pPtAry[i].mnX - devX) + pOutDevRef->GetOutOffXPixel() - 1; 231cdf0e10cSrcweir pPtAry2[j].mnY = pPtAry[i].mnY; 232cdf0e10cSrcweir } 233cdf0e10cSrcweir } 234cdf0e10cSrcweir } 235cdf0e10cSrcweir } 236cdf0e10cSrcweir else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) ) 237cdf0e10cSrcweir { 238cdf0e10cSrcweir for( i=0, j=nPoints-1; i<nPoints; i++,j-- ) 239cdf0e10cSrcweir { 240cdf0e10cSrcweir pPtAry2[j].mnX = w-1-pPtAry[i].mnX; 241cdf0e10cSrcweir pPtAry2[j].mnY = pPtAry[i].mnY; 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } 244cdf0e10cSrcweir return sal_True; 245cdf0e10cSrcweir } 246cdf0e10cSrcweir else 247cdf0e10cSrcweir return sal_False; 248cdf0e10cSrcweir } 249cdf0e10cSrcweir 250cdf0e10cSrcweir void SalGraphics::mirror( Region& rRgn, const OutputDevice *pOutDev, bool bBack ) const 251cdf0e10cSrcweir { 252*e6f63103SArmin Le Grand if( rRgn.HasPolyPolygonOrB2DPolyPolygon() ) 253cdf0e10cSrcweir { 254*e6f63103SArmin Le Grand const basegfx::B2DPolyPolygon aPolyPoly(mirror(rRgn.GetAsB2DPolyPolygon(), pOutDev, bBack)); 255*e6f63103SArmin Le Grand 256*e6f63103SArmin Le Grand rRgn = Region(aPolyPoly); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir else 259cdf0e10cSrcweir { 260*e6f63103SArmin Le Grand RectangleVector aRectangles; 261*e6f63103SArmin Le Grand rRgn.GetRegionRectangles(aRectangles); 262*e6f63103SArmin Le Grand rRgn.SetEmpty(); 263*e6f63103SArmin Le Grand 264*e6f63103SArmin Le Grand for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); aRectIter++) 265cdf0e10cSrcweir { 266*e6f63103SArmin Le Grand mirror(*aRectIter, pOutDev, bBack); 267*e6f63103SArmin Le Grand rRgn.Union(*aRectIter); 268cdf0e10cSrcweir } 269*e6f63103SArmin Le Grand 270*e6f63103SArmin Le Grand //ImplRegionInfo aInfo; 271*e6f63103SArmin Le Grand //bool bRegionRect; 272*e6f63103SArmin Le Grand //Region aMirroredRegion; 273*e6f63103SArmin Le Grand //long nX, nY, nWidth, nHeight; 274*e6f63103SArmin Le Grand // 275*e6f63103SArmin Le Grand //bRegionRect = rRgn.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight ); 276*e6f63103SArmin Le Grand //while ( bRegionRect ) 277*e6f63103SArmin Le Grand //{ 278*e6f63103SArmin Le Grand // Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) ); 279*e6f63103SArmin Le Grand // mirror( aRect, pOutDev, bBack ); 280*e6f63103SArmin Le Grand // aMirroredRegion.Union( aRect ); 281*e6f63103SArmin Le Grand // bRegionRect = rRgn.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight ); 282*e6f63103SArmin Le Grand //} 283*e6f63103SArmin Le Grand //rRgn = aMirroredRegion; 284cdf0e10cSrcweir } 285cdf0e10cSrcweir } 286cdf0e10cSrcweir 287cdf0e10cSrcweir void SalGraphics::mirror( Rectangle& rRect, const OutputDevice *pOutDev, bool bBack ) const 288cdf0e10cSrcweir { 289cdf0e10cSrcweir long nWidth = rRect.GetWidth(); 290cdf0e10cSrcweir long x = rRect.Left(); 291cdf0e10cSrcweir long x_org = x; 292cdf0e10cSrcweir 293cdf0e10cSrcweir mirror( x, nWidth, pOutDev, bBack ); 294cdf0e10cSrcweir rRect.Move( x - x_org, 0 ); 295cdf0e10cSrcweir } 296cdf0e10cSrcweir 297cdf0e10cSrcweir basegfx::B2DPoint SalGraphics::mirror( const basegfx::B2DPoint& i_rPoint, const OutputDevice *i_pOutDev, bool i_bBack ) const 298cdf0e10cSrcweir { 299cdf0e10cSrcweir long w; 300cdf0e10cSrcweir if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV ) 301cdf0e10cSrcweir w = i_pOutDev->GetOutputWidthPixel(); 302cdf0e10cSrcweir else 303cdf0e10cSrcweir w = GetGraphicsWidth(); 304cdf0e10cSrcweir 305cdf0e10cSrcweir DBG_ASSERT( w, "missing graphics width" ); 306cdf0e10cSrcweir 307cdf0e10cSrcweir basegfx::B2DPoint aRet( i_rPoint ); 308cdf0e10cSrcweir if( w ) 309cdf0e10cSrcweir { 310cdf0e10cSrcweir if( i_pOutDev && !i_pOutDev->IsRTLEnabled() ) 311cdf0e10cSrcweir { 312cdf0e10cSrcweir OutputDevice *pOutDevRef = (OutputDevice*)i_pOutDev; 313cdf0e10cSrcweir // mirror this window back 314cdf0e10cSrcweir double devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX 315cdf0e10cSrcweir if( i_bBack ) 316cdf0e10cSrcweir aRet.setX( i_rPoint.getX() - devX + pOutDevRef->GetOutOffXPixel() ); 317cdf0e10cSrcweir else 318cdf0e10cSrcweir aRet.setX( devX + (i_rPoint.getX() - pOutDevRef->GetOutOffXPixel()) ); 319cdf0e10cSrcweir } 320cdf0e10cSrcweir else 321cdf0e10cSrcweir aRet.setX( w-1-i_rPoint.getX() ); 322cdf0e10cSrcweir } 323cdf0e10cSrcweir return aRet; 324cdf0e10cSrcweir } 325cdf0e10cSrcweir 326cdf0e10cSrcweir basegfx::B2DPolygon SalGraphics::mirror( const basegfx::B2DPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const 327cdf0e10cSrcweir { 328cdf0e10cSrcweir long w; 329cdf0e10cSrcweir if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV ) 330cdf0e10cSrcweir w = i_pOutDev->GetOutputWidthPixel(); 331cdf0e10cSrcweir else 332cdf0e10cSrcweir w = GetGraphicsWidth(); 333cdf0e10cSrcweir 334cdf0e10cSrcweir DBG_ASSERT( w, "missing graphics width" ); 335cdf0e10cSrcweir 336cdf0e10cSrcweir basegfx::B2DPolygon aRet; 337cdf0e10cSrcweir if( w ) 338cdf0e10cSrcweir { 339cdf0e10cSrcweir sal_Int32 nPoints = i_rPoly.count(); 340cdf0e10cSrcweir for( sal_Int32 i = 0; i < nPoints; i++ ) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir aRet.append( mirror( i_rPoly.getB2DPoint( i ), i_pOutDev, i_bBack ) ); 343cdf0e10cSrcweir if( i_rPoly.isPrevControlPointUsed( i ) ) 344cdf0e10cSrcweir aRet.setPrevControlPoint( i, mirror( i_rPoly.getPrevControlPoint( i ), i_pOutDev, i_bBack ) ); 345cdf0e10cSrcweir if( i_rPoly.isNextControlPointUsed( i ) ) 346cdf0e10cSrcweir aRet.setNextControlPoint( i, mirror( i_rPoly.getNextControlPoint( i ), i_pOutDev, i_bBack ) ); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir aRet.setClosed( i_rPoly.isClosed() ); 349cdf0e10cSrcweir aRet.flip(); 350cdf0e10cSrcweir } 351cdf0e10cSrcweir else 352cdf0e10cSrcweir aRet = i_rPoly; 353cdf0e10cSrcweir return aRet; 354cdf0e10cSrcweir } 355cdf0e10cSrcweir 356cdf0e10cSrcweir basegfx::B2DPolyPolygon SalGraphics::mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const 357cdf0e10cSrcweir { 358cdf0e10cSrcweir long w; 359cdf0e10cSrcweir if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV ) 360cdf0e10cSrcweir w = i_pOutDev->GetOutputWidthPixel(); 361cdf0e10cSrcweir else 362cdf0e10cSrcweir w = GetGraphicsWidth(); 363cdf0e10cSrcweir 364cdf0e10cSrcweir DBG_ASSERT( w, "missing graphics width" ); 365cdf0e10cSrcweir 366cdf0e10cSrcweir basegfx::B2DPolyPolygon aRet; 367cdf0e10cSrcweir if( w ) 368cdf0e10cSrcweir { 369cdf0e10cSrcweir sal_Int32 nPoly = i_rPoly.count(); 370cdf0e10cSrcweir for( sal_Int32 i = 0; i < nPoly; i++ ) 371cdf0e10cSrcweir aRet.append( mirror( i_rPoly.getB2DPolygon( i ), i_pOutDev, i_bBack ) ); 372cdf0e10cSrcweir aRet.setClosed( i_rPoly.isClosed() ); 373cdf0e10cSrcweir aRet.flip(); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir else 376cdf0e10cSrcweir aRet = i_rPoly; 377cdf0e10cSrcweir return aRet; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir 380cdf0e10cSrcweir // ---------------------------------------------------------------------------- 381cdf0e10cSrcweir 382cdf0e10cSrcweir bool SalGraphics::SetClipRegion( const Region& i_rClip, const OutputDevice *pOutDev ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 385cdf0e10cSrcweir { 386cdf0e10cSrcweir Region aMirror( i_rClip ); 387cdf0e10cSrcweir mirror( aMirror, pOutDev ); 388cdf0e10cSrcweir return setClipRegion( aMirror ); 389cdf0e10cSrcweir } 390cdf0e10cSrcweir return setClipRegion( i_rClip ); 391cdf0e10cSrcweir } 392cdf0e10cSrcweir 393cdf0e10cSrcweir void SalGraphics::DrawPixel( long nX, long nY, const OutputDevice *pOutDev ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 396cdf0e10cSrcweir mirror( nX, pOutDev ); 397cdf0e10cSrcweir drawPixel( nX, nY ); 398cdf0e10cSrcweir } 399cdf0e10cSrcweir void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor, const OutputDevice *pOutDev ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 402cdf0e10cSrcweir mirror( nX, pOutDev ); 403cdf0e10cSrcweir drawPixel( nX, nY, nSalColor ); 404cdf0e10cSrcweir } 405cdf0e10cSrcweir void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2, const OutputDevice *pOutDev ) 406cdf0e10cSrcweir { 407cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir mirror( nX1, pOutDev ); 410cdf0e10cSrcweir mirror( nX2, pOutDev ); 411cdf0e10cSrcweir } 412cdf0e10cSrcweir drawLine( nX1, nY1, nX2, nY2 ); 413cdf0e10cSrcweir } 414cdf0e10cSrcweir void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 417cdf0e10cSrcweir mirror( nX, nWidth, pOutDev ); 418cdf0e10cSrcweir drawRect( nX, nY, nWidth, nHeight ); 419cdf0e10cSrcweir } 420cdf0e10cSrcweir bool SalGraphics::drawPolyLine( 421cdf0e10cSrcweir const basegfx::B2DPolygon& /*rPolyPolygon*/, 422cdf0e10cSrcweir double /*fTransparency*/, 423cdf0e10cSrcweir const basegfx::B2DVector& /*rLineWidths*/, 4245aaf853bSArmin Le Grand basegfx::B2DLineJoin /*eLineJoin*/, 4255aaf853bSArmin Le Grand com::sun::star::drawing::LineCap /*eLineCap*/) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir return false; 428cdf0e10cSrcweir } 429cdf0e10cSrcweir 430cdf0e10cSrcweir void SalGraphics::DrawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 433cdf0e10cSrcweir { 434cdf0e10cSrcweir SalPoint* pPtAry2 = new SalPoint[nPoints]; 435cdf0e10cSrcweir sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev ); 436cdf0e10cSrcweir drawPolyLine( nPoints, bCopied ? pPtAry2 : pPtAry ); 437cdf0e10cSrcweir delete [] pPtAry2; 438cdf0e10cSrcweir } 439cdf0e10cSrcweir else 440cdf0e10cSrcweir drawPolyLine( nPoints, pPtAry ); 441cdf0e10cSrcweir } 442cdf0e10cSrcweir 443cdf0e10cSrcweir void SalGraphics::DrawPolygon( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev ) 444cdf0e10cSrcweir { 445cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 446cdf0e10cSrcweir { 447cdf0e10cSrcweir SalPoint* pPtAry2 = new SalPoint[nPoints]; 448cdf0e10cSrcweir sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev ); 449cdf0e10cSrcweir drawPolygon( nPoints, bCopied ? pPtAry2 : pPtAry ); 450cdf0e10cSrcweir delete [] pPtAry2; 451cdf0e10cSrcweir } 452cdf0e10cSrcweir else 453cdf0e10cSrcweir drawPolygon( nPoints, pPtAry ); 454cdf0e10cSrcweir } 455cdf0e10cSrcweir 456cdf0e10cSrcweir void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry, const OutputDevice *pOutDev ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 459cdf0e10cSrcweir { 460cdf0e10cSrcweir // TODO: optimize, reduce new/delete calls 461cdf0e10cSrcweir SalPoint **pPtAry2 = new SalPoint*[nPoly]; 462cdf0e10cSrcweir sal_uLong i; 463cdf0e10cSrcweir for(i=0; i<nPoly; i++) 464cdf0e10cSrcweir { 465cdf0e10cSrcweir sal_uLong nPoints = pPoints[i]; 466cdf0e10cSrcweir pPtAry2[i] = new SalPoint[ nPoints ]; 467cdf0e10cSrcweir mirror( nPoints, pPtAry[i], pPtAry2[i], pOutDev ); 468cdf0e10cSrcweir } 469cdf0e10cSrcweir 470cdf0e10cSrcweir drawPolyPolygon( nPoly, pPoints, (PCONSTSALPOINT*)pPtAry2 ); 471cdf0e10cSrcweir 472cdf0e10cSrcweir for(i=0; i<nPoly; i++) 473cdf0e10cSrcweir delete [] pPtAry2[i]; 474cdf0e10cSrcweir delete [] pPtAry2; 475cdf0e10cSrcweir } 476cdf0e10cSrcweir else 477cdf0e10cSrcweir drawPolyPolygon( nPoly, pPoints, pPtAry ); 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir bool SalGraphics::DrawPolyPolygon( const ::basegfx::B2DPolyPolygon& i_rPolyPolygon, double i_fTransparency, const OutputDevice* i_pOutDev ) 481cdf0e10cSrcweir { 482cdf0e10cSrcweir bool bRet = false; 483cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) ) 484cdf0e10cSrcweir { 485cdf0e10cSrcweir basegfx::B2DPolyPolygon aMirror( mirror( i_rPolyPolygon, i_pOutDev ) ); 486cdf0e10cSrcweir bRet = drawPolyPolygon( aMirror, i_fTransparency ); 487cdf0e10cSrcweir } 488cdf0e10cSrcweir else 489cdf0e10cSrcweir bRet = drawPolyPolygon( i_rPolyPolygon, i_fTransparency ); 490cdf0e10cSrcweir return bRet; 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir bool SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir return false; 496cdf0e10cSrcweir } 497cdf0e10cSrcweir 498cdf0e10cSrcweir sal_Bool SalGraphics::DrawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev ) 499cdf0e10cSrcweir { 500cdf0e10cSrcweir sal_Bool bResult = sal_False; 501cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir SalPoint* pPtAry2 = new SalPoint[nPoints]; 504cdf0e10cSrcweir sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev ); 505cdf0e10cSrcweir bResult = drawPolyLineBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry ); 506cdf0e10cSrcweir delete [] pPtAry2; 507cdf0e10cSrcweir } 508cdf0e10cSrcweir else 509cdf0e10cSrcweir bResult = drawPolyLineBezier( nPoints, pPtAry, pFlgAry ); 510cdf0e10cSrcweir return bResult; 511cdf0e10cSrcweir } 512cdf0e10cSrcweir 513cdf0e10cSrcweir sal_Bool SalGraphics::DrawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir sal_Bool bResult = sal_False; 516cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 517cdf0e10cSrcweir { 518cdf0e10cSrcweir SalPoint* pPtAry2 = new SalPoint[nPoints]; 519cdf0e10cSrcweir sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev ); 520cdf0e10cSrcweir bResult = drawPolygonBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry ); 521cdf0e10cSrcweir delete [] pPtAry2; 522cdf0e10cSrcweir } 523cdf0e10cSrcweir else 524cdf0e10cSrcweir bResult = drawPolygonBezier( nPoints, pPtAry, pFlgAry ); 525cdf0e10cSrcweir return bResult; 526cdf0e10cSrcweir } 527cdf0e10cSrcweir 528cdf0e10cSrcweir sal_Bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i_pPoints, 529cdf0e10cSrcweir const SalPoint* const* i_pPtAry, const sal_uInt8* const* i_pFlgAry, const OutputDevice* i_pOutDev ) 530cdf0e10cSrcweir { 531cdf0e10cSrcweir sal_Bool bRet = sal_False; 532cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) ) 533cdf0e10cSrcweir { 534cdf0e10cSrcweir // TODO: optimize, reduce new/delete calls 535cdf0e10cSrcweir SalPoint **pPtAry2 = new SalPoint*[i_nPoly]; 536cdf0e10cSrcweir sal_uLong i; 537cdf0e10cSrcweir for(i=0; i<i_nPoly; i++) 538cdf0e10cSrcweir { 539cdf0e10cSrcweir sal_uLong nPoints = i_pPoints[i]; 540cdf0e10cSrcweir pPtAry2[i] = new SalPoint[ nPoints ]; 541cdf0e10cSrcweir mirror( nPoints, i_pPtAry[i], pPtAry2[i], i_pOutDev ); 542cdf0e10cSrcweir } 543cdf0e10cSrcweir 544cdf0e10cSrcweir bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, (PCONSTSALPOINT*)pPtAry2, i_pFlgAry ); 545cdf0e10cSrcweir 546cdf0e10cSrcweir for(i=0; i<i_nPoly; i++) 547cdf0e10cSrcweir delete [] pPtAry2[i]; 548cdf0e10cSrcweir delete [] pPtAry2; 549cdf0e10cSrcweir } 550cdf0e10cSrcweir else 551cdf0e10cSrcweir bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, i_pPtAry, i_pFlgAry ); 552cdf0e10cSrcweir return bRet; 553cdf0e10cSrcweir } 554cdf0e10cSrcweir 5555aaf853bSArmin Le Grand bool SalGraphics::DrawPolyLine( 5565aaf853bSArmin Le Grand const ::basegfx::B2DPolygon& i_rPolygon, 5575aaf853bSArmin Le Grand double i_fTransparency, 5585aaf853bSArmin Le Grand const ::basegfx::B2DVector& i_rLineWidth, 5595aaf853bSArmin Le Grand basegfx::B2DLineJoin i_eLineJoin, 5605aaf853bSArmin Le Grand com::sun::star::drawing::LineCap i_eLineCap, 561cdf0e10cSrcweir const OutputDevice* i_pOutDev ) 562cdf0e10cSrcweir { 563cdf0e10cSrcweir bool bRet = false; 564cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) ) 565cdf0e10cSrcweir { 566cdf0e10cSrcweir basegfx::B2DPolygon aMirror( mirror( i_rPolygon, i_pOutDev ) ); 5675aaf853bSArmin Le Grand bRet = drawPolyLine( aMirror, i_fTransparency, i_rLineWidth, i_eLineJoin, i_eLineCap ); 568cdf0e10cSrcweir } 569cdf0e10cSrcweir else 5705aaf853bSArmin Le Grand bRet = drawPolyLine( i_rPolygon, i_fTransparency, i_rLineWidth, i_eLineJoin, i_eLineCap ); 571cdf0e10cSrcweir return bRet; 572cdf0e10cSrcweir } 573cdf0e10cSrcweir 574cdf0e10cSrcweir void SalGraphics::CopyArea( long nDestX, long nDestY, 575cdf0e10cSrcweir long nSrcX, long nSrcY, 576cdf0e10cSrcweir long nSrcWidth, long nSrcHeight, 577cdf0e10cSrcweir sal_uInt16 nFlags, const OutputDevice *pOutDev ) 578cdf0e10cSrcweir { 579cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 580cdf0e10cSrcweir { 581cdf0e10cSrcweir mirror( nDestX, nSrcWidth, pOutDev ); 582cdf0e10cSrcweir mirror( nSrcX, nSrcWidth, pOutDev ); 583cdf0e10cSrcweir } 584cdf0e10cSrcweir copyArea( nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, nFlags ); 585cdf0e10cSrcweir } 586cdf0e10cSrcweir void SalGraphics::CopyBits( const SalTwoRect* pPosAry, 587cdf0e10cSrcweir SalGraphics* pSrcGraphics, const OutputDevice *pOutDev, const OutputDevice *pSrcOutDev ) 588cdf0e10cSrcweir { 589cdf0e10cSrcweir if( ( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) || 590cdf0e10cSrcweir (pSrcGraphics && ( (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) ) ) ) 591cdf0e10cSrcweir { 592cdf0e10cSrcweir SalTwoRect pPosAry2 = *pPosAry; 593cdf0e10cSrcweir if( (pSrcGraphics && (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL)) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) ) 594cdf0e10cSrcweir mirror( pPosAry2.mnSrcX, pPosAry2.mnSrcWidth, pSrcOutDev ); 595cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 596cdf0e10cSrcweir mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev ); 597cdf0e10cSrcweir copyBits( &pPosAry2, pSrcGraphics ); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir else 600cdf0e10cSrcweir copyBits( pPosAry, pSrcGraphics ); 601cdf0e10cSrcweir } 602cdf0e10cSrcweir void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, 603cdf0e10cSrcweir const SalBitmap& rSalBitmap, const OutputDevice *pOutDev ) 604cdf0e10cSrcweir { 605cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir SalTwoRect pPosAry2 = *pPosAry; 608cdf0e10cSrcweir mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev ); 609cdf0e10cSrcweir drawBitmap( &pPosAry2, rSalBitmap ); 610cdf0e10cSrcweir } 611cdf0e10cSrcweir else 612cdf0e10cSrcweir drawBitmap( pPosAry, rSalBitmap ); 613cdf0e10cSrcweir } 614cdf0e10cSrcweir void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, 615cdf0e10cSrcweir const SalBitmap& rSalBitmap, 616cdf0e10cSrcweir SalColor nTransparentColor, const OutputDevice *pOutDev ) 617cdf0e10cSrcweir { 618cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 619cdf0e10cSrcweir { 620cdf0e10cSrcweir SalTwoRect pPosAry2 = *pPosAry; 621cdf0e10cSrcweir mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev ); 622cdf0e10cSrcweir drawBitmap( &pPosAry2, rSalBitmap, nTransparentColor ); 623cdf0e10cSrcweir } 624cdf0e10cSrcweir else 625cdf0e10cSrcweir drawBitmap( pPosAry, rSalBitmap, nTransparentColor ); 626cdf0e10cSrcweir } 627cdf0e10cSrcweir void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry, 628cdf0e10cSrcweir const SalBitmap& rSalBitmap, 629cdf0e10cSrcweir const SalBitmap& rTransparentBitmap, const OutputDevice *pOutDev ) 630cdf0e10cSrcweir { 631cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 632cdf0e10cSrcweir { 633cdf0e10cSrcweir SalTwoRect pPosAry2 = *pPosAry; 634cdf0e10cSrcweir mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev ); 635cdf0e10cSrcweir drawBitmap( &pPosAry2, rSalBitmap, rTransparentBitmap ); 636cdf0e10cSrcweir } 637cdf0e10cSrcweir else 638cdf0e10cSrcweir drawBitmap( pPosAry, rSalBitmap, rTransparentBitmap ); 639cdf0e10cSrcweir } 640cdf0e10cSrcweir void SalGraphics::DrawMask( const SalTwoRect* pPosAry, 641cdf0e10cSrcweir const SalBitmap& rSalBitmap, 642cdf0e10cSrcweir SalColor nMaskColor, const OutputDevice *pOutDev ) 643cdf0e10cSrcweir { 644cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 645cdf0e10cSrcweir { 646cdf0e10cSrcweir SalTwoRect pPosAry2 = *pPosAry; 647cdf0e10cSrcweir mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev ); 648cdf0e10cSrcweir drawMask( &pPosAry2, rSalBitmap, nMaskColor ); 649cdf0e10cSrcweir } 650cdf0e10cSrcweir else 651cdf0e10cSrcweir drawMask( pPosAry, rSalBitmap, nMaskColor ); 652cdf0e10cSrcweir } 653cdf0e10cSrcweir SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev ) 654cdf0e10cSrcweir { 655cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 656cdf0e10cSrcweir mirror( nX, nWidth, pOutDev ); 657cdf0e10cSrcweir return getBitmap( nX, nY, nWidth, nHeight ); 658cdf0e10cSrcweir } 659cdf0e10cSrcweir SalColor SalGraphics::GetPixel( long nX, long nY, const OutputDevice *pOutDev ) 660cdf0e10cSrcweir { 661cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 662cdf0e10cSrcweir mirror( nX, pOutDev ); 663cdf0e10cSrcweir return getPixel( nX, nY ); 664cdf0e10cSrcweir } 665cdf0e10cSrcweir void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags, const OutputDevice *pOutDev ) 666cdf0e10cSrcweir { 667cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 668cdf0e10cSrcweir mirror( nX, nWidth, pOutDev ); 669cdf0e10cSrcweir invert( nX, nY, nWidth, nHeight, nFlags ); 670cdf0e10cSrcweir } 671cdf0e10cSrcweir void SalGraphics::Invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags, const OutputDevice *pOutDev ) 672cdf0e10cSrcweir { 673cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 674cdf0e10cSrcweir { 675cdf0e10cSrcweir SalPoint* pPtAry2 = new SalPoint[nPoints]; 676cdf0e10cSrcweir sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev ); 677cdf0e10cSrcweir invert( nPoints, bCopied ? pPtAry2 : pPtAry, nFlags ); 678cdf0e10cSrcweir delete [] pPtAry2; 679cdf0e10cSrcweir } 680cdf0e10cSrcweir else 681cdf0e10cSrcweir invert( nPoints, pPtAry, nFlags ); 682cdf0e10cSrcweir } 683cdf0e10cSrcweir 684cdf0e10cSrcweir sal_Bool SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize, const OutputDevice *pOutDev ) 685cdf0e10cSrcweir { 686cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 687cdf0e10cSrcweir mirror( nX, nWidth, pOutDev ); 688cdf0e10cSrcweir return drawEPS( nX, nY, nWidth, nHeight, pPtr, nSize ); 689cdf0e10cSrcweir } 690cdf0e10cSrcweir 691cdf0e10cSrcweir sal_Bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, 692cdf0e10cSrcweir const Point& aPos, sal_Bool& rIsInside, const OutputDevice *pOutDev ) 693cdf0e10cSrcweir { 694cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 695cdf0e10cSrcweir { 696cdf0e10cSrcweir Point pt( aPos ); 697cdf0e10cSrcweir Rectangle rgn( rControlRegion ); 698cdf0e10cSrcweir mirror( pt.X(), pOutDev ); 699cdf0e10cSrcweir mirror( rgn, pOutDev ); 700cdf0e10cSrcweir return hitTestNativeControl( nType, nPart, rgn, pt, rIsInside ); 701cdf0e10cSrcweir } 702cdf0e10cSrcweir else 703cdf0e10cSrcweir return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rIsInside ); 704cdf0e10cSrcweir } 705cdf0e10cSrcweir 706cdf0e10cSrcweir void SalGraphics::mirror( ControlType , const ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const 707cdf0e10cSrcweir { 708cdf0e10cSrcweir switch( rVal.getType() ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir case CTRL_SLIDER: 711cdf0e10cSrcweir { 712cdf0e10cSrcweir SliderValue* pSlVal = static_cast<SliderValue*>(const_cast<ImplControlValue*>(&rVal)); 713cdf0e10cSrcweir mirror(pSlVal->maThumbRect,pOutDev,bBack); 714cdf0e10cSrcweir } 715cdf0e10cSrcweir break; 716cdf0e10cSrcweir case CTRL_SCROLLBAR: 717cdf0e10cSrcweir { 718cdf0e10cSrcweir ScrollbarValue* pScVal = static_cast<ScrollbarValue*>(const_cast<ImplControlValue*>(&rVal)); 719cdf0e10cSrcweir mirror(pScVal->maThumbRect,pOutDev,bBack); 720cdf0e10cSrcweir mirror(pScVal->maButton1Rect,pOutDev,bBack); 721cdf0e10cSrcweir mirror(pScVal->maButton2Rect,pOutDev,bBack); 722cdf0e10cSrcweir } 723cdf0e10cSrcweir break; 724cdf0e10cSrcweir case CTRL_SPINBOX: 725cdf0e10cSrcweir case CTRL_SPINBUTTONS: 726cdf0e10cSrcweir { 727cdf0e10cSrcweir SpinbuttonValue* pSpVal = static_cast<SpinbuttonValue*>(const_cast<ImplControlValue*>(&rVal)); 728cdf0e10cSrcweir mirror(pSpVal->maUpperRect,pOutDev,bBack); 729cdf0e10cSrcweir mirror(pSpVal->maLowerRect,pOutDev,bBack); 730cdf0e10cSrcweir } 731cdf0e10cSrcweir break; 732cdf0e10cSrcweir case CTRL_TOOLBAR: 733cdf0e10cSrcweir { 734cdf0e10cSrcweir ToolbarValue* pTVal = static_cast<ToolbarValue*>(const_cast<ImplControlValue*>(&rVal)); 735cdf0e10cSrcweir mirror(pTVal->maGripRect,pOutDev,bBack); 736cdf0e10cSrcweir } 737cdf0e10cSrcweir break; 738cdf0e10cSrcweir } 739cdf0e10cSrcweir } 740cdf0e10cSrcweir 741cdf0e10cSrcweir sal_Bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, 742cdf0e10cSrcweir ControlState nState, const ImplControlValue& aValue, 743cdf0e10cSrcweir const OUString& aCaption, const OutputDevice *pOutDev ) 744cdf0e10cSrcweir { 745cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 746cdf0e10cSrcweir { 747cdf0e10cSrcweir Rectangle rgn( rControlRegion ); 748cdf0e10cSrcweir mirror( rgn, pOutDev ); 749cdf0e10cSrcweir mirror( nType, aValue, pOutDev ); 750cdf0e10cSrcweir sal_Bool bRet = drawNativeControl( nType, nPart, rgn, nState, aValue, aCaption ); 751cdf0e10cSrcweir mirror( nType, aValue, pOutDev, true ); 752cdf0e10cSrcweir return bRet; 753cdf0e10cSrcweir } 754cdf0e10cSrcweir else 755cdf0e10cSrcweir return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption ); 756cdf0e10cSrcweir } 757cdf0e10cSrcweir 758cdf0e10cSrcweir sal_Bool SalGraphics::DrawNativeControlText( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, 759cdf0e10cSrcweir ControlState nState, const ImplControlValue& aValue, 760cdf0e10cSrcweir const OUString& aCaption, const OutputDevice *pOutDev ) 761cdf0e10cSrcweir { 762cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 763cdf0e10cSrcweir { 764cdf0e10cSrcweir Rectangle rgn( rControlRegion ); 765cdf0e10cSrcweir mirror( rgn, pOutDev ); 766cdf0e10cSrcweir mirror( nType, aValue, pOutDev ); 767cdf0e10cSrcweir sal_Bool bRet = drawNativeControlText( nType, nPart, rgn, nState, aValue, aCaption ); 768cdf0e10cSrcweir mirror( nType, aValue, pOutDev, true ); 769cdf0e10cSrcweir return bRet; 770cdf0e10cSrcweir } 771cdf0e10cSrcweir else 772cdf0e10cSrcweir return drawNativeControlText( nType, nPart, rControlRegion, nState, aValue, aCaption ); 773cdf0e10cSrcweir } 774cdf0e10cSrcweir 775cdf0e10cSrcweir sal_Bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState, 776cdf0e10cSrcweir const ImplControlValue& aValue, const OUString& aCaption, 777cdf0e10cSrcweir Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion, const OutputDevice *pOutDev ) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 780cdf0e10cSrcweir { 781cdf0e10cSrcweir Rectangle rgn( rControlRegion ); 782cdf0e10cSrcweir mirror( rgn, pOutDev ); 783cdf0e10cSrcweir mirror( nType, aValue, pOutDev ); 784cdf0e10cSrcweir if( getNativeControlRegion( nType, nPart, rgn, nState, aValue, aCaption, 785cdf0e10cSrcweir rNativeBoundingRegion, rNativeContentRegion ) ) 786cdf0e10cSrcweir { 787cdf0e10cSrcweir mirror( rNativeBoundingRegion, pOutDev, true ); 788cdf0e10cSrcweir mirror( rNativeContentRegion, pOutDev, true ); 789cdf0e10cSrcweir mirror( nType, aValue, pOutDev, true ); 790cdf0e10cSrcweir return sal_True; 791cdf0e10cSrcweir } 792cdf0e10cSrcweir else 793cdf0e10cSrcweir { 794cdf0e10cSrcweir mirror( nType, aValue, pOutDev, true ); 795cdf0e10cSrcweir return sal_False; 796cdf0e10cSrcweir } 797cdf0e10cSrcweir } 798cdf0e10cSrcweir else 799cdf0e10cSrcweir return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, aCaption, 800cdf0e10cSrcweir rNativeBoundingRegion, rNativeContentRegion ); 801cdf0e10cSrcweir } 802cdf0e10cSrcweir 803cdf0e10cSrcweir bool SalGraphics::DrawAlphaBitmap( const SalTwoRect& rPosAry, 804cdf0e10cSrcweir const SalBitmap& rSourceBitmap, 805cdf0e10cSrcweir const SalBitmap& rAlphaBitmap, 806cdf0e10cSrcweir const OutputDevice *pOutDev ) 807cdf0e10cSrcweir { 808cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 809cdf0e10cSrcweir { 810cdf0e10cSrcweir SalTwoRect pPosAry2 = rPosAry; 811cdf0e10cSrcweir mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev ); 812cdf0e10cSrcweir return drawAlphaBitmap( pPosAry2, rSourceBitmap, rAlphaBitmap ); 813cdf0e10cSrcweir } 814cdf0e10cSrcweir else 815cdf0e10cSrcweir return drawAlphaBitmap( rPosAry, rSourceBitmap, rAlphaBitmap ); 816cdf0e10cSrcweir } 817cdf0e10cSrcweir 818cdf0e10cSrcweir bool SalGraphics::DrawAlphaRect( long nX, long nY, long nWidth, long nHeight, 819cdf0e10cSrcweir sal_uInt8 nTransparency, const OutputDevice *pOutDev ) 820cdf0e10cSrcweir { 821cdf0e10cSrcweir if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) 822cdf0e10cSrcweir mirror( nX, nWidth, pOutDev ); 823cdf0e10cSrcweir 824cdf0e10cSrcweir return drawAlphaRect( nX, nY, nWidth, nHeight, nTransparency ); 825cdf0e10cSrcweir } 826cdf0e10cSrcweir 827cdf0e10cSrcweir bool SalGraphics::filterText( const String&, String&, xub_StrLen, xub_StrLen&, xub_StrLen&, xub_StrLen& ) 828cdf0e10cSrcweir { 829cdf0e10cSrcweir return false; 830cdf0e10cSrcweir } 831cdf0e10cSrcweir 832cdf0e10cSrcweir void SalGraphics::AddDevFontSubstitute( OutputDevice* pOutDev, 833cdf0e10cSrcweir const String& rFontName, 834cdf0e10cSrcweir const String& rReplaceFontName, 835cdf0e10cSrcweir sal_uInt16 nFlags ) 836cdf0e10cSrcweir { 837cdf0e10cSrcweir pOutDev->ImplAddDevFontSubstitute( rFontName, rReplaceFontName, nFlags ); 838cdf0e10cSrcweir } 839cdf0e10cSrcweir 840