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 
29 
31 {
32  mnListenerNum = 0;
33  mpCurrentView = nullptr;
34 }
35 
36 
38 {
39  mpPage = pPage;
40  mpModel = pPage ? &pPage->getSdrModelFromSdrPage() : nullptr;
41  mpObject = nullptr;
42  ImpInitVars();
43 }
44 
45 
47 {
48  mpObject = pObject;
49  mpModel = pObject ? &pObject->getSdrModelFromSdrObject() : nullptr;
50  mpPage = pObject ? pObject->getSdrPageFromSdrObject() : nullptr;
51 
52  if(!mpModel || !mpPage)
53  {
54  mpModel = nullptr;
55  mpPage = nullptr;
56  }
57 
58  ImpInitVars();
59 }
60 
61 
63 {
64  if(!mpPage)
65  return true;
66 
67  bool bMaster(mpPage->IsMasterPage());
68  SdrPage* pPg = pPV->GetPage();
69 
70  if(pPg == mpPage)
71  {
72  if(mpObject)
73  {
74  // Looking for an object? First, determine if it visible in
75  // this PageView.
76  SdrLayerIDSet aObjLay;
78  aObjLay &= pPV->GetVisibleLayers();
79  return !aObjLay.IsEmpty();
80  }
81  else
82  {
83  return true;
84  }
85  }
86  else if(bMaster && (!mpObject || !mpObject->IsNotVisibleAsMaster()))
87  {
88  if(pPg->TRG_HasMasterPage())
89  {
90  SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
91 
92  if(&rMasterPage == mpPage)
93  {
94  // the page we're looking for is a master page in this PageView
95  if(mpObject)
96  {
97  // Looking for an object? First, determine if it visible in
98  // this PageView.
99  SdrLayerIDSet aObjLay;
101  aObjLay &= pPV->GetVisibleLayers();
102  aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
103 
104  if(!aObjLay.IsEmpty())
105  {
106  return true;
107  } // else, look at the next master page of this page...
108  }
109  else
110  {
111  return true;
112  }
113  }
114  }
115  }
116 
117  // master page forbidden or no fitting master page found
118  return false;
119 }
120 
122 {
123  if(mpModel)
124  {
125  const size_t nLsCnt(mpModel->GetSizeOfVector());
126 
127  while(mnListenerNum < nLsCnt)
128  {
130  mpCurrentView = dynamic_cast<SdrView*>( pLs );
131 
132  if(mpCurrentView)
133  {
134  if(mpPage)
135  {
137 
138  if(pPV && ImpCheckPageView(pPV))
139  {
140  return mpCurrentView;
141  }
142  }
143  else
144  {
145  return mpCurrentView;
146  }
147  }
148 
149  mnListenerNum++;
150  }
151  }
152 
153  mpCurrentView = nullptr;
154  return mpCurrentView;
155 }
156 
157 
159 {
160  ImpInitVars();
161  return ImpFindView();
162 }
163 
164 
166 {
167  mnListenerNum++;
168  return ImpFindView();
169 }
170 
171 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1556
bool IsNotVisibleAsMaster() const
Definition: svdobj.hxx:883
const SdrModel * mpModel
Definition: svdviter.hxx:65
bool IsEmpty() const
Definition: svdlayer.cxx:25
SdrView * NextView()
Definition: svdviter.cxx:165
SdrPage * getSdrPageFromSdrObject() const
Definition: svdobj.cxx:263
SVX_DLLPRIVATE SdrView * ImpFindView()
Definition: svdviter.cxx:121
size_t GetSizeOfVector() const
void getMergedHierarchySdrLayerIDSet(SdrLayerIDSet &rSet) const
Definition: svdobj.cxx:582
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:215
SfxListener * GetListener(size_t nNo) const
SVX_DLLPRIVATE bool ImpCheckPageView(SdrPageView const *pPV) const
Definition: svdviter.cxx:62
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:273
const SdrPage * mpPage
Definition: svdviter.hxx:66
bool IsMasterPage() const
Definition: svdpage.hxx:450
SdrView * mpCurrentView
Definition: svdviter.hxx:68
Abstract DrawObject.
Definition: svdobj.hxx:312
SdrViewIter(const SdrPage *pPage)
Definition: svdviter.cxx:37
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:390
SdrPage * GetPage() const
Definition: svdpagv.hxx:171
SVX_DLLPRIVATE void ImpInitVars()
Definition: svdviter.cxx:30
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:365
size_t mnListenerNum
Definition: svdviter.hxx:70
SdrView * FirstView()
Definition: svdviter.cxx:158