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/sdrmasterpagedescriptor.hxx>
21 #include <sdr/contact/viewcontactofmasterpagedescriptor.hxx>
22 #include <svx/svdpage.hxx>
23 #include <svx/svdobj.hxx>
24 #include <svx/xfillit0.hxx>
25 #include <svl/itemset.hxx>
27 using namespace com::sun::star
;
32 sdr::contact::ViewContact
* MasterPageDescriptor::CreateObjectSpecificViewContact()
34 return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
37 MasterPageDescriptor::MasterPageDescriptor(SdrPage
& aOwnerPage
, SdrPage
& aUsedPage
)
38 : maOwnerPage(aOwnerPage
),
39 maUsedPage(aUsedPage
),
43 maVisibleLayers
.SetAll();
45 // register at used page
46 maUsedPage
.AddPageUser(*this);
49 MasterPageDescriptor::~MasterPageDescriptor()
51 // de-register at used page
52 maUsedPage
.RemovePageUser(*this);
62 sdr::contact::ViewContact
& MasterPageDescriptor::GetViewContact() const
66 const_cast< MasterPageDescriptor
* >(this)->mpViewContact
=
67 const_cast< MasterPageDescriptor
* >(this)->CreateObjectSpecificViewContact();
70 return *mpViewContact
;
73 // this method is called form the destructor of the referenced page.
74 // do all necessary action to forget the page. It is not necessary to call
75 // RemovePageUser(), that is done form the destructor.
76 void MasterPageDescriptor::PageInDestruction(const SdrPage
& /*rPage*/)
78 maOwnerPage
.TRG_ClearMasterPage();
81 void MasterPageDescriptor::SetVisibleLayers(const SetOfByte
& rNew
)
83 if(rNew
!= maVisibleLayers
)
85 maVisibleLayers
= rNew
;
86 GetViewContact().ActionChanged();
91 bool MasterPageDescriptor::operator==(const MasterPageDescriptor
& rCandidate
) const
93 return (&maOwnerPage
== &rCandidate
.maOwnerPage
94 && &maUsedPage
== &rCandidate
.maUsedPage
95 && maVisibleLayers
== rCandidate
.maVisibleLayers
);
98 bool MasterPageDescriptor::operator!=(const MasterPageDescriptor
& rCandidate
) const
100 return (&maOwnerPage
!= &rCandidate
.maOwnerPage
101 || &maUsedPage
!= &rCandidate
.maUsedPage
102 || maVisibleLayers
!= rCandidate
.maVisibleLayers
);
105 const SdrPageProperties
* MasterPageDescriptor::getCorrectSdrPageProperties() const
107 const SdrPage
* pCorrectPage
= &GetOwnerPage();
108 const SdrPageProperties
* pCorrectProperties
= &pCorrectPage
->getSdrPageProperties();
110 if(drawing::FillStyle_NONE
== static_cast<const XFillStyleItem
&>(pCorrectProperties
->GetItemSet().Get(XATTR_FILLSTYLE
)).GetValue())
112 pCorrectPage
= &GetUsedPage();
113 pCorrectProperties
= &pCorrectPage
->getSdrPageProperties();
116 if(pCorrectPage
->IsMasterPage() && !pCorrectProperties
->GetStyleSheet())
118 // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
119 // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
120 // MasterPages should have a StyleSheet excactly for this reason, but historically
121 // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
122 pCorrectProperties
= 0;
125 return pCorrectProperties
;
127 } // end of namespace sdr
129 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */