Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <tools/debug.hxx>
21 : #include <tools/poly.hxx>
22 :
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>
34 :
35 : #include <window.h>
36 : #include <openglgdiimpl.hxx>
37 : #include <outdev.h>
38 : #include <sallayout.hxx>
39 : #include <salgdi.hxx>
40 : #include <salframe.hxx>
41 : #include <salvd.hxx>
42 : #include <salprn.hxx>
43 : #include <svdata.hxx>
44 : #include <outdata.hxx>
45 : #include <boost/scoped_array.hpp>
46 : #include <memory>
47 :
48 : #include <basegfx/polygon/b2dpolygon.hxx>
49 :
50 : // The only common SalFrame method
51 :
52 24782 : SalFrameGeometry SalFrame::GetGeometry()
53 : {
54 : // mirror frame coordinates at parent
55 24782 : SalFrame *pParent = GetParent();
56 24782 : if( pParent && AllSettings::GetLayoutRTL() )
57 : {
58 0 : SalFrameGeometry aGeom = maGeometry;
59 0 : int parent_x = aGeom.nX - pParent->maGeometry.nX;
60 0 : aGeom.nX = pParent->maGeometry.nX + pParent->maGeometry.nWidth - maGeometry.nWidth - parent_x;
61 0 : return aGeom;
62 : }
63 : else
64 24782 : return maGeometry;
65 : }
66 :
67 416261 : SalGraphics::SalGraphics()
68 : : m_nLayout( SalLayoutFlags::NONE ),
69 416261 : m_bAntiAliasB2DDraw(false)
70 : {
71 : // read global RTL settings
72 416261 : if( AllSettings::GetLayoutRTL() )
73 0 : m_nLayout = SalLayoutFlags::BiDiRtl;
74 416261 : }
75 :
76 413327 : SalGraphics::~SalGraphics()
77 : {
78 413327 : }
79 :
80 213 : OpenGLContext* SalGraphics::GetOpenGLContext() const
81 : {
82 213 : OpenGLSalGraphicsImpl *pImpl = dynamic_cast<OpenGLSalGraphicsImpl*>(GetImpl());
83 213 : if (pImpl)
84 0 : return pImpl->GetOpenGLContext();
85 :
86 213 : return NULL;
87 : }
88 :
89 0 : 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 */)
95 : {
96 : // here direct support for transformed bitmaps can be implemented
97 0 : return false;
98 : }
99 :
100 13030 : void SalGraphics::mirror( long& x, const OutputDevice *pOutDev, bool bBack ) const
101 : {
102 13030 : long w = GetGraphicsWidth();
103 :
104 13030 : if( w )
105 : {
106 13030 : if( pOutDev && pOutDev->ImplIsAntiparallel() )
107 : {
108 396 : OutputDevice *pOutDevRef = const_cast<OutputDevice*>(pOutDev);
109 : // mirror this window back
110 396 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) )
111 : {
112 0 : long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
113 0 : if( bBack )
114 0 : x = x - devX + pOutDevRef->GetOutOffXPixel();
115 : else
116 0 : x = devX + (x - pOutDevRef->GetOutOffXPixel());
117 : }
118 : else
119 : {
120 396 : long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
121 396 : if( bBack )
122 0 : x = devX + (pOutDevRef->GetOutputWidthPixel() + devX) - (x + 1);
123 : else
124 396 : x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - 1;
125 : }
126 : }
127 12634 : else if( (m_nLayout & SalLayoutFlags::BiDiRtl) )
128 12634 : x = w-1-x;
129 : }
130 13030 : }
131 :
132 13701 : void SalGraphics::mirror( long& x, long& nWidth, const OutputDevice *pOutDev, bool bBack ) const
133 : {
134 13701 : long w = GetGraphicsWidth();
135 :
136 13701 : if( w )
137 : {
138 13701 : if( pOutDev && pOutDev->ImplIsAntiparallel() )
139 : {
140 243 : OutputDevice *pOutDevRef = const_cast<OutputDevice*>(pOutDev);
141 : // mirror this window back
142 243 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) )
143 : {
144 0 : long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
145 0 : if( bBack )
146 0 : x = x - devX + pOutDevRef->GetOutOffXPixel();
147 : else
148 0 : x = devX + (x - pOutDevRef->GetOutOffXPixel());
149 : }
150 : else
151 : {
152 243 : long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
153 243 : if( bBack )
154 0 : x = devX + (pOutDevRef->GetOutputWidthPixel() + devX) - (x + nWidth);
155 : else
156 243 : x = pOutDevRef->GetOutputWidthPixel() - (x - devX) + pOutDevRef->GetOutOffXPixel() - nWidth;
157 : }
158 : }
159 13458 : else if( (m_nLayout & SalLayoutFlags::BiDiRtl) )
160 13164 : x = w-nWidth-x;
161 :
162 : }
163 13701 : }
164 :
165 818 : bool SalGraphics::mirror( sal_uInt32 nPoints, const SalPoint *pPtAry, SalPoint *pPtAry2, const OutputDevice *pOutDev, bool bBack ) const
166 : {
167 818 : long w = GetGraphicsWidth();
168 :
169 818 : if( w )
170 : {
171 : sal_uInt32 i, j;
172 :
173 818 : if( pOutDev && pOutDev->ImplIsAntiparallel() )
174 : {
175 0 : OutputDevice *pOutDevRef = const_cast<OutputDevice*>(pOutDev);
176 : // mirror this window back
177 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) )
178 : {
179 0 : long devX = w-pOutDevRef->GetOutputWidthPixel()-pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
180 0 : if( bBack )
181 : {
182 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
183 : {
184 : //long x = w-1-pPtAry[i].mnX;
185 : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
186 0 : pPtAry2[j].mnX = pOutDevRef->GetOutOffXPixel() + (pPtAry[i].mnX - devX);
187 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
188 : }
189 : }
190 : else
191 : {
192 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
193 : {
194 : //long x = w-1-pPtAry[i].mnX;
195 : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
196 0 : pPtAry2[j].mnX = devX + (pPtAry[i].mnX - pOutDevRef->GetOutOffXPixel());
197 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
198 : }
199 : }
200 : }
201 : else
202 : {
203 0 : long devX = pOutDevRef->GetOutOffXPixel(); // re-mirrored mnOutOffX
204 0 : if( bBack )
205 : {
206 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
207 : {
208 : //long x = w-1-pPtAry[i].mnX;
209 : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
210 0 : pPtAry2[j].mnX = pPtAry[i].mnX - pOutDevRef->GetOutputWidthPixel() + devX - pOutDevRef->GetOutOffXPixel() + 1;
211 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
212 : }
213 : }
214 : else
215 : {
216 0 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
217 : {
218 : //long x = w-1-pPtAry[i].mnX;
219 : //pPtAry2[j].mnX = devX + ( pOutDevRef->mnOutWidth - 1 - (x - devX) );
220 0 : pPtAry2[j].mnX = pOutDevRef->GetOutputWidthPixel() - (pPtAry[i].mnX - devX) + pOutDevRef->GetOutOffXPixel() - 1;
221 0 : pPtAry2[j].mnY = pPtAry[i].mnY;
222 : }
223 : }
224 : }
225 : }
226 818 : else if( (m_nLayout & SalLayoutFlags::BiDiRtl) )
227 : {
228 10092 : for( i=0, j=nPoints-1; i<nPoints; i++,j-- )
229 : {
230 9274 : pPtAry2[j].mnX = w-1-pPtAry[i].mnX;
231 9274 : pPtAry2[j].mnY = pPtAry[i].mnY;
232 : }
233 : }
234 818 : return true;
235 : }
236 : else
237 0 : return false;
238 : }
239 :
240 2935 : void SalGraphics::mirror( vcl::Region& rRgn, const OutputDevice *pOutDev, bool bBack ) const
241 : {
242 2935 : if( rRgn.HasPolyPolygonOrB2DPolyPolygon() )
243 : {
244 0 : const basegfx::B2DPolyPolygon aPolyPoly(mirror(rRgn.GetAsB2DPolyPolygon(), pOutDev, bBack));
245 :
246 0 : rRgn = vcl::Region(aPolyPoly);
247 : }
248 : else
249 : {
250 2935 : RectangleVector aRectangles;
251 2935 : rRgn.GetRegionRectangles(aRectangles);
252 2935 : rRgn.SetEmpty();
253 :
254 5870 : for(RectangleVector::iterator aRectIter(aRectangles.begin()); aRectIter != aRectangles.end(); ++aRectIter)
255 : {
256 2935 : mirror(*aRectIter, pOutDev, bBack);
257 2935 : rRgn.Union(*aRectIter);
258 2935 : }
259 :
260 : //ImplRegionInfo aInfo;
261 : //bool bRegionRect;
262 : //Region aMirroredRegion;
263 : //long nX, nY, nWidth, nHeight;
264 :
265 : //bRegionRect = rRgn.ImplGetFirstRect( aInfo, nX, nY, nWidth, nHeight );
266 : //while ( bRegionRect )
267 : //{
268 : // Rectangle aRect( Point(nX, nY), Size(nWidth, nHeight) );
269 : // mirror( aRect, pOutDev, bBack );
270 : // aMirroredRegion.Union( aRect );
271 : // bRegionRect = rRgn.ImplGetNextRect( aInfo, nX, nY, nWidth, nHeight );
272 : //}
273 : //rRgn = aMirroredRegion;
274 : }
275 2935 : }
276 :
277 3059 : void SalGraphics::mirror( Rectangle& rRect, const OutputDevice *pOutDev, bool bBack ) const
278 : {
279 3059 : long nWidth = rRect.GetWidth();
280 3059 : long x = rRect.Left();
281 3059 : long x_org = x;
282 :
283 3059 : mirror( x, nWidth, pOutDev, bBack );
284 3059 : rRect.Move( x - x_org, 0 );
285 3059 : }
286 :
287 0 : basegfx::B2DPoint SalGraphics::mirror( const basegfx::B2DPoint& i_rPoint, const OutputDevice *i_pOutDev, bool i_bBack ) const
288 : {
289 0 : long 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 = const_cast<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 0 : long w = GetGraphicsWidth();
315 :
316 : DBG_ASSERT( w, "missing graphics width" );
317 :
318 0 : basegfx::B2DPolygon aRet;
319 0 : if( w )
320 : {
321 0 : sal_Int32 nPoints = i_rPoly.count();
322 0 : for( sal_Int32 i = 0; i < nPoints; i++ )
323 : {
324 0 : aRet.append( mirror( i_rPoly.getB2DPoint( i ), i_pOutDev, i_bBack ) );
325 0 : if( i_rPoly.isPrevControlPointUsed( i ) )
326 0 : aRet.setPrevControlPoint( i, mirror( i_rPoly.getPrevControlPoint( i ), i_pOutDev, i_bBack ) );
327 0 : if( i_rPoly.isNextControlPointUsed( i ) )
328 0 : aRet.setNextControlPoint( i, mirror( i_rPoly.getNextControlPoint( i ), i_pOutDev, i_bBack ) );
329 : }
330 0 : aRet.setClosed( i_rPoly.isClosed() );
331 0 : aRet.flip();
332 : }
333 : else
334 0 : aRet = i_rPoly;
335 0 : return aRet;
336 : }
337 :
338 0 : basegfx::B2DPolyPolygon SalGraphics::mirror( const basegfx::B2DPolyPolygon& i_rPoly, const OutputDevice *i_pOutDev, bool i_bBack ) const
339 : {
340 0 : long w = GetGraphicsWidth();
341 :
342 : DBG_ASSERT( w, "missing graphics width" );
343 :
344 0 : basegfx::B2DPolyPolygon aRet;
345 0 : if( w )
346 : {
347 0 : sal_Int32 nPoly = i_rPoly.count();
348 0 : for( sal_Int32 i = 0; i < nPoly; i++ )
349 0 : aRet.append( mirror( i_rPoly.getB2DPolygon( i ), i_pOutDev, i_bBack ) );
350 0 : aRet.setClosed( i_rPoly.isClosed() );
351 0 : aRet.flip();
352 : }
353 : else
354 0 : aRet = i_rPoly;
355 0 : return aRet;
356 : }
357 :
358 513440 : bool SalGraphics::SetClipRegion( const vcl::Region& i_rClip, const OutputDevice *pOutDev )
359 : {
360 513440 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
361 : {
362 2935 : vcl::Region aMirror( i_rClip );
363 2935 : mirror( aMirror, pOutDev );
364 2935 : return setClipRegion( aMirror );
365 : }
366 510505 : return setClipRegion( i_rClip );
367 : }
368 :
369 348844 : void SalGraphics::DrawPixel( long nX, long nY, const OutputDevice *pOutDev )
370 : {
371 348844 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
372 800 : mirror( nX, pOutDev );
373 348844 : drawPixel( nX, nY );
374 348844 : }
375 :
376 402957 : void SalGraphics::DrawPixel( long nX, long nY, SalColor nSalColor, const OutputDevice *pOutDev )
377 : {
378 402957 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
379 0 : mirror( nX, pOutDev );
380 402957 : drawPixel( nX, nY, nSalColor );
381 402957 : }
382 :
383 1113448 : void SalGraphics::DrawLine( long nX1, long nY1, long nX2, long nY2, const OutputDevice *pOutDev )
384 : {
385 1113448 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
386 : {
387 6115 : mirror( nX1, pOutDev );
388 6115 : mirror( nX2, pOutDev );
389 : }
390 1113448 : drawLine( nX1, nY1, nX2, nY2 );
391 1113448 : }
392 :
393 1684288 : void SalGraphics::DrawRect( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
394 : {
395 1684288 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
396 7305 : mirror( nX, nWidth, pOutDev );
397 1684288 : drawRect( nX, nY, nWidth, nHeight );
398 1684288 : }
399 :
400 158086 : void SalGraphics::DrawPolyLine( sal_uInt32 nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
401 : {
402 158086 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
403 : {
404 192 : boost::scoped_array<SalPoint> pPtAry2(new SalPoint[nPoints]);
405 192 : bool bCopied = mirror( nPoints, pPtAry, pPtAry2.get(), pOutDev );
406 192 : drawPolyLine( nPoints, bCopied ? pPtAry2.get() : pPtAry );
407 : }
408 : else
409 157894 : drawPolyLine( nPoints, pPtAry );
410 158086 : }
411 :
412 1760632 : void SalGraphics::DrawPolygon( sal_uInt32 nPoints, const SalPoint* pPtAry, const OutputDevice *pOutDev )
413 : {
414 1760632 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
415 : {
416 626 : boost::scoped_array<SalPoint> pPtAry2(new SalPoint[nPoints]);
417 626 : bool bCopied = mirror( nPoints, pPtAry, pPtAry2.get(), pOutDev );
418 626 : drawPolygon( nPoints, bCopied ? pPtAry2.get() : pPtAry );
419 : }
420 : else
421 1760006 : drawPolygon( nPoints, pPtAry );
422 1760632 : }
423 :
424 3390 : void SalGraphics::DrawPolyPolygon( sal_uInt32 nPoly, const sal_uInt32* pPoints, PCONSTSALPOINT* pPtAry, const OutputDevice *pOutDev )
425 : {
426 3390 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
427 : {
428 : // TODO: optimize, reduce new/delete calls
429 0 : SalPoint **pPtAry2 = new SalPoint*[nPoly];
430 : sal_uLong i;
431 0 : for(i=0; i<nPoly; i++)
432 : {
433 0 : sal_uLong nPoints = pPoints[i];
434 0 : pPtAry2[i] = new SalPoint[ nPoints ];
435 0 : mirror( nPoints, pPtAry[i], pPtAry2[i], pOutDev );
436 : }
437 :
438 0 : drawPolyPolygon( nPoly, pPoints, const_cast<PCONSTSALPOINT*>(pPtAry2) );
439 :
440 0 : for(i=0; i<nPoly; i++)
441 0 : delete [] pPtAry2[i];
442 0 : delete [] pPtAry2;
443 : }
444 : else
445 3390 : drawPolyPolygon( nPoly, pPoints, pPtAry );
446 3390 : }
447 :
448 0 : bool SalGraphics::DrawPolyPolygon( const basegfx::B2DPolyPolygon& i_rPolyPolygon, double i_fTransparency, const OutputDevice* i_pOutDev )
449 : {
450 0 : bool bRet = false;
451 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
452 : {
453 0 : basegfx::B2DPolyPolygon aMirror( mirror( i_rPolyPolygon, i_pOutDev ) );
454 0 : bRet = drawPolyPolygon( aMirror, i_fTransparency );
455 : }
456 : else
457 0 : bRet = drawPolyPolygon( i_rPolyPolygon, i_fTransparency );
458 0 : return bRet;
459 : }
460 :
461 0 : bool SalGraphics::DrawPolyLineBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev )
462 : {
463 0 : bool bResult = false;
464 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
465 : {
466 0 : boost::scoped_array<SalPoint> pPtAry2(new SalPoint[nPoints]);
467 0 : bool bCopied = mirror( nPoints, pPtAry, pPtAry2.get(), pOutDev );
468 0 : bResult = drawPolyLineBezier( nPoints, bCopied ? pPtAry2.get() : pPtAry, pFlgAry );
469 : }
470 : else
471 0 : bResult = drawPolyLineBezier( nPoints, pPtAry, pFlgAry );
472 0 : return bResult;
473 : }
474 :
475 9540 : bool SalGraphics::DrawPolygonBezier( sal_uInt32 nPoints, const SalPoint* pPtAry, const sal_uInt8* pFlgAry, const OutputDevice* pOutDev )
476 : {
477 9540 : bool bResult = false;
478 9540 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
479 : {
480 0 : boost::scoped_array<SalPoint> pPtAry2(new SalPoint[nPoints]);
481 0 : bool bCopied = mirror( nPoints, pPtAry, pPtAry2.get(), pOutDev );
482 0 : bResult = drawPolygonBezier( nPoints, bCopied ? pPtAry2.get() : pPtAry, pFlgAry );
483 : }
484 : else
485 9540 : bResult = drawPolygonBezier( nPoints, pPtAry, pFlgAry );
486 9540 : return bResult;
487 : }
488 :
489 2852 : bool SalGraphics::DrawPolyPolygonBezier( sal_uInt32 i_nPoly, const sal_uInt32* i_pPoints,
490 : const SalPoint* const* i_pPtAry, const sal_uInt8* const* i_pFlgAry, const OutputDevice* i_pOutDev )
491 : {
492 2852 : bool bRet = false;
493 2852 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
494 : {
495 : // TODO: optimize, reduce new/delete calls
496 0 : SalPoint **pPtAry2 = new SalPoint*[i_nPoly];
497 : sal_uLong i;
498 0 : for(i=0; i<i_nPoly; i++)
499 : {
500 0 : sal_uLong nPoints = i_pPoints[i];
501 0 : pPtAry2[i] = new SalPoint[ nPoints ];
502 0 : mirror( nPoints, i_pPtAry[i], pPtAry2[i], i_pOutDev );
503 : }
504 :
505 0 : bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, const_cast<PCONSTSALPOINT const *>(pPtAry2), i_pFlgAry );
506 :
507 0 : for(i=0; i<i_nPoly; i++)
508 0 : delete [] pPtAry2[i];
509 0 : delete [] pPtAry2;
510 : }
511 : else
512 2852 : bRet = drawPolyPolygonBezier( i_nPoly, i_pPoints, i_pPtAry, i_pFlgAry );
513 2852 : return bRet;
514 : }
515 :
516 0 : bool SalGraphics::DrawPolyLine( const basegfx::B2DPolygon& i_rPolygon,
517 : double i_fTransparency,
518 : const basegfx::B2DVector& i_rLineWidth,
519 : basegfx::B2DLineJoin i_eLineJoin,
520 : com::sun::star::drawing::LineCap i_eLineCap,
521 : const OutputDevice* i_pOutDev )
522 : {
523 0 : bool bRet = false;
524 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (i_pOutDev && i_pOutDev->IsRTLEnabled()) )
525 : {
526 0 : basegfx::B2DPolygon aMirror( mirror( i_rPolygon, i_pOutDev ) );
527 0 : bRet = drawPolyLine( aMirror, i_fTransparency, i_rLineWidth, i_eLineJoin, i_eLineCap );
528 : }
529 : else
530 0 : bRet = drawPolyLine( i_rPolygon, i_fTransparency, i_rLineWidth, i_eLineJoin, i_eLineCap );
531 0 : return bRet;
532 : }
533 :
534 155833 : bool SalGraphics::DrawGradient( const tools::PolyPolygon& rPolyPoly, const Gradient& rGradient, OutputDevice* )
535 : {
536 155833 : return drawGradient( rPolyPoly, rGradient );
537 : }
538 :
539 311 : void SalGraphics::CopyArea( long nDestX, long nDestY,
540 : long nSrcX, long nSrcY,
541 : long nSrcWidth, long nSrcHeight,
542 : sal_uInt16 nFlags, const OutputDevice *pOutDev )
543 : {
544 311 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
545 : {
546 0 : mirror( nDestX, nSrcWidth, pOutDev );
547 0 : mirror( nSrcX, nSrcWidth, pOutDev );
548 : }
549 311 : copyArea( nDestX, nDestY, nSrcX, nSrcY, nSrcWidth, nSrcHeight, nFlags );
550 311 : }
551 :
552 96244 : void SalGraphics::CopyBits( const SalTwoRect& rPosAry,
553 : SalGraphics* pSrcGraphics, const OutputDevice *pOutDev, const OutputDevice *pSrcOutDev )
554 : {
555 192635 : if( ( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) ) ||
556 191975 : (pSrcGraphics && ( (pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) ) ) )
557 : {
558 147 : SalTwoRect aPosAry2 = rPosAry;
559 147 : if( (pSrcGraphics && (pSrcGraphics->GetLayout() & SalLayoutFlags::BiDiRtl)) || (pSrcOutDev && pSrcOutDev->IsRTLEnabled()) )
560 147 : mirror( aPosAry2.mnSrcX, aPosAry2.mnSrcWidth, pSrcOutDev );
561 147 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
562 147 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
563 147 : copyBits( aPosAry2, pSrcGraphics );
564 : }
565 : else
566 96097 : copyBits( rPosAry, pSrcGraphics );
567 96244 : }
568 :
569 169667 : void SalGraphics::DrawBitmap( const SalTwoRect& rPosAry,
570 : const SalBitmap& rSalBitmap, const OutputDevice *pOutDev )
571 : {
572 169667 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
573 : {
574 472 : SalTwoRect aPosAry2 = rPosAry;
575 472 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
576 472 : drawBitmap( aPosAry2, rSalBitmap );
577 : }
578 : else
579 169195 : drawBitmap( rPosAry, rSalBitmap );
580 169667 : }
581 :
582 12349 : void SalGraphics::DrawBitmap( const SalTwoRect& rPosAry,
583 : const SalBitmap& rSalBitmap,
584 : const SalBitmap& rTransparentBitmap, const OutputDevice *pOutDev )
585 : {
586 12349 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
587 : {
588 86 : SalTwoRect aPosAry2 = rPosAry;
589 86 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
590 86 : drawBitmap( aPosAry2, rSalBitmap, rTransparentBitmap );
591 : }
592 : else
593 12263 : drawBitmap( rPosAry, rSalBitmap, rTransparentBitmap );
594 12349 : }
595 :
596 9 : void SalGraphics::DrawMask( const SalTwoRect& rPosAry,
597 : const SalBitmap& rSalBitmap,
598 : SalColor nMaskColor, const OutputDevice *pOutDev )
599 : {
600 9 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
601 : {
602 0 : SalTwoRect aPosAry2 = rPosAry;
603 0 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
604 0 : drawMask( aPosAry2, rSalBitmap, nMaskColor );
605 : }
606 : else
607 9 : drawMask( rPosAry, rSalBitmap, nMaskColor );
608 9 : }
609 :
610 176036 : SalBitmap* SalGraphics::GetBitmap( long nX, long nY, long nWidth, long nHeight, const OutputDevice *pOutDev )
611 : {
612 176036 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
613 2163 : mirror( nX, nWidth, pOutDev );
614 176036 : return getBitmap( nX, nY, nWidth, nHeight );
615 : }
616 :
617 4 : SalColor SalGraphics::GetPixel( long nX, long nY, const OutputDevice *pOutDev )
618 : {
619 4 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
620 0 : mirror( nX, pOutDev );
621 4 : return getPixel( nX, nY );
622 : }
623 :
624 62345 : void SalGraphics::Invert( long nX, long nY, long nWidth, long nHeight, SalInvert nFlags, const OutputDevice *pOutDev )
625 : {
626 62345 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
627 0 : mirror( nX, nWidth, pOutDev );
628 62345 : invert( nX, nY, nWidth, nHeight, nFlags );
629 62345 : }
630 :
631 18 : void SalGraphics::Invert( sal_uInt32 nPoints, const SalPoint* pPtAry, SalInvert nFlags, const OutputDevice *pOutDev )
632 : {
633 18 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
634 : {
635 0 : boost::scoped_array<SalPoint> pPtAry2(new SalPoint[nPoints]);
636 0 : bool bCopied = mirror( nPoints, pPtAry, pPtAry2.get(), pOutDev );
637 0 : invert( nPoints, bCopied ? pPtAry2.get() : pPtAry, nFlags );
638 : }
639 : else
640 18 : invert( nPoints, pPtAry, nFlags );
641 18 : }
642 :
643 0 : bool SalGraphics::DrawEPS( long nX, long nY, long nWidth, long nHeight, void* pPtr, sal_uLong nSize, const OutputDevice *pOutDev )
644 : {
645 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
646 0 : mirror( nX, nWidth, pOutDev );
647 0 : return drawEPS( nX, nY, nWidth, nHeight, pPtr, nSize );
648 : }
649 :
650 0 : bool SalGraphics::HitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
651 : const Point& aPos, bool& rIsInside, const OutputDevice *pOutDev )
652 : {
653 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
654 : {
655 0 : Point pt( aPos );
656 0 : Rectangle rgn( rControlRegion );
657 0 : mirror( pt.X(), pOutDev );
658 0 : mirror( rgn, pOutDev );
659 0 : return hitTestNativeControl( nType, nPart, rgn, pt, rIsInside );
660 : }
661 : else
662 0 : return hitTestNativeControl( nType, nPart, rControlRegion, aPos, rIsInside );
663 : }
664 :
665 124 : void SalGraphics::mirror( ImplControlValue& rVal, const OutputDevice* pOutDev, bool bBack ) const
666 : {
667 124 : switch( rVal.getType() )
668 : {
669 : case CTRL_SLIDER:
670 : {
671 0 : SliderValue* pSlVal = static_cast<SliderValue*>(&rVal);
672 0 : mirror(pSlVal->maThumbRect,pOutDev,bBack);
673 : }
674 0 : break;
675 : case CTRL_SCROLLBAR:
676 : {
677 0 : ScrollbarValue* pScVal = static_cast<ScrollbarValue*>(&rVal);
678 0 : mirror(pScVal->maThumbRect,pOutDev,bBack);
679 0 : mirror(pScVal->maButton1Rect,pOutDev,bBack);
680 0 : mirror(pScVal->maButton2Rect,pOutDev,bBack);
681 : }
682 0 : break;
683 : case CTRL_SPINBOX:
684 : case CTRL_SPINBUTTONS:
685 : {
686 0 : SpinbuttonValue* pSpVal = static_cast<SpinbuttonValue*>(&rVal);
687 0 : mirror(pSpVal->maUpperRect,pOutDev,bBack);
688 0 : mirror(pSpVal->maLowerRect,pOutDev,bBack);
689 : }
690 0 : break;
691 : case CTRL_TOOLBAR:
692 : {
693 0 : ToolbarValue* pTVal = static_cast<ToolbarValue*>(&rVal);
694 0 : mirror(pTVal->maGripRect,pOutDev,bBack);
695 : }
696 0 : break;
697 : }
698 124 : }
699 :
700 0 : bool SalGraphics::DrawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
701 : ControlState nState, const ImplControlValue& aValue,
702 : const OUString& aCaption, const OutputDevice *pOutDev )
703 : {
704 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
705 : {
706 0 : Rectangle rgn( rControlRegion );
707 0 : mirror( rgn, pOutDev );
708 0 : std::unique_ptr< ImplControlValue > mirrorValue( aValue.clone());
709 0 : mirror( *mirrorValue, pOutDev );
710 0 : bool bRet = drawNativeControl( nType, nPart, rgn, nState, *mirrorValue, aCaption );
711 0 : return bRet;
712 : }
713 : else
714 0 : return drawNativeControl( nType, nPart, rControlRegion, nState, aValue, aCaption );
715 : }
716 :
717 180152 : bool SalGraphics::GetNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
718 : const ImplControlValue& aValue, const OUString& aCaption,
719 : Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion, const OutputDevice *pOutDev )
720 : {
721 180152 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
722 : {
723 124 : Rectangle rgn( rControlRegion );
724 124 : mirror( rgn, pOutDev );
725 124 : std::unique_ptr< ImplControlValue > mirrorValue( aValue.clone());
726 124 : mirror( *mirrorValue, pOutDev );
727 124 : if( getNativeControlRegion( nType, nPart, rgn, nState, *mirrorValue, aCaption,
728 124 : rNativeBoundingRegion, rNativeContentRegion ) )
729 : {
730 0 : mirror( rNativeBoundingRegion, pOutDev, true );
731 0 : mirror( rNativeContentRegion, pOutDev, true );
732 0 : return true;
733 : }
734 124 : return false;
735 : }
736 : else
737 : return getNativeControlRegion( nType, nPart, rControlRegion, nState, aValue, aCaption,
738 180028 : rNativeBoundingRegion, rNativeContentRegion );
739 : }
740 :
741 0 : bool SalGraphics::BlendBitmap( const SalTwoRect& rPosAry,
742 : const SalBitmap& rBitmap,
743 : const OutputDevice *pOutDev )
744 : {
745 0 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
746 : {
747 0 : SalTwoRect aPosAry2 = rPosAry;
748 0 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
749 0 : return blendBitmap( aPosAry2, rBitmap );
750 : }
751 : else
752 0 : return blendBitmap( rPosAry, rBitmap );
753 : }
754 :
755 286 : bool SalGraphics::BlendAlphaBitmap( const SalTwoRect& rPosAry,
756 : const SalBitmap& rSrcBitmap,
757 : const SalBitmap& rMaskBitmap,
758 : const SalBitmap& rAlphaBitmap,
759 : const OutputDevice *pOutDev )
760 : {
761 286 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
762 : {
763 236 : SalTwoRect aPosAry2 = rPosAry;
764 236 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
765 236 : return blendAlphaBitmap( aPosAry2, rSrcBitmap, rMaskBitmap, rAlphaBitmap );
766 : }
767 : else
768 50 : return blendAlphaBitmap( rPosAry, rSrcBitmap, rMaskBitmap, rAlphaBitmap );
769 : }
770 :
771 143865 : bool SalGraphics::DrawAlphaBitmap( const SalTwoRect& rPosAry,
772 : const SalBitmap& rSourceBitmap,
773 : const SalBitmap& rAlphaBitmap,
774 : const OutputDevice *pOutDev )
775 : {
776 143865 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
777 : {
778 86 : SalTwoRect aPosAry2 = rPosAry;
779 86 : mirror( aPosAry2.mnDestX, aPosAry2.mnDestWidth, pOutDev );
780 86 : return drawAlphaBitmap( aPosAry2, rSourceBitmap, rAlphaBitmap );
781 : }
782 : else
783 143779 : return drawAlphaBitmap( rPosAry, rSourceBitmap, rAlphaBitmap );
784 : }
785 :
786 34 : bool SalGraphics::DrawTransformedBitmap(
787 : const basegfx::B2DPoint& rNull,
788 : const basegfx::B2DPoint& rX,
789 : const basegfx::B2DPoint& rY,
790 : const SalBitmap& rSourceBitmap,
791 : const SalBitmap* pAlphaBitmap,
792 : const OutputDevice* pOutDev)
793 : {
794 34 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
795 : {
796 0 : basegfx::B2DPoint aNull(rNull);
797 0 : basegfx::B2DPoint aX(rX);
798 0 : basegfx::B2DPoint aY(rY);
799 :
800 0 : mirror(aNull, pOutDev);
801 0 : mirror(aX, pOutDev);
802 0 : mirror(aY, pOutDev);
803 :
804 0 : return drawTransformedBitmap(aNull, aX, aY, rSourceBitmap, pAlphaBitmap);
805 : }
806 : else
807 : {
808 34 : return drawTransformedBitmap(rNull, rX, rY, rSourceBitmap, pAlphaBitmap);
809 : }
810 : }
811 :
812 18 : bool SalGraphics::DrawAlphaRect( long nX, long nY, long nWidth, long nHeight,
813 : sal_uInt8 nTransparency, const OutputDevice *pOutDev )
814 : {
815 18 : if( (m_nLayout & SalLayoutFlags::BiDiRtl) || (pOutDev && pOutDev->IsRTLEnabled()) )
816 0 : mirror( nX, nWidth, pOutDev );
817 :
818 18 : return drawAlphaRect( nX, nY, nWidth, nHeight, nTransparency );
819 801 : }
820 :
821 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|