1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
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>
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
;
81 // ----------------------------------------------------------------------------
83 SalGraphics::SalGraphics()
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
& )
104 // ----------------------------------------------------------------------------
106 void SalGraphics::mirror( long& x
, const OutputDevice
*pOutDev
, bool bBack
) const
109 if( pOutDev
&& pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
110 w
= pOutDev
->GetOutputWidthPixel();
112 w
= GetGraphicsWidth();
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
124 x
= x
- devX
+ pOutDevRef
->GetOutOffXPixel();
126 x
= devX
+ (x
- pOutDevRef
->GetOutOffXPixel());
130 long devX
= pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
132 x
= x
- pOutDevRef
->GetOutputWidthPixel() + devX
- pOutDevRef
->GetOutOffXPixel() + 1;
134 x
= pOutDevRef
->GetOutputWidthPixel() - (x
- devX
) + pOutDevRef
->GetOutOffXPixel() - 1;
137 else if( (m_nLayout
& SAL_LAYOUT_BIDI_RTL
) )
142 void SalGraphics::mirror( long& x
, long& nWidth
, const OutputDevice
*pOutDev
, bool bBack
) const
145 if( pOutDev
&& pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
146 w
= pOutDev
->GetOutputWidthPixel();
148 w
= GetGraphicsWidth();
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
160 x
= x
- devX
+ pOutDevRef
->GetOutOffXPixel();
162 x
= devX
+ (x
- pOutDevRef
->GetOutOffXPixel());
166 long devX
= pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
168 x
= x
- pOutDevRef
->GetOutputWidthPixel() + devX
- pOutDevRef
->GetOutOffXPixel() + nWidth
;
170 x
= pOutDevRef
->GetOutputWidthPixel() - (x
- devX
) + pOutDevRef
->GetOutOffXPixel() - nWidth
;
173 else if( (m_nLayout
& SAL_LAYOUT_BIDI_RTL
) )
179 BOOL
SalGraphics::mirror( sal_uInt32 nPoints
, const SalPoint
*pPtAry
, SalPoint
*pPtAry2
, const OutputDevice
*pOutDev
, bool bBack
) const
182 if( pOutDev
&& pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
183 w
= pOutDev
->GetOutputWidthPixel();
185 w
= GetGraphicsWidth();
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
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
;
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
;
221 long devX
= pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
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
;
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
;
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();
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();
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
283 if( i_pOutDev
&& i_pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
284 w
= i_pOutDev
->GetOutputWidthPixel();
286 w
= GetGraphicsWidth();
288 DBG_ASSERT( w
, "missing graphics width" );
290 basegfx::B2DPoint
aRet( i_rPoint
);
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
299 aRet
.setX( i_rPoint
.getX() - devX
+ pOutDevRef
->GetOutOffXPixel() );
301 aRet
.setX( devX
+ (i_rPoint
.getX() - pOutDevRef
->GetOutOffXPixel()) );
304 aRet
.setX( w
-1-i_rPoint
.getX() );
309 basegfx::B2DPolygon
SalGraphics::mirror( const basegfx::B2DPolygon
& i_rPoly
, const OutputDevice
*i_pOutDev
, bool i_bBack
) const
312 if( i_pOutDev
&& i_pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
313 w
= i_pOutDev
->GetOutputWidthPixel();
315 w
= GetGraphicsWidth();
317 DBG_ASSERT( w
, "missing graphics width" );
319 basegfx::B2DPolygon aRet
;
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() );
339 basegfx::B2DPolyPolygon
SalGraphics::mirror( const basegfx::B2DPolyPolygon
& i_rPoly
, const OutputDevice
*i_pOutDev
, bool i_bBack
) const
342 if( i_pOutDev
&& i_pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
343 w
= i_pOutDev
->GetOutputWidthPixel();
345 w
= GetGraphicsWidth();
347 DBG_ASSERT( w
, "missing graphics width" );
349 basegfx::B2DPolyPolygon aRet
;
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() );
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
& )
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
);
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*/)
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
);
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
);
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
];
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
];
465 drawPolyPolygon( nPoly
, pPoints
, pPtAry
);
468 bool SalGraphics::DrawPolyPolygon( const ::basegfx::B2DPolyPolygon
& i_rPolyPolygon
, double i_fTransparency
, const OutputDevice
* i_pOutDev
)
471 if( (m_nLayout
& SAL_LAYOUT_BIDI_RTL
) )
473 basegfx::B2DPolyPolygon
aMirror( mirror( i_rPolyPolygon
, i_pOutDev
) );
474 bRet
= drawPolyPolygon( aMirror
, i_fTransparency
);
477 bRet
= drawPolyPolygon( i_rPolyPolygon
, i_fTransparency
);
481 bool SalGraphics::drawPolyPolygon( const ::basegfx::B2DPolyPolygon
&, double /*fTransparency*/)
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
);
497 bResult
= drawPolyLineBezier( nPoints
, pPtAry
, pFlgAry
);
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
);
512 bResult
= drawPolygonBezier( nPoints
, pPtAry
, pFlgAry
);
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
];
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
];
539 bRet
= drawPolyPolygonBezier( i_nPoly
, i_pPoints
, i_pPtAry
, i_pFlgAry
);
543 bool SalGraphics::DrawPolyLine( const ::basegfx::B2DPolygon
& i_rPolygon
,
544 const ::basegfx::B2DVector
& i_rLineWidth
, basegfx::B2DLineJoin i_eLineJoin
,
545 const OutputDevice
* i_pOutDev
)
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
);
554 bRet
= drawPolyLine( i_rPolygon
, i_rLineWidth
, i_eLineJoin
);
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
);
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
);
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
);
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
);
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
);
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
);
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()) )
681 Region
rgn( rControlRegion
);
682 mirror( pt
.X(), pOutDev
);
683 mirror( rgn
, pOutDev
);
684 return hitTestNativeControl( nType
, nPart
, rgn
, pt
, rControlHandle
, rIsInside
);
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() )
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
);
705 case CTRL_SPINBUTTONS
:
707 SpinbuttonValue
* pSpVal
= reinterpret_cast<SpinbuttonValue
*>(rVal
.getOptionalVal());
708 mirror(pSpVal
->maUpperRect
,pOutDev
,bBack
);
709 mirror(pSpVal
->maLowerRect
,pOutDev
,bBack
);
714 ToolbarValue
* pTVal
= reinterpret_cast<ToolbarValue
*>(rVal
.getOptionalVal());
715 mirror(pTVal
->maGripRect
,pOutDev
,bBack
);
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 );
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 );
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 );
775 mirror( nType
, aValue
, pOutDev
, true );
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
);
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
& )
813 void SalGraphics::AddDevFontSubstitute( OutputDevice
* pOutDev
,
814 const String
& rFontName
,
815 const String
& rReplaceFontName
,
818 pOutDev
->ImplAddDevFontSubstitute( rFontName
, rReplaceFontName
, nFlags
);