Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/sdr/properties/properties.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 <libxml/xmlwriter.h>
21
22
#include <svx/sdr/properties/properties.hxx>
23
#include <sdr/properties/itemsettools.hxx>
24
#include <svl/itemset.hxx>
25
#include <svx/svdogrp.hxx>
26
#include <svx/svditer.hxx>
27
#include <svx/xdef.hxx>
28
#include <svx/xfillit0.hxx>
29
30
using namespace com::sun::star;
31
32
namespace sdr::properties
33
{
34
        BaseProperties::BaseProperties(SdrObject& rObj)
35
1.67M
        :   mrObject(rObj)
36
1.67M
        {
37
1.67M
        }
38
39
        BaseProperties::~BaseProperties()
40
1.67M
        {
41
1.67M
        }
42
43
        const SdrObject& BaseProperties::GetSdrObject() const
44
18.3M
        {
45
18.3M
            return mrObject;
46
18.3M
        }
47
48
        SdrObject& BaseProperties::GetSdrObject()
49
95.9M
        {
50
95.9M
            return mrObject;
51
95.9M
        }
52
53
        const SfxItemSet& BaseProperties::GetMergedItemSet() const
54
5.22M
        {
55
            // default implementation falls back to GetObjectItemSet()
56
5.22M
            return GetObjectItemSet();
57
5.22M
        }
58
59
        void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems, bool bAdjustTextFrameWidthAndHeight)
60
2.47M
        {
61
            // clear items if requested
62
2.47M
            if(bClearAllItems)
63
0
            {
64
0
                ClearObjectItem();
65
0
            }
66
67
            // default implementation falls back to SetObjectItemSet()
68
2.47M
            SetObjectItemSet(rSet, bAdjustTextFrameWidthAndHeight);
69
2.47M
        }
70
71
        void BaseProperties::SetMergedItem(const SfxPoolItem& rItem)
72
2.25M
        {
73
            // default implementation falls back to SetObjectItem()
74
2.25M
            SetObjectItem(rItem);
75
2.25M
        }
76
77
        void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich)
78
17.4k
        {
79
            // default implementation falls back to ClearObjectItem()
80
17.4k
            ClearObjectItem(nWhich);
81
17.4k
        }
82
83
        void BaseProperties::ForceStyleToHardAttributes()
84
0
        {
85
            // force all attributes which come from styles to hard attributes
86
            // to be able to live without the style. Default implementation does nothing.
87
            // Override where an ItemSet is implemented.
88
0
        }
89
90
        void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, bool bClearAllItems)
91
694k
        {
92
694k
            ItemChangeBroadcaster aC(GetSdrObject());
93
94
694k
            if(bClearAllItems)
95
0
            {
96
0
                ClearObjectItem();
97
0
            }
98
99
694k
            SetMergedItemSet(rSet);
100
694k
            BroadcastItemChange(aC);
101
694k
        }
102
103
        const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const
104
1.79M
        {
105
1.79M
            return GetObjectItemSet().Get(nWhich);
106
1.79M
        }
107
108
        void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange)
109
695k
        {
110
695k
            const sal_uInt32 nCount(rChange.GetRectangleCount());
111
112
            // invalidate all new rectangles
113
695k
            SdrObject* pObj = &GetSdrObject();
114
695k
            if (pObj->GetObjIdentifier() == SdrObjKind::Group)
115
1.10k
            {
116
1.10k
                SdrObjGroup* pObjGroup = static_cast<SdrObjGroup*>(pObj);
117
1.10k
                SdrObjListIter aIter(pObjGroup, SdrIterMode::DeepNoGroups);
118
119
4.77k
                while(aIter.IsMore())
120
3.66k
                {
121
3.66k
                    SdrObject* pChildObj = aIter.Next();
122
3.66k
                    pChildObj->BroadcastObjectChange();
123
3.66k
                }
124
1.10k
            }
125
694k
            else
126
694k
            {
127
694k
                pObj->BroadcastObjectChange();
128
694k
            }
129
130
            // also send the user calls
131
1.39M
            for(sal_uInt32 a(0); a < nCount; a++)
132
698k
            {
133
698k
                pObj->SendUserCall(SdrUserCallType::ChangeAttr, rChange.GetRectangle(a));
134
698k
            }
135
695k
        }
136
137
        sal_uInt32 BaseProperties::getVersion() const
138
0
        {
139
0
            return 0;
140
0
        }
141
142
        void BaseProperties::dumpAsXml(xmlTextWriterPtr pWriter) const
143
0
        {
144
0
            (void)xmlTextWriterStartElement(pWriter, BAD_CAST("BaseProperties"));
145
0
            (void)xmlTextWriterEndElement(pWriter);
146
0
        }
147
148
        void CleanupFillProperties( SfxItemSet& rItemSet )
149
620k
        {
150
620k
            const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, false) == SfxItemState::SET;
151
620k
            const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, false) == SfxItemState::SET;
152
620k
            const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, false) == SfxItemState::SET;
153
620k
            if( !(bFillBitmap || bFillGradient || bFillHatch) )
154
606k
                return;
155
156
14.0k
            const XFillStyleItem* pFillStyleItem = rItemSet.GetItem(XATTR_FILLSTYLE);
157
14.0k
            if( !pFillStyleItem )
158
0
                return;
159
160
14.0k
            if( bFillBitmap && (pFillStyleItem->GetValue() != drawing::FillStyle_BITMAP) )
161
597
            {
162
597
                rItemSet.ClearItem( XATTR_FILLBITMAP );
163
597
            }
164
165
14.0k
            if( bFillGradient && (pFillStyleItem->GetValue() != drawing::FillStyle_GRADIENT) )
166
1.49k
            {
167
1.49k
                rItemSet.ClearItem( XATTR_FILLGRADIENT );
168
1.49k
            }
169
170
14.0k
            if( bFillHatch && (pFillStyleItem->GetValue() != drawing::FillStyle_HATCH) )
171
0
            {
172
0
                rItemSet.ClearItem( XATTR_FILLHATCH );
173
0
            }
174
14.0k
        }
175
176
} // end of namespace
177
178
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */