LCOV - code coverage report
Current view: top level - sd/source/core - PageListWatcher.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 76 76 100.0 %
Date: 2014-04-11 Functions: 16 17 94.1 %
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 "PageListWatcher.hxx"
      22             : 
      23             : #include "sdpage.hxx"
      24             : #include <tools/debug.hxx>
      25             : #include <svx/svdmodel.hxx>
      26             : 
      27             : 
      28             : 
      29         719 : void ImpPageListWatcher::ImpRecreateSortedPageListOnDemand()
      30             : {
      31             :     // clear vectors
      32         719 :     maPageVectorStandard.clear();
      33         719 :     maPageVectorNotes.clear();
      34         719 :     mpHandoutPage = 0L;
      35         719 :     mnVisiblePageCount = -1;
      36             : 
      37             :     // build up vectors again
      38         719 :     const sal_uInt32 nPageCount(ImpGetPageCount());
      39             : 
      40        2266 :     for(sal_uInt32 a(0L); a < nPageCount; a++)
      41             :     {
      42        1547 :         SdPage* pCandidate = ImpGetPage(a);
      43             :         DBG_ASSERT(pCandidate, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Invalid PageList in Model (!)");
      44             : 
      45        1547 :         switch(pCandidate->GetPageKind())
      46             :         {
      47             :             case PK_STANDARD:
      48             :             {
      49         572 :                 maPageVectorStandard.push_back(pCandidate);
      50         572 :                 if (!pCandidate->IsExcluded()) mnVisiblePageCount++;
      51         572 :                 break;
      52             :             }
      53             :             case PK_NOTES:
      54             :             {
      55         544 :                 maPageVectorNotes.push_back(pCandidate);
      56         544 :                 break;
      57             :             }
      58             :             case PK_HANDOUT:
      59             :             {
      60             :                 DBG_ASSERT(!mpHandoutPage, "ImpPageListWatcher::ImpRecreateSortedPageListOnDemand: Two Handout pages in PageList of Model (!)");
      61         431 :                 mpHandoutPage = pCandidate;
      62         431 :                 break;
      63             :             }
      64             :         }
      65             :     }
      66             : 
      67             :     // set to valid
      68         719 :     mbPageListValid = sal_True;
      69         719 : }
      70             : 
      71         312 : ImpPageListWatcher::ImpPageListWatcher(const SdrModel& rModel)
      72             :     : mrModel(rModel)
      73             :     , mpHandoutPage(0L)
      74             :     , mbPageListValid(sal_False)
      75         312 :     , mnVisiblePageCount(0)
      76             : {
      77         312 : }
      78             : 
      79         222 : ImpPageListWatcher::~ImpPageListWatcher()
      80             : {
      81         222 : }
      82             : 
      83        5761 : SdPage* ImpPageListWatcher::GetSdPage(PageKind ePgKind, sal_uInt32 nPgNum)
      84             : {
      85        5761 :     SdPage* pRetval(0L);
      86             : 
      87        5761 :     if(!mbPageListValid)
      88             :     {
      89         239 :         ImpRecreateSortedPageListOnDemand();
      90             :     }
      91             : 
      92        5761 :     switch(ePgKind)
      93             :     {
      94             :         case PK_STANDARD:
      95             :         {
      96        5117 :             if( nPgNum < (sal_uInt32)maPageVectorStandard.size() )
      97        4197 :                 pRetval = maPageVectorStandard[nPgNum];
      98             :             else
      99             :             {
     100             :                 SAL_WARN( "sd.core",
     101             :                           "ImpPageListWatcher::GetSdPage(PK_STANDARD): page number " << nPgNum << " >= " << maPageVectorStandard.size() );
     102             :             }
     103        5117 :             break;
     104             :         }
     105             :         case PK_NOTES:
     106             :         {
     107         387 :             if( nPgNum < (sal_uInt32)maPageVectorNotes.size() )
     108         387 :                 pRetval = maPageVectorNotes[nPgNum];
     109             :             else
     110             :             {
     111             :                 SAL_WARN( "sd.core",
     112             :                           "ImpPageListWatcher::GetSdPage(PK_NOTES): page number " << nPgNum << " >= " << maPageVectorNotes.size() );
     113             :             }
     114         387 :             break;
     115             :         }
     116             :         case PK_HANDOUT:
     117             :         {
     118             : //          #11420# for models used to transfer drawing shapes via clipboard its ok to not have a handout page
     119             :             DBG_ASSERT(nPgNum == 0L, "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
     120         257 :             if (nPgNum == 0)
     121         257 :                 pRetval = mpHandoutPage;
     122             :             else
     123             :             {
     124             :                 DBG_ASSERT(nPgNum == 0L,
     125             :                     "ImpPageListWatcher::GetSdPage: access to non existing handout page (!)");
     126             :             }
     127         257 :             break;
     128             :         }
     129             :     }
     130             : 
     131        5761 :     return pRetval;
     132             : }
     133             : 
     134        5793 : sal_uInt32 ImpPageListWatcher::GetSdPageCount(PageKind ePgKind)
     135             : {
     136        5793 :     sal_uInt32 nRetval(0L);
     137             : 
     138        5793 :     if(!mbPageListValid)
     139             :     {
     140         480 :         ImpRecreateSortedPageListOnDemand();
     141             :     }
     142             : 
     143        5793 :     switch(ePgKind)
     144             :     {
     145             :         case PK_STANDARD:
     146             :         {
     147        5486 :             nRetval = maPageVectorStandard.size();
     148        5486 :             break;
     149             :         }
     150             :         case PK_NOTES:
     151             :         {
     152         295 :             nRetval = maPageVectorNotes.size();
     153         295 :             break;
     154             :         }
     155             :         case PK_HANDOUT:
     156             :         {
     157          12 :             if(mpHandoutPage)
     158             :             {
     159          12 :                 nRetval = 1L;
     160             :             }
     161             : 
     162          12 :             break;
     163             :         }
     164             :     }
     165             : 
     166        5793 :     return nRetval;
     167             : }
     168             : 
     169             : 
     170         130 : sal_uInt32 ImpPageListWatcher::GetVisibleSdPageCount()
     171             : {
     172         130 :     sal_uInt32 nVisiblePageCount = 0;
     173             : 
     174             :     // build up vectors again
     175         130 :     const sal_uInt32 nPageCount(ImpGetPageCount());
     176             : 
     177         534 :     for(sal_uInt32 a(0L); a < nPageCount; a++)
     178             :     {
     179         404 :         SdPage* pCandidate = ImpGetPage(a);
     180         404 :         if ((pCandidate->GetPageKind() == PK_STANDARD)&&(!pCandidate->IsExcluded())) nVisiblePageCount++;
     181             :     }
     182         130 :     return nVisiblePageCount;
     183             : }
     184             : 
     185             : 
     186             : 
     187         519 : sal_uInt32 ImpDrawPageListWatcher::ImpGetPageCount() const
     188             : {
     189         519 :     return (sal_uInt32)mrModel.GetPageCount();
     190             : }
     191             : 
     192        1440 : SdPage* ImpDrawPageListWatcher::ImpGetPage(sal_uInt32 nIndex) const
     193             : {
     194        1440 :     return (SdPage*)mrModel.GetPage((sal_uInt16)nIndex);
     195             : }
     196             : 
     197         156 : ImpDrawPageListWatcher::ImpDrawPageListWatcher(const SdrModel& rModel)
     198         156 : :   ImpPageListWatcher(rModel)
     199             : {
     200         156 : }
     201             : 
     202         222 : ImpDrawPageListWatcher::~ImpDrawPageListWatcher()
     203             : {
     204         222 : }
     205             : 
     206             : 
     207             : 
     208         330 : sal_uInt32 ImpMasterPageListWatcher::ImpGetPageCount() const
     209             : {
     210         330 :     return (sal_uInt32)mrModel.GetMasterPageCount();
     211             : }
     212             : 
     213         511 : SdPage* ImpMasterPageListWatcher::ImpGetPage(sal_uInt32 nIndex) const
     214             : {
     215         511 :     return (SdPage*)mrModel.GetMasterPage((sal_uInt16)nIndex);
     216             : }
     217             : 
     218         156 : ImpMasterPageListWatcher::ImpMasterPageListWatcher(const SdrModel& rModel)
     219         156 : :   ImpPageListWatcher(rModel)
     220             : {
     221         156 : }
     222             : 
     223         222 : ImpMasterPageListWatcher::~ImpMasterPageListWatcher()
     224             : {
     225         222 : }
     226             : 
     227             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10