1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
29 //////////////////////////////////////////////////////////////////////////////
35 // create a new itemset
36 SfxItemSet
& GroupProperties::CreateObjectSpecificItemSet(SfxItemPool
& rPool
)
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 return *(new SfxItemSet(rPool
));
44 GroupProperties::GroupProperties(SdrObject
& rObj
)
45 : DefaultProperties(rObj
)
49 GroupProperties::GroupProperties(const GroupProperties
& rProps
, SdrObject
& rObj
)
50 : DefaultProperties(rProps
, rObj
)
54 GroupProperties::~GroupProperties()
58 BaseProperties
& GroupProperties::Clone(SdrObject
& rObj
) const
60 return *(new GroupProperties(*this, rObj
));
63 const SfxItemSet
& GroupProperties::GetObjectItemSet() const
65 DBG_ASSERT(sal_False
, "GroupProperties::GetObjectItemSet() should never be called (!)");
66 return DefaultProperties::GetObjectItemSet();
69 const SfxItemSet
& GroupProperties::GetMergedItemSet() const
74 // clear local itemset for merge
75 mpItemSet
->ClearItem();
79 // force local itemset
80 DefaultProperties::GetObjectItemSet();
83 // collect all ItemSets in mpItemSet
84 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
85 const sal_uInt32
nCount(pSub
->GetObjCount());
87 for(sal_uInt32
a(0L); a
< nCount
; a
++)
89 const SfxItemSet
& rSet
= pSub
->GetObj(a
)->GetMergedItemSet();
90 SfxWhichIter
aIter(rSet
);
91 sal_uInt16
nWhich(aIter
.FirstWhich());
95 if(SFX_ITEM_DONTCARE
== rSet
.GetItemState(nWhich
, sal_False
))
97 mpItemSet
->InvalidateItem(nWhich
);
101 mpItemSet
->MergeValue(rSet
.Get(nWhich
), sal_True
);
104 nWhich
= aIter
.NextWhich();
108 // For group proerties, do not call parent since groups do
109 // not have local ItemSets.
113 void GroupProperties::SetMergedItemSet(const SfxItemSet
& rSet
, sal_Bool bClearAllItems
)
115 // iterate over contained SdrObjects
116 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
117 const sal_uInt32
nCount(pSub
->GetObjCount());
119 for(sal_uInt32
a(0L); a
< nCount
; a
++)
121 SdrObject
* pObj
= pSub
->GetObj(a
);
125 // Set merged ItemSet at contained object
126 pObj
->SetMergedItemSet(rSet
, bClearAllItems
);
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);
135 void GroupProperties::SetObjectItem(const SfxPoolItem
& /*rItem*/)
137 DBG_ASSERT(sal_False
, "GroupProperties::SetObjectItem() should never be called (!)");
140 void GroupProperties::SetObjectItemDirect(const SfxPoolItem
& /*rItem*/)
142 DBG_ASSERT(sal_False
, "GroupProperties::SetObjectItemDirect() should never be called (!)");
145 void GroupProperties::ClearObjectItem(const sal_uInt16
/*nWhich*/)
147 DBG_ASSERT(sal_False
, "GroupProperties::ClearObjectItem() should never be called (!)");
150 void GroupProperties::ClearObjectItemDirect(const sal_uInt16
/*nWhich*/)
152 DBG_ASSERT(sal_False
, "GroupProperties::ClearObjectItemDirect() should never be called (!)");
155 void GroupProperties::SetMergedItem(const SfxPoolItem
& rItem
)
157 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
158 const sal_uInt32
nCount(pSub
->GetObjCount());
160 for(sal_uInt32
a(0L); a
< nCount
; a
++)
162 pSub
->GetObj(a
)->GetProperties().SetMergedItem(rItem
);
166 void GroupProperties::ClearMergedItem(const sal_uInt16 nWhich
)
168 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
169 const sal_uInt32
nCount(pSub
->GetObjCount());
171 for(sal_uInt32
a(0L); a
< nCount
; a
++)
173 pSub
->GetObj(a
)->GetProperties().ClearMergedItem(nWhich
);
177 void GroupProperties::SetObjectItemSet(const SfxItemSet
& /*rSet*/)
179 DBG_ASSERT(sal_False
, "GroupProperties::SetObjectItemSet() should never be called (!)");
182 void GroupProperties::ItemSetChanged(const SfxItemSet
& /*rSet*/)
184 DBG_ASSERT(sal_False
, "GroupProperties::ItemSetChanged() should never be called (!)");
187 sal_Bool
GroupProperties::AllowItemChange(const sal_uInt16
/*nWhich*/, const SfxPoolItem
* /*pNewItem*/) const
189 DBG_ASSERT(sal_False
, "GroupProperties::AllowItemChange() should never be called (!)");
193 void GroupProperties::ItemChange(const sal_uInt16
/*nWhich*/, const SfxPoolItem
* /*pNewItem*/)
195 DBG_ASSERT(sal_False
, "GroupProperties::ItemChange() should never be called (!)");
198 void GroupProperties::PostItemChange(const sal_uInt16
/*nWhich*/)
200 DBG_ASSERT(sal_False
, "GroupProperties::PostItemChange() should never be called (!)");
203 SfxStyleSheet
* GroupProperties::GetStyleSheet() const
205 SfxStyleSheet
* pRetval
= 0L;
207 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
208 const sal_uInt32
nCount(pSub
->GetObjCount());
210 for(sal_uInt32
a(0L); a
< nCount
; a
++)
212 SfxStyleSheet
* pCandidate
= pSub
->GetObj(a
)->GetStyleSheet();
216 if(pCandidate
!= pRetval
)
218 // different StyleSheelts, return none
224 pRetval
= pCandidate
;
231 void GroupProperties::SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
)
233 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
234 const sal_uInt32
nCount(pSub
->GetObjCount());
236 for(sal_uInt32
a(0L); a
< nCount
; a
++)
238 pSub
->GetObj(a
)->SetStyleSheet(pNewStyleSheet
, bDontRemoveHardAttr
);
242 void GroupProperties::ForceDefaultAttributes()
244 // nothing to do here, groups have no items and thus no default items, too.
247 void GroupProperties::MoveToItemPool(SfxItemPool
* pSrcPool
, SfxItemPool
* pDestPool
, SdrModel
* pNewModel
)
249 if(pSrcPool
&& pDestPool
&& (pSrcPool
!= pDestPool
))
251 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
252 const sal_uInt32
nCount(pSub
->GetObjCount());
254 for(sal_uInt32
a(0L); a
< nCount
; a
++)
256 pSub
->GetObj(a
)->GetProperties().MoveToItemPool(pSrcPool
, pDestPool
, pNewModel
);
259 // also clear local ItemSet, it's only temporary for group objects anyways.
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();
274 void GroupProperties::ForceStyleToHardAttributes()
276 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
277 const sal_uInt32
nCount(pSub
->GetObjCount());
279 for(sal_uInt32
a(0L); a
< nCount
; a
++)
281 pSub
->GetObj(a
)->GetProperties().ForceStyleToHardAttributes();
284 } // end of namespace properties
285 } // end of namespace sdr
287 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */