Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <tools/debug.hxx>
31 : : #include <tools/poly.hxx>
32 : :
33 : : #include <vcl/svapp.hxx>
34 : : #include <vcl/region.hxx>
35 : : #include <vcl/virdev.hxx>
36 : : #include <vcl/window.hxx>
37 : : #include <vcl/metaact.hxx>
38 : : #include <vcl/gdimtf.hxx>
39 : : #include <vcl/print.hxx>
40 : : #include <vcl/outdev.hxx>
41 : : #include <vcl/unowrap.hxx>
42 : :
43 : : #include <window.h>
44 : : #include <region.h>
45 : : #include <outdev.h>
46 : : #include <sallayout.hxx>
47 : : #include <salgdi.hxx>
48 : : #include <salframe.hxx>
49 : : #include <salvd.hxx>
50 : : #include <salprn.hxx>
51 : : #include <svdata.hxx>
52 : : #include <outdata.hxx>
53 : :
54 : : #include <boost/scoped_ptr.hpp>
55 : :
56 : : #include "basegfx/polygon/b2dpolygon.hxx"
57 : :
58 : : // ----------------------------------------------------------------------------
59 : : // The only common SalFrame method
60 : : // ----------------------------------------------------------------------------
61 : :
62 : 49764 : SalFrameGeometry SalFrame::GetGeometry()
63 : : {
64 : : // mirror frame coordinates at parent
65 : 49764 : SalFrame *pParent = GetParent();
66 [ - + ][ - + ]: 49764 : if( pParent && Application::GetSettings().GetLayoutRTL() )
[ + + ]
67 : : {
68 : 0 : SalFrameGeometry aGeom = maGeometry;
69 : 0 : int parent_x = aGeom.nX - pParent->maGeometry.nX;
70 : 0 : aGeom.nX = pParent->maGeometry.nX + pParent->maGeometry.nWidth - maGeometry.nWidth - parent_x;
71 : 0 : return aGeom;
72 : : }
73 : : else
74 : 49764 : return maGeometry;
75 : : }
76 : :
77 : : // ----------------------------------------------------------------------------
78 : :
79 : 230997 : SalGraphics::SalGraphics()
80 : : : m_nLayout( 0 ),
81 : 230997 : m_bAntiAliasB2DDraw(false)
82 : : {
83 : : // read global RTL settings
84 [ - + ]: 230997 : if( Application::GetSettings().GetLayoutRTL() )
85 : 0 : m_nLayout = SAL_LAYOUT_BIDI_RTL;
86 : 230997 : }
87 : :
88 : 227008 : SalGraphics::~SalGraphics()
89 : : {
90 [ - + ]: 227008 : }
91 : :
92 : : // ----------------------------------------------------------------------------
93 : :
94 : 8440 : void SalGraphics::mirror( long& x, const OutputDevice *pOutDev, bool bBack ) const
95 : : {
96 : : long w;
97 [ + - ][ + + ]: 8440 : if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
[ + + ]
98 : 8252 : w = pOutDev->GetOutputWidthPixel();
99 : : else
100 : 188 : w = GetGraphicsWidth();
101 : :
102 [ + - ]: 8440 : if( w )
103 : : {
104 [ + - ][ + + ]: 8440 : if( pOutDev && pOutDev->ImplIsAntiparallel() )
[ + + ]
105 : : {
106 : 188 : OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
107 : : // mirror this window back
108 [ - + ]: 188 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
109 : : {
110 : 0 : long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
111 [ # # ]: 0 : if( bBack )
112 : 0 : x = x - devX + pOutDevRef->GetOutOffXPixel();
113 : : else
114 : 0 : x = devX + (x - pOutDevRef->GetOutOffXPixel());
115 : : }
116 : : else
117 : : {
118 : 188 : long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
119 [ - + ]: 188 : if( bBack )
120 : 0 : x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
121 : : else
122 : 188 : x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - 1;
123 : : }
124 : : }
125 [ + - ]: 8252 : else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
126 : 8252 : x = w-1-x;
127 : : }
128 : 8440 : }
129 : :
130 : 5941 : void SalGraphics::mirror( long& x, long& nWidth, const OutputDevice *pOutDev, bool bBack ) const
131 : : {
132 : : long w;
133 [ + - ][ + + ]: 5941 : if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
[ + + ]
134 : 5796 : w = pOutDev->GetOutputWidthPixel();
135 : : else
136 : 145 : w = GetGraphicsWidth();
137 : :
138 [ + - ]: 5941 : if( w )
139 : : {
140 [ + - ][ + + ]: 5941 : if( pOutDev && pOutDev->ImplIsAntiparallel() )
[ + + ]
141 : : {
142 : 145 : OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
143 : : // mirror this window back
144 [ - + ]: 145 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
145 : : {
146 : 0 : long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
147 [ # # ]: 0 : if( bBack )
148 : 0 : x = x - devX + pOutDevRef->GetOutOffXPixel();
149 : : else
150 : 0 : x = devX + (x - pOutDevRef->GetOutOffXPixel());
151 : : }
152 : : else
153 : : {
154 : 145 : long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
155 [ - + ]: 145 : if( bBack )
156 : 0 : x = x - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + nWidth;
157 : : else
158 : 145 : x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - nWidth;
159 : : }
160 : : }
161 [ + - ]: 5796 : else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
162 : 5796 : x = w-nWidth-x;
163 : :
164 : : }
165 : 5941 : }
166 : :
167 : 1333 : sal_Bool SalGraphics::mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint *pPtAry2, const OutputDevice *pOutDev, bool bBack ) const
168 : : {
169 : : long w;
170 [ + - ][ + - ]: 1333 : if( pOutDev && pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
[ + - ]
171 : 1333 : w = pOutDev->GetOutputWidthPixel();
172 : : else
173 : 0 : w = GetGraphicsWidth();
174 : :
175 [ + - ]: 1333 : if( w )
176 : : {
177 : : sal_uInt32 i, j;
178 : :
179 [ + - ][ - + ]: 1333 : if( pOutDev && pOutDev->ImplIsAntiparallel() )
[ - + ]
180 : : {
181 : 0 : OutputDevice *pOutDevRef = (OutputDevice*) pOutDev;
182 : : // mirror this window back
183 [ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
184 : : {
185 : 0 : long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
186 [ # # ]: 0 : if( bBack )
187 : : {
188 [ # # ]: 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
189 : : {
190 : : //long x = w-1-pPtAry[i].mnX;
191 : : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
192 : 0 : pPtAry2[j].mnX = pOutDevRef->GetOutOffXPixel() + (pPtAry[i].mnX - devX);
193 : 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
194 : : }
195 : : }
196 : : else
197 : : {
198 [ # # ]: 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
199 : : {
200 : : //long x = w-1-pPtAry[i].mnX;
201 : : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
202 : 0 : pPtAry2[j].mnX = devX + (pPtAry[i].mnX - pOutDevRef->GetOutOffXPixel());
203 : 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
204 : : }
205 : : }
206 : : }
207 : : else
208 : : {
209 : 0 : long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
210 [ # # ]: 0 : if( bBack )
211 : : {
212 [ # # ]: 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
213 : : {
214 : : //long x = w-1-pPtAry[i].mnX;
215 : : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
216 : 0 : pPtAry2[j].mnX = pPtAry[i].mnX - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
217 : 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
218 : : }
219 : : }
220 : : else
221 : : {
222 [ # # ]: 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
223 : : {
224 : : //long x = w-1-pPtAry[i].mnX;
225 : : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
226 : 0 : pPtAry2[j].mnX = pOutDevRef->GetOutputWidthPixel() - (pPtAry[i].mnX - devX) + pOutDevRef->GetOutOffXPixel() - 1;
227 : 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
228 : : }
229 : : }
230 : : }
231 : : }
232 [ + - ]: 1333 : else if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) )
233 : : {
234 [ + + ]: 33864 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
235 : : {
236 : 32531 : pPtAry2[j].mnX = w-1-pPtAry[i].mnX;
237 : 32531 : pPtAry2[j].mnY = pPtAry[i].mnY;
238 : : }
239 : : }
240 : 1333 : return sal_True;
241 : : }
242 : : else
243 : 1333 : return sal_False;
244 : : }
245 : :
246 : 1139 : void SalGraphics::mirror( Region& rRgn, const OutputDevice *pOutDev, bool bBack ) const
247 : : {
248 [ - + ]: 1139 : if( rRgn.HasPolyPolygon() )
249 : : {
250 [ # # ]: 0 : basegfx::B2DPolyPolygon aPolyPoly( rRgn.ConvertToB2DPolyPolygon() );
251 [ # # ][ # # ]: 0 : aPolyPoly = mirror( aPolyPoly, pOutDev, bBack );
[ # # ]
252 [ # # ][ # # ]: 0 : rRgn = Region( aPolyPoly );
[ # # ][ # # ]
253 : : }
254 : : else
255 : : {
256 : : ImplRegionInfo aInfo;
257 : : bool bRegionRect;
258 [ + - ]: 1139 : Region aMirroredRegion;
259 : : long nX, nY, nWidth, nHeight;
260 : :
261 [ + - ]: 1139 : bRegionRect = rRgn.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
262 [ + + ]: 2278 : while ( bRegionRect )
263 : : {
264 [ + - ]: 1139 : Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
265 [ + - ]: 1139 : mirror( aRect, pOutDev, bBack );
266 [ + - ]: 1139 : aMirroredRegion.Union( aRect );
267 [ + - ]: 1139 : bRegionRect = rRgn.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
268 : : }
269 [ + - ][ + - ]: 1139 : rRgn = aMirroredRegion;
270 : : }
271 : 1139 : }
272 : :
273 : 1260 : void SalGraphics::mirror( Rectangle& rRect, const OutputDevice *pOutDev, bool bBack ) const
274 : : {
275 [ + - ]: 1260 : long nWidth = rRect.GetWidth();
276 : 1260 : long x = rRect.Left();
277 : 1260 : long x_org = x;
278 : :
279 [ + - ]: 1260 : mirror( x, nWidth, pOutDev, bBack );
280 [ + - ]: 1260 : rRect.Move( x - x_org, 0 );
281 : 1260 : }
282 : :
283 : 0 : basegfx::B2DPoint SalGraphics::mirror( const basegfx::B2DPoint& i_rPoint, const OutputDevice *i_pOutDev, bool i_bBack ) const
284 : : {
285 : : long w;
286 [ # # ][ # # ]: 0 : if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
[ # # ]
287 : 0 : w = i_pOutDev->GetOutputWidthPixel();
288 : : else
289 : 0 : w = GetGraphicsWidth();
290 : :
291 : : DBG_ASSERT( w, "missing graphics width" );
292 : :
293 : 0 : basegfx::B2DPoint aRet( i_rPoint );
294 [ # # ]: 0 : if( w )
295 : : {
296 [ # # ][ # # ]: 0 : if( i_pOutDev && !i_pOutDev->IsRTLEnabled() )
[ # # ]
297 : : {
298 : 0 : OutputDevice *pOutDevRef = (OutputDevice*)i_pOutDev;
299 : : // mirror this window back
300 : 0 : double devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
301 [ # # ]: 0 : if( i_bBack )
302 : 0 : aRet.setX( i_rPoint.getX() - devX + pOutDevRef->GetOutOffXPixel() );
303 : : else
304 : 0 : aRet.setX( devX + (i_rPoint.getX() - pOutDevRef->GetOutOffXPixel()) );
305 : : }
306 : : else
307 : 0 : aRet.setX( w-1-i_rPoint.getX() );
308 : : }
309 : 0 : return aRet;
310 : : }
311 : :
312 : 0 : basegfx::B2DPolygon SalGraphics::mirror( const basegfx::B2DPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
313 : : {
314 : : long w;
315 [ # # ][ # # ]: 0 : if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
[ # # ]
316 : 0 : w = i_pOutDev->GetOutputWidthPixel();
317 : : else
318 : 0 : w = GetGraphicsWidth();
319 : :
320 : : DBG_ASSERT( w, "missing graphics width" );
321 : :
322 : 0 : basegfx::B2DPolygon aRet;
323 [ # # ]: 0 : if( w )
324 : : {
325 [ # # ]: 0 : sal_Int32 nPoints = i_rPoly.count();
326 [ # # ]: 0 : for( sal_Int32 i = 0; i < nPoints; i++ )
327 : : {
328 [ # # ][ # # ]: 0 : aRet.append( mirror( i_rPoly.getB2DPoint( i ), i_pOutDev, i_bBack ) );
[ # # ]
329 [ # # ][ # # ]: 0 : if( i_rPoly.isPrevControlPointUsed( i ) )
330 [ # # ][ # # ]: 0 : aRet.setPrevControlPoint( i, mirror( i_rPoly.getPrevControlPoint( i ), i_pOutDev, i_bBack ) );
[ # # ]
331 [ # # ][ # # ]: 0 : if( i_rPoly.isNextControlPointUsed( i ) )
332 [ # # ][ # # ]: 0 : aRet.setNextControlPoint( i, mirror( i_rPoly.getNextControlPoint( i ), i_pOutDev, i_bBack ) );
[ # # ]
333 : : }
334 [ # # ][ # # ]: 0 : aRet.setClosed( i_rPoly.isClosed() );
335 [ # # ]: 0 : aRet.flip();
336 : : }
337 : : else
338 [ # # ]: 0 : aRet = i_rPoly;
339 : 0 : return aRet;
340 : : }
341 : :
342 : 0 : basegfx::B2DPolyPolygon SalGraphics::mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
343 : : {
344 : : long w;
345 [ # # ][ # # ]: 0 : if( i_pOutDev && i_pOutDev->GetOutDevType() == OUTDEV_VIRDEV )
[ # # ]
346 : 0 : w = i_pOutDev->GetOutputWidthPixel();
347 : : else
348 : 0 : w = GetGraphicsWidth();
349 : :
350 : : DBG_ASSERT( w, "missing graphics width" );
351 : :
352 : 0 : basegfx::B2DPolyPolygon aRet;
353 [ # # ]: 0 : if( w )
354 : : {
355 [ # # ]: 0 : sal_Int32 nPoly = i_rPoly.count();
356 [ # # ]: 0 : for( sal_Int32 i = 0; i < nPoly; i++ )
357 [ # # ][ # # ]: 0 : aRet.append( mirror( i_rPoly.getB2DPolygon( i ), i_pOutDev, i_bBack ) );
[ # # ][ # # ]
[ # # ]
358 [ # # ][ # # ]: 0 : aRet.setClosed( i_rPoly.isClosed() );
359 [ # # ]: 0 : aRet.flip();
360 : : }
361 : : else
362 [ # # ]: 0 : aRet = i_rPoly;
363 : 0 : return aRet;
364 : : }
365 : :
366 : : // ----------------------------------------------------------------------------
367 : :
368 : 415321 : bool SalGraphics::SetClipRegion( const Region& i_rClip, const OutputDevice *pOutDev )
369 : : {
370 [ + + ][ + - ]: 415321 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ + + ][ + + ]
371 : : {
372 [ + - ]: 1139 : Region aMirror( i_rClip );
373 [ + - ]: 1139 : mirror( aMirror, pOutDev );
374 [ + - ][ + - ]: 1139 : return setClipRegion( aMirror );
375 : : }
376 : 415321 : return setClipRegion( i_rClip );
377 : : }
378 : :
379 : 405090 : void SalGraphics::DrawPixel( long nX, long nY, const OutputDevice *pOutDev )
380 : : {
381 [ + + ][ + - ]: 405090 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ + + ][ + + ]
382 : 468 : mirror( nX, pOutDev );
383 : 405090 : drawPixel( nX, nY );
384 : 405090 : }
385 : 307918 : void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor, const OutputDevice *pOutDev )
386 : : {
387 [ + - ][ + - ]: 307918 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
388 : 0 : mirror( nX, pOutDev );
389 : 307918 : drawPixel( nX, nY, nSalColor );
390 : 307918 : }
391 : 950997 : void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2, const OutputDevice *pOutDev )
392 : : {
393 [ + + ][ + - ]: 950997 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ + + ][ + + ]
394 : : {
395 : 3986 : mirror( nX1, pOutDev );
396 : 3986 : mirror( nX2, pOutDev );
397 : : }
398 : 950997 : drawLine( nX1, nY1, nX2, nY2 );
399 : 950997 : }
400 : 771829 : void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
401 : : {
402 [ + + ][ + - ]: 771829 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ + + ][ + + ]
403 : 3685 : mirror( nX, nWidth, pOutDev );
404 : 771829 : drawRect( nX, nY, nWidth, nHeight );
405 : 771829 : }
406 : :
407 : 214441 : void SalGraphics::DrawPolyLine( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
408 : : {
409 [ + - ][ + - ]: 214441 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
410 : : {
411 : 0 : SalPoint* pPtAry2 = new SalPoint[nPoints];
412 : 0 : sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
413 [ # # ]: 0 : drawPolyLine( nPoints, bCopied ? pPtAry2 : pPtAry );
414 [ # # ]: 0 : delete [] pPtAry2;
415 : : }
416 : : else
417 : 214441 : drawPolyLine( nPoints, pPtAry );
418 : 214441 : }
419 : :
420 : 2645104 : void SalGraphics::DrawPolygon( sal_uLong nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
421 : : {
422 [ + + ][ + - ]: 2645104 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ + + ]
423 : : {
424 : 1333 : SalPoint* pPtAry2 = new SalPoint[nPoints];
425 : 1333 : sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
426 [ + - ]: 1333 : drawPolygon( nPoints, bCopied ? pPtAry2 : pPtAry );
427 [ + - ]: 1333 : delete [] pPtAry2;
428 : : }
429 : : else
430 : 2643771 : drawPolygon( nPoints, pPtAry );
431 : 2645104 : }
432 : :
433 : 26523 : void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry, const OutputDevice *pOutDev )
434 : : {
435 [ + - ][ + - ]: 26523 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
436 : : {
437 : : // TODO: optimize, reduce new/delete calls
438 : 0 : SalPoint **pPtAry2 = new SalPoint*[nPoly];
439 : : sal_uLong i;
440 [ # # ]: 0 : for(i=0; i<nPoly; i++)
441 : : {
442 : 0 : sal_uLong nPoints = pPoints[i];
443 : 0 : pPtAry2[i] = new SalPoint[ nPoints ];
444 : 0 : mirror( nPoints, pPtAry[i], pPtAry2[i], pOutDev );
445 : : }
446 : :
447 : 0 : drawPolyPolygon( nPoly, pPoints, (PCONSTSALPOINT*)pPtAry2 );
448 : :
449 [ # # ]: 0 : for(i=0; i<nPoly; i++)
450 [ # # ]: 0 : delete [] pPtAry2[i];
451 [ # # ]: 0 : delete [] pPtAry2;
452 : : }
453 : : else
454 : 26523 : drawPolyPolygon( nPoly, pPoints, pPtAry );
455 : 26523 : }
456 : :
457 : 0 : bool SalGraphics::DrawPolyPolygon( const ::basegfx::B2DPolyPolygon& i_rPolyPolygon, double i_fTransparency, const OutputDevice* i_pOutDev )
458 : : {
459 : 0 : bool bRet = false;
460 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
461 : : {
462 [ # # ]: 0 : basegfx::B2DPolyPolygon aMirror( mirror( i_rPolyPolygon, i_pOutDev ) );
463 [ # # ][ # # ]: 0 : bRet = drawPolyPolygon( aMirror, i_fTransparency );
464 : : }
465 : : else
466 : 0 : bRet = drawPolyPolygon( i_rPolyPolygon, i_fTransparency );
467 : 0 : return bRet;
468 : : }
469 : :
470 : 0 : sal_Bool SalGraphics::DrawPolyLineBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev )
471 : : {
472 : 0 : sal_Bool bResult = sal_False;
473 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
474 : : {
475 : 0 : SalPoint* pPtAry2 = new SalPoint[nPoints];
476 : 0 : sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
477 [ # # ]: 0 : bResult = drawPolyLineBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry );
478 [ # # ]: 0 : delete [] pPtAry2;
479 : : }
480 : : else
481 : 0 : bResult = drawPolyLineBezier( nPoints, pPtAry, pFlgAry );
482 : 0 : return bResult;
483 : : }
484 : :
485 : 1494 : sal_Bool SalGraphics::DrawPolygonBezier( sal_uLong nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev )
486 : : {
487 : 1494 : sal_Bool bResult = sal_False;
488 [ + - ][ + - ]: 1494 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
489 : : {
490 : 0 : SalPoint* pPtAry2 = new SalPoint[nPoints];
491 : 0 : sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
492 [ # # ]: 0 : bResult = drawPolygonBezier( nPoints, bCopied ? pPtAry2 : pPtAry, pFlgAry );
493 [ # # ]: 0 : delete [] pPtAry2;
494 : : }
495 : : else
496 : 1494 : bResult = drawPolygonBezier( nPoints, pPtAry, pFlgAry );
497 : 1494 : return bResult;
498 : : }
499 : :
500 : 1830 : sal_Bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i_pPoints,
501 : : const SalPoint* const* i_pPtAry, const sal_uInt8* const* i_pFlgAry, const OutputDevice* i_pOutDev )
502 : : {
503 : 1830 : sal_Bool bRet = sal_False;
504 [ + - ][ + - ]: 1830 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
505 : : {
506 : : // TODO: optimize, reduce new/delete calls
507 : 0 : SalPoint **pPtAry2 = new SalPoint*[i_nPoly];
508 : : sal_uLong i;
509 [ # # ]: 0 : for(i=0; i<i_nPoly; i++)
510 : : {
511 : 0 : sal_uLong nPoints = i_pPoints[i];
512 : 0 : pPtAry2[i] = new SalPoint[ nPoints ];
513 : 0 : mirror( nPoints, i_pPtAry[i], pPtAry2[i], i_pOutDev );
514 : : }
515 : :
516 : 0 : bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, (PCONSTSALPOINT*)pPtAry2, i_pFlgAry );
517 : :
518 [ # # ]: 0 : for(i=0; i<i_nPoly; i++)
519 [ # # ]: 0 : delete [] pPtAry2[i];
520 [ # # ]: 0 : delete [] pPtAry2;
521 : : }
522 : : else
523 : 1830 : bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, i_pPtAry, i_pFlgAry );
524 : 1830 : return bRet;
525 : : }
526 : :
527 : 0 : bool SalGraphics::DrawPolyLine( const ::basegfx::B2DPolygon& i_rPolygon, double fTransparency,
528 : : const ::basegfx::B2DVector& i_rLineWidth, basegfx::B2DLineJoin i_eLineJoin,
529 : : const OutputDevice* i_pOutDev )
530 : : {
531 : 0 : bool bRet = false;
532 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
533 : : {
534 [ # # ]: 0 : basegfx::B2DPolygon aMirror( mirror( i_rPolygon, i_pOutDev ) );
535 [ # # ][ # # ]: 0 : bRet = drawPolyLine( aMirror, fTransparency, i_rLineWidth, i_eLineJoin );
536 : : }
537 : : else
538 : 0 : bRet = drawPolyLine( i_rPolygon, fTransparency, i_rLineWidth, i_eLineJoin );
539 : 0 : return bRet;
540 : : }
541 : :
542 : 399 : void SalGraphics::CopyArea( long nDestX, long nDestY,
543 : : long nSrcX, long nSrcY,
544 : : long nSrcWidth, long nSrcHeight,
545 : : sal_uInt16 nFlags, const OutputDevice *pOutDev )
546 : : {
547 [ + - ][ + - ]: 399 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
548 : : {
549 : 0 : mirror( nDestX, nSrcWidth, pOutDev );
550 : 0 : mirror( nSrcX, nSrcWidth, pOutDev );
551 : : }
552 : 399 : copyArea( nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, nFlags );
553 : 399 : }
554 : 54746 : void SalGraphics::CopyBits( const SalTwoRect* pPosAry,
555 : : SalGraphics* pSrcGraphics, const OutputDevice *pOutDev, const OutputDevice *pSrcOutDev )
556 : : {
557 [ + - ][ + - ]: 163388 : if( ( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) ) ||
[ + - ]
[ + + + - ]
[ + - - + ]
[ - + ]
558 : 108642 : (pSrcGraphics && ( (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) ) ) )
559 : : {
560 : 0 : SalTwoRect pPosAry2 = *pPosAry;
561 [ # # ][ # # ]: 0 : if( (pSrcGraphics && (pSrcGraphics->GetLayout() & SAL_LAYOUT_BIDI_RTL)) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
[ # # ]
562 [ # # ]: 0 : mirror( pPosAry2.mnSrcX, pPosAry2.mnSrcWidth, pSrcOutDev );
563 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
564 [ # # ]: 0 : mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
565 [ # # ]: 0 : copyBits( &pPosAry2, pSrcGraphics );
566 : : }
567 : : else
568 : 54746 : copyBits( pPosAry, pSrcGraphics );
569 : 54746 : }
570 : 219953 : void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
571 : : const SalBitmap& rSalBitmap, const OutputDevice *pOutDev )
572 : : {
573 [ + + ][ + - ]: 219953 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ + + ]
574 : : {
575 : 64 : SalTwoRect pPosAry2 = *pPosAry;
576 [ + - ]: 64 : mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
577 [ + - ]: 64 : drawBitmap( &pPosAry2, rSalBitmap );
578 : : }
579 : : else
580 : 219889 : drawBitmap( pPosAry, rSalBitmap );
581 : 219953 : }
582 : 3085 : void SalGraphics::DrawBitmap( const SalTwoRect* pPosAry,
583 : : const SalBitmap& rSalBitmap,
584 : : const SalBitmap& rTransparentBitmap, const OutputDevice *pOutDev )
585 : : {
586 [ + + ][ + - ]: 3085 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ + + ]
587 : : {
588 : 24 : SalTwoRect pPosAry2 = *pPosAry;
589 [ + - ]: 24 : mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
590 [ + - ]: 24 : drawBitmap( &pPosAry2, rSalBitmap, rTransparentBitmap );
591 : : }
592 : : else
593 : 3061 : drawBitmap( pPosAry, rSalBitmap, rTransparentBitmap );
594 : 3085 : }
595 : 0 : void SalGraphics::DrawMask( const SalTwoRect* pPosAry,
596 : : const SalBitmap& rSalBitmap,
597 : : SalColor nMaskColor, const OutputDevice *pOutDev )
598 : : {
599 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
600 : : {
601 : 0 : SalTwoRect pPosAry2 = *pPosAry;
602 [ # # ]: 0 : mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
603 [ # # ]: 0 : drawMask( &pPosAry2, rSalBitmap, nMaskColor );
604 : : }
605 : : else
606 : 0 : drawMask( pPosAry, rSalBitmap, nMaskColor );
607 : 0 : }
608 : 212773 : SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
609 : : {
610 [ + + ][ + - ]: 212773 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ + + ]
611 : 908 : mirror( nX, nWidth, pOutDev );
612 : 212773 : return getBitmap( nX, nY, nWidth, nHeight );
613 : : }
614 : 0 : SalColor SalGraphics::GetPixel( long nX, long nY, const OutputDevice *pOutDev )
615 : : {
616 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
617 : 0 : mirror( nX, pOutDev );
618 : 0 : return getPixel( nX, nY );
619 : : }
620 : 70059 : void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags, const OutputDevice *pOutDev )
621 : : {
622 [ + - ][ + - ]: 70059 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
623 : 0 : mirror( nX, nWidth, pOutDev );
624 : 70059 : invert( nX, nY, nWidth, nHeight, nFlags );
625 : 70059 : }
626 : 0 : void SalGraphics::Invert( sal_uLong nPoints, const SalPoint* pPtAry, SalInvert nFlags, const OutputDevice *pOutDev )
627 : : {
628 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
629 : : {
630 : 0 : SalPoint* pPtAry2 = new SalPoint[nPoints];
631 : 0 : sal_Bool bCopied = mirror( nPoints, pPtAry, pPtAry2, pOutDev );
632 [ # # ]: 0 : invert( nPoints, bCopied ? pPtAry2 : pPtAry, nFlags );
633 [ # # ]: 0 : delete [] pPtAry2;
634 : : }
635 : : else
636 : 0 : invert( nPoints, pPtAry, nFlags );
637 : 0 : }
638 : :
639 : 0 : sal_Bool SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize, const OutputDevice *pOutDev )
640 : : {
641 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
642 : 0 : mirror( nX, nWidth, pOutDev );
643 : 0 : return drawEPS( nX, nY, nWidth, nHeight, pPtr, nSize );
644 : : }
645 : :
646 : 0 : sal_Bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
647 : : const Point& aPos, sal_Bool& rIsInside, const OutputDevice *pOutDev )
648 : : {
649 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
650 : : {
651 : 0 : Point pt( aPos );
652 : 0 : Rectangle rgn( rControlRegion );
653 [ # # ]: 0 : mirror( pt.X(), pOutDev );
654 [ # # ]: 0 : mirror( rgn, pOutDev );
655 [ # # ]: 0 : return hitTestNativeControl( nType, nPart, rgn, pt, rIsInside );
656 : : }
657 : : else
658 : 0 : return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rIsInside );
659 : : }
660 : :
661 : 121 : void SalGraphics::mirror( ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const
662 : : {
663 [ - - - - : 121 : switch( rVal.getType() )
+ ]
664 : : {
665 : : case CTRL_SLIDER:
666 : : {
667 : 0 : SliderValue* pSlVal = static_cast<SliderValue*>(&rVal);
668 : 0 : mirror(pSlVal->maThumbRect,pOutDev,bBack);
669 : : }
670 : 0 : break;
671 : : case CTRL_SCROLLBAR:
672 : : {
673 : 0 : ScrollbarValue* pScVal = static_cast<ScrollbarValue*>(&rVal);
674 : 0 : mirror(pScVal->maThumbRect,pOutDev,bBack);
675 : 0 : mirror(pScVal->maButton1Rect,pOutDev,bBack);
676 : 0 : mirror(pScVal->maButton2Rect,pOutDev,bBack);
677 : : }
678 : 0 : break;
679 : : case CTRL_SPINBOX:
680 : : case CTRL_SPINBUTTONS:
681 : : {
682 : 0 : SpinbuttonValue* pSpVal = static_cast<SpinbuttonValue*>(&rVal);
683 : 0 : mirror(pSpVal->maUpperRect,pOutDev,bBack);
684 : 0 : mirror(pSpVal->maLowerRect,pOutDev,bBack);
685 : : }
686 : 0 : break;
687 : : case CTRL_TOOLBAR:
688 : : {
689 : 0 : ToolbarValue* pTVal = static_cast<ToolbarValue*>(&rVal);
690 : 0 : mirror(pTVal->maGripRect,pOutDev,bBack);
691 : : }
692 : 0 : break;
693 : : }
694 : 121 : }
695 : :
696 : 0 : sal_Bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
697 : : ControlState nState, const ImplControlValue& aValue,
698 : : const OUString& aCaption, const OutputDevice *pOutDev )
699 : : {
700 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
701 : : {
702 : 0 : Rectangle rgn( rControlRegion );
703 [ # # ]: 0 : mirror( rgn, pOutDev );
704 [ # # ]: 0 : boost::scoped_ptr< ImplControlValue > mirrorValue( aValue.clone());
705 [ # # ]: 0 : mirror( *mirrorValue, pOutDev );
706 [ # # ]: 0 : sal_Bool bRet = drawNativeControl( nType, nPart, rgn, nState, *mirrorValue, aCaption );
707 [ # # ]: 0 : return bRet;
708 : : }
709 : : else
710 : 0 : return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption );
711 : : }
712 : :
713 : 54002 : sal_Bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
714 : : const ImplControlValue& aValue, const OUString& aCaption,
715 : : Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion, const OutputDevice *pOutDev )
716 : : {
717 [ + - ][ + - ]: 54002 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ + + ][ + + ]
718 : : {
719 : 121 : Rectangle rgn( rControlRegion );
720 [ + - ]: 121 : mirror( rgn, pOutDev );
721 [ + - ]: 121 : boost::scoped_ptr< ImplControlValue > mirrorValue( aValue.clone());
722 [ + - ]: 121 : mirror( *mirrorValue, pOutDev );
723 [ - + ]: 242 : if( getNativeControlRegion( nType, nPart, rgn, nState, *mirrorValue, aCaption,
724 [ + - ]: 121 : rNativeBoundingRegion, rNativeContentRegion ) )
725 : : {
726 [ # # ]: 0 : mirror( rNativeBoundingRegion, pOutDev, true );
727 [ # # ]: 0 : mirror( rNativeContentRegion, pOutDev, true );
728 : 0 : return sal_True;
729 : : }
730 [ + - ]: 121 : return sal_False;
731 : : }
732 : : else
733 : : return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, aCaption,
734 : 54002 : rNativeBoundingRegion, rNativeContentRegion );
735 : : }
736 : :
737 : 175520 : bool SalGraphics::DrawAlphaBitmap( const SalTwoRect& rPosAry,
738 : : const SalBitmap& rSourceBitmap,
739 : : const SalBitmap& rAlphaBitmap,
740 : : const OutputDevice *pOutDev )
741 : : {
742 [ + - ][ + - ]: 175520 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ - + ][ - + ]
743 : : {
744 : 0 : SalTwoRect pPosAry2 = rPosAry;
745 [ # # ]: 0 : mirror( pPosAry2.mnDestX, pPosAry2.mnDestWidth, pOutDev );
746 [ # # ]: 0 : return drawAlphaBitmap( pPosAry2, rSourceBitmap, rAlphaBitmap );
747 : : }
748 : : else
749 : 175520 : return drawAlphaBitmap( rPosAry, rSourceBitmap, rAlphaBitmap );
750 : : }
751 : :
752 : 0 : bool SalGraphics::DrawAlphaRect( long nX, long nY, long nWidth, long nHeight,
753 : : sal_uInt8 nTransparency, const OutputDevice *pOutDev )
754 : : {
755 [ # # ][ # # ]: 0 : if( (m_nLayout & SAL_LAYOUT_BIDI_RTL) || (pOutDev && pOutDev->IsRTLEnabled()) )
[ # # ][ # # ]
756 : 0 : mirror( nX, nWidth, pOutDev );
757 : :
758 : 0 : return drawAlphaRect( nX, nY, nWidth, nHeight, nTransparency );
759 : : }
760 : :
761 : 150228 : bool SalGraphics::filterText( const rtl::OUString&, rtl::OUString&, xub_StrLen, xub_StrLen&, xub_StrLen&, xub_StrLen& )
762 : : {
763 : 150228 : return false;
764 : : }
765 : :
766 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|