xref: /aoo4110/main/svx/source/svdraw/svdviter.cxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include "svx/svdviter.hxx"
28 #include <svx/svdobj.hxx>
29 #include <svx/svdpage.hxx>
30 #include <svx/svdmodel.hxx>
31 #include <svx/svdview.hxx>
32 #include <svx/svdpagv.hxx>
33 #include <svx/svdsob.hxx>
34 #include <svl/brdcst.hxx>
35 #include <svx/sdrpaintwindow.hxx>
36 
37 ////////////////////////////////////////////////////////////////////////////////////////////////////
38 
ImpInitVars()39 void SdrViewIter::ImpInitVars()
40 {
41 	mnListenerNum = 0L;
42 	mnPageViewNum = 0L;
43 	mnOutDevNum = 0L;
44 	mpAktView = 0L;
45 }
46 
47 ////////////////////////////////////////////////////////////////////////////////////////////////////
48 
SdrViewIter(const SdrModel * pModel)49 SdrViewIter::SdrViewIter(const SdrModel* pModel)
50 {
51 	mpModel = pModel;
52 	mpPage = 0L;
53 	mpObject = 0L;
54 	ImpInitVars();
55 }
56 
57 ////////////////////////////////////////////////////////////////////////////////////////////////////
58 
SdrViewIter(const SdrPage * pPage,sal_Bool bNoMasterPage)59 SdrViewIter::SdrViewIter(const SdrPage* pPage, sal_Bool bNoMasterPage)
60 {
61 	mpPage = pPage;
62 	mpModel = (pPage) ? pPage->GetModel() : 0L;
63 	mpObject = 0L;
64 	mbNoMasterPage = bNoMasterPage;
65 	ImpInitVars();
66 }
67 
68 ////////////////////////////////////////////////////////////////////////////////////////////////////
69 
SdrViewIter(const SdrObject * pObject,sal_Bool bNoMasterPage)70 SdrViewIter::SdrViewIter(const SdrObject* pObject, sal_Bool bNoMasterPage)
71 {
72 	mpObject = pObject;
73 	mpModel = (pObject) ? pObject->GetModel() : 0L;
74 	mpPage = (pObject) ? pObject->GetPage() : 0L;
75 	mbNoMasterPage = bNoMasterPage;
76 
77 	if(!mpModel || !mpPage)
78 	{
79 		mpModel = 0L;
80 		mpPage = 0L;
81 	}
82 
83 	ImpInitVars();
84 }
85 
86 ////////////////////////////////////////////////////////////////////////////////////////////////////
87 
ImpCheckPageView(SdrPageView * pPV) const88 sal_Bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
89 {
90 	if(mpPage)
91 	{
92 		sal_Bool bMaster(mpPage->IsMasterPage());
93 		SdrPage* pPg = pPV->GetPage();
94 
95 		if(pPg == mpPage)
96 		{
97 			if(mpObject)
98 			{
99 				// Objekt gewuenscht? Na dann erstmal sehen, ob
100 				// das Obj in dieser PageView auch sichtbar ist.
101 				SetOfByte aObjLay;
102 				mpObject->getMergedHierarchyLayerSet(aObjLay);
103 				aObjLay &= pPV->GetVisibleLayers();
104 				return !aObjLay.IsEmpty();
105 			}
106 			else
107 			{
108 				return sal_True;
109 			}
110 		}
111 		else
112 		{
113 			if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
114 			{
115 				if(pPg->TRG_HasMasterPage())
116 				{
117 					SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
118 
119 					if(&rMasterPage == mpPage)
120 					{
121 						// Aha, die gewuenschte Page ist also MasterPage in dieser PageView
122 						if(mpObject)
123 						{
124 							// Objekt gewuenscht? Na dann erstmal sehen, ob
125 							// das Obj in dieser PageView auch sichtbar ist.
126 							SetOfByte aObjLay;
127 							mpObject->getMergedHierarchyLayerSet(aObjLay);
128 							aObjLay &= pPV->GetVisibleLayers();
129 							aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
130 
131 							if(!aObjLay.IsEmpty())
132 							{
133 								return sal_True;
134 							} // ansonsten die naechste MasterPage der Page ansehen...
135 						}
136 						else
137 						{
138 							return sal_True;
139 						}
140 					}
141 				}
142 			}
143 
144 			// MasterPage nicht erlaubt oder keine passende gefunden
145 			return sal_False;
146 		}
147 	}
148 	else
149 	{
150 		return sal_True;
151 	}
152 }
153 
154 ////////////////////////////////////////////////////////////////////////////////////////////////////
155 
ImpFindView()156 SdrView* SdrViewIter::ImpFindView()
157 {
158 	if(mpModel)
159 	{
160 		sal_uInt32 nLsAnz(mpModel->GetListenerCount());
161 
162 		while(mnListenerNum < nLsAnz)
163 		{
164 			SfxListener* pLs = mpModel->GetListener((sal_uInt16)mnListenerNum);
165 			mpAktView = PTR_CAST(SdrView, pLs);
166 
167 			if(mpAktView)
168 			{
169 				if(mpPage)
170 				{
171 					SdrPageView* pPV = mpAktView->GetSdrPageView();
172 
173 					if(pPV)
174 					{
175 						if(ImpCheckPageView(pPV))
176 						{
177 							return mpAktView;
178 						}
179 					}
180 				}
181 				else
182 				{
183 					return mpAktView;
184 				}
185 			}
186 
187 			mnListenerNum++;
188 		}
189 	}
190 
191 	mpAktView = 0L;
192 	return mpAktView;
193 }
194 
195 ////////////////////////////////////////////////////////////////////////////////////////////////////
196 
ImpFindPageView()197 SdrPageView* SdrViewIter::ImpFindPageView()
198 {
199 	if(mpModel)
200 	{
201 		while(mpAktView)
202 		{
203 			SdrPageView* pPV = mpAktView->GetSdrPageView();
204 
205 			if(pPV)
206 			{
207 				if(mpPage)
208 				{
209 					if(ImpCheckPageView(pPV))
210 					{
211 						return pPV;
212 					}
213 				}
214 				else
215 				{
216 					return pPV;
217 				}
218 
219 				mnPageViewNum++;
220 			}
221 
222 			mnListenerNum++;
223 			ImpFindView();
224 		}
225 	}
226 
227 	return 0L;
228 }
229 
230 ////////////////////////////////////////////////////////////////////////////////////////////////////
231 
ImpFindOutDev()232 OutputDevice* SdrViewIter::ImpFindOutDev()
233 {
234 	while(mpAktView)
235 	{
236 		const sal_uInt32 nOutDevAnz(mpAktView->PaintWindowCount());
237 
238 		if(mnOutDevNum < nOutDevAnz)
239 		{
240 			SdrPaintWindow* pPaintWindow = mpAktView->GetPaintWindow(mnOutDevNum);
241 			return &pPaintWindow->GetOutputDevice();
242 		}
243 
244 		mnListenerNum++;
245 		ImpFindView();
246 	}
247 
248 	return 0L;
249 }
250 
251 ////////////////////////////////////////////////////////////////////////////////////////////////////
252 
ImpFindWindow()253 Window* SdrViewIter::ImpFindWindow()
254 {
255 	while(mpAktView)
256 	{
257 		const sal_uInt32 nOutDevAnz(mpAktView->PaintWindowCount());
258 
259 		while(mnOutDevNum < nOutDevAnz)
260 		{
261 			SdrPaintWindow* pPaintWindow = mpAktView->GetPaintWindow(mnOutDevNum);
262 			OutputDevice& rOutDev = pPaintWindow->GetOutputDevice();
263 
264 			if(OUTDEV_WINDOW == rOutDev.GetOutDevType())
265 			{
266 				return (Window*)(&rOutDev);
267 			}
268 
269 			mnOutDevNum++;
270 		}
271 
272 		mnListenerNum++;
273 		ImpFindView();
274 	}
275 
276 	return 0L;
277 }
278 
279 ////////////////////////////////////////////////////////////////////////////////////////////////////
280 
FirstView()281 SdrView* SdrViewIter::FirstView()
282 {
283 	ImpInitVars();
284 	return ImpFindView();
285 }
286 
287 ////////////////////////////////////////////////////////////////////////////////////////////////////
288 
NextView()289 SdrView* SdrViewIter::NextView()
290 {
291 	mnListenerNum++;
292 	return ImpFindView();
293 }
294 
295 ////////////////////////////////////////////////////////////////////////////////////////////////////
296 
FirstPageView()297 SdrPageView* SdrViewIter::FirstPageView()
298 {
299 	ImpInitVars();
300 	ImpFindView();
301 	return ImpFindPageView();
302 }
303 
304 ////////////////////////////////////////////////////////////////////////////////////////////////////
305 
NextPageView()306 SdrPageView* SdrViewIter::NextPageView()
307 {
308 	mnPageViewNum++;
309 	return ImpFindPageView();
310 }
311 
312 ////////////////////////////////////////////////////////////////////////////////////////////////////
313 
FirstOutDev()314 OutputDevice* SdrViewIter::FirstOutDev()
315 {
316 	ImpInitVars();
317 	ImpFindView();
318 	return ImpFindOutDev();
319 }
320 
321 ////////////////////////////////////////////////////////////////////////////////////////////////////
322 
NextOutDev()323 OutputDevice* SdrViewIter::NextOutDev()
324 {
325 	mnOutDevNum++;
326 	return ImpFindOutDev();
327 }
328 
329 ////////////////////////////////////////////////////////////////////////////////////////////////////
330 
FirstWindow()331 Window* SdrViewIter::FirstWindow()
332 {
333 	ImpInitVars();
334 	ImpFindView();
335 	return ImpFindWindow();
336 }
337 
338 ////////////////////////////////////////////////////////////////////////////////////////////////////
339 
NextWindow()340 Window* SdrViewIter::NextWindow()
341 {
342 	mnOutDevNum++;
343 	return ImpFindWindow();
344 }
345 
346 ////////////////////////////////////////////////////////////////////////////////////////////////////
347 
348