LibreOffice Module svx (master)  1
svdviter.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 
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>
29 
30 
32 {
33  mnListenerNum = 0;
34  mpCurrentView = nullptr;
35 }
36 
37 
39 {
40  mpPage = pPage;
41  mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
42  mpObject = nullptr;
43  ImpInitVars();
44 }
45 
46 
48 {
49  mpObject = pObject;
50  mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
51  mpPage = pObject ? pObject->getSdrPageFromSdrObject() : nullptr;
52 
53  if(!mpModel || !mpPage)
54  {
55  mpModel = nullptr;
56  mpPage = nullptr;
57  }
58 
59  ImpInitVars();
60 }
61 
62 
64 {
65  if(!mpPage)
66  return true;
67 
68  bool bMaster(mpPage->IsMasterPage());
69  SdrPage* pPg = pPV->GetPage();
70 
71  if(pPg == mpPage)
72  {
73  if(mpObject)
74  {
75  // Looking for an object? First, determine if it visible in
76  // this PageView.
77  SdrLayerIDSet aObjLay;
79  aObjLay &= pPV->GetVisibleLayers();
80  return !aObjLay.IsEmpty();
81  }
82  else
83  {
84  return true;
85  }
86  }
87  else if(bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
88  {
89  if(pPg->TRG_HasMasterPage())
90  {
91  SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
92 
93  if(&rMasterPage == mpPage)
94  {
95  // the page we're looking for is a master page in this PageView
96  if(mpObject)
97  {
98  // Looking for an object? First, determine if it visible in
99  // this PageView.
100  SdrLayerIDSet aObjLay;
102  aObjLay &= pPV->GetVisibleLayers();
103  aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
104 
105  if(!aObjLay.IsEmpty())
106  {
107  return true;
108  } // else, look at the next master page of this page...
109  }
110  else
111  {
112  return true;
113  }
114  }
115  }
116  }
117 
118  // master page forbidden or no fitting master page found
119  return false;
120 }
121 
123 {
124  if(mpModel)
125  {
126  const size_t nLsCnt(mpModel->GetSizeOfVector());
127 
128  while(mnListenerNum < nLsCnt)
129  {
131  mpCurrentView = dynamic_cast<SdrView*>( pLs );
132 
133  if(mpCurrentView)
134  {
135  if(mpPage)
136  {
138 
139  if(pPV && ImpCheckPageView(pPV))
140  {
141  return mpCurrentView;
142  }
143  }
144  else
145  {
146  return mpCurrentView;
147  }
148  }
149 
150  mnListenerNum++;
151  }
152  }
153 
154  mpCurrentView = nullptr;
155  return mpCurrentView;
156 }
157 
158 
160 {
161  ImpInitVars();
162  return ImpFindView();
163 }
164 
165 
167 {
168  mnListenerNum++;
169  return ImpFindView();
170 }
171 
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1580
bool IsNotVisibleAsMaster() const
Definition: svdobj.hxx:882
const SdrModel * mpModel
Definition: svdviter.hxx:65
bool IsEmpty() const
Definition: svdlayer.cxx:27
SdrView * NextView()
Definition: svdviter.cxx:166
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:289
SVX_DLLPRIVATE SdrView * ImpFindView()
Definition: svdviter.cxx:122
size_t GetSizeOfVector() const
void getMergedHierarchySdrLayerIDSet(SdrLayerIDSet &rSet) const
Definition: svdobj.cxx:609
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:217
SfxListener * GetListener(size_t nNo) const
SVX_DLLPRIVATE bool ImpCheckPageView(SdrPageView const *pPV) const
Definition: svdviter.cxx:63
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:299
const SdrPage * mpPage
Definition: svdviter.hxx:66
bool IsMasterPage() const
Definition: svdpage.hxx:451
SdrView * mpCurrentView
Definition: svdviter.hxx:68
Abstract DrawObject.
Definition: svdobj.hxx:312
SdrViewIter(const SdrPage *pPage)
Definition: svdviter.cxx:38
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:391
SdrPage * GetPage() const
Definition: svdpagv.hxx:173
SVX_DLLPRIVATE void ImpInitVars()
Definition: svdviter.cxx:31
SdrPageView * GetSdrPageView() const
Definition: svdpntv.hxx:310
const SdrObject * mpObject
Definition: svdviter.hxx:67
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:366
size_t mnListenerNum
Definition: svdviter.hxx:70
SdrView * FirstView()
Definition: svdviter.cxx:159