update dev300-m58
[ooovba.git] / vcl / source / gdi / salgdilayout.cxx
blob9ed20ce4d8629dfcde1b47c32f2accfff2528d8c
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: salgdilayout.cxx,v $
10 * $Revision: 1.31.30.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_vcl.hxx"
34 #include <tools/ref.hxx>
35 #ifndef _SV_SVSYS_HXX
36 #include <svsys.h>
37 #endif
38 #include <vcl/salgdi.hxx>
39 #include <vcl/salframe.hxx>
40 #include <vcl/salvd.hxx>
41 #include <vcl/salprn.hxx>
42 #include <tools/debug.hxx>
43 #include <vcl/svdata.hxx>
44 #include <vcl/svapp.hxx>
45 #include <tools/poly.hxx>
46 #include <vcl/region.hxx>
47 #include <vcl/region.h>
48 #include <vcl/virdev.hxx>
49 #include <vcl/window.h>
50 #include <vcl/window.hxx>
51 #include <vcl/metaact.hxx>
52 #include <vcl/gdimtf.hxx>
53 #include <vcl/outdata.hxx>
54 #include <vcl/print.hxx>
55 #include <implncvt.hxx>
56 #include <vcl/outdev.h>
57 #include <vcl/outdev.hxx>
58 #include <vcl/unowrap.hxx>
59 #include <vcl/sallayout.hxx>
60 #include "basegfx/polygon/b2dpolygon.hxx"
62 // ----------------------------------------------------------------------------
63 // The only common SalFrame method
64 // ----------------------------------------------------------------------------
66 SalFrameGeometry SalFrame::GetGeometry()
68 // mirror frame coordinates at parent
69 SalFrame *pParent = GetParent();
70 if( pParent && Application::GetSettings().GetLayoutRTL() )
72 SalFrameGeometry aGeom = maGeometry;
73 int parent_x = aGeom.nX - pParent->maGeometry.nX;
74 aGeom.nX = pParent->maGeometry.nX + pParent->maGeometry.nWidth - maGeometry.nWidth - parent_x;
75 return aGeom;
77 else
78 return maGeometry;
81 // ----------------------------------------------------------------------------
83 SalGraphics::SalGraphics()
84 : m_nLayout( 0 ),
85 m_bAntiAliasB2DDraw(false)
87 // read global RTL settings
88 if( Application::GetSettings().GetLayoutRTL() )
89 m_nLayout = SAL_LAYOUT_BIDI_RTL;
92 SalGraphics::~SalGraphics()
96 // ----------------------------------------------------------------------------
98 bool SalGraphics::drawAlphaBitmap( const SalTwoRect&,
99 const SalBitmap&, const SalBitmap& )
101 return false;
104 // ----------------------------------------------------------------------------
106 void SalGraphics::mirror( long& x, const OutputDevice *pOutDev, bool bBack ) const
108 long w;
109 if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
110 w = pOutDev->GetOutputWidthPixel();
111 else
112 w = GetGraphicsWidth();
114 if( w )
116 if( pOutDev && pOutDev->ImplIsAntiparallel() )
118 OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
119 // mirror this window back
120 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
122 long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
123 if( bBack )
124 x = x - devX + pOutDevRef->GetOutOffXPixel();
125 else
126 x = devX + (x - pOutDevRef->GetOutOffXPixel());
128 else
130 long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
131 if( bBack )
132 x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
133 else
134 x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - 1;
137 else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
138 x = w-1-x;
142 void SalGraphics::mirror( long& x, long& nWidth, const OutputDevice *pOutDev, bool bBack ) const
144 long w;
145 if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
146 w = pOutDev->GetOutputWidthPixel();
147 else
148 w = GetGraphicsWidth();
150 if( w )
152 if( pOutDev && pOutDev->ImplIsAntiparallel() )
154 OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
155 // mirror this window back
156 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
158 long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
159 if( bBack )
160 x = x - devX + pOutDevRef->GetOutOffXPixel();
161 else
162 x = devX + (x - pOutDevRef->GetOutOffXPixel());
164 else
166 long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
167 if( bBack )
168 x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + nWidth;
169 else
170 x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - nWidth;
173 else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
174 x = w-nWidth-x;
179 BOOL SalGraphics::mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint *pPtAry2, const OutputDevice *pOutDev, bool bBack ) const
181 long w;
182 if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
183 w = pOutDev->GetOutputWidthPixel();
184 else
185 w = GetGraphicsWidth();
187 if( w )
189 sal_uInt32 i, j;
191 if( pOutDev && pOutDev->ImplIsAntiparallel() )
193 OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
194 // mirror this window back
195 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
197 long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
198 if( bBack )
200 for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
202 //long x = w-1-pPtAry[i].mnX;
203 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
204 pPtAry2[j].mnX = pOutDevRef->GetOutOffXPixel() + (pPtAry[i].mnX - devX);
205 pPtAry2[j].mnY = pPtAry[i].mnY;
208 else
210 for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
212 //long x = w-1-pPtAry[i].mnX;
213 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
214 pPtAry2[j].mnX = devX + (pPtAry[i].mnX - pOutDevRef->GetOutOffXPixel());
215 pPtAry2[j].mnY = pPtAry[i].mnY;
219 else
221 long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
222 if( bBack )
224 for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
226 //long x = w-1-pPtAry[i].mnX;
227 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
228 pPtAry2[j].mnX = pPtAry[i].mnX - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
229 pPtAry2[j].mnY = pPtAry[i].mnY;
232 else
234 for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
236 //long x = w-1-pPtAry[i].mnX;
237 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
238 pPtAry2[j].mnX = pOutDevRef->GetOutputWidthPixel() - (pPtAry[i].mnX - devX) + pOutDevRef->GetOutOffXPixel() - 1;
239 pPtAry2[j].mnY = pPtAry[i].mnY;
244 else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
246 for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
248 pPtAry2[j].mnX = w-1-pPtAry[i].mnX;
249 pPtAry2[j].mnY = pPtAry[i].mnY;
252 return TRUE;
254 else
255 return FALSE;
258 void SalGraphics::mirror( Region& rRgn, const OutputDevice *pOutDev, bool bBack ) const
260 // mirror the bounding rect and move Region by resulting offset
261 Rectangle aRect( rRgn.GetBoundRect() );
262 long nWidth = aRect.GetWidth();
263 long x = aRect.Left();
264 long x_org = x;
266 mirror( x, nWidth, pOutDev, bBack );
267 rRgn.Move( x - x_org, 0 );
270 void SalGraphics::mirror( Rectangle& rRect, const OutputDevice *pOutDev, bool bBack ) const
272 long nWidth = rRect.GetWidth();
273 long x = rRect.Left();
274 long x_org = x;
276 mirror( x, nWidth, pOutDev, bBack );
277 rRect.Move( x - x_org, 0 );
280 basegfx::B2DPoint SalGraphics::mirror( const basegfx::B2DPoint& i_rPoint, const OutputDevice *i_pOutDev, bool i_bBack ) const
282 long w;
283 if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
284 w = i_pOutDev->GetOutputWidthPixel();
285 else
286 w = GetGraphicsWidth();
288 DBG_ASSERT( w, "missing graphics width" );
290 basegfx::B2DPoint aRet( i_rPoint );
291 if( w )
293 if( i_pOutDev && !i_pOutDev->IsRTLEnabled() )
295 OutputDevice *pOutDevRef = (OutputDevice*)i_pOutDev;
296 // mirror this window back
297 double devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
298 if( i_bBack )
299 aRet.setX( i_rPoint.getX() - devX + pOutDevRef->GetOutOffXPixel() );
300 else
301 aRet.setX( devX + (i_rPoint.getX() - pOutDevRef->GetOutOffXPixel()) );
303 else
304 aRet.setX( w-1-i_rPoint.getX() );
306 return aRet;
309 basegfx::B2DPolygon SalGraphics::mirror( const basegfx::B2DPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
311 long w;
312 if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
313 w = i_pOutDev->GetOutputWidthPixel();
314 else
315 w = GetGraphicsWidth();
317 DBG_ASSERT( w, "missing graphics width" );
319 basegfx::B2DPolygon aRet;
320 if( w )
322 sal_Int32 nPoints = i_rPoly.count();
323 for( sal_Int32 i = 0; i < nPoints; i++ )
325 aRet.append( mirror( i_rPoly.getB2DPoint( i ), i_pOutDev, i_bBack ) );
326 if( i_rPoly.isPrevControlPointUsed( i ) )
327 aRet.setPrevControlPoint( i, mirror( i_rPoly.getPrevControlPoint( i ), i_pOutDev, i_bBack ) );
328 if( i_rPoly.isNextControlPointUsed( i ) )
329 aRet.setNextControlPoint( i, mirror( i_rPoly.getNextControlPoint( i ), i_pOutDev, i_bBack ) );
331 aRet.setClosed( i_rPoly.isClosed() );
332 aRet.flip();
334 else
335 aRet = i_rPoly;
336 return aRet;
339 basegfx::B2DPolyPolygon SalGraphics::mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
341 long w;
342 if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
343 w = i_pOutDev->GetOutputWidthPixel();
344 else
345 w = GetGraphicsWidth();
347 DBG_ASSERT( w, "missing graphics width" );
349 basegfx::B2DPolyPolygon aRet;
350 if( w )
352 sal_Int32 nPoly = i_rPoly.count();
353 for( sal_Int32 i = 0; i < nPoly; i++ )
354 aRet.append( mirror( i_rPoly.getB2DPolygon( i ), i_pOutDev, i_bBack ) );
355 aRet.setClosed( i_rPoly.isClosed() );
356 aRet.flip();
358 else
359 aRet = i_rPoly;
360 return aRet;
363 // ----------------------------------------------------------------------------
365 BOOL SalGraphics::UnionClipRegion( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
367 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
368 mirror( nX, nWidth, pOutDev );
369 return unionClipRegion( nX, nY, nWidth, nHeight );
372 bool SalGraphics::unionClipRegion( const ::basegfx::B2DPolyPolygon& )
374 return false;
377 BOOL SalGraphics::UnionClipRegion( const ::basegfx::B2DPolyPolygon& rPoly, const OutputDevice* pOutDev )
379 (void)pOutDev;// TODO: SAL_LAYOUT_BIDI_RTL
380 return unionClipRegion( rPoly );
383 void SalGraphics::DrawPixel( long nX, long nY, const OutputDevice *pOutDev )
385 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
386 mirror( nX, pOutDev );
387 drawPixel( nX, nY );
389 void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor, const OutputDevice *pOutDev )
391 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
392 mirror( nX, pOutDev );
393 drawPixel( nX, nY, nSalColor );
395 void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2, const OutputDevice *pOutDev )
397 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
399 mirror( nX1, pOutDev );
400 mirror( nX2, pOutDev );
402 drawLine( nX1, nY1, nX2, nY2 );
404 void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
406 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
407 mirror( nX, nWidth, pOutDev );
408 drawRect( nX, nY, nWidth, nHeight );
410 bool SalGraphics::drawPolyLine(
411 const basegfx::B2DPolygon& /*rPolyPolygon*/,
412 const basegfx::B2DVector& /*rLineWidths*/,
413 basegfx::B2DLineJoin /*eLineJoin*/)
415 return false;
418 void SalGraphics::DrawPolyLine( ULONG nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
420 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
422 SalPoint* pPtAry2 = new SalPoint[nPoints];
423 BOOL bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
424 drawPolyLine( nPoints, bCopied ? pPtAry2 : pPtAry );
425 delete [] pPtAry2;
427 else
428 drawPolyLine( nPoints, pPtAry );
431 void SalGraphics::DrawPolygon( ULONG nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
433 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
435 SalPoint* pPtAry2 = new SalPoint[nPoints];
436 BOOL bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
437 drawPolygon( nPoints, bCopied ? pPtAry2 : pPtAry );
438 delete [] pPtAry2;
440 else
441 drawPolygon( nPoints, pPtAry );
444 void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry, const OutputDevice *pOutDev )
446 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
448 // TODO: optimize, reduce new/delete calls
449 SalPoint **pPtAry2 = new SalPoint*[nPoly];
450 ULONG i;
451 for(i=0; i<nPoly; i++)
453 ULONG nPoints = pPoints[i];
454 pPtAry2[i] = new SalPoint[ nPoints ];
455 mirror( nPoints, pPtAry[i], pPtAry2[i], pOutDev );
458 drawPolyPolygon( nPoly, pPoints, (PCONSTSALPOINT*)pPtAry2 );
460 for(i=0; i<nPoly; i++)
461 delete [] pPtAry2[i];
462 delete [] pPtAry2;
464 else
465 drawPolyPolygon( nPoly, pPoints, pPtAry );
468 bool SalGraphics::DrawPolyPolygon( const ::basegfx::B2DPolyPolygon& i_rPolyPolygon, double i_fTransparency, const OutputDevice* i_pOutDev )
470 bool bRet = false;
471 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
473 basegfx::B2DPolyPolygon aMirror( mirror( i_rPolyPolygon, i_pOutDev ) );
474 bRet = drawPolyPolygon( aMirror, i_fTransparency );
476 else
477 bRet = drawPolyPolygon( i_rPolyPolygon, i_fTransparency );
478 return bRet;
481 bool SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon&, double /*fTransparency*/)
483 return false;
486 sal_Bool SalGraphics::DrawPolyLineBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry, const OutputDevice* pOutDev )
488 sal_Bool bResult = sal_False;
489 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
491 SalPoint* pPtAry2 = new SalPoint[nPoints];
492 BOOL bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
493 bResult = drawPolyLineBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry );
494 delete [] pPtAry2;
496 else
497 bResult = drawPolyLineBezier( nPoints, pPtAry, pFlgAry );
498 return bResult;
501 sal_Bool SalGraphics::DrawPolygonBezier( ULONG nPoints, const SalPoint* pPtAry, const BYTE* pFlgAry, const OutputDevice* pOutDev )
503 sal_Bool bResult = sal_False;
504 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
506 SalPoint* pPtAry2 = new SalPoint[nPoints];
507 BOOL bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
508 bResult = drawPolygonBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry );
509 delete [] pPtAry2;
511 else
512 bResult = drawPolygonBezier( nPoints, pPtAry, pFlgAry );
513 return bResult;
516 sal_Bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i_pPoints,
517 const SalPoint* const* i_pPtAry, const BYTE* const* i_pFlgAry, const OutputDevice* i_pOutDev )
519 sal_Bool bRet = sal_False;
520 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
522 // TODO: optimize, reduce new/delete calls
523 SalPoint **pPtAry2 = new SalPoint*[i_nPoly];
524 ULONG i;
525 for(i=0; i<i_nPoly; i++)
527 ULONG nPoints = i_pPoints[i];
528 pPtAry2[i] = new SalPoint[ nPoints ];
529 mirror( nPoints, i_pPtAry[i], pPtAry2[i], i_pOutDev );
532 bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, (PCONSTSALPOINT*)pPtAry2, i_pFlgAry );
534 for(i=0; i<i_nPoly; i++)
535 delete [] pPtAry2[i];
536 delete [] pPtAry2;
538 else
539 bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, i_pPtAry, i_pFlgAry );
540 return bRet;
543 bool SalGraphics::DrawPolyLine( const ::basegfx::B2DPolygon& i_rPolygon,
544 const ::basegfx::B2DVector& i_rLineWidth, basegfx::B2DLineJoin i_eLineJoin,
545 const OutputDevice* i_pOutDev )
547 bool bRet = false;
548 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
550 basegfx::B2DPolygon aMirror( mirror( i_rPolygon, i_pOutDev ) );
551 bRet = drawPolyLine( aMirror, i_rLineWidth, i_eLineJoin );
553 else
554 bRet = drawPolyLine( i_rPolygon, i_rLineWidth, i_eLineJoin );
555 return bRet;
558 void SalGraphics::CopyArea( long nDestX, long nDestY,
559 long nSrcX, long nSrcY,
560 long nSrcWidth, long nSrcHeight,
561 USHORT nFlags, const OutputDevice *pOutDev )
563 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
565 mirror( nDestX, nSrcWidth, pOutDev );
566 mirror( nSrcX, nSrcWidth, pOutDev );
568 copyArea( nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, nFlags );
570 void SalGraphics::CopyBits( const SalTwoRect* pPosAry,
571 SalGraphics* pSrcGraphics, const OutputDevice *pOutDev, const OutputDevice *pSrcOutDev )
573 if( ( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) ||
574 (pSrcGraphics && ( (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) ) ) )
576 SalTwoRect pPosAry2 = *pPosAry;
577 if( (pSrcGraphics && (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL)) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) )
578 mirror( pPosAry2.mnSrcX, pPosAry2.mnSrcWidth, pSrcOutDev );
579 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
580 mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
581 copyBits( &pPosAry2, pSrcGraphics );
583 else
584 copyBits( pPosAry, pSrcGraphics );
586 void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
587 const SalBitmap& rSalBitmap, const OutputDevice *pOutDev )
589 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
591 SalTwoRect pPosAry2 = *pPosAry;
592 mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
593 drawBitmap( &pPosAry2, rSalBitmap );
595 else
596 drawBitmap( pPosAry, rSalBitmap );
598 void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
599 const SalBitmap& rSalBitmap,
600 SalColor nTransparentColor, const OutputDevice *pOutDev )
602 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
604 SalTwoRect pPosAry2 = *pPosAry;
605 mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
606 drawBitmap( &pPosAry2, rSalBitmap, nTransparentColor );
608 else
609 drawBitmap( pPosAry, rSalBitmap, nTransparentColor );
611 void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
612 const SalBitmap& rSalBitmap,
613 const SalBitmap& rTransparentBitmap, const OutputDevice *pOutDev )
615 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
617 SalTwoRect pPosAry2 = *pPosAry;
618 mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
619 drawBitmap( &pPosAry2, rSalBitmap, rTransparentBitmap );
621 else
622 drawBitmap( pPosAry, rSalBitmap, rTransparentBitmap );
624 void SalGraphics::DrawMask( const SalTwoRect* pPosAry,
625 const SalBitmap& rSalBitmap,
626 SalColor nMaskColor, const OutputDevice *pOutDev )
628 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
630 SalTwoRect pPosAry2 = *pPosAry;
631 mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
632 drawMask( &pPosAry2, rSalBitmap, nMaskColor );
634 else
635 drawMask( pPosAry, rSalBitmap, nMaskColor );
637 SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
639 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
640 mirror( nX, nWidth, pOutDev );
641 return getBitmap( nX, nY, nWidth, nHeight );
643 SalColor SalGraphics::GetPixel( long nX, long nY, const OutputDevice *pOutDev )
645 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
646 mirror( nX, pOutDev );
647 return getPixel( nX, nY );
649 void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags, const OutputDevice *pOutDev )
651 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
652 mirror( nX, nWidth, pOutDev );
653 invert( nX, nY, nWidth, nHeight, nFlags );
655 void SalGraphics::Invert( ULONG nPoints, const SalPoint* pPtAry, SalInvert nFlags, const OutputDevice *pOutDev )
657 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
659 SalPoint* pPtAry2 = new SalPoint[nPoints];
660 BOOL bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
661 invert( nPoints, bCopied ? pPtAry2 : pPtAry, nFlags );
662 delete [] pPtAry2;
664 else
665 invert( nPoints, pPtAry, nFlags );
668 BOOL SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, ULONG nSize, const OutputDevice *pOutDev )
670 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
671 mirror( nX, nWidth, pOutDev );
672 return drawEPS( nX, nY, nWidth, nHeight, pPtr, nSize );
675 BOOL SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion,
676 const Point& aPos, SalControlHandle& rControlHandle, BOOL& rIsInside, const OutputDevice *pOutDev )
678 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
680 Point pt( aPos );
681 Region rgn( rControlRegion );
682 mirror( pt.X(), pOutDev );
683 mirror( rgn, pOutDev );
684 return hitTestNativeControl( nType, nPart, rgn, pt, rControlHandle, rIsInside );
686 else
687 return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rControlHandle, rIsInside );
690 void SalGraphics::mirror( ControlType nType, const ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const
692 if( rVal.getOptionalVal() )
694 switch( nType )
696 case CTRL_SCROLLBAR:
698 ScrollbarValue* pScVal = reinterpret_cast<ScrollbarValue*>(rVal.getOptionalVal());
699 mirror(pScVal->maThumbRect,pOutDev,bBack);
700 mirror(pScVal->maButton1Rect,pOutDev,bBack);
701 mirror(pScVal->maButton2Rect,pOutDev,bBack);
703 break;
704 case CTRL_SPINBOX:
705 case CTRL_SPINBUTTONS:
707 SpinbuttonValue* pSpVal = reinterpret_cast<SpinbuttonValue*>(rVal.getOptionalVal());
708 mirror(pSpVal->maUpperRect,pOutDev,bBack);
709 mirror(pSpVal->maLowerRect,pOutDev,bBack);
711 break;
712 case CTRL_TOOLBAR:
714 ToolbarValue* pTVal = reinterpret_cast<ToolbarValue*>(rVal.getOptionalVal());
715 mirror(pTVal->maGripRect,pOutDev,bBack);
717 break;
722 BOOL SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Region& rControlRegion,
723 ControlState nState, const ImplControlValue& aValue, SalControlHandle& rControlHandle,
724 const OUString& aCaption, const OutputDevice *pOutDev )
726 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
728 Region rgn( rControlRegion );
729 mirror( rgn, pOutDev );
730 mirror( nType, aValue, pOutDev );
731 BOOL bRet = drawNativeControl( nType, nPart, rgn, nState, aValue, rControlHandle, aCaption );
732 mirror( nType, aValue, pOutDev, true );
733 return bRet;
735 else
736 return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, rControlHandle, aCaption );
739 BOOL SalGraphics::DrawNativeControlText( ControlType nType, ControlPart nPart, const Region& rControlRegion,
740 ControlState nState, const ImplControlValue& aValue,
741 SalControlHandle& rControlHandle, const OUString& aCaption, const OutputDevice *pOutDev )
743 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
745 Region rgn( rControlRegion );
746 mirror( rgn, pOutDev );
747 mirror( nType, aValue, pOutDev );
748 BOOL bRet = drawNativeControlText( nType, nPart, rgn, nState, aValue, rControlHandle, aCaption );
749 mirror( nType, aValue, pOutDev, true );
750 return bRet;
752 else
753 return drawNativeControlText( nType, nPart, rControlRegion, nState, aValue, rControlHandle, aCaption );
756 BOOL SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Region& rControlRegion, ControlState nState,
757 const ImplControlValue& aValue, SalControlHandle& rControlHandle, const OUString& aCaption,
758 Region &rNativeBoundingRegion, Region &rNativeContentRegion, const OutputDevice *pOutDev )
760 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
762 Region rgn( rControlRegion );
763 mirror( rgn, pOutDev );
764 mirror( nType, aValue, pOutDev );
765 if( getNativeControlRegion( nType, nPart, rgn, nState, aValue, rControlHandle, aCaption,
766 rNativeBoundingRegion, rNativeContentRegion ) )
768 mirror( rNativeBoundingRegion, pOutDev, true );
769 mirror( rNativeContentRegion, pOutDev, true );
770 mirror( nType, aValue, pOutDev, true );
771 return TRUE;
773 else
775 mirror( nType, aValue, pOutDev, true );
776 return FALSE;
779 else
780 return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, rControlHandle, aCaption,
781 rNativeBoundingRegion, rNativeContentRegion );
784 bool SalGraphics::DrawAlphaBitmap( const SalTwoRect& rPosAry,
785 const SalBitmap& rSourceBitmap,
786 const SalBitmap& rAlphaBitmap,
787 const OutputDevice *pOutDev )
789 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
791 SalTwoRect pPosAry2 = rPosAry;
792 mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
793 return drawAlphaBitmap( pPosAry2, rSourceBitmap, rAlphaBitmap );
795 else
796 return drawAlphaBitmap( rPosAry, rSourceBitmap, rAlphaBitmap );
799 bool SalGraphics::DrawAlphaRect( long nX, long nY, long nWidth, long nHeight,
800 sal_uInt8 nTransparency, const OutputDevice *pOutDev )
802 if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
803 mirror( nX, nWidth, pOutDev );
805 return drawAlphaRect( nX, nY, nWidth, nHeight, nTransparency );
808 bool SalGraphics::filterText( const String&, String&, xub_StrLen, xub_StrLen&, xub_StrLen&, xub_StrLen& )
810 return false;
813 void SalGraphics::AddDevFontSubstitute( OutputDevice* pOutDev,
814 const String& rFontName,
815 const String& rReplaceFontName,
816 USHORT nFlags )
818 pOutDev->ImplAddDevFontSubstitute( rFontName, rReplaceFontName, nFlags );