LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/model - SlsPageDescriptor.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 68 98 69.4 %
Date: 2014-11-03 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         146 : 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         146 :       mbHasTransition(false)
      52             : {
      53             :     OSL_ASSERT(mpPage);
      54             :     OSL_ASSERT(mpPage == SdPage::getImplementation(rxPage));
      55         146 :     if (mpPage != NULL)
      56             :     {
      57         146 :         if (mpPage->TRG_HasMasterPage())
      58         126 :             mpMasterPage = &mpPage->TRG_GetMasterPage();
      59         146 :         if (mpPage->getTransitionType() > 0)
      60           0 :             mbHasTransition = true;
      61             :     }
      62         146 : }
      63             : 
      64         146 : PageDescriptor::~PageDescriptor (void)
      65             : {
      66         146 : }
      67             : 
      68          10 : void PageDescriptor::SetPageIndex (const sal_Int32 nNewIndex)
      69             : {
      70          10 :     mnIndex = nNewIndex;
      71          10 :     maVisualState.mnPageId = nNewIndex;
      72          10 : }
      73             : 
      74        2130 : bool PageDescriptor::UpdateMasterPage (void)
      75             : {
      76        2130 :     const SdrPage* pMaster = NULL;
      77        2130 :     if (mpPage!=NULL && mpPage->TRG_HasMasterPage())
      78        2130 :         pMaster = &mpPage->TRG_GetMasterPage();
      79        2130 :     if (mpMasterPage != pMaster)
      80             :     {
      81          10 :         mpMasterPage = pMaster;
      82          10 :         return true;
      83             :     }
      84             :     else
      85        2120 :         return false;
      86             : }
      87             : 
      88        2130 : bool PageDescriptor::UpdateTransitionFlag (void)
      89             : {
      90        2130 :     bool bHasSlideTransition (false);
      91        2130 :     if (mpPage != NULL)
      92        2130 :         bHasSlideTransition = mpPage->getTransitionType() > 0;
      93        2130 :     if (bHasSlideTransition != mbHasTransition)
      94             :     {
      95           0 :         mbHasTransition = bHasSlideTransition;
      96           0 :         return true;
      97             :     }
      98             :     else
      99        2130 :         return false;
     100             : }
     101             : 
     102        7859 : bool PageDescriptor::HasState (const State eState) const
     103             : {
     104        7859 :     switch (eState)
     105             :     {
     106             :         case ST_Visible:
     107        2183 :             return mbIsVisible;
     108             : 
     109             :         case ST_Selected:
     110        2182 :             return mbIsSelected;
     111             : 
     112             :         case ST_WasSelected:
     113           0 :             return mbWasSelected;
     114             : 
     115             :         case ST_Focused:
     116         750 :             return mbIsFocused;
     117             : 
     118             :         case ST_MouseOver:
     119         948 :             return mbIsMouseOver;
     120             : 
     121             :         case ST_Current:
     122         661 :             return mbIsCurrent;
     123             : 
     124             :         case ST_Excluded:
     125        1135 :             return mpPage!=NULL && mpPage->IsExcluded();
     126             : 
     127             :         default:
     128             :             OSL_ASSERT(false);
     129           0 :             return false;
     130             :     }
     131             : }
     132             : 
     133        1147 : bool PageDescriptor::SetState (const State eState, const bool bNewStateValue)
     134             : {
     135        1147 :     bool bModified (false);
     136        1147 :     switch (eState)
     137             :     {
     138             :         case ST_Visible:
     139         169 :             bModified = (bNewStateValue!=mbIsVisible);
     140         169 :             if (bModified)
     141         125 :                 mbIsVisible = bNewStateValue;
     142         169 :             break;
     143             : 
     144             :         case ST_Selected:
     145         544 :             bModified = (bNewStateValue!=mbIsSelected);
     146         544 :             if (bModified)
     147         394 :                 mbIsSelected = bNewStateValue;
     148         544 :             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         134 :             bModified = (bNewStateValue!=mbIsFocused);
     158         134 :             if (bModified)
     159           0 :                 mbIsFocused = bNewStateValue;
     160         134 :             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         300 :             bModified = (bNewStateValue!=mbIsCurrent);
     170         300 :             if (bModified)
     171         142 :                 mbIsCurrent = bNewStateValue;
     172         300 :             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        1147 :     if (bModified)
     187         661 :         maVisualState.UpdateVisualState(*this);
     188        1147 :     return bModified;
     189             : }
     190             : 
     191           0 : bool PageDescriptor::GetCoreSelection (void)
     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 (void)
     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         606 : Rectangle PageDescriptor::GetBoundingBox (void) const
     213             : {
     214         606 :     Rectangle aBox (maBoundingBox);
     215         606 :     const Point aOffset (maVisualState.GetLocationOffset());
     216         606 :     aBox.Move(aOffset.X(), aOffset.Y());
     217         606 :     return aBox;
     218             : }
     219             : 
     220        2844 : Point PageDescriptor::GetLocation (const bool bIgnoreOffset) const
     221             : {
     222        2844 :     if (bIgnoreOffset)
     223           0 :         return maBoundingBox.TopLeft();
     224             :     else
     225        2844 :         return maBoundingBox.TopLeft() + maVisualState.GetLocationOffset();
     226             : }
     227             : 
     228         332 : void PageDescriptor::SetBoundingBox (const Rectangle& rBoundingBox)
     229             : {
     230         332 :     maBoundingBox = rBoundingBox;
     231         332 : }
     232             : 
     233         114 : } } } // end of namespace ::sd::slidesorter::model
     234             : 
     235             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10