bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / svdraw / sdrmasterpagedescriptor.cxx
blob9e8e80dd768fee5e69645b85dc1fc351dcb28fd0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
22 #include <svx/svdpage.hxx>
24 // #i42075#
25 #include <svx/svdobj.hxx>
26 #include <svx/xfillit0.hxx>
27 #include <svl/itemset.hxx>
29 //////////////////////////////////////////////////////////////////////////////
31 namespace sdr
33 // ViewContact part
34 sdr::contact::ViewContact* MasterPageDescriptor::CreateObjectSpecificViewContact()
36 return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
39 MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
40 : maOwnerPage(aOwnerPage),
41 maUsedPage(aUsedPage),
42 mpViewContact(0L)
44 // all layers visible
45 maVisibleLayers.SetAll();
47 // register at used page
48 maUsedPage.AddPageUser(*this);
51 MasterPageDescriptor::~MasterPageDescriptor()
53 // de-register at used page
54 maUsedPage.RemovePageUser(*this);
56 if(mpViewContact)
58 delete mpViewContact;
59 mpViewContact = 0L;
63 // ViewContact part
64 sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
66 if(!mpViewContact)
68 const_cast< MasterPageDescriptor* >(this)->mpViewContact =
69 const_cast< MasterPageDescriptor* >(this)->CreateObjectSpecificViewContact();
72 return *mpViewContact;
75 // this method is called form the destructor of the referenced page.
76 // do all necessary action to forget the page. It is not necessary to call
77 // RemovePageUser(), that is done form the destructor.
78 void MasterPageDescriptor::PageInDestruction(const SdrPage& /*rPage*/)
80 maOwnerPage.TRG_ClearMasterPage();
83 void MasterPageDescriptor::SetVisibleLayers(const SetOfByte& rNew)
85 if(rNew != maVisibleLayers)
87 maVisibleLayers = rNew;
88 GetViewContact().ActionChanged();
92 // operators
93 bool MasterPageDescriptor::operator==(const MasterPageDescriptor& rCandidate) const
95 return (&maOwnerPage == &rCandidate.maOwnerPage
96 && &maUsedPage == &rCandidate.maUsedPage
97 && maVisibleLayers == rCandidate.maVisibleLayers);
100 bool MasterPageDescriptor::operator!=(const MasterPageDescriptor& rCandidate) const
102 return (&maOwnerPage != &rCandidate.maOwnerPage
103 || &maUsedPage != &rCandidate.maUsedPage
104 || maVisibleLayers != rCandidate.maVisibleLayers);
107 const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
109 const SdrPage* pCorrectPage = &GetOwnerPage();
110 const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
112 if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
114 pCorrectPage = &GetUsedPage();
115 pCorrectProperties = &pCorrectPage->getSdrPageProperties();
118 if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet())
120 // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
121 // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
122 // MasterPages should have a StyleSheet excactly for this reason, but historically
123 // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
124 pCorrectProperties = 0;
127 return pCorrectProperties;
129 } // end of namespace sdr
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */