Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include "view/SlsPageObjectPainter.hxx"
31 : :
32 : : #include "model/SlsPageDescriptor.hxx"
33 : : #include "view/SlideSorterView.hxx"
34 : : #include "view/SlsPageObjectLayouter.hxx"
35 : : #include "view/SlsLayouter.hxx"
36 : : #include "view/SlsTheme.hxx"
37 : : #include "view/SlsButtonBar.hxx"
38 : : #include "SlsFramePainter.hxx"
39 : : #include "cache/SlsPageCache.hxx"
40 : : #include "controller/SlsProperties.hxx"
41 : : #include "Window.hxx"
42 : : #include "sdpage.hxx"
43 : : #include "sdresid.hxx"
44 : : #include <vcl/svapp.hxx>
45 : : #include <vcl/vclenum.hxx>
46 : : #include <vcl/virdev.hxx>
47 : : #include <boost/scoped_ptr.hpp>
48 : :
49 : : using namespace ::drawinglayer::primitive2d;
50 : :
51 : : namespace sd { namespace slidesorter { namespace view {
52 : :
53 : : //===== PageObjectPainter =====================================================
54 : :
55 : 130 : PageObjectPainter::PageObjectPainter (
56 : : const SlideSorter& rSlideSorter)
57 : 130 : : mrLayouter(rSlideSorter.GetView().GetLayouter()),
58 : : mpPageObjectLayouter(),
59 [ + - ]: 130 : mpCache(rSlideSorter.GetView().GetPreviewCache()),
60 : : mpProperties(rSlideSorter.GetProperties()),
61 : : mpTheme(rSlideSorter.GetTheme()),
62 [ + - ][ + - ]: 260 : mpPageNumberFont(Theme::GetFont(Theme::Font_PageNumber, *rSlideSorter.GetContentWindow())),
63 [ + - ]: 260 : mpShadowPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_RawShadow))),
64 [ + - ]: 260 : mpFocusBorderPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_FocusBorder))),
65 : : maNormalBackground(),
66 : : maSelectionBackground(),
67 : : maFocusedSelectionBackground(),
68 : : maMouseOverBackground(),
69 : : maMouseOverFocusedBackground(),
70 [ + - ][ + - ]: 130 : mrButtonBar(rSlideSorter.GetView().GetButtonBar()),
71 [ + - ][ + - ]: 1040 : maSize()
[ + - + -
+ - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
72 : : {
73 : : // Replace the color (not the alpha values) in the focus border with a
74 : : // color derived from the current selection color.
75 [ + - ]: 130 : Color aColor (mpTheme->GetColor(Theme::Color_Selection));
76 : : sal_uInt16 nHue, nSat, nBri;
77 [ + - ]: 130 : aColor.RGBtoHSB(nHue, nSat, nBri);
78 [ + - ]: 130 : aColor = Color::HSBtoRGB(nHue, 28, 65);
79 [ + - ]: 130 : mpFocusBorderPainter->AdaptColor(aColor, true);
80 : 130 : }
81 : :
82 : :
83 : :
84 : :
85 [ + - ][ + - ]: 130 : PageObjectPainter::~PageObjectPainter (void)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ]
86 : : {
87 : 130 : }
88 : :
89 : :
90 : :
91 : :
92 : 677 : void PageObjectPainter::PaintPageObject (
93 : : OutputDevice& rDevice,
94 : : const model::SharedPageDescriptor& rpDescriptor)
95 : : {
96 : : // The page object layouter is quite volatile. It may have been replaced
97 : : // since the last call. Update it now.
98 [ + - ]: 677 : mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
99 [ - + ]: 677 : if ( ! mpPageObjectLayouter)
100 : : {
101 : : OSL_ASSERT(mpPageObjectLayouter);
102 : 677 : return;
103 : : }
104 : :
105 : : // Turn off antialiasing to avoid the bitmaps from being shifted by
106 : : // fractions of a pixel and thus show blurry edges.
107 : 677 : const sal_uInt16 nSavedAntialiasingMode (rDevice.GetAntialiasing());
108 : 677 : rDevice.SetAntialiasing(nSavedAntialiasingMode & ~ANTIALIASING_ENABLE_B2DDRAW);
109 : :
110 : 677 : PaintBackground(rDevice, rpDescriptor);
111 : 677 : PaintPreview(rDevice, rpDescriptor);
112 : 677 : PaintPageNumber(rDevice, rpDescriptor);
113 : 677 : PaintTransitionEffect(rDevice, rpDescriptor);
114 : 677 : mrButtonBar.Paint(rDevice, rpDescriptor);
115 : :
116 : 677 : rDevice.SetAntialiasing(nSavedAntialiasingMode);
117 : : }
118 : :
119 : :
120 : :
121 : :
122 : 439 : void PageObjectPainter::NotifyResize (const bool bForce)
123 : : {
124 [ + - ]: 439 : mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
125 [ + + ][ + + ]: 439 : if (bForce || ! mpPageObjectLayouter)
[ + - ]
126 : 130 : InvalidateBitmaps();
127 : : else
128 : : {
129 : : const Size aSize (mpPageObjectLayouter->GetSize(
130 : : PageObjectLayouter::FocusIndicator,
131 [ + - ]: 309 : PageObjectLayouter::WindowCoordinateSystem));
132 [ + + ]: 309 : if ( maSize!=aSize)
133 : : {
134 : 133 : maSize = aSize;
135 [ + - ]: 309 : InvalidateBitmaps();
136 : : }
137 : : }
138 : 439 : }
139 : :
140 : :
141 : :
142 : :
143 : 263 : void PageObjectPainter::InvalidateBitmaps (void)
144 : : {
145 : 263 : maNormalBackground.SetEmpty();
146 : 263 : maSelectionBackground.SetEmpty();
147 : 263 : maFocusedSelectionBackground.SetEmpty();
148 : 263 : maFocusedBackground.SetEmpty();
149 : 263 : maMouseOverBackground.SetEmpty();
150 : 263 : maMouseOverFocusedBackground.SetEmpty();
151 : 263 : maMouseOverSelectedAndFocusedBackground.SetEmpty();
152 : 263 : }
153 : :
154 : :
155 : :
156 : :
157 : 0 : void PageObjectPainter::SetTheme (const ::boost::shared_ptr<view::Theme>& rpTheme)
158 : : {
159 : 0 : mpTheme = rpTheme;
160 : 0 : NotifyResize(true);
161 : 0 : }
162 : :
163 : :
164 : :
165 : :
166 : 677 : void PageObjectPainter::PaintBackground (
167 : : OutputDevice& rDevice,
168 : : const model::SharedPageDescriptor& rpDescriptor)
169 : : {
170 : : const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
171 : : rpDescriptor,
172 : : PageObjectLayouter::FocusIndicator,
173 [ + - ]: 677 : PageObjectLayouter::ModelCoordinateSystem));
174 : :
175 [ + - ]: 677 : const Bitmap& rBackground (GetBackgroundForState(rpDescriptor, rDevice));
176 [ + - ]: 677 : rDevice.DrawBitmap(aBox.TopLeft(), rBackground);
177 : :
178 : : // Fill the interior of the preview area with the default background
179 : : // color of the page.
180 [ + - ]: 677 : SdPage* pPage = rpDescriptor->GetPage();
181 [ + - ]: 677 : if (pPage != NULL)
182 : : {
183 [ + - ][ + - ]: 677 : rDevice.SetFillColor(pPage->GetPageBackgroundColor(NULL));
184 [ + - ][ + - ]: 677 : rDevice.SetLineColor(pPage->GetPageBackgroundColor(NULL));
185 : : const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
186 : : rpDescriptor,
187 : : PageObjectLayouter::Preview,
188 [ + - ]: 677 : PageObjectLayouter::ModelCoordinateSystem));
189 [ + - ]: 677 : rDevice.DrawRect(aPreviewBox);
190 : : }
191 : 677 : }
192 : :
193 : :
194 : :
195 : :
196 : 677 : void PageObjectPainter::PaintPreview (
197 : : OutputDevice& rDevice,
198 : : const model::SharedPageDescriptor& rpDescriptor) const
199 : : {
200 : : const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
201 : : rpDescriptor,
202 : : PageObjectLayouter::Preview,
203 [ + - ]: 677 : PageObjectLayouter::ModelCoordinateSystem));
204 : :
205 [ + - ]: 677 : if (mpCache != NULL)
206 : : {
207 [ + - ]: 677 : const SdrPage* pPage = rpDescriptor->GetPage();
208 [ + - ]: 677 : mpCache->SetPreciousFlag(pPage, true);
209 : :
210 [ + - ]: 677 : const Bitmap aPreview (GetPreviewBitmap(rpDescriptor, &rDevice));
211 [ + + ]: 677 : if ( ! aPreview.IsEmpty())
212 : : {
213 [ + - ][ + - ]: 381 : if (aPreview.GetSizePixel() != aBox.GetSize())
[ + + ]
214 [ + - ][ + - ]: 7 : rDevice.DrawBitmap(aBox.TopLeft(), aBox.GetSize(), aPreview);
215 : : else
216 [ + - ]: 374 : rDevice.DrawBitmap(aBox.TopLeft(), aPreview);
217 [ + - ]: 677 : }
218 : : }
219 : 677 : }
220 : :
221 : :
222 : :
223 : :
224 : 0 : Bitmap PageObjectPainter::CreateMarkedPreview (
225 : : const Size& rSize,
226 : : const Bitmap& rPreview,
227 : : const BitmapEx& rOverlay,
228 : : const OutputDevice* pReferenceDevice) const
229 : : {
230 : 0 : ::boost::scoped_ptr<VirtualDevice> pDevice;
231 [ # # ]: 0 : if (pReferenceDevice != NULL)
232 [ # # ][ # # ]: 0 : pDevice.reset(new VirtualDevice(*pReferenceDevice));
[ # # ]
233 : : else
234 [ # # ][ # # ]: 0 : pDevice.reset(new VirtualDevice());
[ # # ]
235 [ # # ]: 0 : pDevice->SetOutputSizePixel(rSize);
236 : :
237 [ # # ]: 0 : pDevice->DrawBitmap(Point(0,0), rSize, rPreview);
238 : :
239 : : // Paint bitmap tiled over the preview to mark it as excluded.
240 : 0 : const sal_Int32 nIconWidth (rOverlay.GetSizePixel().Width());
241 : 0 : const sal_Int32 nIconHeight (rOverlay.GetSizePixel().Height());
242 [ # # ][ # # ]: 0 : if (nIconWidth>0 && nIconHeight>0)
243 : : {
244 [ # # ]: 0 : for (sal_Int32 nX=0; nX<rSize.Width(); nX+=nIconWidth)
245 [ # # ]: 0 : for (sal_Int32 nY=0; nY<rSize.Height(); nY+=nIconHeight)
246 [ # # ]: 0 : pDevice->DrawBitmapEx(Point(nX,nY), rOverlay);
247 : : }
248 [ # # ][ # # ]: 0 : return pDevice->GetBitmap(Point(0,0), rSize);
249 : : }
250 : :
251 : :
252 : :
253 : :
254 : 677 : Bitmap PageObjectPainter::GetPreviewBitmap (
255 : : const model::SharedPageDescriptor& rpDescriptor,
256 : : const OutputDevice* pReferenceDevice) const
257 : : {
258 : 677 : const SdrPage* pPage = rpDescriptor->GetPage();
259 : 677 : const bool bIsExcluded (rpDescriptor->HasState(model::PageDescriptor::ST_Excluded));
260 : :
261 [ - + ]: 677 : if (bIsExcluded)
262 : : {
263 [ # # ]: 0 : Bitmap aMarkedPreview (mpCache->GetMarkedPreviewBitmap(pPage,false));
264 : : const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
265 : : rpDescriptor,
266 : : PageObjectLayouter::Preview,
267 [ # # ]: 0 : PageObjectLayouter::ModelCoordinateSystem));
268 [ # # ][ # # ]: 0 : if (aMarkedPreview.IsEmpty() || aMarkedPreview.GetSizePixel()!=aPreviewBox.GetSize())
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
269 : : {
270 : : aMarkedPreview = CreateMarkedPreview(
271 : : aPreviewBox.GetSize(),
272 : : mpCache->GetPreviewBitmap(pPage,true),
273 [ # # ]: 0 : mpTheme->GetIcon(Theme::Icon_HideSlideOverlay),
274 [ # # ][ # # ]: 0 : pReferenceDevice);
[ # # ][ # # ]
[ # # ][ # # ]
275 [ # # ]: 0 : mpCache->SetMarkedPreviewBitmap(pPage, aMarkedPreview);
276 : : }
277 [ # # ][ # # ]: 0 : return aMarkedPreview;
278 : : }
279 : : else
280 : : {
281 : 677 : return mpCache->GetPreviewBitmap(pPage,false);
282 : : }
283 : : }
284 : :
285 : :
286 : :
287 : :
288 : 677 : void PageObjectPainter::PaintPageNumber (
289 : : OutputDevice& rDevice,
290 : : const model::SharedPageDescriptor& rpDescriptor) const
291 : : {
292 : : const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
293 : : rpDescriptor,
294 : : PageObjectLayouter::PageNumber,
295 [ + - ]: 677 : PageObjectLayouter::ModelCoordinateSystem));
296 : :
297 : : // Determine the color of the page number.
298 [ + - ]: 677 : Color aPageNumberColor (mpTheme->GetColor(Theme::Color_PageNumberDefault));
299 [ + - ][ + + ]: 1354 : if (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) ||
[ + + ][ + - ]
300 [ + - ]: 677 : rpDescriptor->HasState(model::PageDescriptor::ST_Selected))
301 : : {
302 : : // Page number is painted on background for hover or selection or
303 : : // both. Each of these background colors has a predefined luminance
304 : : // which is compatible with the PageNumberHover color.
305 [ + - ]: 606 : aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberHover));
306 : : }
307 : : else
308 : : {
309 [ + - ]: 71 : const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background));
310 [ + - ]: 71 : const sal_Int32 nBackgroundLuminance (aBackgroundColor.GetLuminance());
311 : : // When the background color is black then this is interpreted as
312 : : // high contrast mode and the font color is set to white.
313 [ - + ]: 71 : if (nBackgroundLuminance == 0)
314 [ # # ]: 0 : aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberHighContrast));
315 : : else
316 : : {
317 : : // Compare luminance of default page number color and background
318 : : // color. When the two are similar then use a darker
319 : : // (preferred) or brighter font color.
320 [ + - ]: 71 : const sal_Int32 nFontLuminance (aPageNumberColor.GetLuminance());
321 [ + - ][ - + ]: 71 : if (abs(nBackgroundLuminance - nFontLuminance) < 60)
322 : : {
323 [ # # ]: 0 : if (nBackgroundLuminance > nFontLuminance-30)
324 [ # # ]: 0 : aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberBrightBackground));
325 : : else
326 [ # # ]: 71 : aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberDarkBackground));
327 : : }
328 : : }
329 : : }
330 : :
331 : : // Paint the page number.
332 : : OSL_ASSERT(rpDescriptor->GetPage()!=NULL);
333 [ + - ][ + - ]: 677 : const sal_Int32 nPageNumber ((rpDescriptor->GetPage()->GetPageNum() - 1) / 2 + 1);
334 : 677 : const rtl::OUString sPageNumber(rtl::OUString::valueOf(nPageNumber));
335 [ + - ]: 677 : rDevice.SetFont(*mpPageNumberFont);
336 [ + - ]: 677 : rDevice.SetTextColor(aPageNumberColor);
337 [ + - ][ + - ]: 677 : rDevice.DrawText(aBox, sPageNumber, TEXT_DRAW_RIGHT | TEXT_DRAW_VCENTER);
[ + - ]
338 : 677 : }
339 : :
340 : :
341 : :
342 : :
343 : 677 : void PageObjectPainter::PaintTransitionEffect (
344 : : OutputDevice& rDevice,
345 : : const model::SharedPageDescriptor& rpDescriptor) const
346 : : {
347 : 677 : const SdPage* pPage = rpDescriptor->GetPage();
348 [ - + ][ - + ]: 677 : if (pPage!=NULL && pPage->getTransitionType() > 0)
[ + - ]
349 : : {
350 : : const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
351 : : rpDescriptor,
352 : : PageObjectLayouter::TransitionEffectIndicator,
353 [ # # ]: 0 : PageObjectLayouter::ModelCoordinateSystem));
354 : :
355 : : rDevice.DrawBitmapEx(
356 : : aBox.TopLeft(),
357 [ # # ][ # # ]: 0 : mpPageObjectLayouter->GetTransitionEffectIcon().GetBitmapEx());
[ # # ][ # # ]
[ # # ]
358 : : }
359 : 677 : }
360 : :
361 : :
362 : :
363 : :
364 : 677 : Bitmap& PageObjectPainter::GetBackgroundForState (
365 : : const model::SharedPageDescriptor& rpDescriptor,
366 : : const OutputDevice& rReferenceDevice)
367 : : {
368 : : enum State { None = 0x00, Selected = 0x01, MouseOver = 0x02, Focused = 0x04 };
369 : : const int eState =
370 : 677 : (rpDescriptor->HasState(model::PageDescriptor::ST_Selected) ? Selected : None)
371 : 677 : | (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) ? MouseOver : None)
372 [ - + ][ - + ]: 1354 : | (rpDescriptor->HasState(model::PageDescriptor::ST_Focused) ? Focused : None);
[ + + ]
373 : :
374 [ - - - - : 677 : switch (eState)
+ - + ]
375 : : {
376 : : case MouseOver | Selected | Focused:
377 : : return GetBackground(
378 : : maMouseOverSelectedAndFocusedBackground,
379 : : Theme::Gradient_MouseOverSelectedAndFocusedPage,
380 : : rReferenceDevice,
381 : 0 : true);
382 : :
383 : : case MouseOver | Selected:
384 : : case MouseOver:
385 : : return GetBackground(
386 : : maMouseOverBackground,
387 : : Theme::Gradient_MouseOverPage,
388 : : rReferenceDevice,
389 : 0 : false);
390 : :
391 : : case MouseOver | Focused:
392 : : return GetBackground(
393 : : maMouseOverFocusedBackground,
394 : : Theme::Gradient_MouseOverPage,
395 : : rReferenceDevice,
396 : 0 : true);
397 : :
398 : : case Selected | Focused:
399 : : return GetBackground(
400 : : maFocusedSelectionBackground,
401 : : Theme::Gradient_SelectedAndFocusedPage,
402 : : rReferenceDevice,
403 : 0 : true);
404 : :
405 : : case Selected:
406 : : return GetBackground(
407 : : maSelectionBackground,
408 : : Theme::Gradient_SelectedPage,
409 : : rReferenceDevice,
410 : 606 : false);
411 : :
412 : : case Focused:
413 : : return GetBackground(
414 : : maFocusedBackground,
415 : : Theme::Gradient_FocusedPage,
416 : : rReferenceDevice,
417 : 0 : true);
418 : :
419 : : case None:
420 : : default:
421 : : return GetBackground(
422 : : maNormalBackground,
423 : : Theme::Gradient_NormalPage,
424 : : rReferenceDevice,
425 : 677 : false);
426 : : }
427 : : }
428 : :
429 : :
430 : :
431 : :
432 : 677 : Bitmap& PageObjectPainter::GetBackground(
433 : : Bitmap& rBackground,
434 : : Theme::GradientColorType eType,
435 : : const OutputDevice& rReferenceDevice,
436 : : const bool bHasFocusBorder)
437 : : {
438 [ + + ]: 677 : if (rBackground.IsEmpty())
439 [ + - ]: 147 : rBackground = CreateBackgroundBitmap(rReferenceDevice, eType, bHasFocusBorder);
440 : 677 : return rBackground;
441 : : }
442 : :
443 : :
444 : :
445 : :
446 : 147 : Bitmap PageObjectPainter::CreateBackgroundBitmap(
447 : : const OutputDevice& rReferenceDevice,
448 : : const Theme::GradientColorType eColorType,
449 : : const bool bHasFocusBorder) const
450 : : {
451 : : const Size aSize (mpPageObjectLayouter->GetSize(
452 : : PageObjectLayouter::FocusIndicator,
453 [ + - ]: 147 : PageObjectLayouter::WindowCoordinateSystem));
454 : : const Rectangle aPageObjectBox (mpPageObjectLayouter->GetBoundingBox(
455 : : Point(0,0),
456 : : PageObjectLayouter::PageObject,
457 [ + - ]: 147 : PageObjectLayouter::ModelCoordinateSystem));
458 [ + - ]: 147 : VirtualDevice aBitmapDevice (rReferenceDevice);
459 [ + - ]: 147 : aBitmapDevice.SetOutputSizePixel(aSize);
460 : :
461 : : // Fill the background with the background color of the slide sorter.
462 [ + - ]: 147 : const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background));
463 [ + - ]: 147 : aBitmapDevice.SetFillColor(aBackgroundColor);
464 [ + - ]: 147 : aBitmapDevice.SetLineColor(aBackgroundColor);
465 [ + - ][ + - ]: 147 : aBitmapDevice.DrawRect(Rectangle(Point(0,0), aSize));
466 : :
467 : : // Paint the slide area with a linear gradient that starts some pixels
468 : : // below the top and ends some pixels above the bottom.
469 [ + - ]: 147 : const Color aTopColor(mpTheme->GetGradientColor(eColorType, Theme::Fill1));
470 [ + - ]: 147 : const Color aBottomColor(mpTheme->GetGradientColor(eColorType, Theme::Fill2));
471 [ - + ]: 147 : if (aTopColor != aBottomColor)
472 : : {
473 [ # # ]: 0 : const sal_Int32 nHeight (aPageObjectBox.GetHeight());
474 : 0 : const sal_Int32 nDefaultConstantSize(nHeight/4);
475 : 0 : const sal_Int32 nMinimalGradientSize(40);
476 : : const sal_Int32 nY1 (
477 : : ::std::max<sal_Int32>(
478 : : 0,
479 : : ::std::min<sal_Int32>(
480 : : nDefaultConstantSize,
481 [ # # ][ # # ]: 0 : (nHeight - nMinimalGradientSize)/2)));
482 : 0 : const sal_Int32 nY2 (nHeight-nY1);
483 : 0 : const sal_Int32 nTop (aPageObjectBox.Top());
484 [ # # ]: 0 : for (sal_Int32 nY=0; nY<nHeight; ++nY)
485 : : {
486 [ # # ]: 0 : if (nY<=nY1)
487 [ # # ]: 0 : aBitmapDevice.SetLineColor(aTopColor);
488 [ # # ]: 0 : else if (nY>=nY2)
489 [ # # ]: 0 : aBitmapDevice.SetLineColor(aBottomColor);
490 : : else
491 : : {
492 : 0 : Color aColor (aTopColor);
493 [ # # ]: 0 : aColor.Merge(aBottomColor, 255 * (nY2-nY) / (nY2-nY1));
494 [ # # ]: 0 : aBitmapDevice.SetLineColor(aColor);
495 : : }
496 : : aBitmapDevice.DrawLine(
497 : : Point(aPageObjectBox.Left(), nY+nTop),
498 [ # # ]: 0 : Point(aPageObjectBox.Right(), nY+nTop));
499 : : }
500 : : }
501 : : else
502 : : {
503 [ + - ]: 147 : aBitmapDevice.SetFillColor(aTopColor);
504 [ + - ]: 147 : aBitmapDevice.DrawRect(aPageObjectBox);
505 : : }
506 : :
507 : : // Paint the simple border and, for some backgrounds, the focus border.
508 [ - + ]: 147 : if (bHasFocusBorder)
509 [ # # ]: 0 : mpFocusBorderPainter->PaintFrame(aBitmapDevice, aPageObjectBox);
510 : : else
511 [ + - ]: 147 : PaintBorder(aBitmapDevice, eColorType, aPageObjectBox);
512 : :
513 : : // Get bounding box of the preview around which a shadow is painted.
514 : : // Compensate for the border around the preview.
515 : : const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
516 : : Point(0,0),
517 : : PageObjectLayouter::Preview,
518 [ + - ]: 147 : PageObjectLayouter::ModelCoordinateSystem));
519 [ + - ]: 147 : Rectangle aFrameBox (aBox.Left()-1,aBox.Top()-1,aBox.Right()+1,aBox.Bottom()+1);
520 [ + - ]: 147 : mpShadowPainter->PaintFrame(aBitmapDevice, aFrameBox);
521 : :
522 [ + - ][ + - ]: 147 : return aBitmapDevice.GetBitmap (Point(0,0),aSize);
523 : : }
524 : :
525 : :
526 : :
527 : :
528 : 147 : void PageObjectPainter::PaintBorder (
529 : : OutputDevice& rDevice,
530 : : const Theme::GradientColorType eColorType,
531 : : const Rectangle& rBox) const
532 : : {
533 : 147 : rDevice.SetFillColor();
534 : 147 : const sal_Int32 nBorderWidth (1);
535 [ + + ]: 294 : for (int nIndex=0; nIndex<nBorderWidth; ++nIndex)
536 : : {
537 : 147 : const int nDelta (nIndex);
538 [ + - ]: 147 : rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border2));
539 : : rDevice.DrawLine(
540 : 147 : Point(rBox.Left()-nDelta, rBox.Top()-nDelta),
541 [ + - ]: 294 : Point(rBox.Left()-nDelta, rBox.Bottom()+nDelta));
542 : : rDevice.DrawLine(
543 : 147 : Point(rBox.Left()-nDelta, rBox.Bottom()+nDelta),
544 [ + - ]: 294 : Point(rBox.Right()+nDelta, rBox.Bottom()+nDelta));
545 : : rDevice.DrawLine(
546 : 147 : Point(rBox.Right()+nDelta, rBox.Bottom()+nDelta),
547 [ + - ]: 294 : Point(rBox.Right()+nDelta, rBox.Top()-nDelta));
548 : :
549 [ + - ]: 147 : rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border1));
550 : : rDevice.DrawLine(
551 : 147 : Point(rBox.Left()-nDelta, rBox.Top()-nDelta),
552 [ + - ]: 294 : Point(rBox.Right()+nDelta, rBox.Top()-nDelta));
553 : : }
554 : 147 : }
555 : :
556 : :
557 : :
558 : : } } } // end of namespace sd::slidesorter::view
559 : :
560 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|