Coverage Report

Created: 2025-12-31 10:39

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/svdraw/sdrmasterpagedescriptor.cxx
Line
Count
Source
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/xdef.hxx>
24
#include <svx/xfillit0.hxx>
25
#include <svl/itemset.hxx>
26
27
using namespace com::sun::star;
28
29
namespace sdr
30
{
31
    MasterPageDescriptor::MasterPageDescriptor(SdrPage& aOwnerPage, SdrPage& aUsedPage)
32
608k
    :   maOwnerPage(aOwnerPage),
33
608k
        maUsedPage(aUsedPage)
34
608k
    {
35
        // all layers visible
36
608k
        maVisibleLayers.SetAll();
37
38
        // register at used page
39
608k
        maUsedPage.AddPageUser(*this);
40
608k
    }
41
42
    MasterPageDescriptor::~MasterPageDescriptor()
43
608k
    {
44
        // de-register at used page
45
608k
        maUsedPage.RemovePageUser(*this);
46
47
608k
        mpViewContact.reset();
48
608k
    }
49
50
    // ViewContact part
51
    sdr::contact::ViewContact& MasterPageDescriptor::GetViewContact() const
52
2.17M
    {
53
2.17M
        if(!mpViewContact)
54
608k
        {
55
608k
            mpViewContact.reset(
56
608k
                new sdr::contact::ViewContactOfMasterPageDescriptor(*const_cast< MasterPageDescriptor* >(this)) );
57
608k
        }
58
59
2.17M
        return *mpViewContact;
60
2.17M
    }
61
62
    // this method is called from the destructor of the referenced page.
63
    // do all necessary action to forget the page. It is not necessary to call
64
    // RemovePageUser(), that is done from the destructor.
65
    void MasterPageDescriptor::PageInDestruction(const SdrPage& /*rPage*/)
66
0
    {
67
0
        maOwnerPage.TRG_ClearMasterPage();
68
0
    }
69
70
    void MasterPageDescriptor::SetVisibleLayers(const SdrLayerIDSet& rNew)
71
220k
    {
72
220k
        if(rNew != maVisibleLayers)
73
246
        {
74
246
            maVisibleLayers = rNew;
75
246
            GetViewContact().ActionChanged();
76
246
        }
77
220k
    }
78
79
80
    const SdrPageProperties* MasterPageDescriptor::getCorrectSdrPageProperties() const
81
0
    {
82
0
        const SdrPage* pCorrectPage = &GetOwnerPage();
83
0
        const SdrPageProperties* pCorrectProperties = &pCorrectPage->getSdrPageProperties();
84
85
0
        if(drawing::FillStyle_NONE == pCorrectProperties->GetItemSet().Get(XATTR_FILLSTYLE).GetValue())
86
0
        {
87
0
            pCorrectPage = &GetUsedPage();
88
0
            pCorrectProperties = &pCorrectPage->getSdrPageProperties();
89
0
        }
90
91
0
        if(pCorrectPage->IsMasterPage() && !pCorrectProperties->GetStyleSheet())
92
0
        {
93
            // #i110846# Suppress SdrPage FillStyle for MasterPages without StyleSheets,
94
            // else the PoolDefault (XFILL_COLOR and Blue8) will be used. Normally, all
95
            // MasterPages should have a StyleSheet exactly for this reason, but historically
96
            // e.g. the Notes MasterPage has no StyleSheet set (and there maybe others).
97
0
            pCorrectProperties = nullptr;
98
0
        }
99
100
0
        return pCorrectProperties;
101
0
    }
102
} // end of namespace sdr
103
104
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */