LCOV - code coverage report
Current view: top level - sd/source/ui/slidesorter/model - SlsPageDescriptor.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 76 105 72.4 %
Date: 2012-08-25 Functions: 14 16 87.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 40 82 48.8 %

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

Generated by: LCOV version 1.10