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 <svx/sdr/contact/viewcontactofmasterpagedescriptor.hxx>
22 : #include <svx/svdpage.hxx>
23 :
24 : // #i42075#
25 : #include <svx/svdobj.hxx>
26 : #include <svx/xfillit0.hxx>
27 : #include <svl/itemset.hxx>
28 :
29 : //////////////////////////////////////////////////////////////////////////////
30 :
31 : namespace sdr
32 : {
33 : // ViewContact part
34 127 : sdr::contact::ViewContact* MasterPageDescriptor::CreateObjectSpecificViewContact()
35 : {
36 127 : return new sdr::contact::ViewContactOfMasterPageDescriptor(*this);
37 : }
38 :
39 127 : MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
40 : : maOwnerPage(aOwnerPage),
41 : maUsedPage(aUsedPage),
42 127 : mpViewContact(0L)
43 : {
44 : // all layers visible
45 127 : maVisibleLayers.SetAll();
46 :
47 : // register at used page
48 127 : maUsedPage.AddPageUser(*this);
49 127 : }
50 :
51 363 : MasterPageDescriptor::~MasterPageDescriptor()
52 : {
53 : // de-register at used page
54 121 : maUsedPage.RemovePageUser(*this);
55 :
56 121 : if(mpViewContact)
57 : {
58 121 : delete mpViewContact;
59 121 : mpViewContact = 0L;
60 : }
61 242 : }
62 :
63 : // ViewContact part
64 1467 : sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
65 : {
66 1467 : if(!mpViewContact)
67 : {
68 : const_cast< MasterPageDescriptor* >(this)->mpViewContact =
69 127 : const_cast< MasterPageDescriptor* >(this)->CreateObjectSpecificViewContact();
70 : }
71 :
72 1467 : return *mpViewContact;
73 : }
74 :
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 0 : void MasterPageDescriptor::PageInDestruction(const SdrPage& /*rPage*/)
79 : {
80 0 : maOwnerPage.TRG_ClearMasterPage();
81 0 : }
82 :
83 23 : void MasterPageDescriptor::SetVisibleLayers(const SetOfByte& rNew)
84 : {
85 23 : if(rNew != maVisibleLayers)
86 : {
87 0 : maVisibleLayers = rNew;
88 0 : GetViewContact().ActionChanged();
89 : }
90 23 : }
91 :
92 : // operators
93 0 : sal_Bool MasterPageDescriptor::operator==(const MasterPageDescriptor& rCandidate) const
94 : {
95 : return (&maOwnerPage == &rCandidate.maOwnerPage
96 : && &maUsedPage == &rCandidate.maUsedPage
97 0 : && maVisibleLayers == rCandidate.maVisibleLayers);
98 : }
99 :
100 0 : sal_Bool MasterPageDescriptor::operator!=(const MasterPageDescriptor& rCandidate) const
101 : {
102 : return (&maOwnerPage != &rCandidate.maOwnerPage
103 : || &maUsedPage != &rCandidate.maUsedPage
104 0 : || maVisibleLayers != rCandidate.maVisibleLayers);
105 : }
106 :
107 0 : const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
108 : {
109 0 : const SdrPage* pCorrectPage = &GetOwnerPage();
110 0 : const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
111 :
112 0 : if(XFILL_NONE == ((const XFillStyleItem&)pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE)).GetValue())
113 : {
114 0 : pCorrectPage = &GetUsedPage();
115 0 : pCorrectProperties = &pCorrectPage->getSdrPageProperties();
116 : }
117 :
118 0 : if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet())
119 : {
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 0 : pCorrectProperties = 0;
125 : }
126 :
127 0 : return pCorrectProperties;
128 : }
129 : } // end of namespace sdr
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|