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/properties.hxx>
21 #include <svx/sdr/properties/itemsettools.hxx>
22 #include <svl/itemset.hxx>
23 #include <svx/svdogrp.hxx>
24 #include <svx/svditer.hxx>
25 #include <svx/xfillit0.hxx>
27 //////////////////////////////////////////////////////////////////////////////
33 BaseProperties::BaseProperties(SdrObject
& rObj
)
38 BaseProperties::BaseProperties(const BaseProperties
& /*rProps*/, SdrObject
& rObj
)
43 BaseProperties::~BaseProperties()
47 const SfxItemSet
& BaseProperties::GetMergedItemSet() const
49 // default implementation falls back to GetObjectItemSet()
50 return GetObjectItemSet();
53 void BaseProperties::SetMergedItemSet(const SfxItemSet
& rSet
, sal_Bool bClearAllItems
)
55 // clear items if requested
61 // default implementation falls back to SetObjectItemSet()
62 SetObjectItemSet(rSet
);
65 void BaseProperties::SetMergedItem(const SfxPoolItem
& rItem
)
67 // default implementation falls back to SetObjectItem()
71 void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich
)
73 // default implementation falls back to ClearObjectItem()
74 ClearObjectItem(nWhich
);
77 void BaseProperties::Scale(const Fraction
& /*rScale*/)
79 // default implementation does nothing; overload where
80 // an ItemSet is implemented.
83 void BaseProperties::MoveToItemPool(SfxItemPool
* /*pSrcPool*/, SfxItemPool
* /*pDestPool*/, SdrModel
* /*pNewModel*/)
85 // Move properties to a new ItemPool. Default implementation does nothing.
86 // Overload where an ItemSet is implemented.
89 void BaseProperties::SetModel(SdrModel
* /*pOldModel*/, SdrModel
* /*pNewModel*/)
91 // Set new model. Default implementation does nothing.
92 // Overload where an ItemSet is implemented.
95 void BaseProperties::ForceStyleToHardAttributes()
97 // force all attributes which come from styles to hard attributes
98 // to be able to live without the style. Default implementation does nothing.
99 // Overload where an ItemSet is implemented.
102 void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet
& rSet
, sal_Bool bClearAllItems
)
104 ItemChangeBroadcaster
aC(GetSdrObject());
111 SetMergedItemSet(rSet
);
112 BroadcastItemChange(aC
);
115 const SfxPoolItem
& BaseProperties::GetItem(const sal_uInt16 nWhich
) const
117 return GetObjectItemSet().Get(nWhich
);
120 void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster
& rChange
)
122 const sal_uInt32
nCount(rChange
.GetRectangleCount());
124 // #110094#-14 Reduce to do only second change
125 //// invalidate all remembered rectangles
126 //for(sal_uInt32 a(0); a < nCount; a++)
128 // GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a));
131 // invalidate all new rectangles
132 if(GetSdrObject().ISA(SdrObjGroup
))
134 SdrObjListIter
aIter((SdrObjGroup
&)GetSdrObject(), IM_DEEPNOGROUPS
);
136 while(aIter
.IsMore())
138 SdrObject
* pObj
= aIter
.Next();
139 // This is done with ItemSetChanged
140 // pObj->SetChanged();
141 pObj
->BroadcastObjectChange();
146 // This is done with ItemSetChanged
147 // GetSdrObject().SetChanged();
148 GetSdrObject().BroadcastObjectChange();
151 // also send the user calls
152 for(sal_uInt32
a(0L); a
< nCount
; a
++)
154 GetSdrObject().SendUserCall(SDRUSERCALL_CHGATTR
, rChange
.GetRectangle(a
));
158 sal_uInt32
BaseProperties::getVersion() const
163 void CleanupFillProperties( SfxItemSet
& rItemSet
)
165 const bool bFillBitmap
= rItemSet
.GetItemState(XATTR_FILLBITMAP
, sal_False
) == SFX_ITEM_SET
;
166 const bool bFillGradient
= rItemSet
.GetItemState(XATTR_FILLGRADIENT
, sal_False
) == SFX_ITEM_SET
;
167 const bool bFillHatch
= rItemSet
.GetItemState(XATTR_FILLHATCH
, sal_False
) == SFX_ITEM_SET
;
168 if( bFillBitmap
|| bFillGradient
|| bFillHatch
)
170 const XFillStyleItem
* pFillStyleItem
= dynamic_cast< const XFillStyleItem
* >( rItemSet
.GetItem(XATTR_FILLSTYLE
) );
173 if( bFillBitmap
&& (pFillStyleItem
->GetValue() != XFILL_BITMAP
) )
175 rItemSet
.ClearItem( XATTR_FILLBITMAP
);
178 if( bFillGradient
&& (pFillStyleItem
->GetValue() != XFILL_GRADIENT
) )
180 rItemSet
.ClearItem( XATTR_FILLGRADIENT
);
183 if( bFillHatch
&& (pFillStyleItem
->GetValue() != XFILL_HATCH
) )
185 rItemSet
.ClearItem( XATTR_FILLHATCH
);
191 } // end of namespace properties
192 } // end of namespace sdr
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */