LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/model - SlsPageDescriptor.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 68 98 69.4 %
Date: 2015-06-13 12:38:46 Functions: 12 14 85.7 %
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             : #include "model/SlsPageDescriptor.hxx"
      21             : 
      22             : #include "sdpage.hxx"
      23             : #include "drawdoc.hxx"
      24             : 
      25             : #include <svx/svdopage.hxx>
      26             : #include <svx/svdpagv.hxx>
      27             : #include <svx/sdr/contact/viewcontact.hxx>
      28             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      29             : 
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star;
      32             : 
      33             : namespace sd {  namespace slidesorter { namespace model {
      34             : 
      35          91 : PageDescriptor::PageDescriptor (
      36             :     const Reference<drawing::XDrawPage>& rxPage,
      37             :     SdPage* pPage,
      38             :     const sal_Int32 nIndex)
      39             :     : mpPage(pPage),
      40             :       mxPage(rxPage),
      41             :       mpMasterPage(NULL),
      42             :       mnIndex(nIndex),
      43             :       maBoundingBox(),
      44             :       maVisualState(nIndex),
      45             :       mbIsSelected(false),
      46             :       mbWasSelected(false),
      47             :       mbIsVisible(false),
      48             :       mbIsFocused(false),
      49             :       mbIsCurrent(false),
      50             :       mbIsMouseOver(false),
      51          91 :       mbHasTransition(false)
      52             : {
      53             :     OSL_ASSERT(mpPage);
      54             :     OSL_ASSERT(mpPage == SdPage::getImplementation(rxPage));
      55          91 :     if (mpPage != NULL)
      56             :     {
      57          91 :         if (mpPage->TRG_HasMasterPage())
      58          73 :             mpMasterPage = &mpPage->TRG_GetMasterPage();
      59          91 :         if (mpPage->getTransitionType() > 0)
      60           0 :             mbHasTransition = true;
      61             :     }
      62          91 : }
      63             : 
      64          91 : PageDescriptor::~PageDescriptor()
      65             : {
      66          91 : }
      67             : 
      68           5 : void PageDescriptor::SetPageIndex (const sal_Int32 nNewIndex)
      69             : {
      70           5 :     mnIndex = nNewIndex;
      71           5 :     maVisualState.mnPageId = nNewIndex;
      72           5 : }
      73             : 
      74        1068 : bool PageDescriptor::UpdateMasterPage()
      75             : {
      76        1068 :     const SdrPage* pMaster = NULL;
      77        1068 :     if (mpPage!=NULL && mpPage->TRG_HasMasterPage())
      78        1068 :         pMaster = &mpPage->TRG_GetMasterPage();
      79        1068 :     if (mpMasterPage != pMaster)
      80             :     {
      81           5 :         mpMasterPage = pMaster;
      82           5 :         return true;
      83             :     }
      84             :     else
      85        1063 :         return false;
      86             : }
      87             : 
      88        1068 : bool PageDescriptor::UpdateTransitionFlag()
      89             : {
      90        1068 :     bool bHasSlideTransition (false);
      91        1068 :     if (mpPage != NULL)
      92        1068 :         bHasSlideTransition = mpPage->getTransitionType() > 0;
      93        1068 :     if (bHasSlideTransition != mbHasTransition)
      94             :     {
      95           0 :         mbHasTransition = bHasSlideTransition;
      96           0 :         return true;
      97             :     }
      98             :     else
      99        1068 :         return false;
     100             : }
     101             : 
     102        5002 : bool PageDescriptor::HasState (const State eState) const
     103             : {
     104        5002 :     switch (eState)
     105             :     {
     106             :         case ST_Visible:
     107        1236 :             return mbIsVisible;
     108             : 
     109             :         case ST_Selected:
     110        1484 :             return mbIsSelected;
     111             : 
     112             :         case ST_WasSelected:
     113           0 :             return mbWasSelected;
     114             : 
     115             :         case ST_Focused:
     116         488 :             return mbIsFocused;
     117             : 
     118             :         case ST_MouseOver:
     119         640 :             return mbIsMouseOver;
     120             : 
     121             :         case ST_Current:
     122         417 :             return mbIsCurrent;
     123             : 
     124             :         case ST_Excluded:
     125         737 :             return mpPage!=NULL && mpPage->IsExcluded();
     126             : 
     127             :         default:
     128             :             OSL_ASSERT(false);
     129           0 :             return false;
     130             :     }
     131             : }
     132             : 
     133         745 : bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
     134             : {
     135         745 :     bool bModified (false);
     136         745 :     switch (eState)
     137             :     {
     138             :         case ST_Visible:
     139         101 :             bModified = (bNewStateValue!=mbIsVisible);
     140         101 :             if (bModified)
     141          75 :                 mbIsVisible = bNewStateValue;
     142         101 :             break;
     143             : 
     144             :         case ST_Selected:
     145         379 :             bModified = (bNewStateValue!=mbIsSelected);
     146         379 :             if (bModified)
     147         241 :                 mbIsSelected = bNewStateValue;
     148         379 :             break;
     149             : 
     150             :         case ST_WasSelected:
     151           0 :             bModified = (bNewStateValue!=mbWasSelected);
     152           0 :             if (bModified)
     153           0 :                 mbWasSelected = bNewStateValue;
     154           0 :             break;
     155             : 
     156             :         case ST_Focused:
     157          82 :             bModified = (bNewStateValue!=mbIsFocused);
     158          82 :             if (bModified)
     159           0 :                 mbIsFocused = bNewStateValue;
     160          82 :             break;
     161             : 
     162             :         case ST_MouseOver:
     163           0 :             bModified = (bNewStateValue!=mbIsMouseOver);
     164           0 :             if (bModified)
     165           0 :                 mbIsMouseOver = bNewStateValue;
     166           0 :             break;
     167             : 
     168             :         case ST_Current:
     169         183 :             bModified = (bNewStateValue!=mbIsCurrent);
     170         183 :             if (bModified)
     171         101 :                 mbIsCurrent = bNewStateValue;
     172         183 :             break;
     173             : 
     174             :         case ST_Excluded:
     175             :             // This is a state of the page and has to be handled differently
     176             :             // from the view-only states.
     177           0 :             if (mpPage != NULL)
     178           0 :                 if (bNewStateValue != mpPage->IsExcluded())
     179             :                 {
     180           0 :                     mpPage->SetExcluded(bNewStateValue);
     181           0 :                     bModified = true;
     182             :                 }
     183           0 :             break;
     184             :     }
     185             : 
     186         745 :     if (bModified)
     187         417 :         maVisualState.UpdateVisualState(*this);
     188         745 :     return bModified;
     189             : }
     190             : 
     191           0 : bool PageDescriptor::GetCoreSelection()
     192             : {
     193           0 :     if (mpPage!=NULL && mpPage->IsSelected() != mbIsSelected)
     194           0 :         return SetState(ST_Selected, !mbIsSelected);
     195             :     else
     196           0 :         return false;
     197             : }
     198             : 
     199           0 : void PageDescriptor::SetCoreSelection()
     200             : {
     201           0 :     if (mpPage != NULL)
     202           0 :         if (HasState(ST_Selected))
     203           0 :             mpPage->SetSelected(true);
     204             :         else
     205           0 :             mpPage->SetSelected(false);
     206             :     else
     207             :     {
     208             :         OSL_ASSERT(mpPage!=NULL);
     209             :     }
     210           0 : }
     211             : 
     212         406 : Rectangle PageDescriptor::GetBoundingBox() const
     213             : {
     214         406 :     Rectangle aBox (maBoundingBox);
     215         406 :     const Point aOffset (maVisualState.GetLocationOffset());
     216         406 :     aBox.Move(aOffset.X(), aOffset.Y());
     217         406 :     return aBox;
     218             : }
     219             : 
     220        1920 : Point PageDescriptor::GetLocation (const bool bIgnoreOffset) const
     221             : {
     222        1920 :     if (bIgnoreOffset)
     223           0 :         return maBoundingBox.TopLeft();
     224             :     else
     225        1920 :         return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
     226             : }
     227             : 
     228         196 : void PageDescriptor::SetBoundingBox (const Rectangle& rBoundingBox)
     229             : {
     230         196 :     maBoundingBox = rBoundingBox;
     231         196 : }
     232             : 
     233          66 : } } } // end of namespace ::sd::slidesorter::model
     234             : 
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11