1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <Qt5Graphics.hxx>
22 #include <Qt5Bitmap.hxx>
23 #include <Qt5Painter.hxx>
25 #include <sal/log.hxx>
27 #include <QtGui/QPainter>
28 #include <QtGui/QScreen>
29 #include <QtGui/QWindow>
30 #include <QtWidgets/QWidget>
32 #include <basegfx/polygon/b2dpolygontools.hxx>
34 static const basegfx::B2DPoint
aHalfPointOfs(0.5, 0.5);
36 static void AddPolygonToPath(QPainterPath
& rPath
, const basegfx::B2DPolygon
& rPolygon
,
37 bool bClosePath
, bool bPixelSnap
, bool bLineDraw
)
39 const int nPointCount
= rPolygon
.count();
40 // short circuit if there is nothing to do
44 const bool bHasCurves
= rPolygon
.areControlPointsUsed();
45 for (int nPointIdx
= 0, nPrevIdx
= 0;; nPrevIdx
= nPointIdx
++)
47 int nClosedIdx
= nPointIdx
;
48 if (nPointIdx
>= nPointCount
)
50 // prepare to close last curve segment if needed
51 if (bClosePath
&& (nPointIdx
== nPointCount
))
57 basegfx::B2DPoint aPoint
= rPolygon
.getB2DPoint(nClosedIdx
);
61 // snap device coordinates to full pixels
62 aPoint
.setX(basegfx::fround(aPoint
.getX()));
63 aPoint
.setY(basegfx::fround(aPoint
.getY()));
67 aPoint
+= aHalfPointOfs
;
70 // first point => just move there
71 rPath
.moveTo(aPoint
.getX(), aPoint
.getY());
75 bool bPendingCurve
= false;
78 bPendingCurve
= rPolygon
.isNextControlPointUsed(nPrevIdx
);
79 bPendingCurve
|= rPolygon
.isPrevControlPointUsed(nClosedIdx
);
82 if (!bPendingCurve
) // line segment
83 rPath
.lineTo(aPoint
.getX(), aPoint
.getY());
84 else // cubic bezier segment
86 basegfx::B2DPoint aCP1
= rPolygon
.getNextControlPoint(nPrevIdx
);
87 basegfx::B2DPoint aCP2
= rPolygon
.getPrevControlPoint(nClosedIdx
);
90 aCP1
+= aHalfPointOfs
;
91 aCP2
+= aHalfPointOfs
;
93 rPath
.cubicTo(aCP1
.getX(), aCP1
.getY(), aCP2
.getX(), aCP2
.getY(), aPoint
.getX(),
102 static bool AddPolyPolygonToPath(QPainterPath
& rPath
, const basegfx::B2DPolyPolygon
& rPolyPoly
,
103 bool bPixelSnap
, bool bLineDraw
)
105 if (rPolyPoly
.count() == 0)
107 for (auto const& rPolygon
: rPolyPoly
)
109 AddPolygonToPath(rPath
, rPolygon
, true, bPixelSnap
, bLineDraw
);
114 bool Qt5Graphics::setClipRegion(const vcl::Region
& rRegion
)
116 if (rRegion
.IsRectangle())
118 m_aClipRegion
= toQRect(rRegion
.GetBoundRect());
119 if (!m_aClipPath
.isEmpty())
122 m_aClipPath
.swap(aPath
);
125 else if (!rRegion
.HasPolyPolygonOrB2DPolyPolygon())
128 RectangleVector aRectangles
;
129 rRegion
.GetRegionRectangles(aRectangles
);
130 for (const auto& rRect
: aRectangles
)
131 aQRegion
+= toQRect(rRect
);
132 m_aClipRegion
= aQRegion
;
133 if (!m_aClipPath
.isEmpty())
136 m_aClipPath
.swap(aPath
);
142 const basegfx::B2DPolyPolygon
aPolyClip(rRegion
.GetAsB2DPolyPolygon());
143 AddPolyPolygonToPath(aPath
, aPolyClip
, !getAntiAliasB2DDraw(), false);
144 m_aClipPath
.swap(aPath
);
145 if (!m_aClipRegion
.isEmpty())
148 m_aClipRegion
.swap(aRegion
);
154 void Qt5Graphics::ResetClipRegion()
157 m_aClipRegion
= QRegion(m_pQImage
->rect());
159 m_aClipRegion
= QRegion();
160 if (!m_aClipPath
.isEmpty())
163 m_aClipPath
.swap(aPath
);
167 void Qt5Graphics::drawPixel(long nX
, long nY
)
169 Qt5Painter
aPainter(*this);
170 aPainter
.drawPoint(nX
, nY
);
171 aPainter
.update(nX
, nY
, 1, 1);
174 void Qt5Graphics::drawPixel(long nX
, long nY
, Color nColor
)
176 Qt5Painter
aPainter(*this);
177 aPainter
.setPen(toQColor(nColor
));
178 aPainter
.setPen(Qt::SolidLine
);
179 aPainter
.drawPoint(nX
, nY
);
180 aPainter
.update(nX
, nY
, 1, 1);
183 void Qt5Graphics::drawLine(long nX1
, long nY1
, long nX2
, long nY2
)
185 Qt5Painter
aPainter(*this);
186 aPainter
.drawLine(nX1
, nY1
, nX2
, nY2
);
201 aPainter
.update(nX1
, nY1
, nX2
- nX1
+ 1, nY2
- nY1
+ 1);
204 void Qt5Graphics::drawRect(long nX
, long nY
, long nWidth
, long nHeight
)
206 if (SALCOLOR_NONE
== m_aFillColor
&& SALCOLOR_NONE
== m_aLineColor
)
209 Qt5Painter
aPainter(*this, true);
210 if (SALCOLOR_NONE
!= m_aFillColor
)
211 aPainter
.fillRect(nX
, nY
, nWidth
, nHeight
, aPainter
.brush());
212 if (SALCOLOR_NONE
!= m_aLineColor
)
213 aPainter
.drawRect(nX
, nY
, nWidth
- 1, nHeight
- 1);
214 aPainter
.update(nX
, nY
, nWidth
, nHeight
);
217 void Qt5Graphics::drawPolyLine(sal_uInt32 nPoints
, const SalPoint
* pPtAry
)
222 Qt5Painter
aPainter(*this);
223 QPoint
* pPoints
= new QPoint
[nPoints
];
224 QPoint
aTopLeft(pPtAry
->mnX
, pPtAry
->mnY
);
225 QPoint aBottomRight
= aTopLeft
;
226 for (sal_uInt32 i
= 0; i
< nPoints
; ++i
, ++pPtAry
)
228 pPoints
[i
] = QPoint(pPtAry
->mnX
, pPtAry
->mnY
);
229 if (pPtAry
->mnX
< aTopLeft
.x())
230 aTopLeft
.setX(pPtAry
->mnX
);
231 if (pPtAry
->mnY
< aTopLeft
.y())
232 aTopLeft
.setY(pPtAry
->mnY
);
233 if (pPtAry
->mnX
> aBottomRight
.x())
234 aBottomRight
.setX(pPtAry
->mnX
);
235 if (pPtAry
->mnY
> aBottomRight
.y())
236 aBottomRight
.setY(pPtAry
->mnY
);
238 aPainter
.drawPolyline(pPoints
, nPoints
);
240 aPainter
.update(QRect(aTopLeft
, aBottomRight
));
243 void Qt5Graphics::drawPolygon(sal_uInt32 nPoints
, const SalPoint
* pPtAry
)
245 Qt5Painter
aPainter(*this, true);
246 QPolygon
aPolygon(nPoints
);
247 for (sal_uInt32 i
= 0; i
< nPoints
; ++i
, ++pPtAry
)
248 aPolygon
.setPoint(i
, pPtAry
->mnX
, pPtAry
->mnY
);
249 aPainter
.drawPolygon(aPolygon
);
250 aPainter
.update(aPolygon
.boundingRect());
253 void Qt5Graphics::drawPolyPolygon(sal_uInt32 nPolyCount
, const sal_uInt32
* pPoints
,
254 PCONSTSALPOINT
* ppPtAry
)
256 // ignore invisible polygons
257 if (SALCOLOR_NONE
== m_aFillColor
&& SALCOLOR_NONE
== m_aLineColor
)
261 for (sal_uInt32 nPoly
= 0; nPoly
< nPolyCount
; nPoly
++)
263 const sal_uInt32 nPoints
= pPoints
[nPoly
];
266 const SalPoint
* pPtAry
= ppPtAry
[nPoly
];
267 aPath
.moveTo(pPtAry
->mnX
, pPtAry
->mnY
);
269 for (sal_uInt32 nPoint
= 1; nPoint
< nPoints
; nPoint
++, pPtAry
++)
270 aPath
.lineTo(pPtAry
->mnX
, pPtAry
->mnY
);
271 aPath
.closeSubpath();
275 Qt5Painter
aPainter(*this, true);
276 aPainter
.drawPath(aPath
);
277 aPainter
.update(aPath
.boundingRect());
280 bool Qt5Graphics::drawPolyPolygon(const basegfx::B2DHomMatrix
& rObjectToDevice
,
281 const basegfx::B2DPolyPolygon
& rPolyPolygon
, double fTransparency
)
283 // ignore invisible polygons
284 if (SALCOLOR_NONE
== m_aFillColor
&& SALCOLOR_NONE
== m_aLineColor
)
286 if ((fTransparency
>= 1.0) || (fTransparency
< 0))
289 // Fallback: Transform to DeviceCoordinates
290 basegfx::B2DPolyPolygon
aPolyPolygon(rPolyPolygon
);
291 aPolyPolygon
.transform(rObjectToDevice
);
294 // ignore empty polygons
295 if (!AddPolyPolygonToPath(aPath
, aPolyPolygon
, !getAntiAliasB2DDraw(),
296 m_aLineColor
!= SALCOLOR_NONE
))
299 Qt5Painter
aPainter(*this, true, 255 * (1.0 - fTransparency
));
300 aPainter
.drawPath(aPath
);
301 aPainter
.update(aPath
.boundingRect());
305 bool Qt5Graphics::drawPolyLineBezier(sal_uInt32
/*nPoints*/, const SalPoint
* /*pPtAry*/,
306 const PolyFlags
* /*pFlgAry*/)
311 bool Qt5Graphics::drawPolygonBezier(sal_uInt32
/*nPoints*/, const SalPoint
* /*pPtAry*/,
312 const PolyFlags
* /*pFlgAry*/)
317 bool Qt5Graphics::drawPolyPolygonBezier(sal_uInt32
/*nPoly*/, const sal_uInt32
* /*pPoints*/,
318 const SalPoint
* const* /*pPtAry*/,
319 const PolyFlags
* const* /*pFlgAry*/)
324 bool Qt5Graphics::drawPolyLine(const basegfx::B2DHomMatrix
& rObjectToDevice
,
325 const basegfx::B2DPolygon
& rPolyLine
, double fTransparency
,
326 const basegfx::B2DVector
& rLineWidths
,
327 basegfx::B2DLineJoin eLineJoin
, css::drawing::LineCap eLineCap
,
328 double fMiterMinimumAngle
, bool bPixelSnapHairline
)
330 if (SALCOLOR_NONE
== m_aFillColor
&& SALCOLOR_NONE
== m_aLineColor
)
333 // short circuit if there is nothing to do
334 if (0 == rPolyLine
.count())
339 // Transform to DeviceCoordinates, get DeviceLineWidth, execute PixelSnapHairline
340 basegfx::B2DPolygon
aPolyLine(rPolyLine
);
341 aPolyLine
.transform(rObjectToDevice
);
342 if (bPixelSnapHairline
)
344 aPolyLine
= basegfx::utils::snapPointsOfHorizontalOrVerticalEdges(aPolyLine
);
346 const basegfx::B2DVector
aLineWidths(rObjectToDevice
* rLineWidths
);
348 // setup poly-polygon path
350 AddPolygonToPath(aPath
, aPolyLine
, aPolyLine
.isClosed(), !getAntiAliasB2DDraw(), true);
352 Qt5Painter
aPainter(*this, false, 255 * (1.0 - fTransparency
));
354 // setup line attributes
355 QPen aPen
= aPainter
.pen();
356 aPen
.setWidth(aLineWidths
.getX());
360 case basegfx::B2DLineJoin::Bevel
:
361 aPen
.setJoinStyle(Qt::BevelJoin
);
363 case basegfx::B2DLineJoin::Round
:
364 aPen
.setJoinStyle(Qt::RoundJoin
);
366 case basegfx::B2DLineJoin::NONE
:
367 case basegfx::B2DLineJoin::Miter
:
368 aPen
.setMiterLimit(1.0 / sin(fMiterMinimumAngle
/ 2.0));
369 aPen
.setJoinStyle(Qt::MiterJoin
);
375 default: // css::drawing::LineCap_BUTT:
376 aPen
.setCapStyle(Qt::FlatCap
);
378 case css::drawing::LineCap_ROUND
:
379 aPen
.setCapStyle(Qt::RoundCap
);
381 case css::drawing::LineCap_SQUARE
:
382 aPen
.setCapStyle(Qt::SquareCap
);
386 aPainter
.setPen(aPen
);
387 aPainter
.drawPath(aPath
);
388 aPainter
.update(aPath
.boundingRect());
392 bool Qt5Graphics::drawGradient(const tools::PolyPolygon
&, const Gradient
&) { return false; }
394 void Qt5Graphics::drawScaledImage(const SalTwoRect
& rPosAry
, const QImage
& rImage
)
396 Qt5Painter
aPainter(*this);
397 QRect
aSrcRect(rPosAry
.mnSrcX
, rPosAry
.mnSrcY
, rPosAry
.mnSrcWidth
, rPosAry
.mnSrcHeight
);
398 QRect
aDestRect(rPosAry
.mnDestX
, rPosAry
.mnDestY
, rPosAry
.mnDestWidth
, rPosAry
.mnDestHeight
);
399 aPainter
.drawImage(aDestRect
, rImage
, aSrcRect
);
400 aPainter
.update(aDestRect
);
403 void Qt5Graphics::copyArea(long nDestX
, long nDestY
, long nSrcX
, long nSrcY
, long nSrcWidth
,
404 long nSrcHeight
, bool /*bWindowInvalidate*/)
406 if (nDestX
== nSrcX
&& nDestY
== nSrcY
)
409 SalTwoRect
aTR(nSrcX
, nSrcY
, nSrcWidth
, nSrcHeight
, nDestX
, nDestY
, nSrcWidth
, nSrcHeight
);
413 void Qt5Graphics::copyBits(const SalTwoRect
& rPosAry
, SalGraphics
* pSrcGraphics
)
415 if (rPosAry
.mnSrcWidth
<= 0 || rPosAry
.mnSrcHeight
<= 0 || rPosAry
.mnDestWidth
<= 0
416 || rPosAry
.mnDestHeight
<= 0)
419 QImage aImage
, *pImage
;
420 SalTwoRect aPosAry
= rPosAry
;
421 if (!pSrcGraphics
|| this == pSrcGraphics
)
425 = pImage
->copy(rPosAry
.mnSrcX
, rPosAry
.mnSrcY
, rPosAry
.mnSrcWidth
, rPosAry
.mnSrcHeight
);
431 pImage
= static_cast<Qt5Graphics
*>(pSrcGraphics
)->m_pQImage
;
433 drawScaledImage(aPosAry
, *pImage
);
436 void Qt5Graphics::drawBitmap(const SalTwoRect
& rPosAry
, const SalBitmap
& rSalBitmap
)
438 if (rPosAry
.mnSrcWidth
<= 0 || rPosAry
.mnSrcHeight
<= 0 || rPosAry
.mnDestWidth
<= 0
439 || rPosAry
.mnDestHeight
<= 0)
442 Qt5Bitmap aRGBABitmap
;
443 if (rSalBitmap
.GetBitCount() == 4)
444 aRGBABitmap
.Create(rSalBitmap
, 32);
445 const QImage
* pImage
= (rSalBitmap
.GetBitCount() != 4)
446 ? static_cast<const Qt5Bitmap
*>(&rSalBitmap
)->GetQImage()
447 : aRGBABitmap
.GetQImage();
450 drawScaledImage(rPosAry
, *pImage
);
453 void Qt5Graphics::drawBitmap(const SalTwoRect
& rPosAry
, const SalBitmap
& /*rSalBitmap*/,
454 const SalBitmap
& /*rTransparentBitmap*/)
456 if (rPosAry
.mnSrcWidth
<= 0 || rPosAry
.mnSrcHeight
<= 0 || rPosAry
.mnDestWidth
<= 0
457 || rPosAry
.mnDestHeight
<= 0)
460 assert(rPosAry
.mnSrcWidth
== rPosAry
.mnDestWidth
);
461 assert(rPosAry
.mnSrcHeight
== rPosAry
.mnDestHeight
);
464 void Qt5Graphics::drawMask(const SalTwoRect
& rPosAry
, const SalBitmap
& /*rSalBitmap*/,
465 Color
/*nMaskColor*/)
467 if (rPosAry
.mnSrcWidth
<= 0 || rPosAry
.mnSrcHeight
<= 0 || rPosAry
.mnDestWidth
<= 0
468 || rPosAry
.mnDestHeight
<= 0)
471 assert(rPosAry
.mnSrcWidth
== rPosAry
.mnDestWidth
);
472 assert(rPosAry
.mnSrcHeight
== rPosAry
.mnDestHeight
);
475 std::shared_ptr
<SalBitmap
> Qt5Graphics::getBitmap(long nX
, long nY
, long nWidth
, long nHeight
)
477 return std::make_shared
<Qt5Bitmap
>(m_pQImage
->copy(nX
, nY
, nWidth
, nHeight
));
480 Color
Qt5Graphics::getPixel(long nX
, long nY
) { return m_pQImage
->pixel(nX
, nY
); }
482 void Qt5Graphics::invert(long nX
, long nY
, long nWidth
, long nHeight
, SalInvert nFlags
)
484 Qt5Painter
aPainter(*this);
485 if (SalInvert::N50
& nFlags
)
487 aPainter
.setCompositionMode(QPainter::RasterOp_SourceXorDestination
);
488 QBrush
aBrush(Qt::white
, Qt::Dense4Pattern
);
489 aPainter
.fillRect(nX
, nY
, nWidth
, nHeight
, aBrush
);
493 if (SalInvert::TrackFrame
& nFlags
)
495 aPainter
.setCompositionMode(QPainter::RasterOp_SourceXorDestination
);
496 QPen
aPen(Qt::white
);
497 aPen
.setStyle(Qt::DotLine
);
498 aPainter
.setPen(aPen
);
499 aPainter
.drawRect(nX
, nY
, nWidth
, nHeight
);
503 aPainter
.setCompositionMode(QPainter::RasterOp_SourceXorDestination
);
504 aPainter
.fillRect(nX
, nY
, nWidth
, nHeight
, Qt::white
);
507 aPainter
.update(nX
, nY
, nWidth
, nHeight
);
510 void Qt5Graphics::invert(sal_uInt32
/*nPoints*/, const SalPoint
* /*pPtAry*/, SalInvert
/*nFlags*/)
514 bool Qt5Graphics::drawEPS(long /*nX*/, long /*nY*/, long /*nWidth*/, long /*nHeight*/,
515 void* /*pPtr*/, sal_uInt32
/*nSize*/)
520 bool Qt5Graphics::blendBitmap(const SalTwoRect
&, const SalBitmap
& /*rBitmap*/) { return false; }
522 bool Qt5Graphics::blendAlphaBitmap(const SalTwoRect
&, const SalBitmap
& /*rSrcBitmap*/,
523 const SalBitmap
& /*rMaskBitmap*/,
524 const SalBitmap
& /*rAlphaBitmap*/)
529 static bool getAlphaImage(const SalBitmap
& rSourceBitmap
, const SalBitmap
& rAlphaBitmap
,
532 if (rAlphaBitmap
.GetBitCount() != 8 && rAlphaBitmap
.GetBitCount() != 1)
534 SAL_WARN("vcl.gdi", "unsupported alpha depth case: " << rAlphaBitmap
.GetBitCount());
538 Qt5Bitmap aRGBABitmap
;
539 if (rSourceBitmap
.GetBitCount() == 4)
540 aRGBABitmap
.Create(rSourceBitmap
, 32);
541 const QImage
* pBitmap
= (rSourceBitmap
.GetBitCount() != 4)
542 ? static_cast<const Qt5Bitmap
*>(&rSourceBitmap
)->GetQImage()
543 : aRGBABitmap
.GetQImage();
544 const QImage
* pAlpha
= static_cast<const Qt5Bitmap
*>(&rAlphaBitmap
)->GetQImage();
545 rAlphaImage
= pBitmap
->convertToFormat(Qt5_DefaultFormat32
);
547 if (rAlphaBitmap
.GetBitCount() == 8)
549 for (int y
= 0; y
< rAlphaImage
.height(); ++y
)
551 uchar
* image_line
= rAlphaImage
.scanLine(y
);
552 const uchar
* alpha_line
= pAlpha
->scanLine(y
);
553 for (int x
= 0; x
< rAlphaImage
.width(); ++x
, image_line
+= 4)
554 image_line
[3] = 255 - alpha_line
[x
];
559 for (int y
= 0; y
< rAlphaImage
.height(); ++y
)
561 uchar
* image_line
= rAlphaImage
.scanLine(y
);
562 const uchar
* alpha_line
= pAlpha
->scanLine(y
);
563 for (int x
= 0; x
< rAlphaImage
.width(); ++x
, image_line
+= 4)
567 if (0 != (*alpha_line
& (1 << (7 - x
% 8))))
576 bool Qt5Graphics::drawAlphaBitmap(const SalTwoRect
& rPosAry
, const SalBitmap
& rSourceBitmap
,
577 const SalBitmap
& rAlphaBitmap
)
580 if (!getAlphaImage(rSourceBitmap
, rAlphaBitmap
, aImage
))
582 drawScaledImage(rPosAry
, aImage
);
586 bool Qt5Graphics::drawTransformedBitmap(const basegfx::B2DPoint
& rNull
, const basegfx::B2DPoint
& rX
,
587 const basegfx::B2DPoint
& rY
, const SalBitmap
& rSourceBitmap
,
588 const SalBitmap
* pAlphaBitmap
)
591 if (pAlphaBitmap
&& !getAlphaImage(rSourceBitmap
, *pAlphaBitmap
, aImage
))
595 Qt5Bitmap aRGBABitmap
;
596 if (rSourceBitmap
.GetBitCount() == 4)
597 aRGBABitmap
.Create(rSourceBitmap
, 32);
598 const QImage
* pBitmap
= (rSourceBitmap
.GetBitCount() != 4)
599 ? static_cast<const Qt5Bitmap
*>(&rSourceBitmap
)->GetQImage()
600 : aRGBABitmap
.GetQImage();
601 aImage
= pBitmap
->convertToFormat(Qt5_DefaultFormat32
);
604 Qt5Painter
aPainter(*this);
605 const basegfx::B2DVector aXRel
= rX
- rNull
;
606 const basegfx::B2DVector aYRel
= rY
- rNull
;
607 aPainter
.setTransform(QTransform(aXRel
.getX() / aImage
.width(), aXRel
.getY() / aImage
.width(),
608 aYRel
.getX() / aImage
.height(), aYRel
.getY() / aImage
.height(),
609 rNull
.getX(), rNull
.getY()));
610 aPainter
.drawImage(QPoint(0, 0), aImage
);
611 aPainter
.update(aImage
.rect());
615 bool Qt5Graphics::drawAlphaRect(long nX
, long nY
, long nWidth
, long nHeight
,
616 sal_uInt8 nTransparency
)
618 if (SALCOLOR_NONE
== m_aFillColor
&& SALCOLOR_NONE
== m_aLineColor
)
620 assert(nTransparency
<= 100);
621 if (nTransparency
> 100)
623 Qt5Painter
aPainter(*this, true, (100 - nTransparency
) * (255.0 / 100));
624 if (SALCOLOR_NONE
!= m_aFillColor
)
625 aPainter
.fillRect(nX
, nY
, nWidth
, nHeight
, aPainter
.brush());
626 if (SALCOLOR_NONE
!= m_aLineColor
)
627 aPainter
.drawRect(nX
, nY
, nWidth
- 1, nHeight
- 1);
628 aPainter
.update(nX
, nY
, nWidth
, nHeight
);
632 void Qt5Graphics::GetResolution(sal_Int32
& rDPIX
, sal_Int32
& rDPIY
)
635 if ((pForceDpi
= getenv("SAL_FORCEDPI")))
637 OString
sForceDPI(pForceDpi
);
638 rDPIX
= rDPIY
= sForceDPI
.toInt32();
642 if (!m_pFrame
|| !m_pFrame
->GetQWidget()->window()->windowHandle())
645 QScreen
* pScreen
= m_pFrame
->GetQWidget()->window()->windowHandle()->screen();
646 rDPIX
= pScreen
->logicalDotsPerInchX() * pScreen
->devicePixelRatio() + 0.5;
647 rDPIY
= pScreen
->logicalDotsPerInchY() * pScreen
->devicePixelRatio() + 0.5;
650 sal_uInt16
Qt5Graphics::GetBitCount() const { return getFormatBits(m_pQImage
->format()); }
652 long Qt5Graphics::GetGraphicsWidth() const { return m_pQImage
->width(); }
654 void Qt5Graphics::SetLineColor() { m_aLineColor
= SALCOLOR_NONE
; }
656 void Qt5Graphics::SetLineColor(Color nColor
) { m_aLineColor
= nColor
; }
658 void Qt5Graphics::SetFillColor() { m_aFillColor
= SALCOLOR_NONE
; }
660 void Qt5Graphics::SetFillColor(Color nColor
) { m_aFillColor
= nColor
; }
662 void Qt5Graphics::SetXORMode(bool bSet
, bool)
665 m_eCompositionMode
= QPainter::CompositionMode_Xor
;
667 m_eCompositionMode
= QPainter::CompositionMode_SourceOver
;
670 void Qt5Graphics::SetROPLineColor(SalROPColor
/*nROPColor*/) {}
672 void Qt5Graphics::SetROPFillColor(SalROPColor
/*nROPColor*/) {}
674 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */