Line data Source code
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/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>
26 :
27 : using namespace com::sun::star;
28 :
29 : namespace sdr
30 : {
31 : // ViewContact part
32 2406 : sdr::contact::ViewContact* MasterPageDescriptor::CreateObjectSpecificViewContact()
33 : {
34 2406 : return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
35 : }
36 :
37 2406 : MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
38 : : maOwnerPage(aOwnerPage),
39 : maUsedPage(aUsedPage),
40 2406 : mpViewContact(0L)
41 : {
42 : // all layers visible
43 2406 : maVisibleLayers.SetAll();
44 :
45 : // register at used page
46 2406 : maUsedPage.AddPageUser(*this);
47 2406 : }
48 :
49 7218 : MasterPageDescriptor::~MasterPageDescriptor()
50 : {
51 : // de-register at used page
52 2406 : maUsedPage.RemovePageUser(*this);
53 :
54 2406 : if(mpViewContact)
55 : {
56 2406 : delete mpViewContact;
57 2406 : mpViewContact = 0L;
58 : }
59 4812 : }
60 :
61 : // ViewContact part
62 15260 : sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
63 : {
64 15260 : if(!mpViewContact)
65 : {
66 : const_cast< MasterPageDescriptor* >(this)->mpViewContact =
67 2406 : const_cast< MasterPageDescriptor* >(this)->CreateObjectSpecificViewContact();
68 : }
69 :
70 15260 : return *mpViewContact;
71 : }
72 :
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 0 : void MasterPageDescriptor::PageInDestruction(const SdrPage& /*rPage*/)
77 : {
78 0 : maOwnerPage.TRG_ClearMasterPage();
79 0 : }
80 :
81 450 : void MasterPageDescriptor::SetVisibleLayers(const SetOfByte& rNew)
82 : {
83 450 : if(rNew != maVisibleLayers)
84 : {
85 0 : maVisibleLayers = rNew;
86 0 : GetViewContact().ActionChanged();
87 : }
88 450 : }
89 :
90 : // operators
91 0 : bool MasterPageDescriptor::operator==(const MasterPageDescriptor& rCandidate) const
92 : {
93 0 : return (&maOwnerPage == &rCandidate.maOwnerPage
94 0 : && &maUsedPage == &rCandidate.maUsedPage
95 0 : && maVisibleLayers == rCandidate.maVisibleLayers);
96 : }
97 :
98 0 : bool MasterPageDescriptor::operator!=(const MasterPageDescriptor& rCandidate) const
99 : {
100 0 : return (&maOwnerPage != &rCandidate.maOwnerPage
101 0 : || &maUsedPage != &rCandidate.maUsedPage
102 0 : || maVisibleLayers != rCandidate.maVisibleLayers);
103 : }
104 :
105 1050 : const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
106 : {
107 1050 : const SdrPage* pCorrectPage = &GetOwnerPage();
108 1050 : const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
109 :
110 1050 : if(drawing::FillStyle_NONE == static_cast<const XFillStyleItem&>(pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
111 : {
112 1050 : pCorrectPage = &GetUsedPage();
113 1050 : pCorrectProperties = &pCorrectPage->getSdrPageProperties();
114 : }
115 :
116 1050 : if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet())
117 : {
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 8 : pCorrectProperties = 0;
123 : }
124 :
125 1050 : return pCorrectProperties;
126 : }
127 651 : } // end of namespace sdr
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|