1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 static bool ImpCheckPageView(const SdrPage
* pPage
, const SdrObject
* pObject
, SdrPageView
const* pPV
)
33 bool bMaster(pPage
->IsMasterPage());
34 SdrPage
* pPg
= pPV
->GetPage();
40 // Looking for an object? First, determine if it visible in
42 return pObject
->isVisibleOnAnyOfTheseLayers(pPV
->GetVisibleLayers());
49 else if (bMaster
&& (!pObject
|| !pObject
->IsNotVisibleAsMaster()))
51 if (pPg
->TRG_HasMasterPage())
53 SdrPage
& rMasterPage
= pPg
->TRG_GetMasterPage();
55 if (&rMasterPage
== pPage
)
57 // the page we're looking for is a master page in this PageView
60 // Looking for an object? First, determine if it visible in
62 SdrLayerIDSet aObjLay
= pPV
->GetVisibleLayers();
63 aObjLay
&= pPg
->TRG_GetMasterPageVisibleLayers();
64 if (pObject
->isVisibleOnAnyOfTheseLayers(aObjLay
))
67 } // else, look at the next master page of this page...
77 // master page forbidden or no fitting master page found
83 void ForAllViews(const SdrPage
* pPage
, std::function
<void(SdrView
*)> f
)
87 const SdrModel
* pModel
= &pPage
->getSdrModelFromSdrPage();
89 pModel
->ForAllListeners([&pPage
, &f
](SfxListener
* pLs
) {
90 if (!pLs
->IsSdrView())
92 SdrView
* pCurrentView
= static_cast<SdrView
*>(pLs
);
93 SdrPageView
* pPV
= pCurrentView
->GetSdrPageView();
95 if (pPV
&& ImpCheckPageView(pPage
, nullptr, pPV
))
103 void ForAllViews(const SdrObject
* pObject
, std::function
<void(SdrView
*)> f
)
107 const SdrModel
* pModel
= &pObject
->getSdrModelFromSdrObject();
108 const SdrPage
* pPage
= pObject
->getSdrPageFromSdrObject();
112 pModel
->ForAllListeners([&pPage
, &pObject
, &f
](SfxListener
* pLs
) {
113 if (!pLs
->IsSdrView())
115 SdrView
* pCurrentView
= static_cast<SdrView
*>(pLs
);
116 SdrPageView
* pPV
= pCurrentView
->GetSdrPageView();
118 if (pPV
&& ImpCheckPageView(pPage
, pObject
, pPV
))
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */