LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdviter.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 48 71 67.6 %
Date: 2015-06-13 12:38:46 Functions: 8 9 88.9 %
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 "svx/svdviter.hxx"
      22             : #include <svx/svdobj.hxx>
      23             : #include <svx/svdpage.hxx>
      24             : #include <svx/svdmodel.hxx>
      25             : #include <svx/svdview.hxx>
      26             : #include <svx/svdpagv.hxx>
      27             : #include <svx/svdsob.hxx>
      28             : #include <svx/sdrpaintwindow.hxx>
      29             : 
      30             : 
      31             : 
      32       52710 : void SdrViewIter::ImpInitVars()
      33             : {
      34       52710 :     mnListenerNum = 0L;
      35       52710 :     mnPageViewNum = 0L;
      36       52710 :     mnOutDevNum = 0L;
      37       52710 :     mpAktView = 0L;
      38       52710 : }
      39             : 
      40             : 
      41             : 
      42           0 : SdrViewIter::SdrViewIter(const SdrPage* pPage, bool bNoMasterPage)
      43             : {
      44           0 :     mpPage = pPage;
      45           0 :     mpModel = (pPage) ? pPage->GetModel() : 0L;
      46           0 :     mpObject = 0L;
      47           0 :     mbNoMasterPage = bNoMasterPage;
      48           0 :     ImpInitVars();
      49           0 : }
      50             : 
      51             : 
      52             : 
      53       26355 : SdrViewIter::SdrViewIter(const SdrObject* pObject, bool bNoMasterPage)
      54             : {
      55       26355 :     mpObject = pObject;
      56       26355 :     mpModel = (pObject) ? pObject->GetModel() : 0L;
      57       26355 :     mpPage = (pObject) ? pObject->GetPage() : 0L;
      58       26355 :     mbNoMasterPage = bNoMasterPage;
      59             : 
      60       26355 :     if(!mpModel || !mpPage)
      61             :     {
      62         142 :         mpModel = 0L;
      63         142 :         mpPage = 0L;
      64             :     }
      65             : 
      66       26355 :     ImpInitVars();
      67       26355 : }
      68             : 
      69             : 
      70             : 
      71         987 : bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
      72             : {
      73         987 :     if(!mpPage)
      74           0 :         return true;
      75             : 
      76         987 :     bool bMaster(mpPage->IsMasterPage());
      77         987 :     SdrPage* pPg = pPV->GetPage();
      78             : 
      79         987 :     if(pPg == mpPage)
      80             :     {
      81         987 :         if(mpObject)
      82             :         {
      83             :             // Looking for an object? First, determine if it visible in
      84             :             // this PageView.
      85         987 :             SetOfByte aObjLay;
      86         987 :             mpObject->getMergedHierarchyLayerSet(aObjLay);
      87         987 :             aObjLay &= pPV->GetVisibleLayers();
      88         987 :             return !aObjLay.IsEmpty();
      89             :         }
      90             :         else
      91             :         {
      92           0 :             return true;
      93             :         }
      94             :     }
      95           0 :     else if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
      96             :     {
      97           0 :         if(pPg->TRG_HasMasterPage())
      98             :         {
      99           0 :             SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
     100             : 
     101           0 :             if(&rMasterPage == mpPage)
     102             :             {
     103             :                 // the page we're looking for is a master page in this PageView
     104           0 :                 if(mpObject)
     105             :                 {
     106             :                     // Looking for an object? First, determine if it visible in
     107             :                     // this PageView.
     108           0 :                     SetOfByte aObjLay;
     109           0 :                     mpObject->getMergedHierarchyLayerSet(aObjLay);
     110           0 :                     aObjLay &= pPV->GetVisibleLayers();
     111           0 :                     aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
     112             : 
     113           0 :                     if(!aObjLay.IsEmpty())
     114             :                     {
     115           0 :                         return true;
     116             :                     } // else, look at the next master page of this page...
     117             :                 }
     118             :                 else
     119             :                 {
     120           0 :                     return true;
     121             :                 }
     122             :             }
     123             :         }
     124             :     }
     125             : 
     126             :     // master page forbidden or no fitting master page found
     127           0 :     return false;
     128             : }
     129             : 
     130       26853 : SdrView* SdrViewIter::ImpFindView()
     131             : {
     132       26853 :     if(mpModel)
     133             :     {
     134       26711 :         const size_t nLsAnz(mpModel->GetSizeOfVector());
     135             : 
     136     1441808 :         while(mnListenerNum < nLsAnz)
     137             :         {
     138     1388884 :             SfxListener* pLs = mpModel->GetListener(mnListenerNum);
     139     1388884 :             mpAktView = PTR_CAST(SdrView, pLs);
     140             : 
     141     1388884 :             if(mpAktView)
     142             :             {
     143       36878 :                 if(mpPage)
     144             :                 {
     145       36878 :                     SdrPageView* pPV = mpAktView->GetSdrPageView();
     146             : 
     147       36878 :                     if(pPV)
     148             :                     {
     149         987 :                         if(ImpCheckPageView(pPV))
     150             :                         {
     151         498 :                             return mpAktView;
     152             :                         }
     153             :                     }
     154             :                 }
     155             :                 else
     156             :                 {
     157           0 :                     return mpAktView;
     158             :                 }
     159             :             }
     160             : 
     161     1388386 :             mnListenerNum++;
     162             :         }
     163             :     }
     164             : 
     165       26355 :     mpAktView = 0L;
     166       26355 :     return mpAktView;
     167             : }
     168             : 
     169             : 
     170             : 
     171       26355 : SdrView* SdrViewIter::FirstView()
     172             : {
     173       26355 :     ImpInitVars();
     174       26355 :     return ImpFindView();
     175             : }
     176             : 
     177             : 
     178             : 
     179         498 : SdrView* SdrViewIter::NextView()
     180             : {
     181         498 :     mnListenerNum++;
     182         498 :     return ImpFindView();
     183         435 : }
     184             : 
     185             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11