LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/view - SlsPageObjectPainter.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 208 0.0 %
Date: 2014-04-14 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : 
      21             : #include "view/SlsPageObjectPainter.hxx"
      22             : 
      23             : #include "model/SlsPageDescriptor.hxx"
      24             : #include "view/SlideSorterView.hxx"
      25             : #include "view/SlsPageObjectLayouter.hxx"
      26             : #include "view/SlsLayouter.hxx"
      27             : #include "view/SlsTheme.hxx"
      28             : #include "SlsFramePainter.hxx"
      29             : #include "cache/SlsPageCache.hxx"
      30             : #include "controller/SlsProperties.hxx"
      31             : #include "Window.hxx"
      32             : #include "sdpage.hxx"
      33             : #include "sdresid.hxx"
      34             : #include <vcl/svapp.hxx>
      35             : #include <vcl/vclenum.hxx>
      36             : #include <vcl/virdev.hxx>
      37             : #include <boost/scoped_ptr.hpp>
      38             : #include "CustomAnimationEffect.hxx"
      39             : 
      40             : using namespace ::drawinglayer::primitive2d;
      41             : 
      42             : 
      43             : namespace sd { namespace slidesorter { namespace view {
      44             : 
      45             : //===== PageObjectPainter =====================================================
      46             : 
      47           0 : PageObjectPainter::PageObjectPainter (
      48             :     const SlideSorter& rSlideSorter)
      49           0 :     : mrLayouter(rSlideSorter.GetView().GetLayouter()),
      50             :       mpPageObjectLayouter(),
      51           0 :       mpCache(rSlideSorter.GetView().GetPreviewCache()),
      52             :       mpProperties(rSlideSorter.GetProperties()),
      53             :       mpTheme(rSlideSorter.GetTheme()),
      54           0 :       mpPageNumberFont(Theme::GetFont(Theme::Font_PageNumber, *rSlideSorter.GetContentWindow())),
      55           0 :       mpShadowPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_RawShadow))),
      56           0 :       mpFocusBorderPainter(new FramePainter(mpTheme->GetIcon(Theme::Icon_FocusBorder))),
      57             :       maNormalBackground(),
      58             :       maSelectionBackground(),
      59             :       maFocusedSelectionBackground(),
      60             :       maMouseOverBackground(),
      61             :       maMouseOverFocusedBackground(),
      62           0 :       maSize()
      63             : {
      64             :     // Replace the color (not the alpha values) in the focus border with a
      65             :     // color derived from the current selection color.
      66           0 :     Color aColor (mpTheme->GetColor(Theme::Color_Selection));
      67             :     sal_uInt16 nHue, nSat, nBri;
      68           0 :     aColor.RGBtoHSB(nHue, nSat, nBri);
      69           0 :     aColor = Color::HSBtoRGB(nHue, 28, 65);
      70           0 :     mpFocusBorderPainter->AdaptColor(aColor, true);
      71           0 : }
      72             : 
      73             : 
      74             : 
      75           0 : PageObjectPainter::~PageObjectPainter (void)
      76             : {
      77           0 : }
      78             : 
      79             : 
      80             : 
      81             : 
      82           0 : void PageObjectPainter::PaintPageObject (
      83             :     OutputDevice& rDevice,
      84             :     const model::SharedPageDescriptor& rpDescriptor)
      85             : {
      86           0 :     if (UpdatePageObjectLayouter())
      87             :     {
      88             :         // Turn off antialiasing to avoid the bitmaps from being
      89             :         // shifted by fractions of a pixel and thus show blurry edges.
      90           0 :         const sal_uInt16 nSavedAntialiasingMode (rDevice.GetAntialiasing());
      91           0 :         rDevice.SetAntialiasing(nSavedAntialiasingMode & ~ANTIALIASING_ENABLE_B2DDRAW);
      92             : 
      93           0 :         PaintBackground(rDevice, rpDescriptor);
      94           0 :         PaintPreview(rDevice, rpDescriptor);
      95           0 :         PaintPageNumber(rDevice, rpDescriptor);
      96           0 :         PaintTransitionEffect(rDevice, rpDescriptor);
      97           0 :         PaintCustomAnimationEffect(rDevice, rpDescriptor);
      98           0 :         rDevice.SetAntialiasing(nSavedAntialiasingMode);
      99             :     }
     100           0 : }
     101             : 
     102             : 
     103             : 
     104             : 
     105           0 : bool PageObjectPainter::UpdatePageObjectLayouter (void)
     106             : {
     107             :     // The page object layouter is quite volatile. It may have been replaced
     108             :     // since the last call.  Update it now.
     109           0 :     mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
     110           0 :     if ( ! mpPageObjectLayouter)
     111             :     {
     112             :         OSL_ASSERT(mpPageObjectLayouter);
     113           0 :         return false;
     114             :     }
     115             :     else
     116           0 :         return true;
     117             : }
     118             : 
     119             : 
     120             : 
     121             : 
     122           0 : void PageObjectPainter::NotifyResize (const bool bForce)
     123             : {
     124           0 :     mpPageObjectLayouter = mrLayouter.GetPageObjectLayouter();
     125           0 :     if (bForce || ! mpPageObjectLayouter)
     126           0 :         InvalidateBitmaps();
     127           0 :     else if (UpdatePageObjectLayouter())
     128             :     {
     129             :         const Size aSize (mpPageObjectLayouter->GetSize(
     130             :                 PageObjectLayouter::FocusIndicator,
     131           0 :                 PageObjectLayouter::WindowCoordinateSystem));
     132           0 :         if ( maSize!=aSize)
     133             :         {
     134           0 :             maSize = aSize;
     135           0 :             InvalidateBitmaps();
     136             :         }
     137             :     }
     138           0 : }
     139             : 
     140             : 
     141             : 
     142             : 
     143           0 : void PageObjectPainter::InvalidateBitmaps (void)
     144             : {
     145           0 :     maNormalBackground.SetEmpty();
     146           0 :     maSelectionBackground.SetEmpty();
     147           0 :     maFocusedSelectionBackground.SetEmpty();
     148           0 :     maFocusedBackground.SetEmpty();
     149           0 :     maMouseOverBackground.SetEmpty();
     150           0 :     maMouseOverFocusedBackground.SetEmpty();
     151           0 :     maMouseOverSelectedAndFocusedBackground.SetEmpty();
     152           0 : }
     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           0 : void PageObjectPainter::PaintBackground (
     167             :     OutputDevice& rDevice,
     168             :     const model::SharedPageDescriptor& rpDescriptor)
     169             : {
     170             :     const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
     171             :         rpDescriptor,
     172             :         PageObjectLayouter::FocusIndicator,
     173           0 :         PageObjectLayouter::ModelCoordinateSystem));
     174             : 
     175           0 :     const Bitmap& rBackground (GetBackgroundForState(rpDescriptor, rDevice));
     176           0 :     rDevice.DrawBitmap(aBox.TopLeft(), rBackground);
     177             : 
     178             :     // Fill the interior of the preview area with the default background
     179             :     // color of the page.
     180           0 :     SdPage* pPage = rpDescriptor->GetPage();
     181           0 :     if (pPage != NULL)
     182             :     {
     183           0 :         rDevice.SetFillColor(pPage->GetPageBackgroundColor(NULL));
     184           0 :         rDevice.SetLineColor(pPage->GetPageBackgroundColor(NULL));
     185             :         const Rectangle aPreviewBox (mpPageObjectLayouter->GetBoundingBox(
     186             :             rpDescriptor,
     187             :             PageObjectLayouter::Preview,
     188           0 :             PageObjectLayouter::ModelCoordinateSystem));
     189           0 :         rDevice.DrawRect(aPreviewBox);
     190             :     }
     191           0 : }
     192             : 
     193             : 
     194             : 
     195             : 
     196           0 : 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           0 :         PageObjectLayouter::ModelCoordinateSystem));
     204             : 
     205           0 :     if (mpCache != 0)
     206             :     {
     207           0 :         const SdrPage* pPage = rpDescriptor->GetPage();
     208           0 :         mpCache->SetPreciousFlag(pPage, true);
     209             : 
     210           0 :         const Bitmap aPreview (GetPreviewBitmap(rpDescriptor, &rDevice));
     211           0 :         if ( ! aPreview.IsEmpty())
     212             :         {
     213           0 :             if (aPreview.GetSizePixel() != aBox.GetSize())
     214           0 :                 rDevice.DrawBitmap(aBox.TopLeft(), aBox.GetSize(), aPreview);
     215             :             else
     216           0 :                 rDevice.DrawBitmap(aBox.TopLeft(), aPreview);
     217           0 :         }
     218             :     }
     219           0 : }
     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           0 : Bitmap PageObjectPainter::GetPreviewBitmap (
     255             :     const model::SharedPageDescriptor& rpDescriptor,
     256             :     const OutputDevice* pReferenceDevice) const
     257             : {
     258           0 :     const SdrPage* pPage = rpDescriptor->GetPage();
     259           0 :     const bool bIsExcluded (rpDescriptor->HasState(model::PageDescriptor::ST_Excluded));
     260             : 
     261           0 :     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           0 :             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           0 :         return mpCache->GetPreviewBitmap(pPage,false);
     282             :     }
     283             : }
     284             : 
     285             : 
     286             : 
     287             : 
     288           0 : 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           0 :         PageObjectLayouter::ModelCoordinateSystem));
     296             : 
     297             :     // Determine the color of the page number.
     298           0 :     Color aPageNumberColor (mpTheme->GetColor(Theme::Color_PageNumberDefault));
     299           0 :     if (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) ||
     300           0 :         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           0 :         aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberHover));
     306             :     }
     307             :     else
     308             :     {
     309           0 :         const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background));
     310           0 :         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           0 :         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           0 :             const sal_Int32 nFontLuminance (aPageNumberColor.GetLuminance());
     321           0 :             if (abs(nBackgroundLuminance - nFontLuminance) < 60)
     322             :             {
     323           0 :                 if (nBackgroundLuminance > nFontLuminance-30)
     324           0 :                     aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberBrightBackground));
     325             :                 else
     326           0 :                     aPageNumberColor = Color(mpTheme->GetColor(Theme::Color_PageNumberDarkBackground));
     327             :             }
     328             :         }
     329             :     }
     330             : 
     331             :     // Paint the page number.
     332             :     OSL_ASSERT(rpDescriptor->GetPage()!=NULL);
     333           0 :     const sal_Int32 nPageNumber ((rpDescriptor->GetPage()->GetPageNum() - 1) / 2 + 1);
     334           0 :     const OUString sPageNumber(OUString::number(nPageNumber));
     335           0 :     rDevice.SetFont(*mpPageNumberFont);
     336           0 :     rDevice.SetTextColor(aPageNumberColor);
     337           0 :     rDevice.DrawText(aBox, sPageNumber, TEXT_DRAW_RIGHT | TEXT_DRAW_VCENTER);
     338           0 : }
     339             : 
     340             : 
     341             : 
     342             : 
     343           0 : void PageObjectPainter::PaintTransitionEffect (
     344             :     OutputDevice& rDevice,
     345             :     const model::SharedPageDescriptor& rpDescriptor) const
     346             : {
     347           0 :     const SdPage* pPage = rpDescriptor->GetPage();
     348           0 :     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.TopCenter(),
     357           0 :             mpPageObjectLayouter->GetTransitionEffectIcon().GetBitmapEx());
     358             :     }
     359           0 : }
     360             : 
     361           0 : void PageObjectPainter::PaintCustomAnimationEffect (
     362             :     OutputDevice& rDevice,
     363             :     const model::SharedPageDescriptor& rpDescriptor) const
     364             : {
     365           0 :     SdPage* pPage = rpDescriptor->GetPage();
     366           0 :     boost::shared_ptr< MainSequence > aMainSequence = pPage->getMainSequence();
     367           0 :     EffectSequence::iterator aIter = aMainSequence->getBegin();
     368           0 :     EffectSequence::iterator aEnd = aMainSequence->getEnd();
     369           0 :     if ( aIter != aEnd )
     370             :     {
     371             :         const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
     372             :             rpDescriptor,
     373             :             PageObjectLayouter::CustomAnimationEffectIndicator,
     374           0 :             PageObjectLayouter::ModelCoordinateSystem));
     375             :         rDevice.DrawBitmapEx(
     376             :             aBox.TopCenter(),
     377           0 :             mpPageObjectLayouter->GetCustomAnimationEffectIcon().GetBitmapEx());
     378           0 :     }
     379           0 : }
     380             : 
     381           0 : Bitmap& PageObjectPainter::GetBackgroundForState (
     382             :     const model::SharedPageDescriptor& rpDescriptor,
     383             :     const OutputDevice& rReferenceDevice)
     384             : {
     385             :     enum State { None = 0x00, Selected = 0x01, MouseOver = 0x02, Focused = 0x04 };
     386             :     const int eState =
     387           0 :           (rpDescriptor->HasState(model::PageDescriptor::ST_Selected) ? Selected : None)
     388           0 :         | (rpDescriptor->HasState(model::PageDescriptor::ST_MouseOver) ? MouseOver : None)
     389           0 :         | (rpDescriptor->HasState(model::PageDescriptor::ST_Focused) ? Focused : None);
     390             : 
     391           0 :     switch (eState)
     392             :     {
     393             :         case MouseOver | Selected | Focused:
     394             :             return GetBackground(
     395             :                 maMouseOverSelectedAndFocusedBackground,
     396             :                 Theme::Gradient_MouseOverSelectedAndFocusedPage,
     397             :                 rReferenceDevice,
     398           0 :                 true);
     399             : 
     400             :         case MouseOver | Selected:
     401             :         case MouseOver:
     402             :             return GetBackground(
     403             :                 maMouseOverBackground,
     404             :                 Theme::Gradient_MouseOverPage,
     405             :                 rReferenceDevice,
     406           0 :                 false);
     407             : 
     408             :         case MouseOver | Focused:
     409             :             return GetBackground(
     410             :                 maMouseOverFocusedBackground,
     411             :                 Theme::Gradient_MouseOverPage,
     412             :                 rReferenceDevice,
     413           0 :                 true);
     414             : 
     415             :         case Selected | Focused:
     416             :             return GetBackground(
     417             :                 maFocusedSelectionBackground,
     418             :                 Theme::Gradient_SelectedAndFocusedPage,
     419             :                 rReferenceDevice,
     420           0 :                 true);
     421             : 
     422             :         case Selected:
     423             :             return GetBackground(
     424             :                 maSelectionBackground,
     425             :                 Theme::Gradient_SelectedPage,
     426             :                 rReferenceDevice,
     427           0 :                 false);
     428             : 
     429             :         case Focused:
     430             :             return GetBackground(
     431             :                 maFocusedBackground,
     432             :                 Theme::Gradient_FocusedPage,
     433             :                 rReferenceDevice,
     434           0 :                 true);
     435             : 
     436             :         case None:
     437             :         default:
     438             :             return GetBackground(
     439             :                 maNormalBackground,
     440             :                 Theme::Gradient_NormalPage,
     441             :                 rReferenceDevice,
     442           0 :                 false);
     443             :     }
     444             : }
     445             : 
     446             : 
     447             : 
     448             : 
     449           0 : Bitmap& PageObjectPainter::GetBackground(
     450             :     Bitmap& rBackground,
     451             :     Theme::GradientColorType eType,
     452             :     const OutputDevice& rReferenceDevice,
     453             :     const bool bHasFocusBorder)
     454             : {
     455           0 :     if (rBackground.IsEmpty())
     456           0 :         rBackground = CreateBackgroundBitmap(rReferenceDevice, eType, bHasFocusBorder);
     457           0 :     return rBackground;
     458             : }
     459             : 
     460             : 
     461             : 
     462             : 
     463           0 : Bitmap PageObjectPainter::CreateBackgroundBitmap(
     464             :     const OutputDevice& rReferenceDevice,
     465             :     const Theme::GradientColorType eColorType,
     466             :     const bool bHasFocusBorder) const
     467             : {
     468             :     const Size aSize (mpPageObjectLayouter->GetSize(
     469             :         PageObjectLayouter::FocusIndicator,
     470           0 :         PageObjectLayouter::WindowCoordinateSystem));
     471             :     const Rectangle aPageObjectBox (mpPageObjectLayouter->GetBoundingBox(
     472             :         Point(0,0),
     473             :         PageObjectLayouter::PageObject,
     474           0 :         PageObjectLayouter::ModelCoordinateSystem));
     475           0 :     VirtualDevice aBitmapDevice (rReferenceDevice);
     476           0 :     aBitmapDevice.SetOutputSizePixel(aSize);
     477             : 
     478             :     // Fill the background with the background color of the slide sorter.
     479           0 :     const Color aBackgroundColor (mpTheme->GetColor(Theme::Color_Background));
     480           0 :     aBitmapDevice.SetFillColor(aBackgroundColor);
     481           0 :     aBitmapDevice.SetLineColor(aBackgroundColor);
     482           0 :     aBitmapDevice.DrawRect(Rectangle(Point(0,0), aSize));
     483             : 
     484             :     // Paint the slide area with a linear gradient that starts some pixels
     485             :     // below the top and ends some pixels above the bottom.
     486           0 :     const Color aTopColor(mpTheme->GetGradientColor(eColorType, Theme::Fill1));
     487           0 :     const Color aBottomColor(mpTheme->GetGradientColor(eColorType, Theme::Fill2));
     488           0 :     if (aTopColor != aBottomColor)
     489             :     {
     490           0 :         const sal_Int32 nHeight (aPageObjectBox.GetHeight());
     491           0 :         const sal_Int32 nDefaultConstantSize(nHeight/4);
     492           0 :         const sal_Int32 nMinimalGradientSize(40);
     493             :         const sal_Int32 nY1 (
     494             :             ::std::max<sal_Int32>(
     495             :                 0,
     496             :                 ::std::min<sal_Int32>(
     497             :                     nDefaultConstantSize,
     498           0 :                     (nHeight - nMinimalGradientSize)/2)));
     499           0 :         const sal_Int32 nY2 (nHeight-nY1);
     500           0 :         const sal_Int32 nTop (aPageObjectBox.Top());
     501           0 :         for (sal_Int32 nY=0; nY<nHeight; ++nY)
     502             :         {
     503           0 :             if (nY<=nY1)
     504           0 :                 aBitmapDevice.SetLineColor(aTopColor);
     505           0 :             else if (nY>=nY2)
     506           0 :                 aBitmapDevice.SetLineColor(aBottomColor);
     507             :             else
     508             :             {
     509           0 :                 Color aColor (aTopColor);
     510           0 :                 aColor.Merge(aBottomColor, 255 * (nY2-nY) / (nY2-nY1));
     511           0 :                 aBitmapDevice.SetLineColor(aColor);
     512             :             }
     513             :             aBitmapDevice.DrawLine(
     514             :                 Point(aPageObjectBox.Left(), nY+nTop),
     515           0 :                 Point(aPageObjectBox.Right(), nY+nTop));
     516             :         }
     517             :     }
     518             :     else
     519             :     {
     520           0 :         aBitmapDevice.SetFillColor(aTopColor);
     521           0 :         aBitmapDevice.DrawRect(aPageObjectBox);
     522             :     }
     523             : 
     524             :     // Paint the simple border and, for some backgrounds, the focus border.
     525           0 :     if (bHasFocusBorder)
     526           0 :         mpFocusBorderPainter->PaintFrame(aBitmapDevice, aPageObjectBox);
     527             :     else
     528           0 :         PaintBorder(aBitmapDevice, eColorType, aPageObjectBox);
     529             : 
     530             :     // Get bounding box of the preview around which a shadow is painted.
     531             :     // Compensate for the border around the preview.
     532             :     const Rectangle aBox (mpPageObjectLayouter->GetBoundingBox(
     533             :         Point(0,0),
     534             :         PageObjectLayouter::Preview,
     535           0 :         PageObjectLayouter::ModelCoordinateSystem));
     536           0 :     Rectangle aFrameBox (aBox.Left()-1,aBox.Top()-1,aBox.Right()+1,aBox.Bottom()+1);
     537           0 :     mpShadowPainter->PaintFrame(aBitmapDevice, aFrameBox);
     538             : 
     539           0 :     return aBitmapDevice.GetBitmap (Point(0,0),aSize);
     540             : }
     541             : 
     542             : 
     543             : 
     544             : 
     545           0 : void PageObjectPainter::PaintBorder (
     546             :     OutputDevice& rDevice,
     547             :     const Theme::GradientColorType eColorType,
     548             :     const Rectangle& rBox) const
     549             : {
     550           0 :     rDevice.SetFillColor();
     551           0 :     const sal_Int32 nBorderWidth (1);
     552           0 :     for (int nIndex=0; nIndex<nBorderWidth; ++nIndex)
     553             :     {
     554           0 :         const int nDelta (nIndex);
     555           0 :         rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border2));
     556             :         rDevice.DrawLine(
     557           0 :             Point(rBox.Left()-nDelta, rBox.Top()-nDelta),
     558           0 :             Point(rBox.Left()-nDelta, rBox.Bottom()+nDelta));
     559             :         rDevice.DrawLine(
     560           0 :             Point(rBox.Left()-nDelta, rBox.Bottom()+nDelta),
     561           0 :             Point(rBox.Right()+nDelta, rBox.Bottom()+nDelta));
     562             :         rDevice.DrawLine(
     563           0 :             Point(rBox.Right()+nDelta, rBox.Bottom()+nDelta),
     564           0 :             Point(rBox.Right()+nDelta, rBox.Top()-nDelta));
     565             : 
     566           0 :         rDevice.SetLineColor(mpTheme->GetGradientColor(eColorType, Theme::Border1));
     567             :         rDevice.DrawLine(
     568           0 :             Point(rBox.Left()-nDelta, rBox.Top()-nDelta),
     569           0 :             Point(rBox.Right()+nDelta, rBox.Top()-nDelta));
     570             :     }
     571           0 : }
     572             : 
     573             : 
     574             : 
     575             : } } } // end of namespace sd::slidesorter::view
     576             : 
     577             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10