bump product version to 6.3.0.0.beta1
[LibreOffice.git] / svx / source / svdraw / svdviter.cxx
blobdfc7f7d4153143a51556cd7ed21252cd30989359
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 mpCurrentView = nullptr;
38 SdrViewIter::SdrViewIter(const SdrPage* pPage)
40 mpPage = pPage;
41 mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
42 mpObject = nullptr;
43 ImpInitVars();
47 SdrViewIter::SdrViewIter(const SdrObject* pObject)
49 mpObject = pObject;
50 mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
51 mpPage = pObject ? pObject->getSdrPageFromSdrObject() : nullptr;
53 if(!mpModel || !mpPage)
55 mpModel = nullptr;
56 mpPage = nullptr;
59 ImpInitVars();
63 bool SdrViewIter::ImpCheckPageView(SdrPageView const * pPV) const
65 if(!mpPage)
66 return true;
68 bool bMaster(mpPage->IsMasterPage());
69 SdrPage* pPg = pPV->GetPage();
71 if(pPg == mpPage)
73 if(mpObject)
75 // Looking for an object? First, determine if it visible in
76 // this PageView.
77 SdrLayerIDSet aObjLay;
78 mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
79 aObjLay &= pPV->GetVisibleLayers();
80 return !aObjLay.IsEmpty();
82 else
84 return true;
87 else if(bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
89 if(pPg->TRG_HasMasterPage())
91 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
93 if(&rMasterPage == mpPage)
95 // the page we're looking for is a master page in this PageView
96 if(mpObject)
98 // Looking for an object? First, determine if it visible in
99 // this PageView.
100 SdrLayerIDSet aObjLay;
101 mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
102 aObjLay &= pPV->GetVisibleLayers();
103 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
105 if(!aObjLay.IsEmpty())
107 return true;
108 } // else, look at the next master page of this page...
110 else
112 return true;
118 // master page forbidden or no fitting master page found
119 return false;
122 SdrView* SdrViewIter::ImpFindView()
124 if(mpModel)
126 const size_t nLsCnt(mpModel->GetSizeOfVector());
128 while(mnListenerNum < nLsCnt)
130 SfxListener* pLs = mpModel->GetListener(mnListenerNum);
131 mpCurrentView = dynamic_cast<SdrView*>( pLs );
133 if(mpCurrentView)
135 if(mpPage)
137 SdrPageView* pPV = mpCurrentView->GetSdrPageView();
139 if(pPV && ImpCheckPageView(pPV))
141 return mpCurrentView;
144 else
146 return mpCurrentView;
150 mnListenerNum++;
154 mpCurrentView = nullptr;
155 return mpCurrentView;
159 SdrView* SdrViewIter::FirstView()
161 ImpInitVars();
162 return ImpFindView();
166 SdrView* SdrViewIter::NextView()
168 mnListenerNum++;
169 return ImpFindView();
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */