LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/model - SlsPageDescriptor.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 75 105 71.4 %
Date: 2014-04-11 Functions: 14 16 87.5 %
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 "model/SlsPageDescriptor.hxx"
      22             : 
      23             : #include "sdpage.hxx"
      24             : #include "drawdoc.hxx"
      25             : 
      26             : #include <svx/svdopage.hxx>
      27             : #include <svx/svdpagv.hxx>
      28             : #include <svx/sdr/contact/viewcontact.hxx>
      29             : #include <svx/sdr/contact/viewobjectcontact.hxx>
      30             : 
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star;
      33             : 
      34             : namespace sd {  namespace slidesorter { namespace model {
      35             : 
      36             : 
      37          73 : PageDescriptor::PageDescriptor (
      38             :     const Reference<drawing::XDrawPage>& rxPage,
      39             :     SdPage* pPage,
      40             :     const sal_Int32 nIndex)
      41             :     : mpPage(pPage),
      42             :       mxPage(rxPage),
      43             :       mpMasterPage(NULL),
      44             :       mnIndex(nIndex),
      45             :       maBoundingBox(),
      46             :       maVisualState(nIndex),
      47             :       mbIsSelected(false),
      48             :       mbWasSelected(false),
      49             :       mbIsVisible(false),
      50             :       mbIsFocused(false),
      51             :       mbIsCurrent(false),
      52             :       mbIsMouseOver(false),
      53          73 :       mbHasTransition(false)
      54             : {
      55             :     OSL_ASSERT(mpPage);
      56             :     OSL_ASSERT(mpPage == SdPage::getImplementation(rxPage));
      57          73 :     if (mpPage != NULL)
      58             :     {
      59          73 :         if (mpPage->TRG_HasMasterPage())
      60          63 :             mpMasterPage = &mpPage->TRG_GetMasterPage();
      61          73 :         if (mpPage->getTransitionType() > 0)
      62           0 :             mbHasTransition = true;
      63             :     }
      64          73 : }
      65             : 
      66             : 
      67             : 
      68             : 
      69          73 : PageDescriptor::~PageDescriptor (void)
      70             : {
      71          73 : }
      72             : 
      73             : 
      74             : 
      75             : 
      76        3731 : SdPage* PageDescriptor::GetPage (void) const
      77             : {
      78        3731 :     return mpPage;
      79             : }
      80             : 
      81             : 
      82             : 
      83             : 
      84         189 : Reference<drawing::XDrawPage> PageDescriptor::GetXDrawPage (void) const
      85             : {
      86         189 :     return mxPage;
      87             : }
      88             : 
      89             : 
      90             : 
      91             : 
      92         546 : sal_Int32 PageDescriptor::GetPageIndex (void) const
      93             : {
      94         546 :     return mnIndex;
      95             : }
      96             : 
      97             : 
      98             : 
      99             : 
     100           5 : void PageDescriptor::SetPageIndex (const sal_Int32 nNewIndex)
     101             : {
     102           5 :     mnIndex = nNewIndex;
     103           5 :     maVisualState.mnPageId = nNewIndex;
     104           5 : }
     105             : 
     106             : 
     107             : 
     108             : 
     109        1068 : bool PageDescriptor::UpdateMasterPage (void)
     110             : {
     111        1068 :     const SdrPage* pMaster = NULL;
     112        1068 :     if (mpPage!=NULL && mpPage->TRG_HasMasterPage())
     113        1068 :         pMaster = &mpPage->TRG_GetMasterPage();
     114        1068 :     if (mpMasterPage != pMaster)
     115             :     {
     116           5 :         mpMasterPage = pMaster;
     117           5 :         return true;
     118             :     }
     119             :     else
     120        1063 :         return false;
     121             : }
     122             : 
     123             : 
     124             : 
     125             : 
     126        1068 : bool PageDescriptor::UpdateTransitionFlag (void)
     127             : {
     128        1068 :     bool bHasSlideTransition (false);
     129        1068 :     if (mpPage != NULL)
     130        1068 :         bHasSlideTransition = mpPage->getTransitionType() > 0;
     131        1068 :     if (bHasSlideTransition != mbHasTransition)
     132             :     {
     133           0 :         mbHasTransition = bHasSlideTransition;
     134           0 :         return true;
     135             :     }
     136             :     else
     137        1068 :         return false;
     138             : }
     139             : 
     140             : 
     141             : 
     142             : 
     143        5350 : bool PageDescriptor::HasState (const State eState) const
     144             : {
     145        5350 :     switch (eState)
     146             :     {
     147             :         case ST_Visible:
     148        1372 :             return mbIsVisible;
     149             : 
     150             :         case ST_Selected:
     151        1447 :             return mbIsSelected;
     152             : 
     153             :         case ST_WasSelected:
     154           0 :             return mbWasSelected;
     155             : 
     156             :         case ST_Focused:
     157         551 :             return mbIsFocused;
     158             : 
     159             :         case ST_MouseOver:
     160         692 :             return mbIsMouseOver;
     161             : 
     162             :         case ST_Current:
     163         471 :             return mbIsCurrent;
     164             : 
     165             :         case ST_Excluded:
     166         817 :             return mpPage!=NULL && mpPage->IsExcluded();
     167             : 
     168             :         default:
     169             :             OSL_ASSERT(false);
     170           0 :             return false;
     171             :     }
     172             : }
     173             : 
     174             : 
     175             : 
     176             : 
     177         785 : bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
     178             : {
     179         785 :     bool bModified (false);
     180         785 :     switch (eState)
     181             :     {
     182             :         case ST_Visible:
     183         101 :             bModified = (bNewStateValue!=mbIsVisible);
     184         101 :             if (bModified)
     185          73 :                 mbIsVisible = bNewStateValue;
     186         101 :             break;
     187             : 
     188             :         case ST_Selected:
     189         272 :             bModified = (bNewStateValue!=mbIsSelected);
     190         272 :             if (bModified)
     191         197 :                 mbIsSelected = bNewStateValue;
     192         272 :             break;
     193             : 
     194             :         case ST_WasSelected:
     195           0 :             bModified = (bNewStateValue!=mbWasSelected);
     196           0 :             if (bModified)
     197           0 :                 mbWasSelected = bNewStateValue;
     198           0 :             break;
     199             : 
     200             :         case ST_Focused:
     201         132 :             bModified = (bNewStateValue!=mbIsFocused);
     202         132 :             if (bModified)
     203           0 :                 mbIsFocused = bNewStateValue;
     204         132 :             break;
     205             : 
     206             :         case ST_MouseOver:
     207           0 :             bModified = (bNewStateValue!=mbIsMouseOver);
     208           0 :             if (bModified)
     209           0 :                 mbIsMouseOver = bNewStateValue;
     210           0 :             break;
     211             : 
     212             :         case ST_Current:
     213         280 :             bModified = (bNewStateValue!=mbIsCurrent);
     214         280 :             if (bModified)
     215         201 :                 mbIsCurrent = bNewStateValue;
     216         280 :             break;
     217             : 
     218             :         case ST_Excluded:
     219             :             // This is a state of the page and has to be handled differently
     220             :             // from the view-only states.
     221           0 :             if (mpPage != NULL)
     222           0 :                 if (bNewStateValue != (mpPage->IsExcluded()==sal_True))
     223             :                 {
     224           0 :                     mpPage->SetExcluded(bNewStateValue);
     225           0 :                     bModified = true;
     226             :                 }
     227           0 :             break;
     228             :     }
     229             : 
     230         785 :     if (bModified)
     231         471 :         maVisualState.UpdateVisualState(*this);
     232         785 :     return bModified;
     233             : }
     234             : 
     235             : 
     236             : 
     237             : 
     238         122 : VisualState& PageDescriptor::GetVisualState (void)
     239             : {
     240         122 :     return maVisualState;
     241             : }
     242             : 
     243             : 
     244             : 
     245             : 
     246           0 : bool PageDescriptor::GetCoreSelection (void)
     247             : {
     248           0 :     if (mpPage!=NULL && (mpPage->IsSelected()==sal_True) != mbIsSelected)
     249           0 :         return SetState(ST_Selected, !mbIsSelected);
     250             :     else
     251           0 :         return false;
     252             : }
     253             : 
     254             : 
     255             : 
     256             : 
     257           0 : void PageDescriptor::SetCoreSelection (void)
     258             : {
     259           0 :     if (mpPage != NULL)
     260           0 :         if (HasState(ST_Selected))
     261           0 :             mpPage->SetSelected(sal_True);
     262             :         else
     263           0 :             mpPage->SetSelected(sal_False);
     264             :     else
     265             :     {
     266             :         OSL_ASSERT(mpPage!=NULL);
     267             :     }
     268           0 : }
     269             : 
     270             : 
     271             : 
     272             : 
     273         361 : Rectangle PageDescriptor::GetBoundingBox (void) const
     274             : {
     275         361 :     Rectangle aBox (maBoundingBox);
     276         361 :     const Point aOffset (maVisualState.GetLocationOffset());
     277         361 :     aBox.Move(aOffset.X(), aOffset.Y());
     278         361 :     return aBox;
     279             : }
     280             : 
     281             : 
     282             : 
     283             : 
     284        1384 : Point PageDescriptor::GetLocation (const bool bIgnoreOffset) const
     285             : {
     286        1384 :     if (bIgnoreOffset)
     287           0 :         return maBoundingBox.TopLeft();
     288             :     else
     289        1384 :         return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
     290             : }
     291             : 
     292             : 
     293             : 
     294             : 
     295         184 : void PageDescriptor::SetBoundingBox (const Rectangle& rBoundingBox)
     296             : {
     297         184 :     maBoundingBox = rBoundingBox;
     298         184 : }
     299             : 
     300             : 
     301             : 
     302             : } } } // end of namespace ::sd::slidesorter::model
     303             : 
     304             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10