27#include <com/sun/star/rendering/CompositeOperation.hpp>
35 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
36 const css::awt::Rectangle& rRepaintBox,
37 const css::awt::Rectangle& rBoundingBox,
38 const css::uno::Reference<css::rendering::XBitmap>& rxLeftBitmap,
39 const css::uno::Reference<css::rendering::XBitmap>& rxRepeatableCenterBitmap,
40 const css::uno::Reference<css::rendering::XBitmap>& rxRightBitmap)
50 geometry::IntegerSize2D aLeftBitmapSize;
51 if (rxLeftBitmap.is())
52 aLeftBitmapSize = rxLeftBitmap->getSize();
53 geometry::IntegerSize2D aCenterBitmapSize;
54 if (rxRepeatableCenterBitmap.is())
55 aCenterBitmapSize = rxRepeatableCenterBitmap->getSize();
56 geometry::IntegerSize2D aRightBitmapSize;
57 if (rxRightBitmap.is())
58 aRightBitmapSize = rxRightBitmap->getSize();
61 rendering::ViewState aViewState (
62 geometry::AffineMatrix2D(1,0,0, 0,1,0),
65 rendering::RenderState aRenderState (
66 geometry::AffineMatrix2D(1,0,0, 0,1,0),
69 rendering::CompositeOperation::SOURCE);
72 if (rxLeftBitmap.is())
74 const awt::Rectangle aLeftBoundingBox (
77 ::std::min(aLeftBitmapSize.Width, rBoundingBox.Width),
82 rxCanvas->getDevice()));
83 aRenderState.AffineTransform.m02 = aLeftBoundingBox.X;
84 aRenderState.AffineTransform.m12
85 = aLeftBoundingBox.Y + (aLeftBoundingBox.Height - aLeftBitmapSize.Height) / 2;
86 rxCanvas->drawBitmap(rxLeftBitmap, aViewState, aRenderState);
90 if (rxRightBitmap.is())
92 const awt::Rectangle aRightBoundingBox (
93 rBoundingBox.X + rBoundingBox.Width - aRightBitmapSize.Width,
95 ::std::min(aRightBitmapSize.Width, rBoundingBox.Width),
100 rxCanvas->getDevice()));
101 aRenderState.AffineTransform.m02
102 = aRightBoundingBox.X + aRightBoundingBox.Width - aRightBitmapSize.Width;
103 aRenderState.AffineTransform.m12
104 = aRightBoundingBox.Y + (aRightBoundingBox.Height - aRightBitmapSize.Height) / 2;
105 rxCanvas->drawBitmap(rxRightBitmap, aViewState, aRenderState);
109 if (!rxRepeatableCenterBitmap.is())
112 const awt::Rectangle aCenterBoundingBox (
113 rBoundingBox.X + aLeftBitmapSize.Width,
115 rBoundingBox.Width - aLeftBitmapSize.Width - aRightBitmapSize.Width,
116 rBoundingBox.Height);
117 if (aCenterBoundingBox.Width <= 0)
123 rxCanvas->getDevice()));
124 sal_Int32 nX (aCenterBoundingBox.X);
125 const sal_Int32 nRight (aCenterBoundingBox.X + aCenterBoundingBox.Width - 1);
126 aRenderState.AffineTransform.m12
127 = aCenterBoundingBox.Y + (aCenterBoundingBox.Height-aCenterBitmapSize.Height) / 2;
130 aRenderState.AffineTransform.m02 = nX;
131 rxCanvas->drawBitmap(rxRepeatableCenterBitmap, aViewState, aRenderState);
132 nX += aCenterBitmapSize.Width;
137 const css::uno::Reference<css::rendering::XCanvas>& rxCanvas,
138 const css::awt::Rectangle& rRepaintBox,
139 const css::awt::Rectangle& rBoundingBox,
140 const css::uno::Reference<css::rendering::XBitmap>& rxTopBitmap,
141 const css::uno::Reference<css::rendering::XBitmap>& rxRepeatableCenterBitmap,
142 const css::uno::Reference<css::rendering::XBitmap>& rxBottomBitmap)
152 geometry::IntegerSize2D aTopBitmapSize;
153 if (rxTopBitmap.is())
154 aTopBitmapSize = rxTopBitmap->getSize();
155 geometry::IntegerSize2D aCenterBitmapSize;
156 if (rxRepeatableCenterBitmap.is())
157 aCenterBitmapSize = rxRepeatableCenterBitmap->getSize();
158 geometry::IntegerSize2D aBottomBitmapSize;
159 if (rxBottomBitmap.is())
160 aBottomBitmapSize = rxBottomBitmap->getSize();
163 rendering::ViewState aViewState (
164 geometry::AffineMatrix2D(1,0,0, 0,1,0),
167 rendering::RenderState aRenderState (
168 geometry::AffineMatrix2D(1,0,0, 0,1,0),
171 rendering::CompositeOperation::SOURCE);
174 if (rxTopBitmap.is())
176 const awt::Rectangle aTopBoundingBox (
180 ::std::min(aTopBitmapSize.Height, rBoundingBox.Height));
184 rxCanvas->getDevice()));
185 aRenderState.AffineTransform.m02
186 = aTopBoundingBox.X + (aTopBoundingBox.Width - aTopBitmapSize.Width) / 2;
187 aRenderState.AffineTransform.m12 = aTopBoundingBox.Y;
188 rxCanvas->drawBitmap(rxTopBitmap, aViewState, aRenderState);
192 if (rxBottomBitmap.is())
194 const sal_Int32 nBBoxHeight (::std::min(aBottomBitmapSize.Height, rBoundingBox.Height));
195 const awt::Rectangle aBottomBoundingBox (
197 rBoundingBox.Y + rBoundingBox.Height - nBBoxHeight,
203 rxCanvas->getDevice()));
204 aRenderState.AffineTransform.m02
205 = aBottomBoundingBox.X + (aBottomBoundingBox.Width - aBottomBitmapSize.Width) / 2;
206 aRenderState.AffineTransform.m12
207 = aBottomBoundingBox.Y + aBottomBoundingBox.Height - aBottomBitmapSize.Height;
208 rxCanvas->drawBitmap(rxBottomBitmap, aViewState, aRenderState);
212 if (!rxRepeatableCenterBitmap.is())
215 const awt::Rectangle aCenterBoundingBox (
217 rBoundingBox.Y + aTopBitmapSize.Height,
219 rBoundingBox.Height - aTopBitmapSize.Height - aBottomBitmapSize.Height);
220 if (aCenterBoundingBox.Height <= 0)
226 rxCanvas->getDevice()));
227 sal_Int32 nY (aCenterBoundingBox.Y);
228 const sal_Int32 nBottom (aCenterBoundingBox.Y + aCenterBoundingBox.Height - 1);
229 aRenderState.AffineTransform.m02
230 = aCenterBoundingBox.X + (aCenterBoundingBox.Width-aCenterBitmapSize.Width) / 2;
233 aRenderState.AffineTransform.m12 = nY;
234 rxCanvas->drawBitmap(rxRepeatableCenterBitmap, aViewState, aRenderState);
235 nY += aCenterBitmapSize.Height;
static bool AreRectanglesDisjoint(const css::awt::Rectangle &rBox1, const css::awt::Rectangle &rBox2)
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)
static void PaintVerticalBitmapComposite(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::awt::Rectangle &rBoundingBox, const css::uno::Reference< css::rendering::XBitmap > &rxTopBitmap, const css::uno::Reference< css::rendering::XBitmap > &rxRepeatableCenterBitmap, const css::uno::Reference< css::rendering::XBitmap > &rxBottomBitmap)
static void PaintHorizontalBitmapComposite(const css::uno::Reference< css::rendering::XCanvas > &rxCanvas, const css::awt::Rectangle &rRepaintBox, const css::awt::Rectangle &rBoundingBox, const css::uno::Reference< css::rendering::XBitmap > &rxLeftBitmap, const css::uno::Reference< css::rendering::XBitmap > &rxRepeatableCenterBitmap, const css::uno::Reference< css::rendering::XBitmap > &rxRightBitmap)