/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 | 867k | : mrObject(rObj) |
36 | 867k | { |
37 | 867k | } |
38 | | |
39 | | BaseProperties::~BaseProperties() |
40 | 867k | { |
41 | 867k | } |
42 | | |
43 | | const SdrObject& BaseProperties::GetSdrObject() const |
44 | 15.3M | { |
45 | 15.3M | return mrObject; |
46 | 15.3M | } |
47 | | |
48 | | SdrObject& BaseProperties::GetSdrObject() |
49 | 73.3M | { |
50 | 73.3M | return mrObject; |
51 | 73.3M | } |
52 | | |
53 | | const SfxItemSet& BaseProperties::GetMergedItemSet() const |
54 | 6.16M | { |
55 | | // default implementation falls back to GetObjectItemSet() |
56 | 6.16M | return GetObjectItemSet(); |
57 | 6.16M | } |
58 | | |
59 | | void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, bool bClearAllItems, bool bAdjustTextFrameWidthAndHeight) |
60 | 1.37M | { |
61 | | // clear items if requested |
62 | 1.37M | if(bClearAllItems) |
63 | 0 | { |
64 | 0 | ClearObjectItem(); |
65 | 0 | } |
66 | | |
67 | | // default implementation falls back to SetObjectItemSet() |
68 | 1.37M | SetObjectItemSet(rSet, bAdjustTextFrameWidthAndHeight); |
69 | 1.37M | } |
70 | | |
71 | | void BaseProperties::SetMergedItem(const SfxPoolItem& rItem) |
72 | 2.49M | { |
73 | | // default implementation falls back to SetObjectItem() |
74 | 2.49M | SetObjectItem(rItem); |
75 | 2.49M | } |
76 | | |
77 | | void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich) |
78 | 10.3k | { |
79 | | // default implementation falls back to ClearObjectItem() |
80 | 10.3k | ClearObjectItem(nWhich); |
81 | 10.3k | } |
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 | 621k | { |
92 | 621k | ItemChangeBroadcaster aC(GetSdrObject()); |
93 | | |
94 | 621k | if(bClearAllItems) |
95 | 0 | { |
96 | 0 | ClearObjectItem(); |
97 | 0 | } |
98 | | |
99 | 621k | SetMergedItemSet(rSet); |
100 | 621k | BroadcastItemChange(aC); |
101 | 621k | } |
102 | | |
103 | | const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const |
104 | 1.51M | { |
105 | 1.51M | return GetObjectItemSet().Get(nWhich); |
106 | 1.51M | } |
107 | | |
108 | | void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange) |
109 | 622k | { |
110 | 622k | const sal_uInt32 nCount(rChange.GetRectangleCount()); |
111 | | |
112 | | // invalidate all new rectangles |
113 | 622k | SdrObject* pObj = &GetSdrObject(); |
114 | 622k | if (pObj->GetObjIdentifier() == SdrObjKind::Group) |
115 | 357 | { |
116 | 357 | SdrObjGroup* pObjGroup = static_cast<SdrObjGroup*>(pObj); |
117 | 357 | SdrObjListIter aIter(pObjGroup, SdrIterMode::DeepNoGroups); |
118 | | |
119 | 1.56k | while(aIter.IsMore()) |
120 | 1.20k | { |
121 | 1.20k | SdrObject* pChildObj = aIter.Next(); |
122 | 1.20k | pChildObj->BroadcastObjectChange(); |
123 | 1.20k | } |
124 | 357 | } |
125 | 622k | else |
126 | 622k | { |
127 | 622k | pObj->BroadcastObjectChange(); |
128 | 622k | } |
129 | | |
130 | | // also send the user calls |
131 | 1.24M | for(sal_uInt32 a(0); a < nCount; a++) |
132 | 623k | { |
133 | 623k | pObj->SendUserCall(SdrUserCallType::ChangeAttr, rChange.GetRectangle(a)); |
134 | 623k | } |
135 | 622k | } |
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 | 541k | { |
150 | 541k | const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, false) == SfxItemState::SET; |
151 | 541k | const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, false) == SfxItemState::SET; |
152 | 541k | const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, false) == SfxItemState::SET; |
153 | 541k | if( !(bFillBitmap || bFillGradient || bFillHatch) ) |
154 | 527k | return; |
155 | | |
156 | 13.2k | const XFillStyleItem* pFillStyleItem = rItemSet.GetItem(XATTR_FILLSTYLE); |
157 | 13.2k | if( !pFillStyleItem ) |
158 | 0 | return; |
159 | | |
160 | 13.2k | if( bFillBitmap && (pFillStyleItem->GetValue() != drawing::FillStyle_BITMAP) ) |
161 | 599 | { |
162 | 599 | rItemSet.ClearItem( XATTR_FILLBITMAP ); |
163 | 599 | } |
164 | | |
165 | 13.2k | if( bFillGradient && (pFillStyleItem->GetValue() != drawing::FillStyle_GRADIENT) ) |
166 | 1.32k | { |
167 | 1.32k | rItemSet.ClearItem( XATTR_FILLGRADIENT ); |
168 | 1.32k | } |
169 | | |
170 | 13.2k | if( bFillHatch && (pFillStyleItem->GetValue() != drawing::FillStyle_HATCH) ) |
171 | 0 | { |
172 | 0 | rItemSet.ClearItem( XATTR_FILLHATCH ); |
173 | 0 | } |
174 | 13.2k | } |
175 | | |
176 | | } // end of namespace |
177 | | |
178 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |