Update ooo320-m1
[ooovba.git] / svx / source / svdraw / svdviter.cxx
blobb86fba9d0c356c29bbe11850231f6c26c7269413
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdviter.cxx,v $
10 * $Revision: 1.10 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include "svdviter.hxx"
35 #include <svx/svdobj.hxx>
36 #include <svx/svdpage.hxx>
37 #include <svx/svdmodel.hxx>
38 #include <svx/svdview.hxx>
39 #include <svx/svdpagv.hxx>
40 #include <svx/svdsob.hxx>
41 #include <svtools/brdcst.hxx>
42 #include <sdrpaintwindow.hxx>
44 ////////////////////////////////////////////////////////////////////////////////////////////////////
46 void SdrViewIter::ImpInitVars()
48 mnListenerNum = 0L;
49 mnPageViewNum = 0L;
50 mnOutDevNum = 0L;
51 mpAktView = 0L;
54 ////////////////////////////////////////////////////////////////////////////////////////////////////
56 SdrViewIter::SdrViewIter(const SdrModel* pModel)
58 mpModel = pModel;
59 mpPage = 0L;
60 mpObject = 0L;
61 ImpInitVars();
64 ////////////////////////////////////////////////////////////////////////////////////////////////////
66 SdrViewIter::SdrViewIter(const SdrPage* pPage, sal_Bool bNoMasterPage)
68 mpPage = pPage;
69 mpModel = (pPage) ? pPage->GetModel() : 0L;
70 mpObject = 0L;
71 mbNoMasterPage = bNoMasterPage;
72 ImpInitVars();
75 ////////////////////////////////////////////////////////////////////////////////////////////////////
77 SdrViewIter::SdrViewIter(const SdrObject* pObject, sal_Bool bNoMasterPage)
79 mpObject = pObject;
80 mpModel = (pObject) ? pObject->GetModel() : 0L;
81 mpPage = (pObject) ? pObject->GetPage() : 0L;
82 mbNoMasterPage = bNoMasterPage;
84 if(!mpModel || !mpPage)
86 mpModel = 0L;
87 mpPage = 0L;
90 ImpInitVars();
93 ////////////////////////////////////////////////////////////////////////////////////////////////////
95 sal_Bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
97 if(mpPage)
99 sal_Bool bMaster(mpPage->IsMasterPage());
100 SdrPage* pPg = pPV->GetPage();
102 if(pPg == mpPage)
104 if(mpObject)
106 // Objekt gewuenscht? Na dann erstmal sehen, ob
107 // das Obj in dieser PageView auch sichtbar ist.
108 SetOfByte aObjLay;
109 mpObject->getMergedHierarchyLayerSet(aObjLay);
110 aObjLay &= pPV->GetVisibleLayers();
111 return !aObjLay.IsEmpty();
113 else
115 return sal_True;
118 else
120 if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
122 if(pPg->TRG_HasMasterPage())
124 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
126 if(&rMasterPage == mpPage)
128 // Aha, die gewuenschte Page ist also MasterPage in dieser PageView
129 if(mpObject)
131 // Objekt gewuenscht? Na dann erstmal sehen, ob
132 // das Obj in dieser PageView auch sichtbar ist.
133 SetOfByte aObjLay;
134 mpObject->getMergedHierarchyLayerSet(aObjLay);
135 aObjLay &= pPV->GetVisibleLayers();
136 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
138 if(!aObjLay.IsEmpty())
140 return TRUE;
141 } // ansonsten die naechste MasterPage der Page ansehen...
143 else
145 return sal_True;
151 // MasterPage nicht erlaubt oder keine passende gefunden
152 return sal_False;
155 else
157 return sal_True;
161 ////////////////////////////////////////////////////////////////////////////////////////////////////
163 SdrView* SdrViewIter::ImpFindView()
165 if(mpModel)
167 sal_uInt32 nLsAnz(mpModel->GetListenerCount());
169 while(mnListenerNum < nLsAnz)
171 SfxListener* pLs = mpModel->GetListener((sal_uInt16)mnListenerNum);
172 mpAktView = PTR_CAST(SdrView, pLs);
174 if(mpAktView)
176 if(mpPage)
178 SdrPageView* pPV = mpAktView->GetSdrPageView();
180 if(pPV)
182 if(ImpCheckPageView(pPV))
184 return mpAktView;
188 else
190 return mpAktView;
194 mnListenerNum++;
198 mpAktView = 0L;
199 return mpAktView;
202 ////////////////////////////////////////////////////////////////////////////////////////////////////
204 SdrPageView* SdrViewIter::ImpFindPageView()
206 if(mpModel)
208 while(mpAktView)
210 SdrPageView* pPV = mpAktView->GetSdrPageView();
212 if(pPV)
214 if(mpPage)
216 if(ImpCheckPageView(pPV))
218 return pPV;
221 else
223 return pPV;
226 mnPageViewNum++;
229 mnListenerNum++;
230 ImpFindView();
234 return 0L;
237 ////////////////////////////////////////////////////////////////////////////////////////////////////
239 OutputDevice* SdrViewIter::ImpFindOutDev()
241 while(mpAktView)
243 const sal_uInt32 nOutDevAnz(mpAktView->PaintWindowCount());
245 if(mnOutDevNum < nOutDevAnz)
247 SdrPaintWindow* pPaintWindow = mpAktView->GetPaintWindow(mnOutDevNum);
248 return &pPaintWindow->GetOutputDevice();
251 mnListenerNum++;
252 ImpFindView();
255 return 0L;
258 ////////////////////////////////////////////////////////////////////////////////////////////////////
260 Window* SdrViewIter::ImpFindWindow()
262 while(mpAktView)
264 const sal_uInt32 nOutDevAnz(mpAktView->PaintWindowCount());
266 while(mnOutDevNum < nOutDevAnz)
268 SdrPaintWindow* pPaintWindow = mpAktView->GetPaintWindow(mnOutDevNum);
269 OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
271 if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
273 return (Window*)(&rOutDev);
276 mnOutDevNum++;
279 mnListenerNum++;
280 ImpFindView();
283 return 0L;
286 ////////////////////////////////////////////////////////////////////////////////////////////////////
288 SdrView* SdrViewIter::FirstView()
290 ImpInitVars();
291 return ImpFindView();
294 ////////////////////////////////////////////////////////////////////////////////////////////////////
296 SdrView* SdrViewIter::NextView()
298 mnListenerNum++;
299 return ImpFindView();
302 ////////////////////////////////////////////////////////////////////////////////////////////////////
304 SdrPageView* SdrViewIter::FirstPageView()
306 ImpInitVars();
307 ImpFindView();
308 return ImpFindPageView();
311 ////////////////////////////////////////////////////////////////////////////////////////////////////
313 SdrPageView* SdrViewIter::NextPageView()
315 mnPageViewNum++;
316 return ImpFindPageView();
319 ////////////////////////////////////////////////////////////////////////////////////////////////////
321 OutputDevice* SdrViewIter::FirstOutDev()
323 ImpInitVars();
324 ImpFindView();
325 return ImpFindOutDev();
328 ////////////////////////////////////////////////////////////////////////////////////////////////////
330 OutputDevice* SdrViewIter::NextOutDev()
332 mnOutDevNum++;
333 return ImpFindOutDev();
336 ////////////////////////////////////////////////////////////////////////////////////////////////////
338 Window* SdrViewIter::FirstWindow()
340 ImpInitVars();
341 ImpFindView();
342 return ImpFindWindow();
345 ////////////////////////////////////////////////////////////////////////////////////////////////////
347 Window* SdrViewIter::NextWindow()
349 mnOutDevNum++;
350 return ImpFindWindow();
353 ////////////////////////////////////////////////////////////////////////////////////////////////////