1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: sdrmasterpagedescriptor.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdrmasterpagedescriptor.hxx>
34 #include <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
35 #include <svx/svdpage.hxx>
38 #include <svx/svdobj.hxx>
40 //////////////////////////////////////////////////////////////////////////////
45 sdr::contact::ViewContact
* MasterPageDescriptor::CreateObjectSpecificViewContact()
47 return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
50 MasterPageDescriptor::MasterPageDescriptor(SdrPage
& aOwnerPage
, SdrPage
& aUsedPage
)
51 : maOwnerPage(aOwnerPage
),
52 maUsedPage(aUsedPage
),
56 maVisibleLayers
.SetAll();
58 // register at used page
59 maUsedPage
.AddPageUser(*this);
62 MasterPageDescriptor::~MasterPageDescriptor()
64 // de-register at used page
65 maUsedPage
.RemovePageUser(*this);
75 sdr::contact::ViewContact
& MasterPageDescriptor::GetViewContact() const
79 ((MasterPageDescriptor
*)this)->mpViewContact
= ((MasterPageDescriptor
*)this)->CreateObjectSpecificViewContact();
82 return *mpViewContact
;
85 // this method is called form the destructor of the referenced page.
86 // do all necessary action to forget the page. It is not necessary to call
87 // RemovePageUser(), that is done form the destructor.
88 void MasterPageDescriptor::PageInDestruction(const SdrPage
& /*rPage*/)
90 maOwnerPage
.TRG_ClearMasterPage();
93 void MasterPageDescriptor::SetVisibleLayers(const SetOfByte
& rNew
)
95 if(rNew
!= maVisibleLayers
)
97 maVisibleLayers
= rNew
;
98 GetViewContact().ActionChanged();
100 // #i42075# For AFs convenience, do a change notify at the MasterPageBackgroundObject, too
101 SdrObject
* pObject
= GetBackgroundObject();
105 pObject
->BroadcastObjectChange();
111 sal_Bool
MasterPageDescriptor::operator==(const MasterPageDescriptor
& rCandidate
) const
113 return (&maOwnerPage
== &rCandidate
.maOwnerPage
114 && &maUsedPage
== &rCandidate
.maUsedPage
115 && maVisibleLayers
== rCandidate
.maVisibleLayers
);
118 sal_Bool
MasterPageDescriptor::operator!=(const MasterPageDescriptor
& rCandidate
) const
120 return (&maOwnerPage
!= &rCandidate
.maOwnerPage
121 || &maUsedPage
!= &rCandidate
.maUsedPage
122 || maVisibleLayers
!= rCandidate
.maVisibleLayers
);
125 // #i42075# Get the correct BackgroundObject
126 SdrObject
* MasterPageDescriptor::GetBackgroundObject() const
128 SdrObject
* pRetval
= 0L;
129 const SdrPage
& rMasterPage
= GetUsedPage();
131 // Here i will rely on old knowledge about the 0'st element of a masterpage
132 // being the PageBackgroundObject. This will be removed again when that definition
135 const sal_uInt32
nMasterPageObjectCount(rMasterPage
.GetObjCount());
136 DBG_ASSERT(1 <= nMasterPageObjectCount
,
137 "MasterPageDescriptor::GetBackgroundObject(): MasterPageBackgroundObject missing (!)");
139 pRetval
= rMasterPage
.GetObj(0L);
141 // Test if it's really what we need. There are known problems where
142 // the 0th object is not the MasterPageBackgroundObject at all.
143 if(pRetval
&& !pRetval
->IsMasterPageBackgroundObject())
148 // Get the evtl. existing page background object from the using page and use it
149 // preferred to the MasterPageBackgroundObject
150 const SdrPage
& rOwnerPage
= GetOwnerPage();
151 SdrObject
* pCandidate
= rOwnerPage
.GetBackgroundObj();
155 pRetval
= pCandidate
;
160 } // end of namespace sdr
162 //////////////////////////////////////////////////////////////////////////////