1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/debug.hxx>
21 #include <tools/poly.hxx>
23 #include <vcl/svapp.hxx>
24 #include <vcl/region.hxx>
25 #include <vcl/virdev.hxx>
26 #include <vcl/window.hxx>
27 #include <vcl/metaact.hxx>
28 #include <vcl/gdimtf.hxx>
29 #include <vcl/print.hxx>
30 #include <vcl/opengl/OpenGLContext.hxx>
31 #include <vcl/outdev.hxx>
32 #include <vcl/unowrap.hxx>
33 #include <vcl/settings.hxx>
36 #include <openglgdiimpl.hxx>
38 #include <sallayout.hxx>
40 #include <salframe.hxx>
44 #include <outdata.hxx>
45 #include <boost/scoped_array.hpp>
48 #include <basegfx/polygon/b2dpolygon.hxx>
50 // The only common SalFrame method
52 SalFrameGeometry
SalFrame::GetGeometry()
54 // mirror frame coordinates at parent
55 SalFrame
*pParent
= GetParent();
56 if( pParent
&& AllSettings::GetLayoutRTL() )
58 SalFrameGeometry aGeom
= maGeometry
;
59 int parent_x
= aGeom
.nX
- pParent
->maGeometry
.nX
;
60 aGeom
.nX
= pParent
->maGeometry
.nX
+ pParent
->maGeometry
.nWidth
- maGeometry
.nWidth
- parent_x
;
67 SalGraphics::SalGraphics()
68 : m_nLayout( SalLayoutFlags::NONE
),
69 m_bAntiAliasB2DDraw(false)
71 // read global RTL settings
72 if( AllSettings::GetLayoutRTL() )
73 m_nLayout
= SalLayoutFlags::BiDiRtl
;
76 SalGraphics::~SalGraphics()
80 rtl::Reference
<OpenGLContext
> SalGraphics::GetOpenGLContext() const
82 OpenGLSalGraphicsImpl
*pImpl
= dynamic_cast<OpenGLSalGraphicsImpl
*>(GetImpl());
84 return pImpl
->GetOpenGLContext();
89 bool SalGraphics::drawTransformedBitmap(
90 const basegfx::B2DPoint
& /* rNull */,
91 const basegfx::B2DPoint
& /* rX */,
92 const basegfx::B2DPoint
& /* rY */,
93 const SalBitmap
& /* rSourceBitmap */,
94 const SalBitmap
* /* pAlphaBitmap */)
96 // here direct support for transformed bitmaps can be implemented
100 void SalGraphics::mirror( long& x
, const OutputDevice
*pOutDev
, bool bBack
) const
103 if( pOutDev
&& pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
104 w
= pOutDev
->GetOutputWidthPixel();
106 w
= GetGraphicsWidth();
110 if( pOutDev
&& pOutDev
->ImplIsAntiparallel() )
112 OutputDevice
*pOutDevRef
= const_cast<OutputDevice
*>(pOutDev
);
113 // mirror this window back
114 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) )
116 long devX
= w
-pOutDevRef
->GetOutputWidthPixel()-pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
118 x
= x
- devX
+ pOutDevRef
->GetOutOffXPixel();
120 x
= devX
+ (x
- pOutDevRef
->GetOutOffXPixel());
124 long devX
= pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
126 x
= devX
+ (pOutDevRef
->GetOutputWidthPixel() + devX
) - (x
+ 1);
128 x
= pOutDevRef
->GetOutputWidthPixel() - (x
- devX
) + pOutDevRef
->GetOutOffXPixel() - 1;
131 else if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) )
136 void SalGraphics::mirror( long& x
, long& nWidth
, const OutputDevice
*pOutDev
, bool bBack
) const
139 if( pOutDev
&& pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
140 w
= pOutDev
->GetOutputWidthPixel();
142 w
= GetGraphicsWidth();
146 if( pOutDev
&& pOutDev
->ImplIsAntiparallel() )
148 OutputDevice
*pOutDevRef
= const_cast<OutputDevice
*>(pOutDev
);
149 // mirror this window back
150 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) )
152 long devX
= w
-pOutDevRef
->GetOutputWidthPixel()-pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
154 x
= x
- devX
+ pOutDevRef
->GetOutOffXPixel();
156 x
= devX
+ (x
- pOutDevRef
->GetOutOffXPixel());
160 long devX
= pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
162 x
= devX
+ (pOutDevRef
->GetOutputWidthPixel() + devX
) - (x
+ nWidth
);
164 x
= pOutDevRef
->GetOutputWidthPixel() - (x
- devX
) + pOutDevRef
->GetOutOffXPixel() - nWidth
;
167 else if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) )
173 bool SalGraphics::mirror( sal_uInt32 nPoints
, const SalPoint
*pPtAry
, SalPoint
*pPtAry2
, const OutputDevice
*pOutDev
, bool bBack
) const
176 if( pOutDev
&& pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
177 w
= pOutDev
->GetOutputWidthPixel();
179 w
= GetGraphicsWidth();
185 if( pOutDev
&& pOutDev
->ImplIsAntiparallel() )
187 OutputDevice
*pOutDevRef
= const_cast<OutputDevice
*>(pOutDev
);
188 // mirror this window back
189 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) )
191 long devX
= w
-pOutDevRef
->GetOutputWidthPixel()-pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
194 for( i
=0, j
=nPoints
-1; i
<nPoints
; i
++,j
-- )
196 //long x = w-1-pPtAry[i].mnX;
197 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
198 pPtAry2
[j
].mnX
= pOutDevRef
->GetOutOffXPixel() + (pPtAry
[i
].mnX
- devX
);
199 pPtAry2
[j
].mnY
= pPtAry
[i
].mnY
;
204 for( i
=0, j
=nPoints
-1; i
<nPoints
; i
++,j
-- )
206 //long x = w-1-pPtAry[i].mnX;
207 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
208 pPtAry2
[j
].mnX
= devX
+ (pPtAry
[i
].mnX
- pOutDevRef
->GetOutOffXPixel());
209 pPtAry2
[j
].mnY
= pPtAry
[i
].mnY
;
215 long devX
= pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
218 for( i
=0, j
=nPoints
-1; i
<nPoints
; i
++,j
-- )
220 //long x = w-1-pPtAry[i].mnX;
221 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
222 pPtAry2
[j
].mnX
= pPtAry
[i
].mnX
- pOutDevRef
->GetOutputWidthPixel() + devX
- pOutDevRef
->GetOutOffXPixel() + 1;
223 pPtAry2
[j
].mnY
= pPtAry
[i
].mnY
;
228 for( i
=0, j
=nPoints
-1; i
<nPoints
; i
++,j
-- )
230 //long x = w-1-pPtAry[i].mnX;
231 //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
232 pPtAry2
[j
].mnX
= pOutDevRef
->GetOutputWidthPixel() - (pPtAry
[i
].mnX
- devX
) + pOutDevRef
->GetOutOffXPixel() - 1;
233 pPtAry2
[j
].mnY
= pPtAry
[i
].mnY
;
238 else if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) )
240 for( i
=0, j
=nPoints
-1; i
<nPoints
; i
++,j
-- )
242 pPtAry2
[j
].mnX
= w
-1-pPtAry
[i
].mnX
;
243 pPtAry2
[j
].mnY
= pPtAry
[i
].mnY
;
252 void SalGraphics::mirror( vcl::Region
& rRgn
, const OutputDevice
*pOutDev
, bool bBack
) const
254 if( rRgn
.HasPolyPolygonOrB2DPolyPolygon() )
256 const basegfx::B2DPolyPolygon
aPolyPoly(mirror(rRgn
.GetAsB2DPolyPolygon(), pOutDev
, bBack
));
258 rRgn
= vcl::Region(aPolyPoly
);
262 RectangleVector aRectangles
;
263 rRgn
.GetRegionRectangles(aRectangles
);
266 for(RectangleVector::iterator
aRectIter(aRectangles
.begin()); aRectIter
!= aRectangles
.end(); ++aRectIter
)
268 mirror(*aRectIter
, pOutDev
, bBack
);
269 rRgn
.Union(*aRectIter
);
272 //ImplRegionInfo aInfo;
274 //Region aMirroredRegion;
275 //long nX, nY, nWidth, nHeight;
277 //bRegionRect = rRgn.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
278 //while ( bRegionRect )
280 // Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
281 // mirror( aRect, pOutDev, bBack );
282 // aMirroredRegion.Union( aRect );
283 // bRegionRect = rRgn.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
285 //rRgn = aMirroredRegion;
289 void SalGraphics::mirror( Rectangle
& rRect
, const OutputDevice
*pOutDev
, bool bBack
) const
291 long nWidth
= rRect
.GetWidth();
292 long x
= rRect
.Left();
295 mirror( x
, nWidth
, pOutDev
, bBack
);
296 rRect
.Move( x
- x_org
, 0 );
299 basegfx::B2DPoint
SalGraphics::mirror( const basegfx::B2DPoint
& i_rPoint
, const OutputDevice
*i_pOutDev
, bool i_bBack
) const
302 if( i_pOutDev
&& i_pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
303 w
= i_pOutDev
->GetOutputWidthPixel();
305 w
= GetGraphicsWidth();
307 DBG_ASSERT( w
, "missing graphics width" );
309 basegfx::B2DPoint
aRet( i_rPoint
);
312 if( i_pOutDev
&& !i_pOutDev
->IsRTLEnabled() )
314 OutputDevice
*pOutDevRef
= const_cast<OutputDevice
*>(i_pOutDev
);
315 // mirror this window back
316 double devX
= w
-pOutDevRef
->GetOutputWidthPixel()-pOutDevRef
->GetOutOffXPixel(); // re-mirrored mnOutOffX
318 aRet
.setX( i_rPoint
.getX() - devX
+ pOutDevRef
->GetOutOffXPixel() );
320 aRet
.setX( devX
+ (i_rPoint
.getX() - pOutDevRef
->GetOutOffXPixel()) );
323 aRet
.setX( w
-1-i_rPoint
.getX() );
328 basegfx::B2DPolygon
SalGraphics::mirror( const basegfx::B2DPolygon
& i_rPoly
, const OutputDevice
*i_pOutDev
, bool i_bBack
) const
331 if( i_pOutDev
&& i_pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
332 w
= i_pOutDev
->GetOutputWidthPixel();
334 w
= GetGraphicsWidth();
336 DBG_ASSERT( w
, "missing graphics width" );
338 basegfx::B2DPolygon aRet
;
341 sal_Int32 nPoints
= i_rPoly
.count();
342 for( sal_Int32 i
= 0; i
< nPoints
; i
++ )
344 aRet
.append( mirror( i_rPoly
.getB2DPoint( i
), i_pOutDev
, i_bBack
) );
345 if( i_rPoly
.isPrevControlPointUsed( i
) )
346 aRet
.setPrevControlPoint( i
, mirror( i_rPoly
.getPrevControlPoint( i
), i_pOutDev
, i_bBack
) );
347 if( i_rPoly
.isNextControlPointUsed( i
) )
348 aRet
.setNextControlPoint( i
, mirror( i_rPoly
.getNextControlPoint( i
), i_pOutDev
, i_bBack
) );
350 aRet
.setClosed( i_rPoly
.isClosed() );
358 basegfx::B2DPolyPolygon
SalGraphics::mirror( const basegfx::B2DPolyPolygon
& i_rPoly
, const OutputDevice
*i_pOutDev
, bool i_bBack
) const
361 if( i_pOutDev
&& i_pOutDev
->GetOutDevType() == OUTDEV_VIRDEV
)
362 w
= i_pOutDev
->GetOutputWidthPixel();
364 w
= GetGraphicsWidth();
366 DBG_ASSERT( w
, "missing graphics width" );
368 basegfx::B2DPolyPolygon aRet
;
371 sal_Int32 nPoly
= i_rPoly
.count();
372 for( sal_Int32 i
= 0; i
< nPoly
; i
++ )
373 aRet
.append( mirror( i_rPoly
.getB2DPolygon( i
), i_pOutDev
, i_bBack
) );
374 aRet
.setClosed( i_rPoly
.isClosed() );
382 bool SalGraphics::SetClipRegion( const vcl::Region
& i_rClip
, const OutputDevice
*pOutDev
)
384 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
386 vcl::Region
aMirror( i_rClip
);
387 mirror( aMirror
, pOutDev
);
388 return setClipRegion( aMirror
);
390 return setClipRegion( i_rClip
);
393 void SalGraphics::DrawPixel( long nX
, long nY
, const OutputDevice
*pOutDev
)
395 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
396 mirror( nX
, pOutDev
);
400 void SalGraphics::DrawPixel( long nX
, long nY
, SalColor nSalColor
, const OutputDevice
*pOutDev
)
402 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
403 mirror( nX
, pOutDev
);
404 drawPixel( nX
, nY
, nSalColor
);
407 void SalGraphics::DrawLine( long nX1
, long nY1
, long nX2
, long nY2
, const OutputDevice
*pOutDev
)
409 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
411 mirror( nX1
, pOutDev
);
412 mirror( nX2
, pOutDev
);
414 drawLine( nX1
, nY1
, nX2
, nY2
);
417 void SalGraphics::DrawRect( long nX
, long nY
, long nWidth
, long nHeight
, const OutputDevice
*pOutDev
)
419 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
420 mirror( nX
, nWidth
, pOutDev
);
421 drawRect( nX
, nY
, nWidth
, nHeight
);
424 void SalGraphics::DrawPolyLine( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, const OutputDevice
*pOutDev
)
426 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
428 boost::scoped_array
<SalPoint
> pPtAry2(new SalPoint
[nPoints
]);
429 bool bCopied
= mirror( nPoints
, pPtAry
, pPtAry2
.get(), pOutDev
);
430 drawPolyLine( nPoints
, bCopied
? pPtAry2
.get() : pPtAry
);
433 drawPolyLine( nPoints
, pPtAry
);
436 void SalGraphics::DrawPolygon( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, const OutputDevice
*pOutDev
)
438 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
440 boost::scoped_array
<SalPoint
> pPtAry2(new SalPoint
[nPoints
]);
441 bool bCopied
= mirror( nPoints
, pPtAry
, pPtAry2
.get(), pOutDev
);
442 drawPolygon( nPoints
, bCopied
? pPtAry2
.get() : pPtAry
);
445 drawPolygon( nPoints
, pPtAry
);
448 void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly
, const sal_uInt32
* pPoints
, PCONSTSALPOINT
* pPtAry
, const OutputDevice
*pOutDev
)
450 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
452 // TODO: optimize, reduce new/delete calls
453 SalPoint
**pPtAry2
= new SalPoint
*[nPoly
];
455 for(i
=0; i
<nPoly
; i
++)
457 sal_uLong nPoints
= pPoints
[i
];
458 pPtAry2
[i
] = new SalPoint
[ nPoints
];
459 mirror( nPoints
, pPtAry
[i
], pPtAry2
[i
], pOutDev
);
462 drawPolyPolygon( nPoly
, pPoints
, (PCONSTSALPOINT
*)pPtAry2
);
464 for(i
=0; i
<nPoly
; i
++)
465 delete [] pPtAry2
[i
];
469 drawPolyPolygon( nPoly
, pPoints
, pPtAry
);
472 bool SalGraphics::DrawPolyPolygon( const basegfx::B2DPolyPolygon
& i_rPolyPolygon
, double i_fTransparency
, const OutputDevice
* i_pOutDev
)
475 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (i_pOutDev
&& i_pOutDev
->IsRTLEnabled()) )
477 basegfx::B2DPolyPolygon
aMirror( mirror( i_rPolyPolygon
, i_pOutDev
) );
478 bRet
= drawPolyPolygon( aMirror
, i_fTransparency
);
481 bRet
= drawPolyPolygon( i_rPolyPolygon
, i_fTransparency
);
485 bool SalGraphics::DrawPolyLineBezier( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, const sal_uInt8
* pFlgAry
, const OutputDevice
* pOutDev
)
487 bool bResult
= false;
488 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
490 boost::scoped_array
<SalPoint
> pPtAry2(new SalPoint
[nPoints
]);
491 bool bCopied
= mirror( nPoints
, pPtAry
, pPtAry2
.get(), pOutDev
);
492 bResult
= drawPolyLineBezier( nPoints
, bCopied
? pPtAry2
.get() : pPtAry
, pFlgAry
);
495 bResult
= drawPolyLineBezier( nPoints
, pPtAry
, pFlgAry
);
499 bool SalGraphics::DrawPolygonBezier( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, const sal_uInt8
* pFlgAry
, const OutputDevice
* pOutDev
)
501 bool bResult
= false;
502 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
504 boost::scoped_array
<SalPoint
> pPtAry2(new SalPoint
[nPoints
]);
505 bool bCopied
= mirror( nPoints
, pPtAry
, pPtAry2
.get(), pOutDev
);
506 bResult
= drawPolygonBezier( nPoints
, bCopied
? pPtAry2
.get() : pPtAry
, pFlgAry
);
509 bResult
= drawPolygonBezier( nPoints
, pPtAry
, pFlgAry
);
513 bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly
, const sal_uInt32
* i_pPoints
,
514 const SalPoint
* const* i_pPtAry
, const sal_uInt8
* const* i_pFlgAry
, const OutputDevice
* i_pOutDev
)
517 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (i_pOutDev
&& i_pOutDev
->IsRTLEnabled()) )
519 // TODO: optimize, reduce new/delete calls
520 SalPoint
**pPtAry2
= new SalPoint
*[i_nPoly
];
522 for(i
=0; i
<i_nPoly
; i
++)
524 sal_uLong nPoints
= i_pPoints
[i
];
525 pPtAry2
[i
] = new SalPoint
[ nPoints
];
526 mirror( nPoints
, i_pPtAry
[i
], pPtAry2
[i
], i_pOutDev
);
529 bRet
= drawPolyPolygonBezier( i_nPoly
, i_pPoints
, (PCONSTSALPOINT
*)pPtAry2
, i_pFlgAry
);
531 for(i
=0; i
<i_nPoly
; i
++)
532 delete [] pPtAry2
[i
];
536 bRet
= drawPolyPolygonBezier( i_nPoly
, i_pPoints
, i_pPtAry
, i_pFlgAry
);
540 bool SalGraphics::DrawPolyLine( const basegfx::B2DPolygon
& i_rPolygon
,
541 double i_fTransparency
,
542 const basegfx::B2DVector
& i_rLineWidth
,
543 basegfx::B2DLineJoin i_eLineJoin
,
544 com::sun::star::drawing::LineCap i_eLineCap
,
545 const OutputDevice
* i_pOutDev
)
548 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (i_pOutDev
&& i_pOutDev
->IsRTLEnabled()) )
550 basegfx::B2DPolygon
aMirror( mirror( i_rPolygon
, i_pOutDev
) );
551 bRet
= drawPolyLine( aMirror
, i_fTransparency
, i_rLineWidth
, i_eLineJoin
, i_eLineCap
);
554 bRet
= drawPolyLine( i_rPolygon
, i_fTransparency
, i_rLineWidth
, i_eLineJoin
, i_eLineCap
);
558 bool SalGraphics::DrawGradient( const tools::PolyPolygon
& rPolyPoly
, const Gradient
& rGradient
, OutputDevice
* )
560 return drawGradient( rPolyPoly
, rGradient
);
563 void SalGraphics::CopyArea( long nDestX
, long nDestY
,
564 long nSrcX
, long nSrcY
,
565 long nSrcWidth
, long nSrcHeight
,
566 sal_uInt16 nFlags
, const OutputDevice
*pOutDev
)
568 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
570 mirror( nDestX
, nSrcWidth
, pOutDev
);
571 mirror( nSrcX
, nSrcWidth
, pOutDev
);
573 copyArea( nDestX
, nDestY
, nSrcX
, nSrcY
, nSrcWidth
, nSrcHeight
, nFlags
);
576 void SalGraphics::CopyBits( const SalTwoRect
& rPosAry
,
577 SalGraphics
* pSrcGraphics
, const OutputDevice
*pOutDev
, const OutputDevice
*pSrcOutDev
)
579 if( ( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) ) ||
580 (pSrcGraphics
&& ( (pSrcGraphics
->GetLayout() & SalLayoutFlags::BiDiRtl
) || (pSrcOutDev
&& pSrcOutDev
->IsRTLEnabled()) ) ) )
582 SalTwoRect aPosAry2
= rPosAry
;
583 if( (pSrcGraphics
&& (pSrcGraphics
->GetLayout() & SalLayoutFlags::BiDiRtl
)) || (pSrcOutDev
&& pSrcOutDev
->IsRTLEnabled()) )
584 mirror( aPosAry2
.mnSrcX
, aPosAry2
.mnSrcWidth
, pSrcOutDev
);
585 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
586 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
587 copyBits( aPosAry2
, pSrcGraphics
);
590 copyBits( rPosAry
, pSrcGraphics
);
593 void SalGraphics::DrawBitmap( const SalTwoRect
& rPosAry
,
594 const SalBitmap
& rSalBitmap
, const OutputDevice
*pOutDev
)
596 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
598 SalTwoRect aPosAry2
= rPosAry
;
599 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
600 drawBitmap( aPosAry2
, rSalBitmap
);
603 drawBitmap( rPosAry
, rSalBitmap
);
606 void SalGraphics::DrawBitmap( const SalTwoRect
& rPosAry
,
607 const SalBitmap
& rSalBitmap
,
608 const SalBitmap
& rTransparentBitmap
, const OutputDevice
*pOutDev
)
610 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
612 SalTwoRect aPosAry2
= rPosAry
;
613 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
614 drawBitmap( aPosAry2
, rSalBitmap
, rTransparentBitmap
);
617 drawBitmap( rPosAry
, rSalBitmap
, rTransparentBitmap
);
620 void SalGraphics::DrawMask( const SalTwoRect
& rPosAry
,
621 const SalBitmap
& rSalBitmap
,
622 SalColor nMaskColor
, const OutputDevice
*pOutDev
)
624 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
626 SalTwoRect aPosAry2
= rPosAry
;
627 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
628 drawMask( aPosAry2
, rSalBitmap
, nMaskColor
);
631 drawMask( rPosAry
, rSalBitmap
, nMaskColor
);
634 SalBitmap
* SalGraphics::GetBitmap( long nX
, long nY
, long nWidth
, long nHeight
, const OutputDevice
*pOutDev
)
636 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
637 mirror( nX
, nWidth
, pOutDev
);
638 return getBitmap( nX
, nY
, nWidth
, nHeight
);
641 SalColor
SalGraphics::GetPixel( long nX
, long nY
, const OutputDevice
*pOutDev
)
643 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
644 mirror( nX
, pOutDev
);
645 return getPixel( nX
, nY
);
648 void SalGraphics::Invert( long nX
, long nY
, long nWidth
, long nHeight
, SalInvert nFlags
, const OutputDevice
*pOutDev
)
650 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
651 mirror( nX
, nWidth
, pOutDev
);
652 invert( nX
, nY
, nWidth
, nHeight
, nFlags
);
655 void SalGraphics::Invert( sal_uInt32 nPoints
, const SalPoint
* pPtAry
, SalInvert nFlags
, const OutputDevice
*pOutDev
)
657 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
659 boost::scoped_array
<SalPoint
> pPtAry2(new SalPoint
[nPoints
]);
660 bool bCopied
= mirror( nPoints
, pPtAry
, pPtAry2
.get(), pOutDev
);
661 invert( nPoints
, bCopied
? pPtAry2
.get() : pPtAry
, nFlags
);
664 invert( nPoints
, pPtAry
, nFlags
);
667 bool SalGraphics::DrawEPS( long nX
, long nY
, long nWidth
, long nHeight
, void* pPtr
, sal_uLong nSize
, const OutputDevice
*pOutDev
)
669 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
670 mirror( nX
, nWidth
, pOutDev
);
671 return drawEPS( nX
, nY
, nWidth
, nHeight
, pPtr
, nSize
);
674 bool SalGraphics::HitTestNativeControl( ControlType nType
, ControlPart nPart
, const Rectangle
& rControlRegion
,
675 const Point
& aPos
, bool& rIsInside
, const OutputDevice
*pOutDev
)
677 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
680 Rectangle
rgn( rControlRegion
);
681 mirror( pt
.X(), pOutDev
);
682 mirror( rgn
, pOutDev
);
683 return hitTestNativeControl( nType
, nPart
, rgn
, pt
, rIsInside
);
686 return hitTestNativeControl( nType
, nPart
, rControlRegion
, aPos
, rIsInside
);
689 void SalGraphics::mirror( ImplControlValue
& rVal
, const OutputDevice
* pOutDev
, bool bBack
) const
691 switch( rVal
.getType() )
695 SliderValue
* pSlVal
= static_cast<SliderValue
*>(&rVal
);
696 mirror(pSlVal
->maThumbRect
,pOutDev
,bBack
);
701 ScrollbarValue
* pScVal
= static_cast<ScrollbarValue
*>(&rVal
);
702 mirror(pScVal
->maThumbRect
,pOutDev
,bBack
);
703 mirror(pScVal
->maButton1Rect
,pOutDev
,bBack
);
704 mirror(pScVal
->maButton2Rect
,pOutDev
,bBack
);
708 case CTRL_SPINBUTTONS
:
710 SpinbuttonValue
* pSpVal
= static_cast<SpinbuttonValue
*>(&rVal
);
711 mirror(pSpVal
->maUpperRect
,pOutDev
,bBack
);
712 mirror(pSpVal
->maLowerRect
,pOutDev
,bBack
);
717 ToolbarValue
* pTVal
= static_cast<ToolbarValue
*>(&rVal
);
718 mirror(pTVal
->maGripRect
,pOutDev
,bBack
);
724 bool SalGraphics::DrawNativeControl( ControlType nType
, ControlPart nPart
, const Rectangle
& rControlRegion
,
725 ControlState nState
, const ImplControlValue
& aValue
,
726 const OUString
& aCaption
, const OutputDevice
*pOutDev
)
728 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
730 Rectangle
rgn( rControlRegion
);
733 mirror(rgn
, pOutDev
);
734 std::unique_ptr
< ImplControlValue
> mirrorValue( aValue
.clone());
735 mirror( *mirrorValue
, pOutDev
);
736 bool bRet
= drawNativeControl( nType
, nPart
, rgn
, nState
, *mirrorValue
, aCaption
);
740 return drawNativeControl( nType
, nPart
, rControlRegion
, nState
, aValue
, aCaption
);
743 bool SalGraphics::GetNativeControlRegion( ControlType nType
, ControlPart nPart
, const Rectangle
& rControlRegion
, ControlState nState
,
744 const ImplControlValue
& aValue
, const OUString
& aCaption
,
745 Rectangle
&rNativeBoundingRegion
, Rectangle
&rNativeContentRegion
, const OutputDevice
*pOutDev
)
747 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
749 Rectangle
rgn( rControlRegion
);
750 mirror( rgn
, pOutDev
);
751 std::unique_ptr
< ImplControlValue
> mirrorValue( aValue
.clone());
752 mirror( *mirrorValue
, pOutDev
);
753 if( getNativeControlRegion( nType
, nPart
, rgn
, nState
, *mirrorValue
, aCaption
,
754 rNativeBoundingRegion
, rNativeContentRegion
) )
756 mirror( rNativeBoundingRegion
, pOutDev
, true );
757 mirror( rNativeContentRegion
, pOutDev
, true );
763 return getNativeControlRegion( nType
, nPart
, rControlRegion
, nState
, aValue
, aCaption
,
764 rNativeBoundingRegion
, rNativeContentRegion
);
767 bool SalGraphics::BlendBitmap( const SalTwoRect
& rPosAry
,
768 const SalBitmap
& rBitmap
,
769 const OutputDevice
*pOutDev
)
771 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
773 SalTwoRect aPosAry2
= rPosAry
;
774 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
775 return blendBitmap( aPosAry2
, rBitmap
);
778 return blendBitmap( rPosAry
, rBitmap
);
781 bool SalGraphics::BlendAlphaBitmap( const SalTwoRect
& rPosAry
,
782 const SalBitmap
& rSrcBitmap
,
783 const SalBitmap
& rMaskBitmap
,
784 const SalBitmap
& rAlphaBitmap
,
785 const OutputDevice
*pOutDev
)
787 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
789 SalTwoRect aPosAry2
= rPosAry
;
790 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
791 return blendAlphaBitmap( aPosAry2
, rSrcBitmap
, rMaskBitmap
, rAlphaBitmap
);
794 return blendAlphaBitmap( rPosAry
, rSrcBitmap
, rMaskBitmap
, rAlphaBitmap
);
797 bool SalGraphics::DrawAlphaBitmap( const SalTwoRect
& rPosAry
,
798 const SalBitmap
& rSourceBitmap
,
799 const SalBitmap
& rAlphaBitmap
,
800 const OutputDevice
*pOutDev
)
802 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
804 SalTwoRect aPosAry2
= rPosAry
;
805 mirror( aPosAry2
.mnDestX
, aPosAry2
.mnDestWidth
, pOutDev
);
806 return drawAlphaBitmap( aPosAry2
, rSourceBitmap
, rAlphaBitmap
);
809 return drawAlphaBitmap( rPosAry
, rSourceBitmap
, rAlphaBitmap
);
812 bool SalGraphics::DrawTransformedBitmap(
813 const basegfx::B2DPoint
& rNull
,
814 const basegfx::B2DPoint
& rX
,
815 const basegfx::B2DPoint
& rY
,
816 const SalBitmap
& rSourceBitmap
,
817 const SalBitmap
* pAlphaBitmap
,
818 const OutputDevice
* pOutDev
)
820 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
822 basegfx::B2DPoint
aNull(rNull
);
823 basegfx::B2DPoint
aX(rX
);
824 basegfx::B2DPoint
aY(rY
);
826 mirror(aNull
, pOutDev
);
830 return drawTransformedBitmap(aNull
, aX
, aY
, rSourceBitmap
, pAlphaBitmap
);
834 return drawTransformedBitmap(rNull
, rX
, rY
, rSourceBitmap
, pAlphaBitmap
);
838 bool SalGraphics::DrawAlphaRect( long nX
, long nY
, long nWidth
, long nHeight
,
839 sal_uInt8 nTransparency
, const OutputDevice
*pOutDev
)
841 if( (m_nLayout
& SalLayoutFlags::BiDiRtl
) || (pOutDev
&& pOutDev
->IsRTLEnabled()) )
842 mirror( nX
, nWidth
, pOutDev
);
844 return drawAlphaRect( nX
, nY
, nWidth
, nHeight
, nTransparency
);
847 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */