Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
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>
39 : :
40 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
41 : :
42 : 46584 : void SdrViewIter::ImpInitVars()
43 : : {
44 : 46584 : mnListenerNum = 0L;
45 : 46584 : mnPageViewNum = 0L;
46 : 46584 : mnOutDevNum = 0L;
47 : 46584 : mpAktView = 0L;
48 : 46584 : }
49 : :
50 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
51 : :
52 : 0 : SdrViewIter::SdrViewIter(const SdrPage* pPage, sal_Bool bNoMasterPage)
53 : : {
54 : 0 : mpPage = pPage;
55 [ # # ]: 0 : mpModel = (pPage) ? pPage->GetModel() : 0L;
56 : 0 : mpObject = 0L;
57 : 0 : mbNoMasterPage = bNoMasterPage;
58 : 0 : ImpInitVars();
59 : 0 : }
60 : :
61 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
62 : :
63 : 23292 : SdrViewIter::SdrViewIter(const SdrObject* pObject, sal_Bool bNoMasterPage)
64 : : {
65 : 23292 : mpObject = pObject;
66 [ + - ]: 23292 : mpModel = (pObject) ? pObject->GetModel() : 0L;
67 [ + - ]: 23292 : mpPage = (pObject) ? pObject->GetPage() : 0L;
68 : 23292 : mbNoMasterPage = bNoMasterPage;
69 : :
70 [ + + ][ + + ]: 23292 : if(!mpModel || !mpPage)
71 : : {
72 : 110 : mpModel = 0L;
73 : 110 : mpPage = 0L;
74 : : }
75 : :
76 : 23292 : ImpInitVars();
77 : 23292 : }
78 : :
79 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
80 : :
81 : 1844 : sal_Bool SdrViewIter::ImpCheckPageView(SdrPageView* pPV) const
82 : : {
83 [ + - ]: 1844 : if(mpPage)
84 : : {
85 : 1844 : sal_Bool bMaster(mpPage->IsMasterPage());
86 : 1844 : SdrPage* pPg = pPV->GetPage();
87 : :
88 [ + - ]: 1844 : if(pPg == mpPage)
89 : : {
90 [ + - ]: 1844 : if(mpObject)
91 : : {
92 : : // Looking for an object? First, determine if it visible in
93 : : // this PageView.
94 : 1844 : SetOfByte aObjLay;
95 [ + - ]: 1844 : mpObject->getMergedHierarchyLayerSet(aObjLay);
96 [ + - ]: 1844 : aObjLay &= pPV->GetVisibleLayers();
97 [ + - ]: 1844 : return !aObjLay.IsEmpty();
98 : : }
99 : : else
100 : : {
101 : 0 : return sal_True;
102 : : }
103 : : }
104 : : else
105 : : {
106 [ # # ][ # # ]: 0 : if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
[ # # ][ # # ]
[ # # ]
107 : : {
108 [ # # ]: 0 : if(pPg->TRG_HasMasterPage())
109 : : {
110 : 0 : SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
111 : :
112 [ # # ]: 0 : if(&rMasterPage == mpPage)
113 : : {
114 : : // the page we're looking for is a master page in this PageView
115 [ # # ]: 0 : if(mpObject)
116 : : {
117 : : // Looking for an object? First, determine if it visible in
118 : : // this PageView.
119 : 0 : SetOfByte aObjLay;
120 [ # # ]: 0 : mpObject->getMergedHierarchyLayerSet(aObjLay);
121 [ # # ]: 0 : aObjLay &= pPV->GetVisibleLayers();
122 [ # # ][ # # ]: 0 : aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
123 : :
124 [ # # ][ # # ]: 0 : if(!aObjLay.IsEmpty())
125 : : {
126 : 0 : return sal_True;
127 : : } // else, look at the next master page of this page...
128 : : }
129 : : else
130 : : {
131 : 0 : return sal_True;
132 : : }
133 : : }
134 : : }
135 : : }
136 : :
137 : : // master page forbidden or no fitting master page found
138 : 0 : return sal_False;
139 : : }
140 : : }
141 : : else
142 : : {
143 : 1844 : return sal_True;
144 : : }
145 : : }
146 : :
147 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
148 : :
149 : 24214 : SdrView* SdrViewIter::ImpFindView()
150 : : {
151 [ + + ]: 24214 : if(mpModel)
152 : : {
153 : 24104 : sal_uInt32 nLsAnz(mpModel->GetListenerCount());
154 : :
155 [ + + ]: 1317941 : while(mnListenerNum < nLsAnz)
156 : : {
157 : 1294759 : SfxListener* pLs = mpModel->GetListener((sal_uInt16)mnListenerNum);
158 [ + + ][ + + ]: 1294759 : mpAktView = PTR_CAST(SdrView, pLs);
159 : :
160 [ + + ]: 1294759 : if(mpAktView)
161 : : {
162 [ + - ]: 39041 : if(mpPage)
163 : : {
164 : 39041 : SdrPageView* pPV = mpAktView->GetSdrPageView();
165 : :
166 [ + + ]: 39041 : if(pPV)
167 : : {
168 [ + + ]: 1844 : if(ImpCheckPageView(pPV))
169 : : {
170 : 922 : return mpAktView;
171 : : }
172 : : }
173 : : }
174 : : else
175 : : {
176 : 0 : return mpAktView;
177 : : }
178 : : }
179 : :
180 : 1293837 : mnListenerNum++;
181 : : }
182 : : }
183 : :
184 : 23292 : mpAktView = 0L;
185 : 24214 : return mpAktView;
186 : : }
187 : :
188 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
189 : :
190 : 23292 : SdrView* SdrViewIter::FirstView()
191 : : {
192 : 23292 : ImpInitVars();
193 : 23292 : return ImpFindView();
194 : : }
195 : :
196 : : ////////////////////////////////////////////////////////////////////////////////////////////////////
197 : :
198 : 922 : SdrView* SdrViewIter::NextView()
199 : : {
200 : 922 : mnListenerNum++;
201 : 922 : return ImpFindView();
202 : : }
203 : :
204 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|