1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: svdviter.cxx,v $
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()
54 ////////////////////////////////////////////////////////////////////////////////////////////////////
56 SdrViewIter::SdrViewIter(const SdrModel
* pModel
)
64 ////////////////////////////////////////////////////////////////////////////////////////////////////
66 SdrViewIter::SdrViewIter(const SdrPage
* pPage
, sal_Bool bNoMasterPage
)
69 mpModel
= (pPage
) ? pPage
->GetModel() : 0L;
71 mbNoMasterPage
= bNoMasterPage
;
75 ////////////////////////////////////////////////////////////////////////////////////////////////////
77 SdrViewIter::SdrViewIter(const SdrObject
* pObject
, sal_Bool bNoMasterPage
)
80 mpModel
= (pObject
) ? pObject
->GetModel() : 0L;
81 mpPage
= (pObject
) ? pObject
->GetPage() : 0L;
82 mbNoMasterPage
= bNoMasterPage
;
84 if(!mpModel
|| !mpPage
)
93 ////////////////////////////////////////////////////////////////////////////////////////////////////
95 sal_Bool
SdrViewIter::ImpCheckPageView(SdrPageView
* pPV
) const
99 sal_Bool
bMaster(mpPage
->IsMasterPage());
100 SdrPage
* pPg
= pPV
->GetPage();
106 // Objekt gewuenscht? Na dann erstmal sehen, ob
107 // das Obj in dieser PageView auch sichtbar ist.
109 mpObject
->getMergedHierarchyLayerSet(aObjLay
);
110 aObjLay
&= pPV
->GetVisibleLayers();
111 return !aObjLay
.IsEmpty();
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
131 // Objekt gewuenscht? Na dann erstmal sehen, ob
132 // das Obj in dieser PageView auch sichtbar ist.
134 mpObject
->getMergedHierarchyLayerSet(aObjLay
);
135 aObjLay
&= pPV
->GetVisibleLayers();
136 aObjLay
&= pPg
->TRG_GetMasterPageVisibleLayers();
138 if(!aObjLay
.IsEmpty())
141 } // ansonsten die naechste MasterPage der Page ansehen...
151 // MasterPage nicht erlaubt oder keine passende gefunden
161 ////////////////////////////////////////////////////////////////////////////////////////////////////
163 SdrView
* SdrViewIter::ImpFindView()
167 sal_uInt32
nLsAnz(mpModel
->GetListenerCount());
169 while(mnListenerNum
< nLsAnz
)
171 SfxListener
* pLs
= mpModel
->GetListener((sal_uInt16
)mnListenerNum
);
172 mpAktView
= PTR_CAST(SdrView
, pLs
);
178 SdrPageView
* pPV
= mpAktView
->GetSdrPageView();
182 if(ImpCheckPageView(pPV
))
202 ////////////////////////////////////////////////////////////////////////////////////////////////////
204 SdrPageView
* SdrViewIter::ImpFindPageView()
210 SdrPageView
* pPV
= mpAktView
->GetSdrPageView();
216 if(ImpCheckPageView(pPV
))
237 ////////////////////////////////////////////////////////////////////////////////////////////////////
239 OutputDevice
* SdrViewIter::ImpFindOutDev()
243 const sal_uInt32
nOutDevAnz(mpAktView
->PaintWindowCount());
245 if(mnOutDevNum
< nOutDevAnz
)
247 SdrPaintWindow
* pPaintWindow
= mpAktView
->GetPaintWindow(mnOutDevNum
);
248 return &pPaintWindow
->GetOutputDevice();
258 ////////////////////////////////////////////////////////////////////////////////////////////////////
260 Window
* SdrViewIter::ImpFindWindow()
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
);
286 ////////////////////////////////////////////////////////////////////////////////////////////////////
288 SdrView
* SdrViewIter::FirstView()
291 return ImpFindView();
294 ////////////////////////////////////////////////////////////////////////////////////////////////////
296 SdrView
* SdrViewIter::NextView()
299 return ImpFindView();
302 ////////////////////////////////////////////////////////////////////////////////////////////////////
304 SdrPageView
* SdrViewIter::FirstPageView()
308 return ImpFindPageView();
311 ////////////////////////////////////////////////////////////////////////////////////////////////////
313 SdrPageView
* SdrViewIter::NextPageView()
316 return ImpFindPageView();
319 ////////////////////////////////////////////////////////////////////////////////////////////////////
321 OutputDevice
* SdrViewIter::FirstOutDev()
325 return ImpFindOutDev();
328 ////////////////////////////////////////////////////////////////////////////////////////////////////
330 OutputDevice
* SdrViewIter::NextOutDev()
333 return ImpFindOutDev();
336 ////////////////////////////////////////////////////////////////////////////////////////////////////
338 Window
* SdrViewIter::FirstWindow()
342 return ImpFindWindow();
345 ////////////////////////////////////////////////////////////////////////////////////////////////////
347 Window
* SdrViewIter::NextWindow()
350 return ImpFindWindow();
353 ////////////////////////////////////////////////////////////////////////////////////////////////////