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