LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/controller - SlideSorterController.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 199 420 47.4 %
Date: 2012-08-25 Functions: 31 48 64.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 213 852 25.0 %

           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 "controller/SlideSorterController.hxx"
      31                 :            : 
      32                 :            : #include "SlideSorter.hxx"
      33                 :            : #include "controller/SlsPageSelector.hxx"
      34                 :            : #include "controller/SlsSelectionFunction.hxx"
      35                 :            : #include "controller/SlsProperties.hxx"
      36                 :            : #include "controller/SlsCurrentSlideManager.hxx"
      37                 :            : #include "SlsListener.hxx"
      38                 :            : #include "controller/SlsFocusManager.hxx"
      39                 :            : #include "controller/SlsAnimator.hxx"
      40                 :            : #include "controller/SlsClipboard.hxx"
      41                 :            : #include "controller/SlsInsertionIndicatorHandler.hxx"
      42                 :            : #include "controller/SlsScrollBarManager.hxx"
      43                 :            : #include "controller/SlsSelectionManager.hxx"
      44                 :            : #include "controller/SlsSlotManager.hxx"
      45                 :            : #include "controller/SlsTransferable.hxx"
      46                 :            : #include "controller/SlsVisibleAreaManager.hxx"
      47                 :            : #include "model/SlideSorterModel.hxx"
      48                 :            : #include "model/SlsPageEnumerationProvider.hxx"
      49                 :            : #include "model/SlsPageDescriptor.hxx"
      50                 :            : #include "view/SlideSorterView.hxx"
      51                 :            : #include "view/SlsLayouter.hxx"
      52                 :            : #include "view/SlsFontProvider.hxx"
      53                 :            : #include "view/SlsPageObjectLayouter.hxx"
      54                 :            : #include "view/SlsPageObjectPainter.hxx"
      55                 :            : #include "view/SlsTheme.hxx"
      56                 :            : #include "view/SlsToolTip.hxx"
      57                 :            : #include "cache/SlsPageCache.hxx"
      58                 :            : #include "cache/SlsPageCacheManager.hxx"
      59                 :            : 
      60                 :            : #include "drawdoc.hxx"
      61                 :            : #include "DrawViewShell.hxx"
      62                 :            : #include "TextLogger.hxx"
      63                 :            : #include "ViewShellBase.hxx"
      64                 :            : #include "Window.hxx"
      65                 :            : #include "FrameView.hxx"
      66                 :            : #include "DrawDocShell.hxx"
      67                 :            : #include "sdpage.hxx"
      68                 :            : #include "res_bmp.hrc"
      69                 :            : #include "sdresid.hxx"
      70                 :            : #include "strings.hrc"
      71                 :            : #include "app.hrc"
      72                 :            : #include "glob.hrc"
      73                 :            : #include "sdmod.hxx"
      74                 :            : #include "sdxfer.hxx"
      75                 :            : #include "ViewShellHint.hxx"
      76                 :            : #include "AccessibleSlideSorterView.hxx"
      77                 :            : #include "AccessibleSlideSorterObject.hxx"
      78                 :            : 
      79                 :            : #include <vcl/window.hxx>
      80                 :            : #include <svx/svdopage.hxx>
      81                 :            : #include <svx/svxids.hrc>
      82                 :            : #include <svx/ruler.hxx>
      83                 :            : #include <sfx2/zoomitem.hxx>
      84                 :            : #include <svtools/tabbar.hxx>
      85                 :            : #include <sfx2/request.hxx>
      86                 :            : #include <sfx2/viewfrm.hxx>
      87                 :            : #include <sfx2/dispatch.hxx>
      88                 :            : #include <vcl/svapp.hxx>
      89                 :            : 
      90                 :            : #include <com/sun/star/lang/XComponent.hpp>
      91                 :            : #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
      92                 :            : #include <com/sun/star/drawing/XDrawPagesSupplier.hpp>
      93                 :            : #include <com/sun/star/drawing/XDrawPages.hpp>
      94                 :            : #include <com/sun/star/accessibility/AccessibleEventId.hpp>
      95                 :            : 
      96                 :            : using namespace ::com::sun::star;
      97                 :            : using namespace ::com::sun::star::uno;
      98                 :            : using namespace ::sd::slidesorter::model;
      99                 :            : using namespace ::sd::slidesorter::view;
     100                 :            : using namespace ::sd::slidesorter::controller;
     101                 :            : using namespace ::basegfx;
     102                 :            : 
     103                 :            : namespace sd { namespace slidesorter { namespace controller {
     104                 :            : 
     105                 :            : 
     106                 :        130 : SlideSorterController::SlideSorterController (SlideSorter& rSlideSorter)
     107                 :            :     : mrSlideSorter(rSlideSorter),
     108                 :        130 :       mrModel(mrSlideSorter.GetModel()),
     109                 :        130 :       mrView(mrSlideSorter.GetView()),
     110                 :            :       mpPageSelector(),
     111                 :            :       mpFocusManager(),
     112                 :            :       mpSlotManager(),
     113                 :            :       mpScrollBarManager(),
     114                 :            :       mpCurrentSlideManager(),
     115                 :            :       mpSelectionManager(),
     116                 :            :       mpClipboard(),
     117         [ +  - ]:        130 :       mpInsertionIndicatorHandler(new InsertionIndicatorHandler(rSlideSorter)),
     118         [ +  - ]:        130 :       mpAnimator(new Animator(rSlideSorter)),
     119         [ +  - ]:        130 :       mpVisibleAreaManager(new VisibleAreaManager(rSlideSorter)),
     120                 :            :       mpListener(),
     121                 :            :       mnModelChangeLockCount(0),
     122                 :            :       mbIsForcedRearrangePending(false),
     123                 :            :       mbPreModelChangeDone(false),
     124                 :            :       mbPostModelChangePending(false),
     125                 :            :       maSelectionBeforeSwitch(),
     126                 :            :       mnCurrentPageBeforeSwitch(0),
     127                 :            :       mpEditModeChangeMasterPage(NULL),
     128                 :            :       maTotalWindowArea(),
     129                 :            :       mnPaintEntranceCount(0),
     130 [ +  - ][ +  - ]:        520 :       mbIsContextMenuOpen(false)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     131                 :            : {
     132         [ +  - ]:        130 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     133                 :            :     OSL_ASSERT(pWindow);
     134         [ +  - ]:        130 :     if (pWindow)
     135                 :            :     {
     136                 :            :         // The whole background is painted by the view and controls.
     137         [ +  - ]:        130 :         ::Window* pParentWindow = pWindow->GetParent();
     138                 :            :         OSL_ASSERT(pParentWindow!=NULL);
     139 [ +  - ][ +  - ]:        130 :         pParentWindow->SetBackground (Wallpaper());
                 [ +  - ]
     140                 :            : 
     141                 :            :         // Connect the view with the window that has been created by our base
     142                 :            :         // class.
     143 [ +  - ][ +  - ]:        130 :         pWindow->SetBackground(Wallpaper());
                 [ +  - ]
     144         [ +  - ]:        130 :         pWindow->SetCenterAllowed(false);
     145 [ +  - ][ +  - ]:        130 :         pWindow->SetMapMode(MapMode(MAP_PIXEL));
                 [ +  - ]
     146 [ +  - ][ +  - ]:        130 :         pWindow->SetViewSize(mrView.GetModelArea().GetSize());
                 [ +  - ]
     147         [ +  - ]:        130 :     }
     148                 :        130 : }
     149                 :            : 
     150                 :            : 
     151                 :            : 
     152                 :            : 
     153                 :        130 : void SlideSorterController::Init (void)
     154                 :            : {
     155 [ +  - ][ +  - ]:        130 :     mpCurrentSlideManager.reset(new CurrentSlideManager(mrSlideSorter));
                 [ +  - ]
     156 [ +  - ][ +  - ]:        130 :     mpPageSelector.reset(new PageSelector(mrSlideSorter));
                 [ +  - ]
     157 [ +  - ][ +  - ]:        130 :     mpFocusManager.reset(new FocusManager(mrSlideSorter));
                 [ +  - ]
     158 [ +  - ][ +  - ]:        130 :     mpSlotManager.reset(new SlotManager(mrSlideSorter));
                 [ +  - ]
     159 [ +  - ][ +  - ]:        130 :     mpScrollBarManager.reset(new ScrollBarManager(mrSlideSorter));
                 [ +  - ]
     160 [ +  - ][ +  - ]:        130 :     mpSelectionManager.reset(new SelectionManager(mrSlideSorter));
                 [ +  - ]
     161 [ +  - ][ +  - ]:        130 :     mpClipboard.reset(new Clipboard(mrSlideSorter));
                 [ +  - ]
     162                 :            : 
     163         [ +  - ]:        130 :     mpScrollBarManager->LateInitialization();
     164                 :            : 
     165                 :            :     // Create the selection function.
     166                 :            :     SfxRequest aRequest (
     167                 :            :         SID_OBJECT_SELECT,
     168                 :            :         0,
     169 [ +  - ][ +  - ]:        130 :         mrModel.GetDocument()->GetItemPool());
     170 [ +  - ][ +  - ]:        130 :     mrSlideSorter.SetCurrentFunction(CreateSelectionFunction(aRequest));
                 [ +  - ]
     171                 :            : 
     172 [ +  - ][ +  - ]:        130 :     mpListener = new Listener(mrSlideSorter);
     173                 :            : 
     174         [ +  - ]:        130 :     mpPageSelector->GetCoreSelection();
     175 [ +  - ][ +  - ]:        130 :     GetSelectionManager()->SelectionHasChanged();
         [ +  - ][ +  - ]
     176                 :        130 : }
     177                 :            : 
     178                 :            : 
     179                 :            : 
     180                 :            : 
     181 [ +  - ][ +  - ]:        130 : SlideSorterController::~SlideSorterController (void)
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
     182                 :            : {
     183                 :            :     try
     184                 :            :     {
     185                 :            :         uno::Reference<lang::XComponent> xComponent (
     186         [ +  - ]:        130 :             static_cast<XWeak*>(mpListener.get()), uno::UNO_QUERY);
     187         [ +  - ]:        130 :         if (xComponent.is())
     188 [ +  - ][ +  - ]:        130 :             xComponent->dispose();
                 [ #  # ]
     189                 :            :     }
     190         [ #  # ]:          0 :     catch( uno::Exception& )
     191                 :            :     {
     192                 :            :         OSL_FAIL( "sd::SlideSorterController::~SlideSorterController(), exception caught!" );
     193                 :            :     }
     194                 :            : 
     195                 :            :     // dispose should have been called by now so that nothing is to be done
     196                 :            :     // to shut down cleanly.
     197         [ -  + ]:        260 : }
     198                 :            : 
     199                 :            : 
     200                 :            : 
     201                 :            : 
     202                 :        130 : void SlideSorterController::Dispose (void)
     203                 :            : {
     204                 :        130 :     mpInsertionIndicatorHandler->End(Animator::AM_Immediate);
     205                 :        130 :     mpClipboard.reset();
     206                 :        130 :     mpSelectionManager.reset();
     207                 :        130 :     mpAnimator->Dispose();
     208                 :        130 : }
     209                 :            : 
     210                 :            : 
     211                 :            : 
     212                 :            : 
     213                 :        126 : model::SharedPageDescriptor SlideSorterController::GetPageAt (
     214                 :            :     const Point& aWindowPosition)
     215                 :            : {
     216                 :        126 :     sal_Int32 nHitPageIndex (mrView.GetPageIndexAtPoint(aWindowPosition));
     217                 :        126 :     model::SharedPageDescriptor pDescriptorAtPoint;
     218         [ -  + ]:        126 :     if (nHitPageIndex >= 0)
     219                 :            :     {
     220 [ #  # ][ #  # ]:          0 :         pDescriptorAtPoint = mrModel.GetPageDescriptor(nHitPageIndex);
                 [ #  # ]
     221                 :            : 
     222                 :            :         // Depending on a property we may have to check that the mouse is no
     223                 :            :         // just over the page object but over the preview area.
     224 [ #  # ][ #  # ]:          0 :         if (pDescriptorAtPoint
         [ #  # ][ #  # ]
     225 [ #  # ][ #  # ]:          0 :             && mrSlideSorter.GetProperties()->IsOnlyPreviewTriggersMouseOver()
         [ #  # ][ #  # ]
                 [ #  # ]
     226         [ #  # ]:          0 :             && ! pDescriptorAtPoint->HasState(PageDescriptor::ST_Selected))
     227                 :            :         {
     228                 :            :             // Make sure that the mouse is over the preview area.
     229 [ #  # ][ #  # ]:          0 :             if ( ! mrView.GetLayouter().GetPageObjectLayouter()->GetBoundingBox(
     230                 :            :                 pDescriptorAtPoint,
     231                 :            :                 view::PageObjectLayouter::Preview,
     232 [ #  # ][ #  # ]:          0 :                 view::PageObjectLayouter::WindowCoordinateSystem).IsInside(aWindowPosition))
         [ #  # ][ #  # ]
     233                 :            :             {
     234         [ #  # ]:          0 :                 pDescriptorAtPoint.reset();
     235                 :            :             }
     236                 :            :         }
     237                 :            :     }
     238                 :            : 
     239                 :        126 :     return pDescriptorAtPoint;
     240                 :            : }
     241                 :            : 
     242                 :            : 
     243                 :            : 
     244                 :            : 
     245                 :        414 : PageSelector& SlideSorterController::GetPageSelector (void)
     246                 :            : {
     247                 :            :     OSL_ASSERT(mpPageSelector.get()!=NULL);
     248                 :        414 :     return *mpPageSelector.get();
     249                 :            : }
     250                 :            : 
     251                 :            : 
     252                 :            : 
     253                 :            : 
     254                 :        138 : FocusManager& SlideSorterController::GetFocusManager (void)
     255                 :            : {
     256                 :            :     OSL_ASSERT(mpFocusManager.get()!=NULL);
     257                 :        138 :     return *mpFocusManager.get();
     258                 :            : }
     259                 :            : 
     260                 :            : 
     261                 :            : 
     262                 :            : 
     263                 :          0 : Clipboard& SlideSorterController::GetClipboard (void)
     264                 :            : {
     265                 :            :     OSL_ASSERT(mpClipboard.get()!=NULL);
     266                 :          0 :     return *mpClipboard.get();
     267                 :            : }
     268                 :            : 
     269                 :            : 
     270                 :            : 
     271                 :            : 
     272                 :       1384 : ScrollBarManager& SlideSorterController::GetScrollBarManager (void)
     273                 :            : {
     274                 :            :     OSL_ASSERT(mpScrollBarManager.get()!=NULL);
     275                 :       1384 :     return *mpScrollBarManager.get();
     276                 :            : }
     277                 :            : 
     278                 :            : 
     279                 :            : 
     280                 :            : 
     281                 :       2103 : ::boost::shared_ptr<CurrentSlideManager> SlideSorterController::GetCurrentSlideManager (void) const
     282                 :            : {
     283                 :            :     OSL_ASSERT(mpCurrentSlideManager.get()!=NULL);
     284                 :       2103 :     return mpCurrentSlideManager;
     285                 :            : }
     286                 :            : 
     287                 :            : 
     288                 :            : 
     289                 :            : 
     290                 :        132 : ::boost::shared_ptr<SlotManager> SlideSorterController::GetSlotManager (void) const
     291                 :            : {
     292                 :            :     OSL_ASSERT(mpSlotManager.get()!=NULL);
     293                 :        132 :     return mpSlotManager;
     294                 :            : }
     295                 :            : 
     296                 :            : 
     297                 :            : 
     298                 :            : 
     299                 :        948 : ::boost::shared_ptr<SelectionManager> SlideSorterController::GetSelectionManager (void) const
     300                 :            : {
     301                 :            :     OSL_ASSERT(mpSelectionManager.get()!=NULL);
     302                 :        948 :     return mpSelectionManager;
     303                 :            : }
     304                 :            : 
     305                 :            : 
     306                 :            : 
     307                 :            : 
     308                 :            : ::boost::shared_ptr<InsertionIndicatorHandler>
     309                 :          0 :     SlideSorterController::GetInsertionIndicatorHandler (void) const
     310                 :            : {
     311                 :            :     OSL_ASSERT(mpInsertionIndicatorHandler.get()!=NULL);
     312                 :          0 :     return mpInsertionIndicatorHandler;
     313                 :            : }
     314                 :            : 
     315                 :            : 
     316                 :            : 
     317                 :            : 
     318                 :        636 : void SlideSorterController::Paint (
     319                 :            :     const Rectangle& rBBox,
     320                 :            :     ::Window* pWindow)
     321                 :            : {
     322         [ +  - ]:        636 :     if (mnPaintEntranceCount == 0)
     323                 :            :     {
     324                 :        636 :         ++mnPaintEntranceCount;
     325                 :            : 
     326                 :            :         try
     327                 :            :         {
     328 [ +  - ][ +  - ]:        636 :             mrView.CompleteRedraw(pWindow, Region(rBBox), 0);
         [ +  - ][ #  # ]
     329                 :            :         }
     330                 :          0 :         catch (const Exception&)
     331                 :            :         {
     332                 :            :             // Ignore all exceptions.
     333                 :            :         }
     334                 :            : 
     335                 :        636 :         --mnPaintEntranceCount;
     336                 :            :     }
     337                 :        636 : }
     338                 :            : 
     339                 :            : 
     340                 :            : 
     341                 :            : 
     342                 :          0 : void SlideSorterController::FuTemporary (SfxRequest& rRequest)
     343                 :            : {
     344                 :          0 :     mpSlotManager->FuTemporary (rRequest);
     345                 :          0 : }
     346                 :            : 
     347                 :            : 
     348                 :            : 
     349                 :            : 
     350                 :          0 : void SlideSorterController::FuPermanent (SfxRequest &rRequest)
     351                 :            : {
     352                 :          0 :     mpSlotManager->FuPermanent (rRequest);
     353                 :          0 : }
     354                 :            : 
     355                 :            : 
     356                 :            : 
     357                 :            : 
     358                 :          0 : void SlideSorterController::FuSupport (SfxRequest &rRequest)
     359                 :            : {
     360                 :          0 :     mpSlotManager->FuSupport (rRequest);
     361                 :          0 : }
     362                 :            : 
     363                 :            : 
     364                 :            : 
     365                 :            : 
     366                 :          0 : bool SlideSorterController::Command (
     367                 :            :     const CommandEvent& rEvent,
     368                 :            :     ::sd::Window* pWindow)
     369                 :            : {
     370                 :          0 :     bool bEventHasBeenHandled = false;
     371                 :            : 
     372         [ #  # ]:          0 :     if (pWindow == NULL)
     373                 :          0 :         return false;
     374                 :            : 
     375                 :          0 :     ViewShell* pViewShell = mrSlideSorter.GetViewShell();
     376         [ #  # ]:          0 :     if (pViewShell == NULL)
     377                 :          0 :         return false;
     378                 :            : 
     379      [ #  #  # ]:          0 :     switch (rEvent.GetCommand())
     380                 :            :     {
     381                 :            :         case COMMAND_CONTEXTMENU:
     382                 :            :         {
     383                 :          0 :             SdPage* pPage = NULL;
     384                 :            :             sal_uInt16 nPopupId;
     385                 :            : 
     386                 :            :             model::PageEnumeration aSelectedPages (
     387         [ #  # ]:          0 :                 PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel));
     388 [ #  # ][ #  # ]:          0 :             if (aSelectedPages.HasMoreElements())
     389 [ #  # ][ #  # ]:          0 :                 pPage = aSelectedPages.GetNextElement()->GetPage();
                 [ #  # ]
     390                 :            : 
     391                 :            :             // Choose the popup menu depending on a) the type of the main
     392                 :            :             // view shell, b) the edit mode, and c) on whether the selection
     393                 :            :             // is empty or not.
     394                 :          0 :             ViewShell::ShellType eMainViewShellType (ViewShell::ST_NONE);
     395                 :            :             ::boost::shared_ptr<ViewShell> pMainViewShell (
     396 [ #  # ][ #  # ]:          0 :                 pViewShell->GetViewShellBase().GetMainViewShell());
     397         [ #  # ]:          0 :             if (pMainViewShell.get() != NULL)
     398         [ #  # ]:          0 :                 eMainViewShellType = pMainViewShell->GetShellType();
     399         [ #  # ]:          0 :             switch (eMainViewShellType)
     400                 :            :             {
     401                 :            :                 case ViewShell::ST_DRAW:
     402         [ #  # ]:          0 :                     if (pPage != NULL)
     403                 :          0 :                         nPopupId = RID_SLIDE_SORTER_DRAW_SEL_POPUP;
     404                 :            :                     else
     405                 :          0 :                         nPopupId = RID_SLIDE_SORTER_DRAW_NOSEL_POPUP;
     406                 :          0 :                     break;
     407                 :            : 
     408                 :            :                 default:
     409 [ #  # ][ #  # ]:          0 :                     if (mrModel.GetEditMode() == EM_PAGE)
     410         [ #  # ]:          0 :                         if (pPage != NULL)
     411                 :          0 :                             nPopupId = RID_SLIDE_SORTER_IMPRESS_SEL_POPUP;
     412                 :            :                         else
     413                 :          0 :                             nPopupId = RID_SLIDE_SORTER_IMPRESS_NOSEL_POPUP;
     414                 :            :                     else
     415         [ #  # ]:          0 :                         if (pPage != NULL)
     416                 :          0 :                             nPopupId = RID_SLIDE_SORTER_MASTER_SEL_POPUP;
     417                 :            :                         else
     418                 :          0 :                             nPopupId = RID_SLIDE_SORTER_MASTER_NOSEL_POPUP;
     419                 :            :             }
     420                 :          0 :             ::boost::scoped_ptr<InsertionIndicatorHandler::ForceShowContext> pContext;
     421         [ #  # ]:          0 :             if (pPage == NULL)
     422                 :            :             {
     423                 :            :                 // When there is no selection, then we show the insertion
     424                 :            :                 // indicator so that the user knows where a page insertion
     425                 :            :                 // would take place.
     426         [ #  # ]:          0 :                 mpInsertionIndicatorHandler->Start(false);
     427                 :            :                 mpInsertionIndicatorHandler->UpdateIndicatorIcon(
     428 [ #  # ][ #  # ]:          0 :                     dynamic_cast<Transferable*>(SD_MOD()->pTransferClip));
                 [ #  # ]
     429                 :            :                 mpInsertionIndicatorHandler->UpdatePosition(
     430                 :          0 :                     pWindow->PixelToLogic(rEvent.GetMousePosPixel()),
     431 [ #  # ][ #  # ]:          0 :                     InsertionIndicatorHandler::MoveMode);
     432                 :            :                 pContext.reset(new InsertionIndicatorHandler::ForceShowContext(
     433 [ #  # ][ #  # ]:          0 :                     mpInsertionIndicatorHandler));
                 [ #  # ]
     434                 :            :             }
     435                 :            : 
     436         [ #  # ]:          0 :             pWindow->ReleaseMouse();
     437                 :            : 
     438                 :          0 :             Point aMenuLocation (0,0);
     439         [ #  # ]:          0 :             if (rEvent.IsMouseEvent())
     440                 :            :             {
     441                 :            :                 // We have to explicitly specify the location of the menu
     442                 :            :                 // when the slide sorter is placed in an undocked child
     443                 :            :                 // menu.  But when it is docked it does not hurt, so we
     444                 :            :                 // specify the location always.
     445                 :          0 :                 aMenuLocation = rEvent.GetMousePosPixel();
     446                 :            :             }
     447                 :            :             else
     448                 :            :             {
     449                 :            :                 // The event is not a mouse event.  Use the center of the
     450                 :            :                 // focused page as top left position of the context menu.
     451                 :            :                 model::SharedPageDescriptor pDescriptor (
     452 [ #  # ][ #  # ]:          0 :                     GetFocusManager().GetFocusedPageDescriptor());
     453         [ #  # ]:          0 :                 if (pDescriptor.get() != NULL)
     454                 :            :                 {
     455                 :            :                     Rectangle aBBox (
     456         [ #  # ]:          0 :                         mrView.GetLayouter().GetPageObjectLayouter()->GetBoundingBox (
     457                 :            :                             pDescriptor,
     458                 :            :                             PageObjectLayouter::PageObject,
     459 [ #  # ][ #  # ]:          0 :                             PageObjectLayouter::ModelCoordinateSystem));
                 [ #  # ]
     460         [ #  # ]:          0 :                     aMenuLocation = aBBox.Center();
     461         [ #  # ]:          0 :                 }
     462                 :            :             }
     463                 :            : 
     464                 :          0 :             mbIsContextMenuOpen = true;
     465         [ #  # ]:          0 :             if (pViewShell != NULL)
     466                 :            :             {
     467         [ #  # ]:          0 :                 SfxDispatcher* pDispatcher = pViewShell->GetDispatcher();
     468         [ #  # ]:          0 :                 if (pDispatcher != NULL)
     469                 :            :                 {
     470                 :            :                     pDispatcher->ExecutePopup(
     471                 :            :                         SdResId(nPopupId),
     472                 :            :                         pWindow,
     473 [ #  # ][ #  # ]:          0 :                         &aMenuLocation);
     474 [ #  # ][ #  # ]:          0 :                     mrSlideSorter.GetView().UpdatePageUnderMouse(false);
     475         [ #  # ]:          0 :                     ::rtl::Reference<SelectionFunction> pFunction(GetCurrentSelectionFunction());
     476         [ #  # ]:          0 :                     if (pFunction.is())
     477 [ #  # ][ #  # ]:          0 :                         pFunction->ResetMouseAnchor();
     478                 :            :                 }
     479                 :            :             }
     480                 :          0 :             mbIsContextMenuOpen = false;
     481         [ #  # ]:          0 :             if (pPage == NULL)
     482                 :            :             {
     483                 :            :                 // Remember the position of the insertion indicator before
     484                 :            :                 // it is hidden, so that a pending slide insertion slot call
     485                 :            :                 // finds the right place to insert a new slide.
     486                 :            :                 GetSelectionManager()->SetInsertionPosition(
     487 [ #  # ][ #  # ]:          0 :                     GetInsertionIndicatorHandler()->GetInsertionPageIndex());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     488                 :            :             }
     489         [ #  # ]:          0 :             pContext.reset();
     490 [ #  # ][ #  # ]:          0 :             bEventHasBeenHandled = true;
                 [ #  # ]
     491                 :            :         }
     492                 :          0 :         break;
     493                 :            : 
     494                 :            :         case COMMAND_WHEEL:
     495                 :            :         {
     496                 :          0 :             const CommandWheelData* pData = rEvent.GetWheelData();
     497         [ #  # ]:          0 :             if (pData == NULL)
     498                 :          0 :                 return false;
     499         [ #  # ]:          0 :             if (pData->IsMod1())
     500                 :            :             {
     501                 :            :                 // We do not support zooming with control+mouse wheel.
     502                 :          0 :                 return false;
     503                 :            :             }
     504                 :            :             // Determine whether to scroll horizontally or vertically.  This
     505                 :            :             // depends on the orientation of the scroll bar and the
     506                 :            :             // IsHoriz() flag of the event.
     507         [ #  # ]:          0 :             if ((mrSlideSorter.GetView().GetOrientation()==view::Layouter::HORIZONTAL)
     508                 :          0 :                 == pData->IsHorz())
     509                 :            :             {
     510                 :          0 :                 GetScrollBarManager().Scroll(
     511                 :            :                     ScrollBarManager::Orientation_Vertical,
     512                 :            :                     ScrollBarManager::Unit_Slide,
     513                 :          0 :                     -pData->GetNotchDelta());
     514                 :            :             }
     515                 :            :             else
     516                 :            :             {
     517                 :          0 :                 GetScrollBarManager().Scroll(
     518                 :            :                     ScrollBarManager::Orientation_Horizontal,
     519                 :            :                     ScrollBarManager::Unit_Slide,
     520                 :          0 :                     -pData->GetNotchDelta());
     521                 :            :             }
     522                 :          0 :             mrSlideSorter.GetView().UpdatePageUnderMouse(rEvent.GetMousePosPixel(), false);
     523                 :            : 
     524                 :          0 :             bEventHasBeenHandled = true;
     525                 :            :         }
     526                 :          0 :         break;
     527                 :            :     }
     528                 :            : 
     529                 :          0 :     return bEventHasBeenHandled;
     530                 :            : }
     531                 :            : 
     532                 :            : 
     533                 :            : 
     534                 :            : 
     535                 :        162 : void SlideSorterController::LockModelChange (void)
     536                 :            : {
     537                 :        162 :     mnModelChangeLockCount += 1;
     538                 :        162 : }
     539                 :            : 
     540                 :            : 
     541                 :            : 
     542                 :            : 
     543                 :        162 : void SlideSorterController::UnlockModelChange (void)
     544                 :            : {
     545                 :        162 :     mnModelChangeLockCount -= 1;
     546 [ +  - ][ +  - ]:        162 :     if (mnModelChangeLockCount==0 && mbPostModelChangePending)
     547                 :            :     {
     548                 :        162 :         PostModelChange();
     549                 :            :     }
     550                 :        162 : }
     551                 :            : 
     552                 :            : 
     553                 :            : 
     554                 :            : 
     555                 :        162 : void SlideSorterController::PreModelChange (void)
     556                 :            : {
     557                 :            :     // Prevent PreModelChange to execute more than once per model lock.
     558         [ -  + ]:        162 :     if (mbPostModelChangePending)
     559                 :        162 :         return;
     560                 :        162 :     mbPreModelChangeDone = true;
     561                 :            : 
     562         [ +  - ]:        162 :     if (mrSlideSorter.GetViewShell() != NULL)
     563         [ +  - ]:        162 :         mrSlideSorter.GetViewShell()->Broadcast(
     564         [ +  - ]:        324 :             ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
     565                 :            : 
     566         [ +  - ]:        162 :     GetCurrentSlideManager()->PrepareModelChange();
     567                 :            : 
     568         [ +  - ]:        162 :     if (mrSlideSorter.GetContentWindow())
     569                 :        162 :         mrView.PreModelChange();
     570                 :            : 
     571                 :        162 :     mbPostModelChangePending = true;
     572                 :            : }
     573                 :            : 
     574                 :            : 
     575                 :            : 
     576                 :            : 
     577                 :        162 : void SlideSorterController::PostModelChange (void)
     578                 :            : {
     579                 :        162 :     mbPostModelChangePending = false;
     580         [ +  - ]:        162 :     mrModel.Resync();
     581                 :            : 
     582         [ +  - ]:        162 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     583         [ +  - ]:        162 :     if (pWindow)
     584                 :            :     {
     585 [ +  - ][ +  - ]:        162 :         GetCurrentSlideManager()->HandleModelChange();
                 [ +  - ]
     586                 :            : 
     587         [ +  - ]:        162 :         mrView.PostModelChange ();
     588                 :            : 
     589         [ +  - ]:        162 :         pWindow->SetViewOrigin (Point (0,0));
     590 [ +  - ][ +  - ]:        162 :         pWindow->SetViewSize (mrView.GetModelArea().GetSize());
                 [ +  - ]
     591                 :            : 
     592                 :            :         // The visibility of the scroll bars may have to be changed.  Then
     593                 :            :         // the size of the view has to change, too.  Let Rearrange() handle
     594                 :            :         // that.
     595         [ +  - ]:        162 :         Rearrange(mbIsForcedRearrangePending);
     596                 :            :     }
     597                 :            : 
     598 [ +  - ][ +  - ]:        162 :     if (mrSlideSorter.GetViewShell() != NULL)
     599         [ +  - ]:        162 :         mrSlideSorter.GetViewShell()->Broadcast(
     600 [ +  - ][ +  - ]:        324 :             ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
         [ +  - ][ +  - ]
     601                 :        162 : }
     602                 :            : 
     603                 :            : 
     604                 :            : 
     605                 :            : 
     606                 :         94 : void SlideSorterController::HandleModelChange (void)
     607                 :            : {
     608                 :            :     // Ignore this call when the document is not in a valid state, i.e. has
     609                 :            :     // not the same number of regular and notes pages.
     610                 :         94 :     bool bIsDocumentValid = (mrModel.GetDocument()->GetPageCount() % 2 == 1);
     611                 :            : 
     612         [ +  + ]:         94 :     if (bIsDocumentValid)
     613                 :            :     {
     614                 :         32 :         ModelChangeLock aLock (*this);
     615 [ +  - ][ +  - ]:         32 :         PreModelChange();
     616                 :            :     }
     617                 :         94 : }
     618                 :            : 
     619                 :            : 
     620                 :            : 
     621                 :            : 
     622                 :     178324 : IMPL_LINK(SlideSorterController, WindowEventHandler, VclWindowEvent*, pEvent)
     623                 :            : {
     624         [ +  - ]:     178324 :     if (pEvent != NULL)
     625                 :            :     {
     626                 :     178324 :         ::Window* pWindow = pEvent->GetWindow();
     627         [ +  - ]:     178324 :         SharedSdWindow pActiveWindow (mrSlideSorter.GetContentWindow());
     628   [ +  +  +  +  :     178324 :         switch (pEvent->GetId())
                   -  + ]
     629                 :            :         {
     630                 :            :             case VCLEVENT_WINDOW_ACTIVATE:
     631                 :            :             case VCLEVENT_WINDOW_SHOW:
     632 [ +  - ][ +  - ]:      14136 :                 if (pActiveWindow && pWindow == pActiveWindow->GetParent())
         [ +  + ][ +  + ]
     633         [ +  - ]:        206 :                     mrView.RequestRepaint();
     634                 :      14136 :                 break;
     635                 :            : 
     636                 :            :             case VCLEVENT_WINDOW_HIDE:
     637 [ +  - ][ +  - ]:      10298 :                 if (pActiveWindow && pWindow == pActiveWindow->GetParent())
         [ -  + ][ -  + ]
     638 [ #  # ][ #  # ]:          0 :                     mrView.SetPageUnderMouse(SharedPageDescriptor());
                 [ #  # ]
     639                 :      10298 :                 break;
     640                 :            : 
     641                 :            :             case VCLEVENT_WINDOW_GETFOCUS:
     642         [ +  - ]:        340 :                 if (pActiveWindow)
     643         [ -  + ]:        340 :                     if (pWindow == pActiveWindow.get())
     644 [ #  # ][ #  # ]:          0 :                         GetFocusManager().ShowFocus(false);
     645                 :        340 :                 break;
     646                 :            : 
     647                 :            :             case VCLEVENT_WINDOW_LOSEFOCUS:
     648 [ +  - ][ -  + ]:        227 :                 if (pActiveWindow && pWindow == pActiveWindow.get())
                 [ -  + ]
     649                 :            :                 {
     650 [ #  # ][ #  # ]:          0 :                     GetFocusManager().HideFocus();
     651 [ #  # ][ #  # ]:          0 :                     mrView.GetToolTip().Hide();
     652                 :            : 
     653                 :            :                     // Select the current slide so that it is properly
     654                 :            :                     // visualized when the focus is moved to the edit view.
     655 [ #  # ][ #  # ]:          0 :                     GetPageSelector().SelectPage(GetCurrentSlideManager()->GetCurrentSlide());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     656                 :            :                 }
     657                 :        227 :                 break;
     658                 :            : 
     659                 :            :             case VCLEVENT_APPLICATION_DATACHANGED:
     660                 :            :             {
     661                 :            :                 // Invalidate the preview cache.
     662 [ #  # ][ #  # ]:          0 :                 cache::PageCacheManager::Instance()->InvalidateAllCaches();
                 [ #  # ]
     663                 :            : 
     664                 :            :                 // Update the draw mode.
     665         [ #  # ]:          0 :                 sal_uLong nDrawMode (Application::GetSettings().GetStyleSettings().GetHighContrastMode()
     666                 :            :                     ? ViewShell::OUTPUT_DRAWMODE_CONTRAST
     667         [ #  # ]:          0 :                     : ViewShell::OUTPUT_DRAWMODE_COLOR);
     668 [ #  # ][ #  # ]:          0 :                 if (mrSlideSorter.GetViewShell() != NULL)
     669 [ #  # ][ #  # ]:          0 :                     mrSlideSorter.GetViewShell()->GetFrameView()->SetDrawMode(nDrawMode);
     670         [ #  # ]:          0 :                 if (pActiveWindow != NULL)
     671         [ #  # ]:          0 :                     pActiveWindow->SetDrawMode(nDrawMode);
     672         [ #  # ]:          0 :                 mrView.HandleDrawModeChange();
     673                 :            : 
     674                 :            :                 // When the system font has changed a layout has to be done.
     675         [ #  # ]:          0 :                 mrView.Resize();
     676 [ #  # ][ #  # ]:          0 :                 FontProvider::Instance().Invalidate();
     677                 :            : 
     678                 :            :                 // Update theme colors.
     679 [ #  # ][ #  # ]:          0 :                 mrSlideSorter.GetProperties()->HandleDataChangeEvent();
                 [ #  # ]
     680 [ #  # ][ #  # ]:          0 :                 mrSlideSorter.GetTheme()->Update(mrSlideSorter.GetProperties());
         [ #  # ][ #  # ]
                 [ #  # ]
     681         [ #  # ]:          0 :                 mrView.HandleDataChangeEvent();
     682                 :            :             }
     683                 :          0 :             break;
     684                 :            : 
     685                 :            :             default:
     686                 :     153323 :                 break;
     687         [ +  - ]:     178324 :         }
     688                 :            :     }
     689                 :            : 
     690                 :     178324 :     return sal_True;
     691                 :            : }
     692                 :            : 
     693                 :            : 
     694                 :            : 
     695                 :            : 
     696                 :          0 : void SlideSorterController::GetCtrlState (SfxItemSet& rSet)
     697                 :            : {
     698         [ #  # ]:          0 :     if (rSet.GetItemState(SID_RELOAD) != SFX_ITEM_UNKNOWN)
     699                 :            :     {
     700                 :            :         // "Letzte Version" vom SFx en/disablen lassen
     701                 :          0 :         SfxViewFrame* pSlideViewFrame = SfxViewFrame::Current();
     702                 :            :         DBG_ASSERT(pSlideViewFrame!=NULL,
     703                 :            :             "SlideSorterController::GetCtrlState: ViewFrame not found");
     704         [ #  # ]:          0 :         if (pSlideViewFrame)
     705                 :            :         {
     706                 :          0 :             pSlideViewFrame->GetSlotState (SID_RELOAD, NULL, &rSet);
     707                 :            :         }
     708                 :            :         else        // MI sagt: kein MDIFrame --> disablen
     709                 :            :         {
     710                 :          0 :             rSet.DisableItem(SID_RELOAD);
     711                 :            :         }
     712                 :            :     }
     713                 :            : 
     714                 :            :     // Output quality.
     715   [ #  #  #  #  :          0 :     if (rSet.GetItemState(SID_OUTPUT_QUALITY_COLOR)==SFX_ITEM_AVAILABLE
             #  #  #  # ]
                 [ #  # ]
     716                 :          0 :         ||rSet.GetItemState(SID_OUTPUT_QUALITY_GRAYSCALE)==SFX_ITEM_AVAILABLE
     717                 :          0 :         ||rSet.GetItemState(SID_OUTPUT_QUALITY_BLACKWHITE)==SFX_ITEM_AVAILABLE
     718                 :          0 :         ||rSet.GetItemState(SID_OUTPUT_QUALITY_CONTRAST)==SFX_ITEM_AVAILABLE)
     719                 :            :     {
     720         [ #  # ]:          0 :         if (mrSlideSorter.GetContentWindow())
     721                 :            :         {
     722                 :          0 :             sal_uLong nMode = mrSlideSorter.GetContentWindow()->GetDrawMode();
     723                 :          0 :             sal_uInt16 nQuality = 0;
     724                 :            : 
     725   [ #  #  #  #  :          0 :             switch (nMode)
                      # ]
     726                 :            :             {
     727                 :            :                 case ViewShell::OUTPUT_DRAWMODE_COLOR:
     728                 :          0 :                     nQuality = 0;
     729                 :          0 :                     break;
     730                 :            :                 case ViewShell::OUTPUT_DRAWMODE_GRAYSCALE:
     731                 :          0 :                     nQuality = 1;
     732                 :          0 :                     break;
     733                 :            :                 case ViewShell::OUTPUT_DRAWMODE_BLACKWHITE:
     734                 :          0 :                     nQuality = 2;
     735                 :          0 :                     break;
     736                 :            :                 case ViewShell::OUTPUT_DRAWMODE_CONTRAST:
     737                 :          0 :                     nQuality = 3;
     738                 :          0 :                     break;
     739                 :            :             }
     740                 :            : 
     741                 :            :             rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_COLOR,
     742         [ #  # ]:          0 :                     (sal_Bool)(nQuality==0)));
     743                 :            :             rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_GRAYSCALE,
     744         [ #  # ]:          0 :                     (sal_Bool)(nQuality==1)));
     745                 :            :             rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_BLACKWHITE,
     746         [ #  # ]:          0 :                     (sal_Bool)(nQuality==2)));
     747                 :            :             rSet.Put (SfxBoolItem (SID_OUTPUT_QUALITY_CONTRAST,
     748         [ #  # ]:          0 :                     (sal_Bool)(nQuality==3)));
     749                 :            :         }
     750                 :            :     }
     751                 :            : 
     752         [ #  # ]:          0 :     if (rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) == SFX_ITEM_AVAILABLE)
     753                 :            :     {
     754         [ #  # ]:          0 :         rSet.Put (SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, sal_True));
     755                 :            :     }
     756                 :          0 : }
     757                 :            : 
     758                 :            : 
     759                 :            : 
     760                 :            : 
     761                 :          0 : void SlideSorterController::GetStatusBarState (SfxItemSet& rSet)
     762                 :            : {
     763                 :          0 :     mpSlotManager->GetStatusBarState (rSet);
     764                 :          0 : }
     765                 :            : 
     766                 :            : 
     767                 :            : 
     768                 :            : 
     769                 :          0 : void SlideSorterController::ExecCtrl (SfxRequest& rRequest)
     770                 :            : {
     771                 :          0 :     mpSlotManager->ExecCtrl (rRequest);
     772                 :          0 : }
     773                 :            : 
     774                 :            : 
     775                 :            : 
     776                 :            : 
     777                 :          0 : void SlideSorterController::GetAttrState (SfxItemSet& rSet)
     778                 :            : {
     779                 :          0 :     mpSlotManager->GetAttrState (rSet);
     780                 :          0 : }
     781                 :            : 
     782                 :            : 
     783                 :            : 
     784                 :            : 
     785                 :          0 : void SlideSorterController::ExecStatusBar (SfxRequest& )
     786                 :            : {
     787                 :          0 : }
     788                 :            : 
     789                 :            : 
     790                 :            : 
     791                 :            : 
     792                 :          0 : void SlideSorterController::UpdateAllPages (void)
     793                 :            : {
     794                 :            :     // Do a redraw.
     795         [ #  # ]:          0 :     mrSlideSorter.GetContentWindow()->Invalidate();
     796                 :          0 : }
     797                 :            : 
     798                 :            : 
     799                 :            : 
     800                 :            : 
     801                 :        133 : Rectangle SlideSorterController::Resize (const Rectangle& rAvailableSpace)
     802                 :            : {
     803                 :        133 :     Rectangle aContentArea (rAvailableSpace);
     804                 :            : 
     805         [ +  - ]:        133 :     if (maTotalWindowArea != rAvailableSpace)
     806                 :            :     {
     807                 :        133 :         maTotalWindowArea = rAvailableSpace;
     808                 :        133 :         aContentArea = Rearrange(true);
     809                 :            :     }
     810                 :            : 
     811                 :        133 :     return aContentArea;
     812                 :            : }
     813                 :            : 
     814                 :            : 
     815                 :            : 
     816                 :            : 
     817                 :        570 : Rectangle  SlideSorterController::Rearrange (bool bForce)
     818                 :            : {
     819                 :        570 :     Rectangle aNewContentArea (maTotalWindowArea);
     820                 :            : 
     821 [ +  - ][ +  + ]:        570 :     if (aNewContentArea.IsEmpty())
     822                 :            :         return aNewContentArea;
     823                 :            : 
     824         [ -  + ]:        302 :     if (mnModelChangeLockCount>0)
     825                 :            :     {
     826                 :          0 :         mbIsForcedRearrangePending |= bForce;
     827                 :            :         return aNewContentArea;
     828                 :            :     }
     829                 :            :     else
     830                 :        302 :         mbIsForcedRearrangePending = false;
     831                 :            : 
     832         [ +  - ]:        302 :     SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     833         [ +  - ]:        302 :     if (pWindow)
     834                 :            :     {
     835         [ +  + ]:        302 :         if (bForce)
     836         [ +  - ]:        272 :             mrView.UpdateOrientation();
     837                 :            : 
     838                 :            :         // Place the scroll bars.
     839         [ +  - ]:        302 :         aNewContentArea = GetScrollBarManager().PlaceScrollBars(
     840                 :            :             maTotalWindowArea,
     841         [ +  - ]:        302 :             mrView.GetOrientation() != view::Layouter::VERTICAL,
     842 [ +  - ][ +  - ]:        604 :             mrView.GetOrientation() != view::Layouter::HORIZONTAL);
     843                 :            : 
     844                 :        302 :         bool bSizeHasChanged (false);
     845                 :            :         // Only when bForce is not true we have to test for a size change in
     846                 :            :         // order to determine whether the window and the view have to be resized.
     847         [ +  + ]:        302 :         if ( ! bForce)
     848                 :            :         {
     849 [ +  - ][ +  - ]:         30 :             Rectangle aCurrentContentArea (pWindow->GetPosPixel(), pWindow->GetOutputSizePixel());
     850         [ +  - ]:         30 :             bSizeHasChanged = (aNewContentArea != aCurrentContentArea);
     851                 :            :         }
     852 [ +  + ][ +  + ]:        302 :         if (bForce || bSizeHasChanged)
     853                 :            :         {
     854                 :            :             // The browser window gets the remaining space.
     855 [ +  - ][ +  - ]:        279 :             pWindow->SetPosSizePixel (aNewContentArea.TopLeft(), aNewContentArea.GetSize());
     856         [ +  - ]:        279 :             mrView.Resize();
     857                 :            :         }
     858                 :            : 
     859                 :            :         // Adapt the scroll bars to the new zoom factor of the browser
     860                 :            :         // window and the arrangement of the page objects.
     861 [ +  - ][ +  - ]:        302 :         GetScrollBarManager().UpdateScrollBars(false, !bForce);
     862                 :            : 
     863                 :            :         // Keep the current slide in the visible area.
     864 [ +  - ][ +  - ]:        302 :         GetVisibleAreaManager().RequestCurrentSlideVisible();
     865                 :            : 
     866         [ +  - ]:        302 :         mrView.RequestRepaint();
     867                 :            :     }
     868                 :            : 
     869         [ +  - ]:        570 :     return aNewContentArea;
     870                 :            : }
     871                 :            : 
     872                 :            : 
     873                 :            : 
     874                 :            : 
     875                 :        130 : FunctionReference SlideSorterController::CreateSelectionFunction (SfxRequest& rRequest)
     876                 :            : {
     877                 :        130 :     FunctionReference xFunc( SelectionFunction::Create(mrSlideSorter, rRequest) );
     878                 :        130 :     return xFunc;
     879                 :            : }
     880                 :            : 
     881                 :            : 
     882                 :            : 
     883                 :            : 
     884                 :          0 : ::rtl::Reference<SelectionFunction> SlideSorterController::GetCurrentSelectionFunction (void)
     885                 :            : {
     886 [ #  # ][ #  # ]:          0 :     FunctionReference pFunction (mrSlideSorter.GetViewShell()->GetCurrentFunction());
     887 [ #  # ][ #  # ]:          0 :     return ::rtl::Reference<SelectionFunction>(dynamic_cast<SelectionFunction*>(pFunction.get()));
                 [ #  # ]
     888                 :            : }
     889                 :            : 
     890                 :            : 
     891                 :            : 
     892                 :            : 
     893                 :          0 : void SlideSorterController::PrepareEditModeChange (void)
     894                 :            : {
     895                 :            :     //  Before we throw away the page descriptors we prepare for selecting
     896                 :            :     //  descriptors in the other mode and for restoring the current
     897                 :            :     //  selection when switching back to the current mode.
     898         [ #  # ]:          0 :     if (mrModel.GetEditMode() == EM_PAGE)
     899                 :            :     {
     900                 :          0 :         maSelectionBeforeSwitch.clear();
     901                 :            : 
     902                 :            :         // Search for the first selected page and determine the master page
     903                 :            :         // used by its page object.  It will be selected after the switch.
     904                 :            :         // In the same loop the current selection is stored.
     905                 :            :         PageEnumeration aSelectedPages (
     906         [ #  # ]:          0 :             PageEnumerationProvider::CreateSelectedPagesEnumeration(mrModel));
     907 [ #  # ][ #  # ]:          0 :         while (aSelectedPages.HasMoreElements())
     908                 :            :         {
     909         [ #  # ]:          0 :             SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
     910         [ #  # ]:          0 :             SdPage* pPage = pDescriptor->GetPage();
     911                 :            :             // Remember the master page of the first selected descriptor.
     912 [ #  # ][ #  # ]:          0 :             if (pPage!=NULL && mpEditModeChangeMasterPage==NULL)
     913                 :            :                 mpEditModeChangeMasterPage = &static_cast<SdPage&>(
     914         [ #  # ]:          0 :                     pPage->TRG_GetMasterPage());
     915                 :            : 
     916         [ #  # ]:          0 :             maSelectionBeforeSwitch.push_back(pPage);
     917         [ #  # ]:          0 :         }
     918                 :            : 
     919                 :            :         // Remember the current page.
     920 [ #  # ][ #  # ]:          0 :         if (mrSlideSorter.GetViewShell() != NULL)
     921 [ #  # ][ #  # ]:          0 :             mnCurrentPageBeforeSwitch = (mrSlideSorter.GetViewShell()->GetViewShellBase()
     922 [ #  # ][ #  # ]:          0 :             .GetMainViewShell()->GetActualPage()->GetPageNum()-1)/2;
         [ #  # ][ #  # ]
                 [ #  # ]
     923                 :            :     }
     924                 :          0 : }
     925                 :            : 
     926                 :            : 
     927                 :            : 
     928                 :            : 
     929                 :          0 : bool SlideSorterController::ChangeEditMode (EditMode eEditMode)
     930                 :            : {
     931                 :          0 :     bool bResult (false);
     932         [ #  # ]:          0 :     if (mrModel.GetEditMode() != eEditMode)
     933                 :            :     {
     934                 :          0 :         ModelChangeLock aLock (*this);
     935         [ #  # ]:          0 :         PreModelChange();
     936                 :            :         // Do the actual edit mode switching.
     937         [ #  # ]:          0 :         bResult = mrModel.SetEditMode(eEditMode);
     938         [ #  # ]:          0 :         if (bResult)
     939 [ #  # ][ #  # ]:          0 :             HandleModelChange();
     940                 :            :     }
     941                 :          0 :     return bResult;
     942                 :            : }
     943                 :            : 
     944                 :            : 
     945                 :            : 
     946                 :            : 
     947                 :          0 : void SlideSorterController::FinishEditModeChange (void)
     948                 :            : {
     949         [ #  # ]:          0 :     if (mrModel.GetEditMode() == EM_MASTERPAGE)
     950                 :            :     {
     951                 :            :         // Search for the master page that was determined in
     952                 :            :         // PrepareEditModeChange() and make it the current page.
     953         [ #  # ]:          0 :         PageEnumeration aAllPages (PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
     954 [ #  # ][ #  # ]:          0 :         while (aAllPages.HasMoreElements())
     955                 :            :         {
     956         [ #  # ]:          0 :             SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
     957 [ #  # ][ #  # ]:          0 :             if (pDescriptor->GetPage() == mpEditModeChangeMasterPage)
     958                 :            :             {
     959 [ #  # ][ #  # ]:          0 :                 GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor);
                 [ #  # ]
     960                 :            :                 break;
     961                 :            :             }
     962 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
     963                 :            :     }
     964                 :            :     else
     965                 :            :     {
     966         [ #  # ]:          0 :         SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(mnCurrentPageBeforeSwitch));
     967 [ #  # ][ #  # ]:          0 :         GetCurrentSlideManager()->SwitchCurrentSlide(pDescriptor);
                 [ #  # ]
     968                 :            : 
     969                 :            :         // Restore the selection.
     970                 :          0 :         ::std::vector<SdPage*>::iterator iPage;
     971 [ #  # ][ #  # ]:          0 :         for (iPage=maSelectionBeforeSwitch.begin();
     972                 :          0 :              iPage!=maSelectionBeforeSwitch.end();
     973                 :            :              ++iPage)
     974                 :            :         {
     975         [ #  # ]:          0 :             mpPageSelector->SelectPage(*iPage);
     976                 :            :         }
     977         [ #  # ]:          0 :         maSelectionBeforeSwitch.clear( );
     978                 :            :     }
     979                 :          0 :     mpEditModeChangeMasterPage = NULL;
     980                 :          0 : }
     981                 :            : 
     982                 :            : 
     983                 :            : 
     984                 :            : 
     985                 :          0 : void SlideSorterController::PageNameHasChanged (int nPageIndex, const String& rsOldName)
     986                 :            : {
     987                 :            :     // Request a repaint for the page object whose name has changed.
     988         [ #  # ]:          0 :     model::SharedPageDescriptor pDescriptor (mrModel.GetPageDescriptor(nPageIndex));
     989         [ #  # ]:          0 :     if (pDescriptor.get() != NULL)
     990         [ #  # ]:          0 :         mrView.RequestRepaint(pDescriptor);
     991                 :            : 
     992                 :            :     // Get a pointer to the corresponding accessible object and notify
     993                 :            :     // that of the name change.
     994         [ #  # ]:          0 :         SharedSdWindow pWindow (mrSlideSorter.GetContentWindow());
     995         [ #  # ]:          0 :         if ( ! pWindow)
     996                 :            :             return;
     997                 :            : 
     998                 :            :     ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible >
     999         [ #  # ]:          0 :         xAccessible (pWindow->GetAccessible(sal_False));
    1000         [ #  # ]:          0 :     if ( ! xAccessible.is())
    1001                 :            :         return;
    1002                 :            : 
    1003                 :            :     // Now comes a small hack.  We assume that the accessible object is
    1004                 :            :     // an instantiation of AccessibleSlideSorterView and cast it to that
    1005                 :            :     // class.  The cleaner alternative to this cast would be a new member
    1006                 :            :     // in which we would store the last AccessibleSlideSorterView object
    1007                 :            :     // created by SlideSorterViewShell::CreateAccessibleDocumentView().
    1008                 :            :     // But then there is no guaranty that the accessible object obtained
    1009                 :            :     // from the window really is that instance last created by
    1010                 :            :     // CreateAccessibleDocumentView().
    1011                 :            :     // However, the dynamic cast together with the check of the result
    1012                 :            :     // being NULL should be safe enough.
    1013                 :            :     ::accessibility::AccessibleSlideSorterView* pAccessibleView
    1014 [ #  # ][ #  # ]:          0 :             = dynamic_cast< ::accessibility::AccessibleSlideSorterView*>(xAccessible.get());
    1015         [ #  # ]:          0 :     if (pAccessibleView == NULL)
    1016                 :            :         return;
    1017                 :            : 
    1018                 :            :     ::accessibility::AccessibleSlideSorterObject* pChild
    1019         [ #  # ]:          0 :             = pAccessibleView->GetAccessibleChildImplementation(nPageIndex);
    1020 [ #  # ][ #  # ]:          0 :     if (pChild == NULL || pChild->GetPage() == NULL)
         [ #  # ][ #  # ]
    1021                 :            :         return;
    1022                 :            : 
    1023         [ #  # ]:          0 :     ::rtl::OUString sOldName (rsOldName);
    1024 [ #  # ][ #  # ]:          0 :     ::rtl::OUString sNewName (pChild->GetPage()->GetName());
                 [ #  # ]
    1025                 :            :     pChild->FireAccessibleEvent(
    1026                 :            :         ::com::sun::star::accessibility::AccessibleEventId::NAME_CHANGED,
    1027                 :            :         makeAny(sOldName),
    1028 [ #  # ][ #  # ]:          0 :         makeAny(sNewName));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1029                 :            : }
    1030                 :            : 
    1031                 :            : 
    1032                 :            : 
    1033                 :            : 
    1034                 :        130 : void SlideSorterController::SetDocumentSlides (const Reference<container::XIndexAccess>& rxSlides)
    1035                 :            : {
    1036 [ +  - ][ +  - ]:        130 :     if (mrModel.GetDocumentSlides() != rxSlides)
    1037                 :            :     {
    1038                 :        130 :         ModelChangeLock aLock (*this);
    1039         [ +  - ]:        130 :         PreModelChange();
    1040                 :            : 
    1041         [ +  - ]:        130 :         mrModel.SetDocumentSlides(rxSlides);
    1042         [ +  - ]:        130 :         mrView.Layout();
    1043                 :            : 
    1044                 :            :         // Select just the current slide.
    1045         [ +  - ]:        130 :         PageSelector::BroadcastLock aBroadcastLock (*mpPageSelector);
    1046         [ +  - ]:        130 :         mpPageSelector->DeselectAllPages();
    1047 [ +  - ][ +  - ]:        130 :         mpPageSelector->SelectPage(mpCurrentSlideManager->GetCurrentSlide());
         [ +  - ][ +  - ]
                 [ +  - ]
    1048                 :            :     }
    1049                 :        130 : }
    1050                 :            : 
    1051                 :            : 
    1052                 :            : 
    1053                 :            : 
    1054                 :        130 : ::boost::shared_ptr<Animator> SlideSorterController::GetAnimator (void) const
    1055                 :            : {
    1056                 :        130 :     return mpAnimator;
    1057                 :            : }
    1058                 :            : 
    1059                 :            : 
    1060                 :            : 
    1061                 :            : 
    1062                 :       1106 : VisibleAreaManager& SlideSorterController::GetVisibleAreaManager (void) const
    1063                 :            : {
    1064                 :            :     OSL_ASSERT(mpVisibleAreaManager);
    1065                 :       1106 :     return *mpVisibleAreaManager;
    1066                 :            : }
    1067                 :            : 
    1068                 :            : 
    1069                 :            : 
    1070                 :            : 
    1071                 :       2270 : void SlideSorterController::CheckForMasterPageAssignment (void)
    1072                 :            : {
    1073 [ +  - ][ +  + ]:       2270 :     if (mrModel.GetPageCount()%2==0)
    1074                 :       2270 :         return;
    1075         [ +  - ]:       1984 :     PageEnumeration aAllPages (PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
    1076 [ +  - ][ +  + ]:       4140 :     while (aAllPages.HasMoreElements())
    1077                 :            :     {
    1078         [ +  - ]:       2156 :         SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
    1079 [ +  - ][ +  + ]:       2156 :         if (pDescriptor->UpdateMasterPage())
    1080                 :            :         {
    1081                 :            :             mrView.GetPreviewCache()->InvalidatePreviewBitmap (
    1082         [ +  - ]:         10 :                 pDescriptor->GetPage(),
    1083 [ +  - ][ +  - ]:         10 :                 true);
                 [ +  - ]
    1084                 :            :         }
    1085 [ +  - ][ +  - ]:       4426 :     }
    1086                 :            : }
    1087                 :            : 
    1088                 :            : 
    1089                 :            : 
    1090                 :            : 
    1091                 :       2270 : void SlideSorterController::CheckForSlideTransitionAssignment (void)
    1092                 :            : {
    1093 [ +  - ][ +  + ]:       2270 :     if (mrModel.GetPageCount()%2==0)
    1094                 :       2270 :         return;
    1095         [ +  - ]:       1984 :     PageEnumeration aAllPages (PageEnumerationProvider::CreateAllPagesEnumeration(mrModel));
    1096 [ +  - ][ +  + ]:       4140 :     while (aAllPages.HasMoreElements())
    1097                 :            :     {
    1098         [ +  - ]:       2156 :         SharedPageDescriptor pDescriptor (aAllPages.GetNextElement());
    1099 [ +  - ][ -  + ]:       2156 :         if (pDescriptor->UpdateTransitionFlag())
    1100                 :            :         {
    1101                 :            :             mrView.GetPreviewCache()->InvalidatePreviewBitmap (
    1102         [ #  # ]:          0 :                 pDescriptor->GetPage(),
    1103 [ #  # ][ #  # ]:          0 :                 true);
                 [ #  # ]
    1104                 :            :         }
    1105 [ +  - ][ +  - ]:       4426 :     }
    1106                 :            : }
    1107                 :            : 
    1108                 :            : 
    1109                 :            : 
    1110                 :            : 
    1111                 :            : //===== SlideSorterController::ModelChangeLock ================================
    1112                 :            : 
    1113                 :        162 : SlideSorterController::ModelChangeLock::ModelChangeLock (
    1114                 :            :     SlideSorterController& rController)
    1115                 :        162 :     : mpController(&rController)
    1116                 :            : {
    1117                 :        162 :     mpController->LockModelChange();
    1118                 :        162 : }
    1119                 :            : 
    1120                 :            : 
    1121                 :            : 
    1122                 :            : 
    1123                 :        162 : SlideSorterController::ModelChangeLock::~ModelChangeLock (void)
    1124                 :            : {
    1125                 :        162 :     Release();
    1126                 :        162 : }
    1127                 :            : 
    1128                 :            : 
    1129                 :            : 
    1130                 :            : 
    1131                 :        162 : void SlideSorterController::ModelChangeLock::Release (void)
    1132                 :            : {
    1133         [ +  - ]:        162 :     if (mpController != NULL)
    1134                 :            :     {
    1135                 :        162 :         mpController->UnlockModelChange();
    1136                 :        162 :         mpController = NULL;
    1137                 :            :     }
    1138                 :        162 : }
    1139                 :            : 
    1140                 :            : } } } // end of namespace ::sd::slidesorter
    1141                 :            : 
    1142                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10