23#include <com/sun/star/rendering/CompositeOperation.hpp>
24#include <osl/diagnose.h>
33 geometry::AffineMatrix2D(1,0,0, 0,1,0),
36 geometry::AffineMatrix2D(1,0,0, 0,1,0),
39 rendering::CompositeOperation::SOURCE)
49 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
50 const css::awt::Rectangle& rRepaintBox,
51 const css::awt::Rectangle& rOuterBoundingBox,
52 const css::awt::Rectangle& rContentBoundingBox)
const
54 PaintRectangle(rpBitmap,rxCanvas,rRepaintBox,rOuterBoundingBox,rContentBoundingBox,
60 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
61 const css::awt::Rectangle& rRepaintBox,
62 const css::awt::Rectangle& rOuterBoundingBox,
63 const css::awt::Rectangle& rContentBoundingBox,
64 const css::rendering::ViewState& rDefaultViewState,
65 const css::rendering::RenderState& rDefaultRenderState)
70 if ( ! rxCanvas.is() || ! rxCanvas->getDevice().is())
74 ::std::vector<awt::Rectangle> aRectangles;
75 aRectangles.reserve(2);
76 aRectangles.push_back(
78 if (rContentBoundingBox.Width > 0 && rContentBoundingBox.Height > 0)
79 aRectangles.push_back(
81 Reference<rendering::XPolyPolygon2D> xPolyPolygon (
84 rxCanvas->getDevice()));
85 if ( ! xPolyPolygon.is())
87 xPolyPolygon->setFillRule(rendering::FillRule_EVEN_ODD);
89 if (rpBitmap->GetNormalBitmap().is())
95 rpBitmap->GetNormalBitmap(),
101 rDefaultRenderState);
106 rpBitmap->GetNormalBitmap(),
107 awt::Point(rOuterBoundingBox.X, rOuterBoundingBox.Y),
112 rDefaultRenderState);
118 rpBitmap->maReplacementColor,
123 rDefaultRenderState);
128 const css::uno::Reference<css::rendering::XBitmap>& rxTexture,
129 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
130 const css::awt::Rectangle& rRepaintBox,
131 const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxPolygon,
132 const css::awt::Rectangle& rHole,
133 const css::rendering::ViewState& rDefaultViewState,
134 const css::rendering::RenderState& rDefaultRenderState)
136 if ( ! rxCanvas.is() || ! rxCanvas->getDevice().is())
139 if ( ! rxTexture.is())
142 if ( ! rxPolygon.is())
145 rendering::ViewState aViewState (rDefaultViewState);
146 aViewState.Clip = rxPolygon;
150 rendering::RenderState aRenderState (rDefaultRenderState);
153 const geometry::IntegerSize2D aBitmapSize (rxTexture->getSize());
154 if( aBitmapSize.Width < 1 || aBitmapSize.Height < 1)
157 const sal_Int32 nLeft = (rRepaintBox.X / aBitmapSize.Width) * aBitmapSize.Width;
158 const sal_Int32 nTop = (rRepaintBox.Y / aBitmapSize.Height) * aBitmapSize.Height;
159 const sal_Int32 nRight = ((rRepaintBox.X + rRepaintBox.Width - 1 + aBitmapSize.Width - 1)
160 / aBitmapSize.Width) * aBitmapSize.Width;
161 const sal_Int32 nBottom = ((rRepaintBox.Y + rRepaintBox.Height - 1 + aBitmapSize.Height - 1)
162 / aBitmapSize.Height) * aBitmapSize.Height;
164 for (sal_Int32 nY=nTop; nY<=nBottom; nY+=aBitmapSize.Height)
165 for (sal_Int32 nX=nLeft; nX<=nRight; nX+=aBitmapSize.Width)
168 awt::Rectangle(nX,nY,aBitmapSize.Width,aBitmapSize.Height),
173 aRenderState.AffineTransform.m02 = nX;
174 aRenderState.AffineTransform.m12 = nY;
175 rxCanvas->drawBitmap(
183 const css::uno::Reference<css::rendering::XBitmap>& rxBitmap,
184 const awt::Point& rLocation,
185 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
186 const css::awt::Rectangle& rRepaintBox,
187 const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxPolygon,
188 const css::rendering::ViewState& rDefaultViewState,
189 const css::rendering::RenderState& rDefaultRenderState)
191 if ( ! rxCanvas.is() || ! rxCanvas->getDevice().is())
194 if ( ! rxBitmap.is())
197 if ( ! rxPolygon.is())
201 rendering::ViewState aViewState (rDefaultViewState);
206 rendering::RenderState aRenderState (rDefaultRenderState);
207 aRenderState.AffineTransform = geometry::AffineMatrix2D(1,0, rLocation.X, 0,1,rLocation.Y);
208 aRenderState.Clip = rxPolygon;
210 rxCanvas->drawBitmap(
217 const css::util::Color nColor,
218 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
219 const css::awt::Rectangle& rRepaintBox,
220 const css::uno::Reference<css::rendering::XPolyPolygon2D>& rxPolygon,
221 const css::rendering::ViewState& rDefaultViewState,
222 const css::rendering::RenderState& rDefaultRenderState)
224 if ( ! rxCanvas.is() || ! rxCanvas->getDevice().is())
227 if ( ! rxPolygon.is())
231 rendering::ViewState aViewState (rDefaultViewState);
235 rendering::RenderState aRenderState (rDefaultRenderState);
238 rxCanvas->fillPolyPolygon(
245 rendering::RenderState& rRenderState,
246 const util::Color aColor)
250 OSL_ASSERT(rRenderState.DeviceColor.getLength() == 4);
251 if (rRenderState.DeviceColor.getLength() == 4)
253 auto pDeviceColor = rRenderState.DeviceColor.getArray();
254 pDeviceColor[0] = ((aColor >> 16) & 0x0ff) / 255.0;
255 pDeviceColor[1] = ((aColor >> 8) & 0x0ff) / 255.0;
256 pDeviceColor[2] = ((aColor >> 0) & 0x0ff) / 255.0;
257 pDeviceColor[3] = 1.0 - ((aColor >> 24) & 0x0ff) / 255.0;
262 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
263 const OUString& rsText,
266 if (rxFont.is() && !rsText.isEmpty())
268 rendering::StringContext aContext (rsText, 0, rsText.getLength());
269 Reference<rendering::XTextLayout> xLayout (
270 rxFont->createTextLayout(aContext, nTextDirection, 0));
271 return xLayout->queryTextBounds();
275 return geometry::RealRectangle2D(0,0,0,0);
280 const css::uno::Reference<css::rendering::XCanvasFont>& rxFont,
281 const OUString& rsText)
284 return css::geometry::RealSize2D(aTextBBox.X2 - aTextBBox.X1, aTextBBox.Y2 - aTextBBox.Y1);
static css::geometry::RealSize2D GetTextSize(const css::uno::Reference< css::rendering::XCanvasFont > &rxFont, const OUString &rsText)
const css::rendering::ViewState maDefaultViewState
void Paint(const SharedBitmapDescriptor &rpBitmap, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::awt::Rectangle &rBackgroundBoundingBox, const css::awt::Rectangle &rContentBoundingBox) const
static void SetDeviceColor(css::rendering::RenderState &rRenderState, const css::util::Color aColor)
static css::geometry::RealRectangle2D GetTextBoundingBox(const css::uno::Reference< css::rendering::XCanvasFont > &rxFont, const OUString &rsText, const sal_Int8=css::rendering::TextDirection::WEAK_LEFT_TO_RIGHT)
const css::rendering::RenderState maDefaultRenderState
static void PaintColor(const css::util::Color nColor, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::uno::Reference< css::rendering::XPolyPolygon2D > &rxPolygon, const css::rendering::ViewState &rDefaultViewState, const css::rendering::RenderState &rDefaultRenderState)
static void PaintRectangle(const SharedBitmapDescriptor &rpBitmap, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::awt::Rectangle &rBackgroundBoundingBox, const css::awt::Rectangle &rContentBoundingBox, const css::rendering::ViewState &rDefaultViewState, const css::rendering::RenderState &rDefaultRenderState)
static void PaintBitmap(const css::uno::Reference< css::rendering::XBitmap > &rxBitmap, const css::awt::Point &rLocation, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::uno::Reference< css::rendering::XPolyPolygon2D > &rxPolygon, const css::rendering::ViewState &rDefaultViewState, const css::rendering::RenderState &rDefaultRenderState)
static void PaintTiledBitmap(const css::uno::Reference< css::rendering::XBitmap > &rxTexture, const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::uno::Reference< css::rendering::XPolyPolygon2D > &rxPolygon, const css::awt::Rectangle &rHole, const css::rendering::ViewState &rDefaultViewState, const css::rendering::RenderState &rDefaultRenderState)
static bool IsInside(const css::geometry::RealRectangle2D &rBox, const css::geometry::RealPoint2D &rPoint)
static css::awt::Rectangle Intersection(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
static css::uno::Reference< css::rendering::XPolyPolygon2D > CreatePolygon(const css::awt::Rectangle &rBox, const css::uno::Reference< css::rendering::XGraphicDevice > &rxDevice)
std::shared_ptr< PresenterBitmapContainer::BitmapDescriptor > SharedBitmapDescriptor