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

Generated by: LCOV version 1.10