1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: groupproperties.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #include <svx/sdr/properties/groupproperties.hxx>
34 #include <svtools/itemset.hxx>
35 #include <svtools/whiter.hxx>
36 #include <svx/svddef.hxx>
37 #include <svx/eeitem.hxx>
38 #include <svx/svdogrp.hxx>
39 #include <svx/svdpool.hxx>
40 #include <svx/svdpage.hxx>
42 //////////////////////////////////////////////////////////////////////////////
48 // create a new itemset
49 SfxItemSet
& GroupProperties::CreateObjectSpecificItemSet(SfxItemPool
& rPool
)
51 // Groups have in principle no ItemSet. To support methods like
52 // GetMergedItemSet() the local one is used. Thus, all items in the pool
53 // may be used and a pool itemset is created.
54 return *(new SfxItemSet(rPool
));
57 GroupProperties::GroupProperties(SdrObject
& rObj
)
58 : DefaultProperties(rObj
)
62 GroupProperties::GroupProperties(const GroupProperties
& rProps
, SdrObject
& rObj
)
63 : DefaultProperties(rProps
, rObj
)
67 GroupProperties::~GroupProperties()
71 BaseProperties
& GroupProperties::Clone(SdrObject
& rObj
) const
73 return *(new GroupProperties(*this, rObj
));
76 const SfxItemSet
& GroupProperties::GetObjectItemSet() const
78 DBG_ASSERT(sal_False
, "GroupProperties::GetObjectItemSet() should never be called (!)");
79 return DefaultProperties::GetObjectItemSet();
82 const SfxItemSet
& GroupProperties::GetMergedItemSet() const
87 // clear local itemset for merge
88 mpItemSet
->ClearItem();
92 // force local itemset
93 DefaultProperties::GetObjectItemSet();
96 // collect all ItemSets in mpItemSet
97 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
98 const sal_uInt32
nCount(pSub
->GetObjCount());
100 for(sal_uInt32
a(0L); a
< nCount
; a
++)
102 const SfxItemSet
& rSet
= pSub
->GetObj(a
)->GetMergedItemSet();
103 SfxWhichIter
aIter(rSet
);
104 sal_uInt16
nWhich(aIter
.FirstWhich());
108 if(SFX_ITEM_DONTCARE
== rSet
.GetItemState(nWhich
, FALSE
))
110 mpItemSet
->InvalidateItem(nWhich
);
114 mpItemSet
->MergeValue(rSet
.Get(nWhich
), TRUE
);
117 nWhich
= aIter
.NextWhich();
121 // For group proerties, do not call parent since groups do
122 // not have local ItemSets.
126 void GroupProperties::SetMergedItemSet(const SfxItemSet
& rSet
, sal_Bool bClearAllItems
)
128 // iterate over contained SdrObjects
129 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
130 const sal_uInt32
nCount(pSub
->GetObjCount());
132 for(sal_uInt32
a(0L); a
< nCount
; a
++)
134 SdrObject
* pObj
= pSub
->GetObj(a
);
138 // Set merged ItemSet at contained object
139 pObj
->SetMergedItemSet(rSet
, bClearAllItems
);
143 // Do not call parent here. Group objects do not have local ItemSets
144 // where items need to be set.
145 // DefaultProperties::SetMergedItemSet(rSet, bClearAllItems);
148 void GroupProperties::SetObjectItem(const SfxPoolItem
& /*rItem*/)
150 DBG_ASSERT(sal_False
, "GroupProperties::SetObjectItem() should never be called (!)");
153 void GroupProperties::SetObjectItemDirect(const SfxPoolItem
& /*rItem*/)
155 DBG_ASSERT(sal_False
, "GroupProperties::SetObjectItemDirect() should never be called (!)");
158 void GroupProperties::ClearObjectItem(const sal_uInt16
/*nWhich*/)
160 DBG_ASSERT(sal_False
, "GroupProperties::ClearObjectItem() should never be called (!)");
163 void GroupProperties::ClearObjectItemDirect(const sal_uInt16
/*nWhich*/)
165 DBG_ASSERT(sal_False
, "GroupProperties::ClearObjectItemDirect() should never be called (!)");
168 void GroupProperties::SetMergedItem(const SfxPoolItem
& rItem
)
170 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
171 const sal_uInt32
nCount(pSub
->GetObjCount());
173 for(sal_uInt32
a(0L); a
< nCount
; a
++)
175 pSub
->GetObj(a
)->GetProperties().SetMergedItem(rItem
);
179 void GroupProperties::ClearMergedItem(const sal_uInt16 nWhich
)
181 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
182 const sal_uInt32
nCount(pSub
->GetObjCount());
184 for(sal_uInt32
a(0L); a
< nCount
; a
++)
186 pSub
->GetObj(a
)->GetProperties().ClearMergedItem(nWhich
);
190 void GroupProperties::SetObjectItemSet(const SfxItemSet
& /*rSet*/)
192 DBG_ASSERT(sal_False
, "GroupProperties::SetObjectItemSet() should never be called (!)");
195 void GroupProperties::ItemSetChanged(const SfxItemSet
& /*rSet*/)
197 DBG_ASSERT(sal_False
, "GroupProperties::ItemSetChanged() should never be called (!)");
200 sal_Bool
GroupProperties::AllowItemChange(const sal_uInt16
/*nWhich*/, const SfxPoolItem
* /*pNewItem*/) const
202 DBG_ASSERT(sal_False
, "GroupProperties::AllowItemChange() should never be called (!)");
206 void GroupProperties::ItemChange(const sal_uInt16
/*nWhich*/, const SfxPoolItem
* /*pNewItem*/)
208 DBG_ASSERT(sal_False
, "GroupProperties::ItemChange() should never be called (!)");
211 void GroupProperties::PostItemChange(const sal_uInt16
/*nWhich*/)
213 DBG_ASSERT(sal_False
, "GroupProperties::PostItemChange() should never be called (!)");
216 SfxStyleSheet
* GroupProperties::GetStyleSheet() const
218 SfxStyleSheet
* pRetval
= 0L;
220 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
221 const sal_uInt32
nCount(pSub
->GetObjCount());
223 for(sal_uInt32
a(0L); a
< nCount
; a
++)
225 SfxStyleSheet
* pCandidate
= pSub
->GetObj(a
)->GetStyleSheet();
229 if(pCandidate
!= pRetval
)
231 // different StyleSheelts, return none
237 pRetval
= pCandidate
;
244 void GroupProperties::SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
)
246 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
247 const sal_uInt32
nCount(pSub
->GetObjCount());
249 for(sal_uInt32
a(0L); a
< nCount
; a
++)
251 pSub
->GetObj(a
)->SetStyleSheet(pNewStyleSheet
, bDontRemoveHardAttr
);
255 void GroupProperties::ForceDefaultAttributes()
257 // nothing to do here, groups have no items and thus no default items, too.
260 void GroupProperties::MoveToItemPool(SfxItemPool
* pSrcPool
, SfxItemPool
* pDestPool
, SdrModel
* pNewModel
)
262 if(pSrcPool
&& pDestPool
&& (pSrcPool
!= pDestPool
))
264 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
265 const sal_uInt32
nCount(pSub
->GetObjCount());
267 for(sal_uInt32
a(0L); a
< nCount
; a
++)
269 pSub
->GetObj(a
)->GetProperties().MoveToItemPool(pSrcPool
, pDestPool
, pNewModel
);
272 // also clear local ItemSet, it's only temporary for group objects anyways.
276 // copy/paste is still using clone operators and MoveToItemPool functionality.
277 // Since SfxItemSet contains a pool pointer, ClearItem is not enough here.
278 // The ItemSet for merge is constructed on demand, so it's enough here to
279 // just delete it and set to 0L.
280 // mpItemSet->ClearItem();
287 void GroupProperties::ForceStyleToHardAttributes()
289 const SdrObjList
* pSub
= ((const SdrObjGroup
&)GetSdrObject()).GetSubList();
290 const sal_uInt32
nCount(pSub
->GetObjCount());
292 for(sal_uInt32
a(0L); a
< nCount
; a
++)
294 pSub
->GetObj(a
)->GetProperties().ForceStyleToHardAttributes();
297 } // end of namespace properties
298 } // end of namespace sdr
300 //////////////////////////////////////////////////////////////////////////////