LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/view - SlideSorterView.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 295 376 78.5 %
Date: 2012-08-25 Functions: 48 64 75.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 331 730 45.3 %

           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/SlideSorterView.hxx"
      31                 :            : 
      32                 :            : #include "ViewShellBase.hxx"
      33                 :            : #include "SlideSorter.hxx"
      34                 :            : #include "SlideSorterViewShell.hxx"
      35                 :            : #include "ViewShell.hxx"
      36                 :            : #include "SlsViewCacheContext.hxx"
      37                 :            : #include "SlsLayeredDevice.hxx"
      38                 :            : #include "view/SlsLayouter.hxx"
      39                 :            : #include "view/SlsPageObjectLayouter.hxx"
      40                 :            : #include "view/SlsPageObjectPainter.hxx"
      41                 :            : #include "view/SlsILayerPainter.hxx"
      42                 :            : #include "view/SlsButtonBar.hxx"
      43                 :            : #include "view/SlsToolTip.hxx"
      44                 :            : #include "controller/SlideSorterController.hxx"
      45                 :            : #include "controller/SlsProperties.hxx"
      46                 :            : #include "model/SlideSorterModel.hxx"
      47                 :            : #include "model/SlsPageEnumerationProvider.hxx"
      48                 :            : #include "model/SlsPageDescriptor.hxx"
      49                 :            : #include "cache/SlsPageCache.hxx"
      50                 :            : #include "cache/SlsPageCacheManager.hxx"
      51                 :            : #include "cache/SlsCacheContext.hxx"
      52                 :            : #include "taskpane/SlideSorterCacheDisplay.hxx"
      53                 :            : #include "DrawDocShell.hxx"
      54                 :            : #include "PaneDockingWindow.hxx"
      55                 :            : 
      56                 :            : #include "drawdoc.hxx"
      57                 :            : #include "sdpage.hxx"
      58                 :            : #include "Window.hxx"
      59                 :            : #include "sdresid.hxx"
      60                 :            : #include "glob.hrc"
      61                 :            : 
      62                 :            : #include <svl/itempool.hxx>
      63                 :            : #include <svx/svdpagv.hxx>
      64                 :            : #include <svx/svdopage.hxx>
      65                 :            : #include <svx/xlndsit.hxx>
      66                 :            : #include <svx/xlnclit.hxx>
      67                 :            : #include <vcl/svapp.hxx>
      68                 :            : #include <vcl/scrbar.hxx>
      69                 :            : #include <tools/poly.hxx>
      70                 :            : #include <vcl/lineinfo.hxx>
      71                 :            : #include <algorithm>
      72                 :            : #include <svx/sdrpagewindow.hxx>
      73                 :            : #include <basegfx/matrix/b2dhommatrix.hxx>
      74                 :            : #include <basegfx/polygon/b2dpolygontools.hxx>
      75                 :            : #include <basegfx/polygon/b2dpolygon.hxx>
      76                 :            : #include <drawinglayer/geometry/viewinformation2d.hxx>
      77                 :            : #include <canvas/elapsedtime.hxx>
      78                 :            : 
      79                 :            : //#define DEBUG_TIMING
      80                 :            : #ifdef DEBUG_TIMING
      81                 :            : #include <vector>
      82                 :            : #endif
      83                 :            : #include <boost/foreach.hpp>
      84                 :            : 
      85                 :            : 
      86                 :            : using namespace std;
      87                 :            : using namespace ::sd::slidesorter::model;
      88                 :            : using namespace ::drawinglayer::primitive2d;
      89                 :            : 
      90                 :            : 
      91                 :            : namespace sd { namespace slidesorter { namespace view {
      92                 :            : 
      93                 :            : namespace {
      94                 :            :     /** Wrapper around the SlideSorterView that supports the IPainter
      95                 :            :         interface and that allows the LayeredDevice to hold the
      96                 :            :         SlideSorterView (held as scoped_ptr by the SlideSorter) as
      97                 :            :         shared_ptr.
      98                 :            :     */
      99                 :            :     class Painter : public ILayerPainter
     100                 :            :     {
     101                 :            :     public:
     102                 :        130 :         Painter (SlideSorterView& rView) : mrView(rView) {}
     103         [ -  + ]:        260 :         virtual ~Painter (void) {}
     104                 :            : 
     105                 :        636 :         virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea)
     106                 :            :         {
     107                 :        636 :             mrView.Paint(rDevice,rRepaintArea);
     108                 :        636 :         }
     109                 :            : 
     110                 :        130 :         virtual void SetLayerInvalidator (const SharedILayerInvalidator&) {}
     111                 :            : 
     112                 :            :     private:
     113                 :            :         SlideSorterView& mrView;
     114                 :            :     };
     115                 :            : }
     116                 :            : 
     117                 :            : 
     118                 :            : 
     119                 :            : class BackgroundPainter
     120                 :            :     : public ILayerPainter,
     121                 :            :       public ::boost::noncopyable
     122                 :            : {
     123                 :            : public:
     124                 :        130 :     BackgroundPainter (const Color aBackgroundColor) : maBackgroundColor(aBackgroundColor) {}
     125         [ -  + ]:        260 :     virtual ~BackgroundPainter (void) {}
     126                 :            : 
     127                 :        636 :     virtual void Paint (OutputDevice& rDevice, const Rectangle& rRepaintArea)
     128                 :            :     {
     129                 :        636 :         rDevice.SetFillColor(maBackgroundColor);
     130                 :        636 :         rDevice.SetLineColor();
     131                 :        636 :         rDevice.DrawRect(rRepaintArea);
     132                 :        636 :     }
     133                 :            : 
     134                 :        130 :     virtual void SetLayerInvalidator (const SharedILayerInvalidator&) {}
     135                 :            : 
     136                 :          0 :     void SetColor (const Color aColor) { maBackgroundColor = aColor; }
     137                 :            : 
     138                 :            : private:
     139                 :            :     Color maBackgroundColor;
     140                 :            : };
     141                 :            : 
     142                 :            : 
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 : TYPEINIT1(SlideSorterView, ::sd::View);
     145                 :            : 
     146                 :        130 : SlideSorterView::SlideSorterView (SlideSorter& rSlideSorter)
     147                 :            :     : ::sd::View (
     148 [ +  - ][ +  - ]:        130 :           *rSlideSorter.GetModel().GetDocument(),
     149                 :        260 :           rSlideSorter.GetContentWindow().get(),
     150                 :            :           rSlideSorter.GetViewShell()),
     151                 :            :       mrSlideSorter(rSlideSorter),
     152         [ +  - ]:        130 :       mrModel(rSlideSorter.GetModel()),
     153                 :            :       mbIsDisposed(false),
     154         [ +  - ]:        130 :       mpLayouter (new Layouter(rSlideSorter.GetContentWindow(), rSlideSorter.GetTheme())),
     155                 :            :       mbPageObjectVisibilitiesValid (false),
     156                 :            :       mpPreviewCache(),
     157         [ +  - ]:        130 :       mpLayeredDevice(new LayeredDevice(rSlideSorter.GetContentWindow())),
     158                 :            :       maVisiblePageRange(-1,-1),
     159                 :            :       mbModelChangedWhileModifyEnabled(true),
     160                 :            :       maPreviewSize(0,0),
     161                 :            :       mbPreciousFlagUpdatePending(true),
     162                 :            :       meOrientation(Layouter::GRID),
     163                 :            :       mpProperties(rSlideSorter.GetProperties()),
     164                 :            :       mpPageUnderMouse(),
     165                 :            :       mnButtonUnderMouse(-1),
     166                 :            :       mpPageObjectPainter(),
     167                 :            :       mpSelectionPainter(),
     168                 :            :       mpBackgroundPainter(
     169                 :        130 :           new BackgroundPainter(mrSlideSorter.GetTheme()->GetColor(Theme::Color_Background))),
     170         [ +  - ]:        130 :       mpButtonBar(new ButtonBar(mrSlideSorter)),
     171         [ +  - ]:        130 :       mpToolTip(new ToolTip(mrSlideSorter)),
     172                 :            :       mbIsRearrangePending(true),
     173 [ +  - ][ +  - ]:       1170 :       maVisibilityChangeListeners()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
           [ +  -  +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     174                 :            : {
     175                 :            :     // Hide the page that contains the page objects.
     176         [ +  - ]:        130 :     SetPageVisible (sal_False);
     177                 :            : 
     178                 :            : 
     179                 :            :     // Register the background painter on level 1 to avoid the creation of a
     180                 :            :     // background buffer.
     181         [ +  - ]:        130 :     mpLayeredDevice->RegisterPainter(mpBackgroundPainter, 1);
     182                 :            : 
     183                 :            :     // Wrap a shared_ptr-held-wrapper around this view and register it as
     184                 :            :     // painter at the layered device.  There is no explicit destruction: in
     185                 :            :     // the SlideSorterView destructor the layered device is destroyed and
     186                 :            :     // with it the only reference to the wrapper which therefore is also
     187                 :            :     // destroyed.
     188 [ +  - ][ +  - ]:        130 :     SharedILayerPainter pPainter (new Painter(*this));
     189                 :            : 
     190                 :            :     // The painter is placed on level 1 to avoid buffering.  This should be
     191                 :            :     // a little faster during animations because the previews are painted
     192                 :            :     // directly into the window, not via the buffer.
     193 [ +  - ][ +  - ]:        130 :     mpLayeredDevice->RegisterPainter(pPainter, 1);
     194                 :        130 : }
     195                 :            : 
     196                 :            : 
     197                 :            : 
     198                 :            : 
     199 [ +  - ][ +  - ]:        130 : SlideSorterView::~SlideSorterView (void)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     200                 :            : {
     201         [ -  + ]:        130 :     if ( ! mbIsDisposed)
     202                 :            :     {
     203                 :            :         OSL_ASSERT(mbIsDisposed);
     204         [ #  # ]:          0 :         Dispose();
     205                 :            :     }
     206         [ -  + ]:        260 : }
     207                 :            : 
     208                 :            : 
     209                 :            : 
     210                 :            : 
     211                 :        130 : void SlideSorterView::Init (void)
     212                 :            : {
     213                 :        130 :     HandleModelChange();
     214                 :        130 : }
     215                 :            : 
     216                 :            : 
     217                 :            : 
     218                 :            : 
     219                 :        130 : void SlideSorterView::Dispose (void)
     220                 :            : {
     221                 :        130 :     mpSelectionPainter.reset();
     222                 :            : 
     223                 :        130 :     mpLayeredDevice->Dispose();
     224                 :        130 :     mpPreviewCache.reset();
     225                 :            : 
     226         [ +  - ]:        130 :     SetPageUnderMouse(SharedPageDescriptor(),false);
     227                 :            : 
     228                 :            :     // Hide the page to avoid problems in the view when deleting
     229                 :            :     // visualized objects
     230                 :        130 :     HideSdrPage();
     231                 :            : 
     232                 :            :     // Deletion of the objects and the page will be done in SdrModel
     233                 :            :     // destructor (as long as objects and pages are added)
     234                 :            : 
     235                 :            :     OSL_ASSERT(mpLayeredDevice.unique());
     236                 :        130 :     mpLayeredDevice.reset();
     237                 :            : 
     238                 :        130 :     mbIsDisposed = true;
     239                 :        130 : }
     240                 :            : 
     241                 :            : 
     242                 :            : 
     243                 :            : 
     244                 :        126 : sal_Int32 SlideSorterView::GetPageIndexAtPoint (const Point& rWindowPosition) const
     245                 :            : {
     246                 :        126 :     sal_Int32 nIndex (-1);
     247                 :            : 
     248         [ +  - ]:        126 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     249         [ +  - ]:        126 :     if (pWindow)
     250                 :            :     {
     251 [ +  - ][ +  - ]:        126 :         nIndex = mpLayouter->GetIndexAtPoint(pWindow->PixelToLogic(rWindowPosition), false, false);
     252                 :            : 
     253                 :            :         // Clip the page index against the page count.
     254 [ +  - ][ -  + ]:        126 :         if (nIndex >= mrModel.GetPageCount())
     255                 :          0 :             nIndex = -1;
     256                 :            :     }
     257                 :            : 
     258         [ +  - ]:        126 :     return nIndex;
     259                 :            : }
     260                 :            : 
     261                 :            : 
     262                 :            : 
     263                 :            : 
     264                 :       1775 : Layouter& SlideSorterView::GetLayouter (void)
     265                 :            : {
     266                 :       1775 :     return *mpLayouter.get();
     267                 :            : }
     268                 :            : 
     269                 :            : 
     270                 :            : 
     271                 :            : 
     272                 :        195 : void SlideSorterView::ModelHasChanged (void)
     273                 :            : {
     274                 :            :     // Ignore this call.  Rely on hints sent by the model to get informed of
     275                 :            :     // model changes.
     276                 :        195 : }
     277                 :            : 
     278                 :            : 
     279                 :            : 
     280                 :            : 
     281                 :        292 : void SlideSorterView::PreModelChange (void)
     282                 :            : {
     283                 :            :     // Reset the slide under the mouse.  It will be re-set in PostModelChange().
     284         [ +  - ]:        292 :     SetPageUnderMouse(SharedPageDescriptor());
     285                 :        292 : }
     286                 :            : 
     287                 :            : 
     288                 :            : 
     289                 :            : 
     290                 :        292 : void SlideSorterView::PostModelChange (void)
     291                 :            : {
     292                 :            :     // In PreModelChange() the page objects have been released.  Here we
     293                 :            :     // create new ones.
     294 [ +  - ][ +  - ]:        292 :     ::osl::MutexGuard aGuard (mrModel.GetMutex());
     295                 :            : 
     296                 :            :     model::PageEnumeration aPageEnumeration (
     297         [ +  - ]:        292 :         model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
     298                 :            : 
     299                 :            :     // The new page objects have to be scaled and positioned.
     300         [ +  - ]:        292 :     RequestRearrange();
     301 [ +  - ][ +  - ]:        292 :     RequestRepaint();
                 [ +  - ]
     302                 :        292 : }
     303                 :            : 
     304                 :            : 
     305                 :            : 
     306                 :            : 
     307                 :            : /** At the moment for every model change all page objects are destroyed and
     308                 :            :     re-created again.  This can be optimized by accepting hints that
     309                 :            :     describe the type of change so that existing page objects can be
     310                 :            :     reused.
     311                 :            : */
     312                 :        130 : void SlideSorterView::HandleModelChange (void)
     313                 :            : {
     314                 :        130 :     PreModelChange ();
     315                 :        130 :     PostModelChange();
     316                 :        130 : }
     317                 :            : 
     318                 :            : 
     319                 :            : 
     320                 :            : 
     321                 :          0 : void SlideSorterView::HandleDrawModeChange (void)
     322                 :            : {
     323                 :            :     // Replace the preview cache with a new and empty one.  The
     324                 :            :     // PreviewRenderer that is used by the cache is replaced by this as
     325                 :            :     // well.
     326                 :          0 :     mpPreviewCache.reset();
     327         [ #  # ]:          0 :     GetPreviewCache()->InvalidateCache(true);
     328                 :            : 
     329                 :          0 :     RequestRepaint();
     330                 :          0 : }
     331                 :            : 
     332                 :            : 
     333                 :            : 
     334                 :            : 
     335                 :          0 : void SlideSorterView::HandleDataChangeEvent (void)
     336                 :            : {
     337 [ #  # ][ #  # ]:          0 :     GetPageObjectPainter()->SetTheme(mrSlideSorter.GetTheme());
         [ #  # ][ #  # ]
                 [ #  # ]
     338                 :            : 
     339                 :            :     // Update the color used by the background painter.
     340                 :            :     ::boost::shared_ptr<BackgroundPainter> pPainter (
     341         [ #  # ]:          0 :         ::boost::dynamic_pointer_cast<BackgroundPainter>(mpBackgroundPainter));
     342         [ #  # ]:          0 :     if (pPainter)
     343 [ #  # ][ #  # ]:          0 :         pPainter->SetColor(mrSlideSorter.GetTheme()->GetColor(Theme::Color_Background));
                 [ #  # ]
     344                 :            : 
     345         [ #  # ]:          0 :     if (mpButtonBar)
     346         [ #  # ]:          0 :         mpButtonBar->HandleDataChangeEvent();
     347                 :            : 
     348 [ #  # ][ #  # ]:          0 :     RequestRepaint();
     349                 :          0 : }
     350                 :            : 
     351                 :            : 
     352                 :            : 
     353                 :            : 
     354                 :        279 : void SlideSorterView::Resize (void)
     355                 :            : {
     356                 :        279 :     UpdateOrientation();
     357                 :            : 
     358                 :        279 :     mpLayeredDevice->Resize();
     359                 :        279 :     RequestRearrange();
     360                 :        279 : }
     361                 :            : 
     362                 :            : 
     363                 :            : 
     364                 :            : 
     365                 :        571 : void SlideSorterView::RequestRearrange (void)
     366                 :            : {
     367                 :        571 :     mbIsRearrangePending = true;
     368                 :        571 :     Rearrange();
     369                 :        571 : }
     370                 :            : 
     371                 :            : 
     372                 :            : 
     373                 :            : 
     374                 :        571 : void SlideSorterView::Rearrange (void)
     375                 :            : {
     376         [ +  - ]:        571 :     if ( ! mbIsRearrangePending)
     377                 :            :         return;
     378 [ +  - ][ +  + ]:        571 :     if (mrModel.GetPageCount() <= 0)
     379                 :            :         return;
     380                 :            : 
     381         [ +  - ]:        441 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     382         [ -  + ]:        441 :     if ( ! pWindow)
     383                 :            :         return;
     384         [ +  - ]:        441 :     const Size aWindowSize (pWindow->GetSizePixel());
     385 [ +  + ][ -  + ]:        441 :     if (aWindowSize.Width()<=0 || aWindowSize.Height()<=0)
                 [ +  + ]
     386                 :            :         return;
     387                 :            : 
     388                 :            :     const bool bRearrangeSuccess (
     389                 :            :         mpLayouter->Rearrange (
     390                 :            :             meOrientation,
     391                 :            :             aWindowSize,
     392 [ +  - ][ +  - ]:        618 :             mrModel.GetPageDescriptor(0)->GetPage()->GetSize(),
                 [ +  - ]
     393 [ +  - ][ +  - ]:        618 :             mrModel.GetPageCount()));
                 [ +  - ]
     394         [ +  - ]:        309 :     if (bRearrangeSuccess)
     395                 :            :     {
     396                 :        309 :         mbIsRearrangePending = false;
     397         [ +  - ]:        309 :         Layout();
     398         [ +  - ]:        309 :         UpdatePageUnderMouse(false);
     399                 :            :         //        RequestRepaint();
     400 [ +  - ][ +  + ]:        571 :     }
     401                 :            : }
     402                 :            : 
     403                 :            : 
     404                 :            : 
     405                 :            : 
     406                 :        551 : void SlideSorterView::UpdateOrientation (void)
     407                 :            : {
     408                 :            :     // The layout of slides depends on whether the slide sorter is
     409                 :            :     // displayed in the center or the side pane.
     410         [ -  + ]:        551 :     if (mrSlideSorter.GetViewShell()->IsMainViewShell())
     411                 :          0 :         SetOrientation(Layouter::GRID);
     412                 :            :     else
     413                 :            :     {
     414                 :            :         // Get access to the docking window.
     415                 :        551 :         ::Window* pWindow = mrSlideSorter.GetContentWindow().get();
     416                 :        551 :         PaneDockingWindow* pDockingWindow = NULL;
     417 [ +  + ][ +  + ]:       2204 :         while (pWindow!=NULL && pDockingWindow==NULL)
                 [ +  + ]
     418                 :            :         {
     419         [ -  + ]:       1653 :             pDockingWindow = dynamic_cast<PaneDockingWindow*>(pWindow);
     420                 :       1653 :             pWindow = pWindow->GetParent();
     421                 :            :         }
     422                 :            : 
     423         [ +  + ]:        551 :         if (pDockingWindow != NULL)
     424                 :            :         {
     425                 :            :             const long nScrollBarSize (
     426                 :        299 :                 Application::GetSettings().GetStyleSettings().GetScrollBarSize());
     427   [ -  +  -  - ]:        299 :             switch (pDockingWindow->GetOrientation())
     428                 :            :             {
     429                 :            :                 case PaneDockingWindow::HorizontalOrientation:
     430         [ #  # ]:          0 :                     if (SetOrientation(Layouter::HORIZONTAL))
     431                 :            :                     {
     432         [ #  # ]:          0 :                         const Range aRange (mpLayouter->GetValidVerticalSizeRange());
     433                 :            :                         pDockingWindow->SetValidSizeRange(Range(
     434                 :          0 :                             aRange.Min() + nScrollBarSize,
     435         [ #  # ]:          0 :                             aRange.Max() + nScrollBarSize));
     436                 :            :                     }
     437                 :          0 :                     break;
     438                 :            : 
     439                 :            :                 case PaneDockingWindow::VerticalOrientation:
     440         [ +  + ]:        299 :                     if (SetOrientation(Layouter::VERTICAL))
     441                 :            :                     {
     442         [ +  - ]:        126 :                         const Range aRange (mpLayouter->GetValidHorizontalSizeRange());
     443                 :            :                         pDockingWindow->SetValidSizeRange(Range(
     444                 :        126 :                             aRange.Min() + nScrollBarSize,
     445         [ +  - ]:        252 :                             aRange.Max() + nScrollBarSize));
     446                 :            :                     }
     447                 :        299 :                     break;
     448                 :            : 
     449                 :            :                 case PaneDockingWindow::UnknownOrientation:
     450         [ #  # ]:          0 :                     if (SetOrientation(Layouter::GRID))
     451                 :            :                     {
     452                 :          0 :                         const sal_Int32 nAdditionalSize (10);
     453                 :            :                         pDockingWindow->SetMinOutputSizePixel(Size(
     454         [ #  # ]:          0 :                             mpLayouter->GetValidHorizontalSizeRange().Min()
     455                 :            :                                 + nScrollBarSize
     456                 :            :                                 + nAdditionalSize,
     457                 :          0 :                             mpLayouter->GetValidVerticalSizeRange().Min()
     458                 :            :                                 + nScrollBarSize
     459         [ #  # ]:          0 :                                 + nAdditionalSize));
     460                 :            :                     }
     461                 :        551 :                     return;
     462                 :            :             }
     463                 :            :         }
     464                 :            :         else
     465                 :            :         {
     466                 :            :             // We are not placed in a docking window.  One possible reason
     467                 :            :             // is that the slide sorter is temporarily into a cache and was
     468                 :            :             // reparented to a non-docking window.
     469                 :        252 :             SetOrientation(Layouter::GRID);
     470                 :            :         }
     471                 :            :     }
     472                 :            : }
     473                 :            : 
     474                 :            : 
     475                 :            : 
     476                 :            : 
     477                 :        439 : void SlideSorterView::Layout ()
     478                 :            : {
     479         [ +  - ]:        439 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     480         [ +  - ]:        439 :     if (pWindow)
     481                 :            :     {
     482                 :            :         // Set the model area, i.e. the smallest rectangle that includes all
     483                 :            :         // page objects.
     484         [ +  - ]:        439 :         const Rectangle aViewBox (mpLayouter->GetTotalBoundingBox());
     485         [ +  - ]:        439 :         pWindow->SetViewOrigin (aViewBox.TopLeft());
     486 [ +  - ][ +  - ]:        439 :         pWindow->SetViewSize (aViewBox.GetSize());
     487                 :            : 
     488                 :            :         ::boost::shared_ptr<PageObjectLayouter> pPageObjectLayouter(
     489         [ +  - ]:        439 :             mpLayouter->GetPageObjectLayouter());
     490         [ +  + ]:        439 :         if (pPageObjectLayouter)
     491                 :            :         {
     492                 :            :             const Size aNewPreviewSize (mpLayouter->GetPageObjectLayouter()->GetSize(
     493                 :            :                 PageObjectLayouter::Preview,
     494 [ +  - ][ +  - ]:        309 :                 PageObjectLayouter::WindowCoordinateSystem));
                 [ +  - ]
     495 [ +  + ][ +  - ]:        309 :             if (maPreviewSize != aNewPreviewSize && GetPreviewCache())
         [ +  - ][ +  + ]
                 [ +  - ]
           [ +  +  #  # ]
     496                 :            :             {
     497         [ +  - ]:        133 :                 mpPreviewCache->ChangeSize(aNewPreviewSize, true);
     498                 :        309 :                 maPreviewSize = aNewPreviewSize;
     499                 :            :             }
     500                 :            :         }
     501                 :            : 
     502                 :            :         // Iterate over all page objects and place them relative to the
     503                 :            :         // containing page.
     504                 :            :         model::PageEnumeration aPageEnumeration (
     505         [ +  - ]:        439 :             model::PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
     506 [ +  - ][ +  + ]:        935 :         while (aPageEnumeration.HasMoreElements())
     507                 :            :         {
     508         [ +  - ]:        496 :             model::SharedPageDescriptor pDescriptor (aPageEnumeration.GetNextElement());
     509 [ +  - ][ +  - ]:        496 :             pDescriptor->SetBoundingBox(mpLayouter->GetPageObjectBox(pDescriptor->GetPageIndex()));
                 [ +  - ]
     510         [ +  - ]:        496 :         }
     511                 :            : 
     512 [ +  - ][ +  - ]:        439 :         GetPageObjectPainter()->NotifyResize();
         [ +  - ][ +  - ]
                 [ +  - ]
     513                 :            :     }
     514                 :            : 
     515         [ +  - ]:        439 :     InvalidatePageObjectVisibilities ();
     516                 :        439 : }
     517                 :            : 
     518                 :            : 
     519                 :            : 
     520                 :            : 
     521                 :        439 : void SlideSorterView::InvalidatePageObjectVisibilities (void)
     522                 :            : {
     523                 :        439 :     mbPageObjectVisibilitiesValid = false;
     524                 :        439 : }
     525                 :            : 
     526                 :            : 
     527                 :            : 
     528                 :            : 
     529                 :        168 : void SlideSorterView::DeterminePageObjectVisibilities (void)
     530                 :            : {
     531         [ +  - ]:        168 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     532         [ +  - ]:        168 :     if (pWindow)
     533                 :            :     {
     534                 :            :         // Set this flag to true here so that an invalidate during the
     535                 :            :         // visibility calculation can correctly invalidate it again.
     536                 :        168 :         mbPageObjectVisibilitiesValid = true;
     537                 :            : 
     538 [ +  - ][ +  - ]:        168 :         Rectangle aViewArea (pWindow->PixelToLogic(Rectangle(Point(0,0),pWindow->GetSizePixel())));
                 [ +  - ]
     539         [ +  - ]:        168 :         const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(aViewArea));
     540                 :            :         const Range aUnion(
     541         [ +  - ]:        168 :             ::std::min(maVisiblePageRange.Min(), aRange.Min()),
     542         [ +  - ]:        336 :             ::std::max(maVisiblePageRange.Max(), aRange.Max()));
     543                 :            : 
     544                 :            :         // For page objects that just dropped off the visible area we
     545                 :            :         // decrease the priority of pending requests for preview bitmaps.
     546         [ +  + ]:        168 :         if (maVisiblePageRange != aRange)
     547                 :        141 :             mbPreciousFlagUpdatePending |= true;
     548                 :            : 
     549         [ +  - ]:        168 :         model::SharedPageDescriptor pDescriptor;
     550         [ +  + ]:        491 :         for (int nIndex=aUnion.Min(); nIndex<=aUnion.Max(); nIndex++)
     551                 :            :         {
     552 [ +  - ][ +  - ]:        323 :             pDescriptor = mrModel.GetPageDescriptor(nIndex);
                 [ +  - ]
     553         [ +  + ]:        323 :             if (pDescriptor.get() != NULL)
     554                 :            :                 SetState(
     555                 :            :                     pDescriptor,
     556                 :            :                     PageDescriptor::ST_Visible,
     557         [ +  - ]:        197 :                     aRange.IsInside(nIndex));
     558                 :            :         }
     559                 :            : 
     560                 :            :         // Broadcast a change of the set of visible page objects.
     561         [ +  + ]:        168 :         if (maVisiblePageRange != aRange)
     562                 :            :         {
     563                 :        141 :             maVisiblePageRange = aRange;
     564                 :            : 
     565                 :            :             // Tell the listeners that the visibility of some objects has
     566                 :            :             // changed.
     567                 :        141 :             ::std::vector<Link>& aChangeListeners (maVisibilityChangeListeners);
     568 [ #  # ][ +  - ]:        141 :             for (::std::vector<Link>::const_iterator
                 [ -  + ]
     569         [ +  - ]:        141 :                      iLink(aChangeListeners.begin()),
     570         [ +  - ]:        141 :                      iEnd(aChangeListeners.end());
     571                 :            :                  iLink!=iEnd;
     572                 :            :                  ++iLink)
     573                 :            :             {
     574 [ #  # ][ #  # ]:          0 :                 iLink->Call(NULL);
     575                 :            :             }
     576                 :            :         }
     577                 :            : 
     578                 :            : 
     579                 :            :         // Restore the mouse over state.
     580 [ +  - ][ +  - ]:        168 :         UpdatePageUnderMouse(true);
     581         [ +  - ]:        168 :     }
     582                 :        168 : }
     583                 :            : 
     584                 :            : 
     585                 :            : 
     586                 :            : 
     587                 :        636 : void SlideSorterView::UpdatePreciousFlags (void)
     588                 :            : {
     589         [ +  - ]:        636 :     if (mbPreciousFlagUpdatePending)
     590                 :            :     {
     591                 :        636 :         mbPreciousFlagUpdatePending = false;
     592                 :            : 
     593         [ +  - ]:        636 :         model::SharedPageDescriptor pDescriptor;
     594         [ +  - ]:        636 :         ::boost::shared_ptr<cache::PageCache> pCache = GetPreviewCache();
     595         [ +  - ]:        636 :         sal_Int32 nPageCount (mrModel.GetPageCount());
     596                 :            : 
     597         [ +  - ]:       1372 :         for (int nIndex=0; nIndex<=nPageCount; ++nIndex)
     598                 :            :         {
     599 [ +  - ][ +  - ]:       1372 :             pDescriptor = mrModel.GetPageDescriptor(nIndex);
                 [ +  - ]
     600         [ +  + ]:       1372 :             if (pDescriptor.get() != NULL)
     601                 :            :             {
     602                 :            :                 pCache->SetPreciousFlag(
     603         [ +  - ]:        736 :                     pDescriptor->GetPage(),
     604         [ +  - ]:       1472 :                     maVisiblePageRange.IsInside(nIndex));
     605                 :            :                 SSCD_SET_VISIBILITY(mrModel.GetDocument(), nIndex,
     606                 :            :                     maVisiblePageRange.IsInside(nIndex));
     607                 :            :             }
     608                 :            :             else
     609                 :            :             {
     610                 :            :                 // At least one cache entry can not be updated.  Remember to
     611                 :            :                 // repeat the whole updating later and leave the loop now.
     612                 :        636 :                 mbPreciousFlagUpdatePending = true;
     613                 :        636 :                 break;
     614                 :            :             }
     615 [ +  - ][ +  - ]:        636 :         }
     616                 :            :     }
     617                 :        636 : }
     618                 :            : 
     619                 :            : 
     620                 :            : 
     621                 :            : 
     622                 :        551 : bool SlideSorterView::SetOrientation (const Layouter::Orientation eOrientation)
     623                 :            : {
     624         [ +  + ]:        551 :     if (meOrientation != eOrientation)
     625                 :            :     {
     626                 :        252 :         meOrientation = eOrientation;
     627                 :        252 :         return true;
     628                 :            :     }
     629                 :            :     else
     630                 :        551 :         return false;
     631                 :            : }
     632                 :            : 
     633                 :            : 
     634                 :            : 
     635                 :            : 
     636                 :       1214 : Layouter::Orientation SlideSorterView::GetOrientation (void) const
     637                 :            : {
     638                 :       1214 :     return meOrientation;
     639                 :            : }
     640                 :            : 
     641                 :            : 
     642                 :            : 
     643                 :            : 
     644                 :        800 : void SlideSorterView::RequestRepaint (void)
     645                 :            : {
     646         [ +  - ]:        800 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     647         [ +  - ]:        800 :     if (pWindow)
     648                 :            :     {
     649                 :            :         mpLayeredDevice->InvalidateAllLayers(
     650                 :            :             Rectangle(
     651                 :        800 :                 pWindow->PixelToLogic(Point(0,0)),
     652         [ +  - ]:       1600 :                 pWindow->PixelToLogic(pWindow->GetSizePixel())));
           [ +  -  +  - ]
         [ +  - ][ +  - ]
     653         [ +  - ]:        800 :         pWindow->Invalidate();
     654         [ +  - ]:        800 :     }
     655                 :        800 : }
     656                 :            : 
     657                 :            : 
     658                 :            : 
     659                 :            : 
     660                 :        984 : void SlideSorterView::RequestRepaint (const model::SharedPageDescriptor& rpDescriptor)
     661                 :            : {
     662         [ +  - ]:        984 :     if (rpDescriptor)
     663         [ +  - ]:        984 :         RequestRepaint(rpDescriptor->GetBoundingBox());
     664                 :        984 : }
     665                 :            : 
     666                 :            : 
     667                 :            : 
     668                 :            : 
     669                 :        984 : void SlideSorterView::RequestRepaint (const Rectangle& rRepaintBox)
     670                 :            : {
     671         [ +  - ]:        984 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     672         [ +  - ]:        984 :     if (pWindow)
     673                 :            :     {
     674         [ +  - ]:        984 :         mpLayeredDevice->InvalidateAllLayers(rRepaintBox);
     675         [ +  - ]:        984 :         pWindow->Invalidate(rRepaintBox);
     676         [ +  - ]:        984 :     }
     677                 :        984 : }
     678                 :            : 
     679                 :            : 
     680                 :            : 
     681                 :          0 : void SlideSorterView::RequestRepaint (const Region& rRepaintRegion)
     682                 :            : {
     683         [ #  # ]:          0 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     684         [ #  # ]:          0 :     if (pWindow)
     685                 :            :     {
     686         [ #  # ]:          0 :         mpLayeredDevice->InvalidateAllLayers(rRepaintRegion);
     687         [ #  # ]:          0 :         pWindow->Invalidate(rRepaintRegion);
     688         [ #  # ]:          0 :     }
     689                 :          0 : }
     690                 :            : 
     691                 :            : 
     692                 :            : 
     693                 :            : 
     694                 :       1164 : Rectangle SlideSorterView::GetModelArea (void)
     695                 :            : {
     696                 :       1164 :     return mpLayouter->GetTotalBoundingBox();
     697                 :            : }
     698                 :            : 
     699                 :            : 
     700                 :            : #ifdef DEBUG_TIMING
     701                 :            : static ::canvas::tools::ElapsedTime gaTimer;
     702                 :            : static const size_t gFrameTimeCount (10);
     703                 :            : static size_t gFrameTimeIndex (0);
     704                 :            : static ::std::vector<double> gFrameTimes (gFrameTimeCount, 0);
     705                 :            : static double gFrameTimeSum (0);
     706                 :            : static const Rectangle gFrameTimeBox (10,10,150,20);
     707                 :            : static double gnLastFrameStart = 0;
     708                 :            : #endif
     709                 :            : 
     710                 :        636 : void SlideSorterView::CompleteRedraw (
     711                 :            :     OutputDevice* pDevice,
     712                 :            :     const Region& rPaintArea,
     713                 :            :     sdr::contact::ViewObjectContactRedirector* pRedirector)
     714                 :            : {
     715                 :            :     (void)pRedirector;
     716                 :            : #ifdef DEBUG_TIMING
     717                 :            :     const double nStartTime (gaTimer.getElapsedTime());
     718                 :            :     OSL_TRACE("SlideSorterView::CompleteRedraw start at %f, %s",
     719                 :            :         nStartTime,
     720                 :            :         mnLockRedrawSmph ? "locked" : "");
     721                 :            : #endif
     722                 :            : 
     723 [ +  - ][ +  - ]:        636 :     if (pDevice == NULL || pDevice!=mrSlideSorter.GetContentWindow().get())
         [ -  + ][ +  - ]
           [ -  +  #  # ]
     724                 :        636 :         return;
     725                 :            : 
     726                 :            :     // The parent implementation of CompleteRedraw is called only when
     727                 :            :     // painting is locked.  We do all the painting ourself.  When painting
     728                 :            :     // is locked the parent implementation keeps track of the repaint
     729                 :            :     // requests and later, when painting is unlocked, calls CompleteRedraw
     730                 :            :     // for all missed repaints.
     731                 :            : 
     732         [ +  - ]:        636 :     if (mnLockRedrawSmph == 0)
     733                 :            :     {
     734         [ +  - ]:        636 :         mrSlideSorter.GetContentWindow()->IncrementLockCount();
     735         [ +  + ]:        636 :         if (mpLayeredDevice->HandleMapModeChange())
     736                 :        126 :             DeterminePageObjectVisibilities();
     737                 :        636 :         mpLayeredDevice->Repaint(rPaintArea);
     738         [ +  - ]:        636 :         mrSlideSorter.GetContentWindow()->DecrementLockCount();
     739                 :            :     }
     740                 :            :     else
     741                 :            :     {
     742                 :          0 :         maRedrawRegion.Union(rPaintArea);
     743                 :            :     }
     744                 :            : 
     745                 :            : #ifdef DEBUG_TIMING
     746                 :            :     const double nEndTime (gaTimer.getElapsedTime());
     747                 :            :     OSL_TRACE("SlideSorterView::CompleteRedraw end at %f after %fms", nEndTime, (nEndTime-nStartTime)*1000);
     748                 :            :     gFrameTimeSum -= gFrameTimes[gFrameTimeIndex];
     749                 :            :     gFrameTimes[gFrameTimeIndex] = nStartTime - gnLastFrameStart;
     750                 :            :     gnLastFrameStart = nStartTime;
     751                 :            :     gFrameTimeSum += gFrameTimes[gFrameTimeIndex];
     752                 :            :     gFrameTimeIndex = (gFrameTimeIndex+1) % gFrameTimeCount;
     753                 :            : 
     754                 :            : 
     755                 :            :     mrSlideSorter.GetContentWindow()->SetFillColor(COL_BLUE);
     756                 :            :     mrSlideSorter.GetContentWindow()->DrawRect(gFrameTimeBox);
     757                 :            :     mrSlideSorter.GetContentWindow()->SetTextColor(COL_WHITE);
     758                 :            :     mrSlideSorter.GetContentWindow()->DrawText(
     759                 :            :         gFrameTimeBox,
     760                 :            :         ::rtl::OUString::valueOf(1 / (gFrameTimeSum / gFrameTimeCount)),
     761                 :            :         TEXT_DRAW_RIGHT | TEXT_DRAW_VCENTER);
     762                 :            :     //    mrSlideSorter.GetContentWindow()->Invalidate(gFrameTimeBox);
     763                 :            : #endif
     764                 :            : }
     765                 :            : 
     766                 :            : 
     767                 :            : 
     768                 :            : 
     769                 :        636 : void SlideSorterView::Paint (
     770                 :            :     OutputDevice& rDevice,
     771                 :            :     const Rectangle& rRepaintArea)
     772                 :            : {
     773         [ -  + ]:        636 :     if ( ! mpPageObjectPainter)
     774 [ #  # ][ #  # ]:          0 :         if ( ! GetPageObjectPainter())
                 [ #  # ]
     775                 :        636 :             return;
     776                 :            : 
     777                 :            :     // Update the page visibilities when they have been invalidated.
     778         [ +  + ]:        636 :     if ( ! mbPageObjectVisibilitiesValid)
     779         [ +  - ]:         42 :         DeterminePageObjectVisibilities();
     780                 :            : 
     781         [ +  - ]:        636 :     if (mbPreciousFlagUpdatePending)
     782         [ +  - ]:        636 :         UpdatePreciousFlags();
     783                 :            : 
     784         [ -  + ]:        636 :     if (mbIsRearrangePending)
     785         [ #  # ]:          0 :         Rearrange();
     786                 :            : 
     787                 :            :     // Paint all page objects that are fully or partially inside the
     788                 :            :     // repaint region.
     789         [ +  - ]:        636 :     const Range aRange (mpLayouter->GetRangeOfVisiblePageObjects(rRepaintArea));
     790         [ +  + ]:       1313 :     for (sal_Int32 nIndex=aRange.Min(); nIndex<=aRange.Max(); ++nIndex)
     791                 :            :     {
     792         [ +  - ]:        677 :         model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nIndex));
     793 [ +  - ][ +  - ]:        677 :         if (!pDescriptor || ! pDescriptor->HasState(PageDescriptor::ST_Visible))
         [ -  + ][ -  + ]
     794                 :          0 :             continue;
     795                 :            : 
     796 [ +  - ][ +  - ]:       1354 :         mpPageObjectPainter->PaintPageObject(rDevice, pDescriptor);
     797         [ +  - ]:        677 :     }
     798                 :            : }
     799                 :            : 
     800                 :            : 
     801                 :            : 
     802                 :            : 
     803                 :          0 : void SlideSorterView::ConfigurationChanged (
     804                 :            :     utl::ConfigurationBroadcaster* pBroadcaster,
     805                 :            :     sal_uInt32 nHint)
     806                 :            : {
     807                 :            :     // Some changes of the configuration (some of the colors for example)
     808                 :            :     // may affect the previews.  Throw away the old ones and create new ones.
     809         [ #  # ]:          0 :     cache::PageCacheManager::Instance()->InvalidateAllCaches();
     810                 :            : 
     811                 :          0 :     ::sd::View::ConfigurationChanged(pBroadcaster, nHint);
     812                 :          0 :     RequestRepaint();
     813                 :            : 
     814                 :          0 : }
     815                 :            : 
     816                 :            : 
     817                 :            : 
     818                 :            : 
     819                 :       1747 : ::boost::shared_ptr<cache::PageCache> SlideSorterView::GetPreviewCache (void)
     820                 :            : {
     821         [ +  - ]:       1747 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     822 [ +  - ][ +  + ]:       1747 :     if (pWindow && mpPreviewCache.get() == NULL)
                 [ +  + ]
     823                 :            :     {
     824                 :            :         mpPreviewCache.reset(
     825                 :            :             new cache::PageCache(
     826                 :        130 :                 mpLayouter->GetPageObjectSize(),
     827                 :            :                 false,
     828 [ +  - ][ +  - ]:        130 :                 cache::SharedCacheContext(new ViewCacheContext(mrSlideSorter))));
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     829                 :            :     }
     830                 :            : 
     831 [ +  - ][ +  - ]:       1747 :     return mpPreviewCache;
     832                 :            : }
     833                 :            : 
     834                 :            : 
     835                 :            : 
     836                 :            : 
     837                 :          0 : Pair SlideSorterView::GetVisiblePageRange (void)
     838                 :            : {
     839         [ #  # ]:          0 :     if ( ! mbPageObjectVisibilitiesValid)
     840                 :          0 :         DeterminePageObjectVisibilities();
     841                 :          0 :     return maVisiblePageRange;
     842                 :            : }
     843                 :            : 
     844                 :            : 
     845                 :            : 
     846                 :            : 
     847                 :          0 : void SlideSorterView::AddVisibilityChangeListener (const Link& rListener)
     848                 :            : {
     849 [ #  # ][ #  # ]:          0 :     if (::std::find (
     850                 :            :         maVisibilityChangeListeners.begin(),
     851                 :            :         maVisibilityChangeListeners.end(),
     852         [ #  # ]:          0 :         rListener) == maVisibilityChangeListeners.end())
     853                 :            :     {
     854                 :          0 :         maVisibilityChangeListeners.push_back(rListener);
     855                 :            :     }
     856                 :          0 : }
     857                 :            : 
     858                 :            : 
     859                 :            : 
     860                 :            : 
     861                 :          0 : void SlideSorterView::RemoveVisibilityChangeListener(const Link&rListener)
     862                 :            : {
     863                 :            :     maVisibilityChangeListeners.erase (
     864                 :            :         ::std::find (
     865                 :            :             maVisibilityChangeListeners.begin(),
     866                 :            :             maVisibilityChangeListeners.end(),
     867                 :          0 :             rListener));
     868                 :          0 : }
     869                 :            : 
     870                 :            : 
     871                 :            : 
     872                 :            : 
     873                 :        130 : ButtonBar& SlideSorterView::GetButtonBar (void) const
     874                 :            : {
     875                 :            :     OSL_ASSERT(mpButtonBar);
     876                 :        130 :     return *mpButtonBar;
     877                 :            : }
     878                 :            : 
     879                 :            : 
     880                 :            : 
     881                 :            : 
     882                 :          0 : ToolTip& SlideSorterView::GetToolTip (void) const
     883                 :            : {
     884                 :            :     OSL_ASSERT(mpToolTip);
     885                 :          0 :     return *mpToolTip;
     886                 :            : }
     887                 :            : 
     888                 :            : 
     889                 :            : 
     890                 :            : 
     891                 :        962 : void SlideSorterView::Notify (SfxBroadcaster& rBroadcaster, const SfxHint& rHint)
     892                 :            : {
     893                 :        962 :     ::sd::DrawDocShell* pDocShell = mrModel.GetDocument()->GetDocSh();
     894 [ +  - ][ +  - ]:        962 :     if (pDocShell!=NULL && pDocShell->IsEnableSetModified())
                 [ +  - ]
     895                 :        962 :         mbModelChangedWhileModifyEnabled = true;
     896                 :            : 
     897                 :        962 :     ::sd::View::Notify(rBroadcaster, rHint);
     898                 :        962 : }
     899                 :            : 
     900                 :            : 
     901                 :            : 
     902                 :            : 
     903                 :        477 : void SlideSorterView::UpdatePageUnderMouse (bool bAnimate)
     904                 :            : {
     905         [ +  - ]:        477 :     ::boost::shared_ptr<ScrollBar> pVScrollBar (mrSlideSorter.GetVerticalScrollBar());
     906         [ +  - ]:        477 :     ::boost::shared_ptr<ScrollBar> pHScrollBar (mrSlideSorter.GetHorizontalScrollBar());
     907 [ +  - ][ +  - ]:       1431 :     if ((pVScrollBar && pVScrollBar->IsVisible() && pVScrollBar->IsTracking())
         [ +  + ][ +  - ]
           [ +  -  +  - ]
         [ -  + ][ #  # ]
                 [ -  + ]
     908 [ +  - ][ #  # ]:        954 :         || (pHScrollBar && pHScrollBar->IsVisible() && pHScrollBar->IsTracking()))
     909                 :            :     {
     910                 :            :         // One of the scroll bars is tracking mouse movement.  Do not
     911                 :            :         // highlight the slide under the mouse in this case.
     912 [ #  # ][ #  # ]:          0 :         SetPageUnderMouse(SharedPageDescriptor(),false);
                 [ #  # ]
     913                 :            :         return;
     914                 :            :     }
     915                 :            : 
     916         [ +  - ]:        477 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     917 [ +  - ][ +  - ]:        477 :     if (pWindow && pWindow->IsVisible() && ! pWindow->IsMouseCaptured())
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
     918                 :            :     {
     919         [ +  - ]:        477 :         const Window::PointerState aPointerState (pWindow->GetPointerState());
     920 [ +  - ][ +  - ]:        477 :         const Rectangle aWindowBox (pWindow->GetPosPixel(), pWindow->GetSizePixel());
                 [ +  - ]
     921 [ +  - ][ +  + ]:        477 :         if (aWindowBox.IsInside(aPointerState.maPos))
     922                 :            :         {
     923                 :            :             UpdatePageUnderMouse (
     924                 :            :                 aPointerState.maPos,
     925                 :            :                 (aPointerState.mnState & MOUSE_LEFT)!=0,
     926         [ +  - ]:        477 :                 bAnimate);
     927                 :            :             return;
     928                 :            :         }
     929                 :            :     }
     930                 :            : 
     931 [ +  - ][ +  - ]:        477 :     SetPageUnderMouse(SharedPageDescriptor(),false);
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  + ][ +  - ]
                 [ +  + ]
     932                 :            : }
     933                 :            : 
     934                 :            : 
     935                 :            : 
     936                 :            : 
     937                 :        126 : void SlideSorterView::UpdatePageUnderMouse (
     938                 :            :     const Point& rMousePosition,
     939                 :            :     const bool bIsMouseButtonDown,
     940                 :            :     const bool bAnimate)
     941                 :            : {
     942                 :            :     UpdatePageUnderMouse(
     943                 :        126 :         mrSlideSorter.GetController().GetPageAt(rMousePosition),
     944                 :            :         rMousePosition,
     945                 :            :         bIsMouseButtonDown,
     946         [ +  - ]:        126 :         bAnimate);
     947                 :        126 : }
     948                 :            : 
     949                 :            : 
     950                 :            : 
     951                 :            : 
     952                 :        126 : void SlideSorterView::UpdatePageUnderMouse (
     953                 :            :     const model::SharedPageDescriptor& rpDescriptor,
     954                 :            :     const Point& rMousePosition,
     955                 :            :     const bool bIsMouseButtonDown,
     956                 :            :     const bool bAnimate)
     957                 :            : {
     958                 :            :     // Update the page under the mouse.
     959         [ +  - ]:        126 :     SetPageUnderMouse(rpDescriptor, bAnimate);
     960                 :            : 
     961                 :            :     // Tell the button bar about the new mouse position.
     962         [ +  - ]:        126 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     963         [ +  - ]:        126 :     const Point aMouseModelPosition (pWindow->PixelToLogic(rMousePosition));
     964                 :            : 
     965 [ +  - ][ +  - ]:        126 :     ::boost::shared_ptr<ViewShell> pMainViewShell (mrSlideSorter.GetViewShellBase()->GetMainViewShell());
     966 [ #  # ][ -  + ]:        126 :     if (pMainViewShell
                 [ -  + ]
     967         [ #  # ]:        126 :         && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW)
     968                 :            :     {
     969 [ #  # ][ #  # ]:          0 :         const bool bIsMouseOverButtonBar (GetButtonBar().IsMouseOverBar());
     970 [ #  # ][ #  # ]:          0 :         GetButtonBar().ProcessMouseMotionEvent(rpDescriptor, aMouseModelPosition, bIsMouseButtonDown);
     971                 :            :         // Set the help text of the slide when the mouse was moved from the
     972                 :            :         // button bar back over the preview.
     973 [ #  # ][ #  # ]:          0 :         if (rpDescriptor
         [ #  # ][ #  # ]
     974 [ #  # ][ #  # ]:          0 :             && GetButtonBar().IsMouseOverBar() != bIsMouseOverButtonBar
     975                 :            :             && bIsMouseOverButtonBar)
     976                 :            :         {
     977         [ #  # ]:          0 :             mpToolTip->ShowDefaultHelpText();
     978                 :            :         }
     979 [ +  - ][ +  - ]:        126 :     }
     980                 :        126 : }
     981                 :            : 
     982                 :            : 
     983                 :            : 
     984                 :            : 
     985                 :        899 : void SlideSorterView::SetPageUnderMouse (
     986                 :            :     const model::SharedPageDescriptor& rpDescriptor,
     987                 :            :     const bool bAnimate)
     988                 :            : {
     989         [ -  + ]:        899 :     if (mpPageUnderMouse != rpDescriptor)
     990                 :            :     {
     991         [ #  # ]:          0 :         if (mpPageUnderMouse)
     992                 :          0 :             SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, false, bAnimate);
     993                 :            : 
     994                 :          0 :         mpPageUnderMouse = rpDescriptor;
     995                 :            : 
     996         [ #  # ]:          0 :         if (mpPageUnderMouse)
     997                 :          0 :             SetState(mpPageUnderMouse, PageDescriptor::ST_MouseOver, true, bAnimate);
     998                 :            : 
     999                 :            :         // Change the quick help text to display the name of the page under
    1000                 :            :         // the mouse.
    1001                 :          0 :         mpToolTip->SetPage(rpDescriptor);
    1002                 :            :     }
    1003                 :        899 : }
    1004                 :            : 
    1005                 :            : 
    1006                 :            : 
    1007                 :            : 
    1008                 :       1463 : bool SlideSorterView::SetState (
    1009                 :            :     const model::SharedPageDescriptor& rpDescriptor,
    1010                 :            :     const PageDescriptor::State eState,
    1011                 :            :     const bool bStateValue,
    1012                 :            :     const bool bAnimate)
    1013                 :            : {
    1014         [ +  - ]:       1463 :     model::SharedPageDescriptor pDescriptor (rpDescriptor);
    1015         [ -  + ]:       1463 :     if ( ! pDescriptor)
    1016                 :          0 :         return false;
    1017                 :            : 
    1018         [ +  - ]:       1463 :     const bool bModified (pDescriptor->SetState(eState, bStateValue));
    1019         [ +  + ]:       1463 :     if ( ! bModified)
    1020                 :        635 :         return false;
    1021                 :            : 
    1022                 :            :     // When the page object is not visible (i.e. not on the screen then
    1023                 :            :     // nothing has to be painted.
    1024 [ +  - ][ +  + ]:        828 :     if (pDescriptor->HasState(PageDescriptor::ST_Visible))
    1025                 :            :     {
    1026                 :            :         // For most states a change of that state leads to visible
    1027                 :            :         // difference and we have to request a repaint.
    1028         [ +  - ]:        178 :         if (eState != PageDescriptor::ST_WasSelected)
    1029         [ +  - ]:        178 :             RequestRepaint(pDescriptor);
    1030                 :            :     }
    1031                 :            : 
    1032 [ +  - ][ +  - ]:        828 :     ::boost::shared_ptr<ViewShell> pMainViewShell(mrSlideSorter.GetViewShellBase()->GetMainViewShell());
    1033 [ +  + ][ +  + ]:       1656 :     if (pMainViewShell
                 [ +  - ]
    1034         [ +  - ]:       1656 :         && pMainViewShell->GetShellType()!=ViewShell::ST_DRAW)
    1035                 :            :     {
    1036                 :            :         // Fade in or out the buttons.
    1037         [ -  + ]:        160 :         if (eState == PageDescriptor::ST_MouseOver)
    1038                 :            :         {
    1039         [ #  # ]:          0 :             if (bStateValue)
    1040 [ #  # ][ #  # ]:          0 :                 GetButtonBar().RequestFadeIn(rpDescriptor, bAnimate);
    1041                 :            :             else
    1042 [ #  # ][ #  # ]:          0 :                 GetButtonBar().RequestFadeOut(rpDescriptor, bAnimate);
    1043                 :            :         }
    1044                 :            :     }
    1045                 :            : 
    1046 [ +  - ][ +  - ]:       1463 :     return bModified;
    1047                 :            : }
    1048                 :            : 
    1049                 :            : 
    1050                 :            : 
    1051                 :            : 
    1052                 :        439 : ::boost::shared_ptr<PageObjectPainter> SlideSorterView::GetPageObjectPainter (void)
    1053                 :            : {
    1054         [ +  + ]:        439 :     if ( ! mpPageObjectPainter)
    1055         [ +  - ]:        130 :         mpPageObjectPainter.reset(new PageObjectPainter(mrSlideSorter));
    1056                 :        439 :     return mpPageObjectPainter;
    1057                 :            : }
    1058                 :            : 
    1059                 :            : 
    1060                 :            : 
    1061                 :            : 
    1062                 :          0 : ::boost::shared_ptr<LayeredDevice> SlideSorterView::GetLayeredDevice (void) const
    1063                 :            : {
    1064                 :          0 :     return mpLayeredDevice;
    1065                 :            : }
    1066                 :            : 
    1067                 :            : 
    1068                 :            : 
    1069                 :            : 
    1070                 :            : //===== SlideSorterView::DrawLock =============================================
    1071                 :            : 
    1072                 :        133 : SlideSorterView::DrawLock::DrawLock (SlideSorter& rSlideSorter)
    1073                 :        133 :     : mrView(rSlideSorter.GetView()),
    1074                 :        133 :       mpWindow(rSlideSorter.GetContentWindow())
    1075                 :            : {
    1076         [ +  - ]:        133 :     if (mrView.mnLockRedrawSmph == 0)
    1077         [ +  - ]:        133 :         mrView.maRedrawRegion.SetEmpty();
    1078                 :        133 :     ++mrView.mnLockRedrawSmph;
    1079                 :        133 : }
    1080                 :            : 
    1081                 :            : 
    1082                 :            : 
    1083                 :            : 
    1084                 :        133 : SlideSorterView::DrawLock::~DrawLock (void)
    1085                 :            : {
    1086                 :            :     OSL_ASSERT(mrView.mnLockRedrawSmph>0);
    1087                 :        133 :     --mrView.mnLockRedrawSmph;
    1088         [ +  - ]:        133 :     if (mrView.mnLockRedrawSmph == 0)
    1089         [ +  - ]:        133 :         if (mpWindow)
    1090                 :            :         {
    1091         [ +  - ]:        133 :             mpWindow->Invalidate(mrView.maRedrawRegion);
    1092         [ +  - ]:        133 :             mpWindow->Update();
    1093                 :            :         }
    1094                 :        133 : }
    1095                 :            : 
    1096                 :            : 
    1097                 :            : 
    1098                 :            : 
    1099                 :          0 : void SlideSorterView::DrawLock::Dispose (void)
    1100                 :            : {
    1101                 :          0 :     mpWindow.reset();
    1102                 :          0 : }
    1103                 :            : 
    1104                 :            : 
    1105                 :            : } } } // end of namespace ::sd::slidesorter::view
    1106                 :            : 
    1107                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10