Branch data 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/sdr/properties/groupproperties.hxx>
21 : : #include <svl/itemset.hxx>
22 : : #include <svl/whiter.hxx>
23 : : #include <svx/svddef.hxx>
24 : : #include <editeng/eeitem.hxx>
25 : : #include <svx/svdogrp.hxx>
26 : : #include <svx/svdpool.hxx>
27 : : #include <svx/svdpage.hxx>
28 : :
29 : : //////////////////////////////////////////////////////////////////////////////
30 : :
31 : : namespace sdr
32 : : {
33 : : namespace properties
34 : : {
35 : : // create a new itemset
36 : 0 : SfxItemSet& GroupProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool)
37 : : {
38 : : // Groups have in principle no ItemSet. To support methods like
39 : : // GetMergedItemSet() the local one is used. Thus, all items in the pool
40 : : // may be used and a pool itemset is created.
41 [ # # ]: 0 : return *(new SfxItemSet(rPool));
42 : : }
43 : :
44 : 34814 : GroupProperties::GroupProperties(SdrObject& rObj)
45 : 34814 : : DefaultProperties(rObj)
46 : : {
47 : 34814 : }
48 : :
49 : 0 : GroupProperties::GroupProperties(const GroupProperties& rProps, SdrObject& rObj)
50 : 0 : : DefaultProperties(rProps, rObj)
51 : : {
52 : 0 : }
53 : :
54 : 34814 : GroupProperties::~GroupProperties()
55 : : {
56 [ - + ]: 69628 : }
57 : :
58 : 0 : BaseProperties& GroupProperties::Clone(SdrObject& rObj) const
59 : : {
60 [ # # ]: 0 : return *(new GroupProperties(*this, rObj));
61 : : }
62 : :
63 : 0 : const SfxItemSet& GroupProperties::GetObjectItemSet() const
64 : : {
65 : : DBG_ASSERT(sal_False, "GroupProperties::GetObjectItemSet() should never be called (!)");
66 : 0 : return DefaultProperties::GetObjectItemSet();
67 : : }
68 : :
69 : 0 : const SfxItemSet& GroupProperties::GetMergedItemSet() const
70 : : {
71 : : // prepare ItemSet
72 [ # # ]: 0 : if(mpItemSet)
73 : : {
74 : : // clear local itemset for merge
75 : 0 : mpItemSet->ClearItem();
76 : : }
77 : : else
78 : : {
79 : : // force local itemset
80 : 0 : DefaultProperties::GetObjectItemSet();
81 : : }
82 : :
83 : : // collect all ItemSets in mpItemSet
84 : 0 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
85 : 0 : const sal_uInt32 nCount(pSub->GetObjCount());
86 : :
87 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
88 : : {
89 [ # # ][ # # ]: 0 : const SfxItemSet& rSet = pSub->GetObj(a)->GetMergedItemSet();
90 [ # # ]: 0 : SfxWhichIter aIter(rSet);
91 [ # # ]: 0 : sal_uInt16 nWhich(aIter.FirstWhich());
92 : :
93 [ # # ]: 0 : while(nWhich)
94 : : {
95 [ # # ][ # # ]: 0 : if(SFX_ITEM_DONTCARE == rSet.GetItemState(nWhich, sal_False))
96 : : {
97 [ # # ]: 0 : mpItemSet->InvalidateItem(nWhich);
98 : : }
99 : : else
100 : : {
101 [ # # ][ # # ]: 0 : mpItemSet->MergeValue(rSet.Get(nWhich), sal_True);
102 : : }
103 : :
104 [ # # ]: 0 : nWhich = aIter.NextWhich();
105 : : }
106 [ # # ]: 0 : }
107 : :
108 : : // For group proerties, do not call parent since groups do
109 : : // not have local ItemSets.
110 : 0 : return *mpItemSet;
111 : : }
112 : :
113 : 0 : void GroupProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems)
114 : : {
115 : : // iterate over contained SdrObjects
116 : 0 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
117 : 0 : const sal_uInt32 nCount(pSub->GetObjCount());
118 : :
119 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
120 : : {
121 : 0 : SdrObject* pObj = pSub->GetObj(a);
122 : :
123 [ # # ]: 0 : if(pObj)
124 : : {
125 : : // Set merged ItemSet at contained object
126 : 0 : pObj->SetMergedItemSet(rSet, bClearAllItems);
127 : : }
128 : : }
129 : :
130 : : // Do not call parent here. Group objects do not have local ItemSets
131 : : // where items need to be set.
132 : : // DefaultProperties::SetMergedItemSet(rSet, bClearAllItems);
133 : 0 : }
134 : :
135 : 0 : void GroupProperties::SetObjectItem(const SfxPoolItem& /*rItem*/)
136 : : {
137 : : DBG_ASSERT(sal_False, "GroupProperties::SetObjectItem() should never be called (!)");
138 : 0 : }
139 : :
140 : 0 : void GroupProperties::SetObjectItemDirect(const SfxPoolItem& /*rItem*/)
141 : : {
142 : : DBG_ASSERT(sal_False, "GroupProperties::SetObjectItemDirect() should never be called (!)");
143 : 0 : }
144 : :
145 : 0 : void GroupProperties::ClearObjectItem(const sal_uInt16 /*nWhich*/)
146 : : {
147 : : DBG_ASSERT(sal_False, "GroupProperties::ClearObjectItem() should never be called (!)");
148 : 0 : }
149 : :
150 : 0 : void GroupProperties::ClearObjectItemDirect(const sal_uInt16 /*nWhich*/)
151 : : {
152 : : DBG_ASSERT(sal_False, "GroupProperties::ClearObjectItemDirect() should never be called (!)");
153 : 0 : }
154 : :
155 : 0 : void GroupProperties::SetMergedItem(const SfxPoolItem& rItem)
156 : : {
157 : 0 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
158 : 0 : const sal_uInt32 nCount(pSub->GetObjCount());
159 : :
160 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
161 : : {
162 : 0 : pSub->GetObj(a)->GetProperties().SetMergedItem(rItem);
163 : : }
164 : 0 : }
165 : :
166 : 6 : void GroupProperties::ClearMergedItem(const sal_uInt16 nWhich)
167 : : {
168 : 6 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
169 : 6 : const sal_uInt32 nCount(pSub->GetObjCount());
170 : :
171 [ - + ]: 6 : for(sal_uInt32 a(0L); a < nCount; a++)
172 : : {
173 : 0 : pSub->GetObj(a)->GetProperties().ClearMergedItem(nWhich);
174 : : }
175 : 6 : }
176 : :
177 : 0 : void GroupProperties::SetObjectItemSet(const SfxItemSet& /*rSet*/)
178 : : {
179 : : DBG_ASSERT(sal_False, "GroupProperties::SetObjectItemSet() should never be called (!)");
180 : 0 : }
181 : :
182 : 0 : void GroupProperties::ItemSetChanged(const SfxItemSet& /*rSet*/)
183 : : {
184 : : DBG_ASSERT(sal_False, "GroupProperties::ItemSetChanged() should never be called (!)");
185 : 0 : }
186 : :
187 : 0 : sal_Bool GroupProperties::AllowItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/) const
188 : : {
189 : : DBG_ASSERT(sal_False, "GroupProperties::AllowItemChange() should never be called (!)");
190 : 0 : return sal_False;
191 : : }
192 : :
193 : 0 : void GroupProperties::ItemChange(const sal_uInt16 /*nWhich*/, const SfxPoolItem* /*pNewItem*/)
194 : : {
195 : : DBG_ASSERT(sal_False, "GroupProperties::ItemChange() should never be called (!)");
196 : 0 : }
197 : :
198 : 0 : void GroupProperties::PostItemChange(const sal_uInt16 /*nWhich*/)
199 : : {
200 : : DBG_ASSERT(sal_False, "GroupProperties::PostItemChange() should never be called (!)");
201 : 0 : }
202 : :
203 : 0 : SfxStyleSheet* GroupProperties::GetStyleSheet() const
204 : : {
205 : 0 : SfxStyleSheet* pRetval = 0L;
206 : :
207 : 0 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
208 : 0 : const sal_uInt32 nCount(pSub->GetObjCount());
209 : :
210 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
211 : : {
212 : 0 : SfxStyleSheet* pCandidate = pSub->GetObj(a)->GetStyleSheet();
213 : :
214 [ # # ]: 0 : if(pRetval)
215 : : {
216 [ # # ]: 0 : if(pCandidate != pRetval)
217 : : {
218 : : // different StyleSheelts, return none
219 : 0 : return 0L;
220 : : }
221 : : }
222 : : else
223 : : {
224 : 0 : pRetval = pCandidate;
225 : : }
226 : : }
227 : :
228 : 0 : return pRetval;
229 : : }
230 : :
231 : 0 : void GroupProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr)
232 : : {
233 : 0 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
234 : 0 : const sal_uInt32 nCount(pSub->GetObjCount());
235 : :
236 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
237 : : {
238 : 0 : pSub->GetObj(a)->SetStyleSheet(pNewStyleSheet, bDontRemoveHardAttr);
239 : : }
240 : 0 : }
241 : :
242 : 0 : void GroupProperties::ForceDefaultAttributes()
243 : : {
244 : : // nothing to do here, groups have no items and thus no default items, too.
245 : 0 : }
246 : :
247 : 34814 : void GroupProperties::MoveToItemPool(SfxItemPool* pSrcPool, SfxItemPool* pDestPool, SdrModel* pNewModel)
248 : : {
249 [ + - ][ + - ]: 34814 : if(pSrcPool && pDestPool && (pSrcPool != pDestPool))
[ + - ]
250 : : {
251 : 34814 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
252 : 34814 : const sal_uInt32 nCount(pSub->GetObjCount());
253 : :
254 [ + + ]: 35202 : for(sal_uInt32 a(0L); a < nCount; a++)
255 : : {
256 : 388 : pSub->GetObj(a)->GetProperties().MoveToItemPool(pSrcPool, pDestPool, pNewModel);
257 : : }
258 : :
259 : : // also clear local ItemSet, it's only temporary for group objects anyways.
260 [ - + ]: 34814 : if(mpItemSet)
261 : : {
262 : : // #121905#
263 : : // copy/paste is still using clone operators and MoveToItemPool functionality.
264 : : // Since SfxItemSet contains a pool pointer, ClearItem is not enough here.
265 : : // The ItemSet for merge is constructed on demand, so it's enough here to
266 : : // just delete it and set to 0L.
267 : : // mpItemSet->ClearItem();
268 [ # # ]: 0 : delete mpItemSet;
269 : 0 : mpItemSet = 0L;
270 : : }
271 : : }
272 : 34814 : }
273 : :
274 : 0 : void GroupProperties::ForceStyleToHardAttributes()
275 : : {
276 : 0 : const SdrObjList* pSub = ((const SdrObjGroup&)GetSdrObject()).GetSubList();
277 : 0 : const sal_uInt32 nCount(pSub->GetObjCount());
278 : :
279 [ # # ]: 0 : for(sal_uInt32 a(0L); a < nCount; a++)
280 : : {
281 : 0 : pSub->GetObj(a)->GetProperties().ForceStyleToHardAttributes();
282 : : }
283 : 0 : }
284 : : } // end of namespace properties
285 : : } // end of namespace sdr
286 : :
287 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|