Version 3.6.0.2, tag libreoffice-3.6.0.2
[LibreOffice.git] / svx / source / svdraw / svdviter.cxx
blobe4ba756951647e7eac525a22b883d17b8a025bfb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include "svx/svdviter.hxx"
31 #include <svx/svdobj.hxx>
32 #include <svx/svdpage.hxx>
33 #include <svx/svdmodel.hxx>
34 #include <svx/svdview.hxx>
35 #include <svx/svdpagv.hxx>
36 #include <svx/svdsob.hxx>
37 #include <svl/brdcst.hxx>
38 #include <svx/sdrpaintwindow.hxx>
40 ////////////////////////////////////////////////////////////////////////////////////////////////////
42 void SdrViewIter::ImpInitVars()
44 mnListenerNum = 0L;
45 mnPageViewNum = 0L;
46 mnOutDevNum = 0L;
47 mpAktView = 0L;
50 ////////////////////////////////////////////////////////////////////////////////////////////////////
52 SdrViewIter::SdrViewIter(const SdrPage* pPage, sal_Bool bNoMasterPage)
54 mpPage = pPage;
55 mpModel = (pPage) ? pPage->GetModel() : 0L;
56 mpObject = 0L;
57 mbNoMasterPage = bNoMasterPage;
58 ImpInitVars();
61 ////////////////////////////////////////////////////////////////////////////////////////////////////
63 SdrViewIter::SdrViewIter(const SdrObject* pObject, sal_Bool bNoMasterPage)
65 mpObject = pObject;
66 mpModel = (pObject) ? pObject->GetModel() : 0L;
67 mpPage = (pObject) ? pObject->GetPage() : 0L;
68 mbNoMasterPage = bNoMasterPage;
70 if(!mpModel || !mpPage)
72 mpModel = 0L;
73 mpPage = 0L;
76 ImpInitVars();
79 ////////////////////////////////////////////////////////////////////////////////////////////////////
81 sal_Bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
83 if(mpPage)
85 sal_Bool bMaster(mpPage->IsMasterPage());
86 SdrPage* pPg = pPV->GetPage();
88 if(pPg == mpPage)
90 if(mpObject)
92 // Looking for an object? First, determine if it visible in
93 // this PageView.
94 SetOfByte aObjLay;
95 mpObject->getMergedHierarchyLayerSet(aObjLay);
96 aObjLay &= pPV->GetVisibleLayers();
97 return !aObjLay.IsEmpty();
99 else
101 return sal_True;
104 else
106 if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
108 if(pPg->TRG_HasMasterPage())
110 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
112 if(&rMasterPage == mpPage)
114 // the page we're looking for is a master page in this PageView
115 if(mpObject)
117 // Looking for an object? First, determine if it visible in
118 // this PageView.
119 SetOfByte aObjLay;
120 mpObject->getMergedHierarchyLayerSet(aObjLay);
121 aObjLay &= pPV->GetVisibleLayers();
122 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
124 if(!aObjLay.IsEmpty())
126 return sal_True;
127 } // else, look at the next master page of this page...
129 else
131 return sal_True;
137 // master page forbidden or no fitting master page found
138 return sal_False;
141 else
143 return sal_True;
147 ////////////////////////////////////////////////////////////////////////////////////////////////////
149 SdrView* SdrViewIter::ImpFindView()
151 if(mpModel)
153 sal_uInt32 nLsAnz(mpModel->GetListenerCount());
155 while(mnListenerNum < nLsAnz)
157 SfxListener* pLs = mpModel->GetListener((sal_uInt16)mnListenerNum);
158 mpAktView = PTR_CAST(SdrView, pLs);
160 if(mpAktView)
162 if(mpPage)
164 SdrPageView* pPV = mpAktView->GetSdrPageView();
166 if(pPV)
168 if(ImpCheckPageView(pPV))
170 return mpAktView;
174 else
176 return mpAktView;
180 mnListenerNum++;
184 mpAktView = 0L;
185 return mpAktView;
188 ////////////////////////////////////////////////////////////////////////////////////////////////////
190 SdrView* SdrViewIter::FirstView()
192 ImpInitVars();
193 return ImpFindView();
196 ////////////////////////////////////////////////////////////////////////////////////////////////////
198 SdrView* SdrViewIter::NextView()
200 mnListenerNum++;
201 return ImpFindView();
204 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */