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
28static bool ImpCheckPageView(const SdrPage* pPage, const SdrObject* pObject, SdrPageView const* pPV)
29{
30 if (!pPage)
31 return true;
32
33 bool bMaster(pPage->IsMasterPage());
34 SdrPage* pPg = pPV->GetPage();
35
36 if (pPg == pPage)
37 {
38 if (pObject)
39 {
40 // Looking for an object? First, determine if it visible in
41 // this PageView.
42 return pObject->isVisibleOnAnyOfTheseLayers(pPV->GetVisibleLayers());
43 }
44 else
45 {
46 return true;
47 }
48 }
49 else if (bMaster && (!pObject || !pObject->IsNotVisibleAsMaster()))
50 {
51 if (pPg->TRG_HasMasterPage())
52 {
53 SdrPage& rMasterPage = pPg->TRG_GetMasterPage();
54
55 if (&rMasterPage == pPage)
56 {
57 // the page we're looking for is a master page in this PageView
58 if (pObject)
59 {
60 // Looking for an object? First, determine if it visible in
61 // this PageView.
62 SdrLayerIDSet aObjLay = pPV->GetVisibleLayers();
63 aObjLay &= pPg->TRG_GetMasterPageVisibleLayers();
64 if (pObject->isVisibleOnAnyOfTheseLayers(aObjLay))
65 {
66 return true;
67 } // else, look at the next master page of this page...
68 }
69 else
70 {
71 return true;
72 }
73 }
74 }
75 }
76
77 // master page forbidden or no fitting master page found
78 return false;
79}
80
81namespace SdrViewIter
82{
83void ForAllViews(const SdrPage* pPage, std::function<void(SdrView*)> f)
84{
85 if (!pPage)
86 return;
87 const SdrModel* pModel = &pPage->getSdrModelFromSdrPage();
88
89 pModel->ForAllListeners([&pPage, &f](SfxListener* pLs) {
90 if (!pLs->IsSdrView())
91 return false;
92 SdrView* pCurrentView = static_cast<SdrView*>(pLs);
93 SdrPageView* pPV = pCurrentView->GetSdrPageView();
94
95 if (pPV && ImpCheckPageView(pPage, nullptr, pPV))
96 {
97 f(pCurrentView);
98 }
99 return false;
100 });
101}
102
103void ForAllViews(const SdrObject* pObject, std::function<void(SdrView*)> f)
104{
105 if (!pObject)
106 return;
107 const SdrModel* pModel = &pObject->getSdrModelFromSdrObject();
108 const SdrPage* pPage = pObject->getSdrPageFromSdrObject();
109 if (!pPage)
110 return;
111
112 pModel->ForAllListeners([&pPage, &pObject, &f](SfxListener* pLs) {
113 if (!pLs->IsSdrView())
114 return false;
115 SdrView* pCurrentView = static_cast<SdrView*>(pLs);
116 SdrPageView* pPV = pCurrentView->GetSdrPageView();
117
118 if (pPV && ImpCheckPageView(pPage, pObject, pPV))
119 {
120 f(pCurrentView);
121 }
122 return false;
123 });
124}
125}
126/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Abstract DrawObject.
Definition: svdobj.hxx:260
const SdrLayerIDSet & GetVisibleLayers() const
Definition: svdpagv.hxx:210
SdrPage * GetPage() const
Definition: svdpagv.hxx:166
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:379
SdrPage & TRG_GetMasterPage() const
Definition: svdpage.cxx:1658
bool IsMasterPage() const
Definition: svdpage.hxx:464
bool TRG_HasMasterPage() const
Definition: svdpage.hxx:500
const SdrLayerIDSet & TRG_GetMasterPageVisibleLayers() const
Definition: svdpage.cxx:1664
SdrModel & getSdrModelFromSdrPage() const
Definition: svdpage.hxx:403
void ForAllListeners(std::function< bool(SfxListener *)> f) const
virtual bool IsSdrView() const
EmbeddedObjectRef * pObject
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
void ForAllViews(const SdrPage *pPage, std::function< void(SdrView *)> f)
Definition: svdviter.cxx:83
static bool ImpCheckPageView(const SdrPage *pPage, const SdrObject *pObject, SdrPageView const *pPV)
Definition: svdviter.cxx:28