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