LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/slidesorter/controller - SlsSelectionObserver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 55 0.0 %
Date: 2012-12-27 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "SlideSorter.hxx"
      22             : #include "controller/SlideSorterController.hxx"
      23             : #include "controller/SlsSelectionManager.hxx"
      24             : #include "controller/SlsSelectionObserver.hxx"
      25             : #include "controller/SlsPageSelector.hxx"
      26             : #include "controller/SlsFocusManager.hxx"
      27             : #include "model/SlideSorterModel.hxx"
      28             : #include "model/SlsPageDescriptor.hxx"
      29             : #include <svx/svdmodel.hxx>
      30             : #include "drawdoc.hxx"
      31             : 
      32             : 
      33             : namespace sd { namespace slidesorter { namespace controller {
      34             : 
      35           0 : SelectionObserver::Context::Context (SlideSorter& rSlideSorter)
      36             :     : mpSelectionObserver(
      37           0 :         rSlideSorter.GetController().GetSelectionManager()->GetSelectionObserver())
      38             : {
      39           0 :     if (mpSelectionObserver)
      40           0 :         mpSelectionObserver->StartObservation();
      41           0 : }
      42             : 
      43             : 
      44             : 
      45             : 
      46           0 : SelectionObserver::Context::~Context(void)
      47             : {
      48           0 :     if (mpSelectionObserver)
      49           0 :         mpSelectionObserver->EndObservation();
      50           0 : }
      51             : 
      52             : 
      53             : 
      54             : 
      55           0 : void SelectionObserver::Context::Abort(void)
      56             : {
      57           0 :     if (mpSelectionObserver)
      58             :     {
      59           0 :         mpSelectionObserver->AbortObservation();
      60           0 :         mpSelectionObserver.reset();
      61             :     }
      62           0 : }
      63             : 
      64             : 
      65             : 
      66             : 
      67             : //===== SelectionObserver =====================================================
      68             : 
      69           0 : SelectionObserver::SelectionObserver (SlideSorter& rSlideSorter)
      70             :     : mrSlideSorter(rSlideSorter),
      71           0 :       mpDocument(mrSlideSorter.GetModel().GetDocument()),
      72             :       mbIsOvservationActive(false),
      73             :       maInsertedPages(),
      74           0 :       maDeletedPages()
      75             : {
      76           0 : }
      77             : 
      78             : 
      79             : 
      80             : 
      81           0 : SelectionObserver::~SelectionObserver (void)
      82             : {
      83           0 : }
      84             : 
      85             : 
      86             : 
      87             : 
      88           0 : void SelectionObserver::NotifyPageEvent (const SdrPage* pSdrPage)
      89             : {
      90           0 :     if ( ! mbIsOvservationActive)
      91             :         return;
      92             : 
      93           0 :     const SdPage* pPage = dynamic_cast<const SdPage*>(pSdrPage);
      94           0 :     if (pPage == NULL)
      95             :         return;
      96             : 
      97           0 :     if (pPage->IsInserted())
      98           0 :         maInsertedPages.push_back(pPage);
      99             :     else
     100             :     {
     101             :         ::std::vector<const SdPage*>::iterator iPage(
     102           0 :             ::std::find(maInsertedPages.begin(), maInsertedPages.end(), pPage));
     103           0 :         if (iPage != maInsertedPages.end())
     104           0 :             maInsertedPages.erase(iPage);
     105             : 
     106           0 :         maDeletedPages.push_back(pPage->GetPageNum());
     107             :     }
     108             : }
     109             : 
     110             : 
     111             : 
     112           0 : void SelectionObserver::StartObservation (void)
     113             : {
     114             :     OSL_ASSERT(!mbIsOvservationActive);
     115           0 :     maInsertedPages.clear();
     116           0 :     maDeletedPages.clear();
     117           0 :     mbIsOvservationActive = true;
     118           0 : }
     119             : 
     120             : 
     121             : 
     122             : 
     123           0 : void SelectionObserver::AbortObservation (void)
     124             : {
     125             :     OSL_ASSERT(mbIsOvservationActive);
     126           0 :     mbIsOvservationActive = false;
     127           0 :     maInsertedPages.clear();
     128           0 :     maDeletedPages.clear();
     129           0 : }
     130             : 
     131             : 
     132             : 
     133             : 
     134           0 : void SelectionObserver::EndObservation (void)
     135             : {
     136             :     OSL_ASSERT(mbIsOvservationActive);
     137           0 :     mbIsOvservationActive = false;
     138             : 
     139           0 :     PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
     140           0 :     PageSelector::UpdateLock aUpdateLock (mrSlideSorter);
     141           0 :     rSelector.DeselectAllPages();
     142           0 :     if ( ! maInsertedPages.empty())
     143             :     {
     144             :         // Select the inserted pages.
     145           0 :         for (::std::vector<const SdPage*>::const_iterator
     146           0 :                  iPage(maInsertedPages.begin()),
     147           0 :                  iEnd(maInsertedPages.end());
     148             :              iPage!=iEnd;
     149             :              ++iPage)
     150             :         {
     151           0 :             rSelector.SelectPage(*iPage);
     152             :         }
     153           0 :         maInsertedPages.clear();
     154             :     }
     155           0 :     maDeletedPages.clear();
     156             : 
     157           0 :     aUpdateLock.Release();
     158           0 :     mrSlideSorter.GetController().GetFocusManager().SetFocusedPageToCurrentPage();
     159             : 
     160           0 : }
     161             : 
     162             : 
     163             : 
     164             : } } } // end of namespace ::sd::slidesorter::controller
     165             : 
     166             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10