Adjust includes
[LibreOffice.git] / svx / source / svdraw / svdviter.cxx
blob6ef07497b40b811df0ae6c6092b015efbce2b356
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svx/svdviter.hxx>
22 #include <svx/svdobj.hxx>
23 #include <svx/svdpage.hxx>
24 #include <svx/svdmodel.hxx>
25 #include <svx/svdview.hxx>
26 #include <svx/svdpagv.hxx>
27 #include <svx/svdsob.hxx>
28 #include <svx/sdrpaintwindow.hxx>
31 void SdrViewIter::ImpInitVars()
33 mnListenerNum = 0;
34 mpAktView = nullptr;
38 SdrViewIter::SdrViewIter(const SdrPage* pPage)
40 mpPage = pPage;
41 mpModel = pPage ? pPage->GetModel() : nullptr;
42 mpObject = nullptr;
43 mbNoMasterPage = false;
44 ImpInitVars();
48 SdrViewIter::SdrViewIter(const SdrObject* pObject)
50 mpObject = pObject;
51 mpModel = pObject ? pObject->GetModel() : nullptr;
52 mpPage = pObject ? pObject->GetPage() : nullptr;
53 mbNoMasterPage = false;
55 if(!mpModel || !mpPage)
57 mpModel = nullptr;
58 mpPage = nullptr;
61 ImpInitVars();
65 bool SdrViewIter::ImpCheckPageView(SdrPageView const * pPV) const
67 if(!mpPage)
68 return true;
70 bool bMaster(mpPage->IsMasterPage());
71 SdrPage* pPg = pPV->GetPage();
73 if(pPg == mpPage)
75 if(mpObject)
77 // Looking for an object? First, determine if it visible in
78 // this PageView.
79 SdrLayerIDSet aObjLay;
80 mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
81 aObjLay &= pPV->GetVisibleLayers();
82 return !aObjLay.IsEmpty();
84 else
86 return true;
89 else if(!mbNoMasterPage && bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
91 if(pPg->TRG_HasMasterPage())
93 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
95 if(&rMasterPage == mpPage)
97 // the page we're looking for is a master page in this PageView
98 if(mpObject)
100 // Looking for an object? First, determine if it visible in
101 // this PageView.
102 SdrLayerIDSet aObjLay;
103 mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
104 aObjLay &= pPV->GetVisibleLayers();
105 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
107 if(!aObjLay.IsEmpty())
109 return true;
110 } // else, look at the next master page of this page...
112 else
114 return true;
120 // master page forbidden or no fitting master page found
121 return false;
124 SdrView* SdrViewIter::ImpFindView()
126 if(mpModel)
128 const size_t nLsCnt(mpModel->GetSizeOfVector());
130 while(mnListenerNum < nLsCnt)
132 SfxListener* pLs = mpModel->GetListener(mnListenerNum);
133 mpAktView = dynamic_cast<SdrView*>( pLs );
135 if(mpAktView)
137 if(mpPage)
139 SdrPageView* pPV = mpAktView->GetSdrPageView();
141 if(pPV)
143 if(ImpCheckPageView(pPV))
145 return mpAktView;
149 else
151 return mpAktView;
155 mnListenerNum++;
159 mpAktView = nullptr;
160 return mpAktView;
164 SdrView* SdrViewIter::FirstView()
166 ImpInitVars();
167 return ImpFindView();
171 SdrView* SdrViewIter::NextView()
173 mnListenerNum++;
174 return ImpFindView();
177 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */