nss: upgrade to release 3.73
[LibreOffice.git] / svx / source / svdraw / svdviter.cxx
blobff2d6da5f7a3d6b9d4c66c699cb3580927911559
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 .
20 #include <svx/svdviter.hxx>
21 #include <svx/svdobj.hxx>
22 #include <svx/svdpage.hxx>
23 #include <svx/svdmodel.hxx>
24 #include <svx/svdview.hxx>
25 #include <svx/svdpagv.hxx>
26 #include <svx/svdsob.hxx>
28 void SdrViewIter::ImpInitVars()
30 mnListenerNum = 0;
31 mpCurrentView = nullptr;
34 SdrViewIter::SdrViewIter(const SdrPage* pPage)
36 mpPage = pPage;
37 mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
38 mpObject = nullptr;
39 ImpInitVars();
42 SdrViewIter::SdrViewIter(const SdrObject* pObject)
44 mpObject = pObject;
45 mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
46 mpPage = pObject ? pObject->getSdrPageFromSdrObject() : nullptr;
48 if (!mpModel || !mpPage)
50 mpModel = nullptr;
51 mpPage = nullptr;
54 ImpInitVars();
57 bool SdrViewIter::ImpCheckPageView(SdrPageView const* pPV) const
59 if (!mpPage)
60 return true;
62 bool bMaster(mpPage->IsMasterPage());
63 SdrPage* pPg = pPV->GetPage();
65 if (pPg == mpPage)
67 if (mpObject)
69 // Looking for an object? First, determine if it visible in
70 // this PageView.
71 SdrLayerIDSet aObjLay;
72 mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
73 aObjLay &= pPV->GetVisibleLayers();
74 return !aObjLay.IsEmpty();
76 else
78 return true;
81 else if (bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
83 if (pPg->TRG_HasMasterPage())
85 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
87 if (&rMasterPage == mpPage)
89 // the page we're looking for is a master page in this PageView
90 if (mpObject)
92 // Looking for an object? First, determine if it visible in
93 // this PageView.
94 SdrLayerIDSet aObjLay;
95 mpObject->getMergedHierarchySdrLayerIDSet(aObjLay);
96 aObjLay &= pPV->GetVisibleLayers();
97 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
99 if (!aObjLay.IsEmpty())
101 return true;
102 } // else, look at the next master page of this page...
104 else
106 return true;
112 // master page forbidden or no fitting master page found
113 return false;
116 SdrView* SdrViewIter::ImpFindView()
118 if (mpModel)
120 const size_t nLsCnt(mpModel->GetSizeOfVector());
122 while (mnListenerNum < nLsCnt)
124 SfxListener* pLs = mpModel->GetListener(mnListenerNum);
125 mpCurrentView = dynamic_cast<SdrView*>(pLs);
127 if (mpCurrentView)
129 if (mpPage)
131 SdrPageView* pPV = mpCurrentView->GetSdrPageView();
133 if (pPV && ImpCheckPageView(pPV))
135 return mpCurrentView;
138 else
140 return mpCurrentView;
144 mnListenerNum++;
148 mpCurrentView = nullptr;
149 return mpCurrentView;
152 SdrView* SdrViewIter::FirstView()
154 ImpInitVars();
155 return ImpFindView();
158 SdrView* SdrViewIter::NextView()
160 mnListenerNum++;
161 return ImpFindView();
164 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */