bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / svdraw / svdviter.cxx
blobf9b738aa84c5589d16dda3ed597a2b32335e04d2
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 <svl/brdcst.hxx>
29 #include <svx/sdrpaintwindow.hxx>
31 ////////////////////////////////////////////////////////////////////////////////////////////////////
33 void SdrViewIter::ImpInitVars()
35 mnListenerNum = 0L;
36 mnPageViewNum = 0L;
37 mnOutDevNum = 0L;
38 mpAktView = 0L;
41 ////////////////////////////////////////////////////////////////////////////////////////////////////
43 SdrViewIter::SdrViewIter(const SdrPage* pPage, sal_Bool bNoMasterPage)
45 mpPage = pPage;
46 mpModel = (pPage) ? pPage->GetModel() : 0L;
47 mpObject = 0L;
48 mbNoMasterPage = bNoMasterPage;
49 ImpInitVars();
52 ////////////////////////////////////////////////////////////////////////////////////////////////////
54 SdrViewIter::SdrViewIter(const SdrObject* pObject, sal_Bool bNoMasterPage)
56 mpObject = pObject;
57 mpModel = (pObject) ? pObject->GetModel() : 0L;
58 mpPage = (pObject) ? pObject->GetPage() : 0L;
59 mbNoMasterPage = bNoMasterPage;
61 if(!mpModel || !mpPage)
63 mpModel = 0L;
64 mpPage = 0L;
67 ImpInitVars();
70 ////////////////////////////////////////////////////////////////////////////////////////////////////
72 sal_Bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
74 if(mpPage)
76 sal_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 sal_True;
95 else
97 if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
99 if(pPg->TRG_HasMasterPage())
101 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
103 if(&rMasterPage == mpPage)
105 // the page we're looking for is a master page in this PageView
106 if(mpObject)
108 // Looking for an object? First, determine if it visible in
109 // this PageView.
110 SetOfByte aObjLay;
111 mpObject->getMergedHierarchyLayerSet(aObjLay);
112 aObjLay &= pPV->GetVisibleLayers();
113 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
115 if(!aObjLay.IsEmpty())
117 return sal_True;
118 } // else, look at the next master page of this page...
120 else
122 return sal_True;
128 // master page forbidden or no fitting master page found
129 return sal_False;
132 else
134 return sal_True;
138 ////////////////////////////////////////////////////////////////////////////////////////////////////
140 SdrView* SdrViewIter::ImpFindView()
142 if(mpModel)
144 sal_uInt32 nLsAnz(mpModel->GetListenerCount());
146 while(mnListenerNum < nLsAnz)
148 SfxListener* pLs = mpModel->GetListener((sal_uInt16)mnListenerNum);
149 mpAktView = PTR_CAST(SdrView, pLs);
151 if(mpAktView)
153 if(mpPage)
155 SdrPageView* pPV = mpAktView->GetSdrPageView();
157 if(pPV)
159 if(ImpCheckPageView(pPV))
161 return mpAktView;
165 else
167 return mpAktView;
171 mnListenerNum++;
175 mpAktView = 0L;
176 return mpAktView;
179 ////////////////////////////////////////////////////////////////////////////////////////////////////
181 SdrView* SdrViewIter::FirstView()
183 ImpInitVars();
184 return ImpFindView();
187 ////////////////////////////////////////////////////////////////////////////////////////////////////
189 SdrView* SdrViewIter::NextView()
191 mnListenerNum++;
192 return ImpFindView();
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */