bump product version to 5.0.4.1
[LibreOffice.git] / svx / source / svdraw / svdviter.cxx
blob1078dc76a1b9610c2dc13d81f0f5390208eff0b2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
32 void SdrViewIter::ImpInitVars()
34 mnListenerNum = 0L;
35 mnPageViewNum = 0L;
36 mnOutDevNum = 0L;
37 mpAktView = 0L;
42 SdrViewIter::SdrViewIter(const SdrPage* pPage, bool bNoMasterPage)
44 mpPage = pPage;
45 mpModel = (pPage) ? pPage->GetModel() : 0L;
46 mpObject = 0L;
47 mbNoMasterPage = bNoMasterPage;
48 ImpInitVars();
53 SdrViewIter::SdrViewIter(const SdrObject* pObject, bool bNoMasterPage)
55 mpObject = pObject;
56 mpModel = (pObject) ? pObject->GetModel() : 0L;
57 mpPage = (pObject) ? pObject->GetPage() : 0L;
58 mbNoMasterPage = bNoMasterPage;
60 if(!mpModel || !mpPage)
62 mpModel = 0L;
63 mpPage = 0L;
66 ImpInitVars();
71 bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
73 if(!mpPage)
74 return true;
76 bool bMaster(mpPage->IsMasterPage());
77 SdrPage* pPg = pPV->GetPage();
79 if(pPg == mpPage)
81 if(mpObject)
83 // Looking for an object? First, determine if it visible in
84 // this PageView.
85 SetOfByte aObjLay;
86 mpObject->getMergedHierarchyLayerSet(aObjLay);
87 aObjLay &= pPV->GetVisibleLayers();
88 return !aObjLay.IsEmpty();
90 else
92 return true;
95 else if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
97 if(pPg->TRG_HasMasterPage())
99 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
101 if(&rMasterPage == mpPage)
103 // the page we're looking for is a master page in this PageView
104 if(mpObject)
106 // Looking for an object? First, determine if it visible in
107 // this PageView.
108 SetOfByte aObjLay;
109 mpObject->getMergedHierarchyLayerSet(aObjLay);
110 aObjLay &= pPV->GetVisibleLayers();
111 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
113 if(!aObjLay.IsEmpty())
115 return true;
116 } // else, look at the next master page of this page...
118 else
120 return true;
126 // master page forbidden or no fitting master page found
127 return false;
130 SdrView* SdrViewIter::ImpFindView()
132 if(mpModel)
134 const size_t nLsAnz(mpModel->GetSizeOfVector());
136 while(mnListenerNum < nLsAnz)
138 SfxListener* pLs = mpModel->GetListener(mnListenerNum);
139 mpAktView = PTR_CAST(SdrView, pLs);
141 if(mpAktView)
143 if(mpPage)
145 SdrPageView* pPV = mpAktView->GetSdrPageView();
147 if(pPV)
149 if(ImpCheckPageView(pPV))
151 return mpAktView;
155 else
157 return mpAktView;
161 mnListenerNum++;
165 mpAktView = 0L;
166 return mpAktView;
171 SdrView* SdrViewIter::FirstView()
173 ImpInitVars();
174 return ImpFindView();
179 SdrView* SdrViewIter::NextView()
181 mnListenerNum++;
182 return ImpFindView();
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */