1*f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f6e50924SAndrew Rist * distributed with this work for additional information 6*f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9*f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10*f6e50924SAndrew Rist * 11*f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f6e50924SAndrew Rist * 13*f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f6e50924SAndrew Rist * software distributed under the License is distributed on an 15*f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17*f6e50924SAndrew Rist * specific language governing permissions and limitations 18*f6e50924SAndrew Rist * under the License. 19*f6e50924SAndrew Rist * 20*f6e50924SAndrew Rist *************************************************************/ 21*f6e50924SAndrew Rist 22*f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <svx/sdr/properties/properties.hxx> 27cdf0e10cSrcweir #include <svx/sdr/properties/itemsettools.hxx> 28cdf0e10cSrcweir #include <svl/itemset.hxx> 29cdf0e10cSrcweir #include <svx/svdogrp.hxx> 30cdf0e10cSrcweir #include <svx/svditer.hxx> 31cdf0e10cSrcweir #include <svx/xfillit0.hxx> 32cdf0e10cSrcweir 33cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace sdr 36cdf0e10cSrcweir { 37cdf0e10cSrcweir namespace properties 38cdf0e10cSrcweir { BaseProperties(SdrObject & rObj)39cdf0e10cSrcweir BaseProperties::BaseProperties(SdrObject& rObj) 40cdf0e10cSrcweir : mrObject(rObj) 41cdf0e10cSrcweir { 42cdf0e10cSrcweir } 43cdf0e10cSrcweir BaseProperties(const BaseProperties &,SdrObject & rObj)44cdf0e10cSrcweir BaseProperties::BaseProperties(const BaseProperties& /*rProps*/, SdrObject& rObj) 45cdf0e10cSrcweir : mrObject(rObj) 46cdf0e10cSrcweir { 47cdf0e10cSrcweir } 48cdf0e10cSrcweir ~BaseProperties()49cdf0e10cSrcweir BaseProperties::~BaseProperties() 50cdf0e10cSrcweir { 51cdf0e10cSrcweir } 52cdf0e10cSrcweir GetMergedItemSet() const53cdf0e10cSrcweir const SfxItemSet& BaseProperties::GetMergedItemSet() const 54cdf0e10cSrcweir { 55cdf0e10cSrcweir // default implementation falls back to GetObjectItemSet() 56cdf0e10cSrcweir return GetObjectItemSet(); 57cdf0e10cSrcweir } 58cdf0e10cSrcweir SetMergedItemSet(const SfxItemSet & rSet,sal_Bool bClearAllItems)59cdf0e10cSrcweir void BaseProperties::SetMergedItemSet(const SfxItemSet& rSet, sal_Bool bClearAllItems) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir // clear items if requested 62cdf0e10cSrcweir if(bClearAllItems) 63cdf0e10cSrcweir { 64cdf0e10cSrcweir ClearObjectItem(); 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir // default implementation falls back to SetObjectItemSet() 68cdf0e10cSrcweir SetObjectItemSet(rSet); 69cdf0e10cSrcweir } 70cdf0e10cSrcweir SetMergedItem(const SfxPoolItem & rItem)71cdf0e10cSrcweir void BaseProperties::SetMergedItem(const SfxPoolItem& rItem) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir // default implementation falls back to SetObjectItem() 74cdf0e10cSrcweir SetObjectItem(rItem); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir ClearMergedItem(const sal_uInt16 nWhich)77cdf0e10cSrcweir void BaseProperties::ClearMergedItem(const sal_uInt16 nWhich) 78cdf0e10cSrcweir { 79cdf0e10cSrcweir // default implementation falls back to ClearObjectItem() 80cdf0e10cSrcweir ClearObjectItem(nWhich); 81cdf0e10cSrcweir } 82cdf0e10cSrcweir Scale(const Fraction &)83cdf0e10cSrcweir void BaseProperties::Scale(const Fraction& /*rScale*/) 84cdf0e10cSrcweir { 85cdf0e10cSrcweir // default implementation does nothing; overload where 86cdf0e10cSrcweir // an ItemSet is implemented. 87cdf0e10cSrcweir } 88cdf0e10cSrcweir MoveToItemPool(SfxItemPool *,SfxItemPool *,SdrModel *)89cdf0e10cSrcweir void BaseProperties::MoveToItemPool(SfxItemPool* /*pSrcPool*/, SfxItemPool* /*pDestPool*/, SdrModel* /*pNewModel*/) 90cdf0e10cSrcweir { 91cdf0e10cSrcweir // Move properties to a new ItemPool. Default implementation does nothing. 92cdf0e10cSrcweir // Overload where an ItemSet is implemented. 93cdf0e10cSrcweir } 94cdf0e10cSrcweir SetModel(SdrModel *,SdrModel *)95cdf0e10cSrcweir void BaseProperties::SetModel(SdrModel* /*pOldModel*/, SdrModel* /*pNewModel*/) 96cdf0e10cSrcweir { 97cdf0e10cSrcweir // Set new model. Default implementation does nothing. 98cdf0e10cSrcweir // Overload where an ItemSet is implemented. 99cdf0e10cSrcweir } 100cdf0e10cSrcweir ForceStyleToHardAttributes()101cdf0e10cSrcweir void BaseProperties::ForceStyleToHardAttributes() 102cdf0e10cSrcweir { 103cdf0e10cSrcweir // force all attributes which come from styles to hard attributes 104cdf0e10cSrcweir // to be able to live without the style. Default implementation does nothing. 105cdf0e10cSrcweir // Overload where an ItemSet is implemented. 106cdf0e10cSrcweir } 107cdf0e10cSrcweir 108cdf0e10cSrcweir //void BaseProperties::SetItemAndBroadcast(const SfxPoolItem& rItem) 109cdf0e10cSrcweir //{ 110cdf0e10cSrcweir // ItemChangeBroadcaster aC(GetSdrObject()); 111cdf0e10cSrcweir // SetObjectItem(rItem); 112cdf0e10cSrcweir // BroadcastItemChange(aC); 113cdf0e10cSrcweir //} 114cdf0e10cSrcweir 115cdf0e10cSrcweir //void BaseProperties::ClearItemAndBroadcast(const sal_uInt16 nWhich) 116cdf0e10cSrcweir //{ 117cdf0e10cSrcweir // ItemChangeBroadcaster aC(GetSdrObject()); 118cdf0e10cSrcweir // ClearObjectItem(nWhich); 119cdf0e10cSrcweir // BroadcastItemChange(aC); 120cdf0e10cSrcweir //} 121cdf0e10cSrcweir SetMergedItemSetAndBroadcast(const SfxItemSet & rSet,sal_Bool bClearAllItems)122cdf0e10cSrcweir void BaseProperties::SetMergedItemSetAndBroadcast(const SfxItemSet& rSet, sal_Bool bClearAllItems) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir ItemChangeBroadcaster aC(GetSdrObject()); 125cdf0e10cSrcweir 126cdf0e10cSrcweir if(bClearAllItems) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir ClearObjectItem(); 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir SetMergedItemSet(rSet); 132cdf0e10cSrcweir BroadcastItemChange(aC); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir GetItem(const sal_uInt16 nWhich) const135cdf0e10cSrcweir const SfxPoolItem& BaseProperties::GetItem(const sal_uInt16 nWhich) const 136cdf0e10cSrcweir { 137cdf0e10cSrcweir return GetObjectItemSet().Get(nWhich); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir BroadcastItemChange(const ItemChangeBroadcaster & rChange)140cdf0e10cSrcweir void BaseProperties::BroadcastItemChange(const ItemChangeBroadcaster& rChange) 141cdf0e10cSrcweir { 142cdf0e10cSrcweir const sal_uInt32 nCount(rChange.GetRectangleCount()); 143cdf0e10cSrcweir 144cdf0e10cSrcweir // #110094#-14 Reduce to do only second change 145cdf0e10cSrcweir //// invalidate all remembered rectangles 146cdf0e10cSrcweir //for(sal_uInt32 a(0); a < nCount; a++) 147cdf0e10cSrcweir //{ 148cdf0e10cSrcweir // GetSdrObject().BroadcastObjectChange(rChange.GetRectangle(a)); 149cdf0e10cSrcweir //} 150cdf0e10cSrcweir 151cdf0e10cSrcweir // invalidate all new rectangles 152cdf0e10cSrcweir if(GetSdrObject().ISA(SdrObjGroup)) 153cdf0e10cSrcweir { 154cdf0e10cSrcweir SdrObjListIter aIter((SdrObjGroup&)GetSdrObject(), IM_DEEPNOGROUPS); 155cdf0e10cSrcweir 156cdf0e10cSrcweir while(aIter.IsMore()) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir SdrObject* pObj = aIter.Next(); 159cdf0e10cSrcweir // This is done with ItemSetChanged 160cdf0e10cSrcweir // pObj->SetChanged(); 161cdf0e10cSrcweir pObj->BroadcastObjectChange(); 162cdf0e10cSrcweir } 163cdf0e10cSrcweir } 164cdf0e10cSrcweir else 165cdf0e10cSrcweir { 166cdf0e10cSrcweir // This is done with ItemSetChanged 167cdf0e10cSrcweir // GetSdrObject().SetChanged(); 168cdf0e10cSrcweir GetSdrObject().BroadcastObjectChange(); 169cdf0e10cSrcweir } 170cdf0e10cSrcweir 171cdf0e10cSrcweir // also send the user calls 172cdf0e10cSrcweir for(sal_uInt32 a(0L); a < nCount; a++) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir GetSdrObject().SendUserCall(SDRUSERCALL_CHGATTR, rChange.GetRectangle(a)); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir } 177cdf0e10cSrcweir getVersion() const178cdf0e10cSrcweir sal_uInt32 BaseProperties::getVersion() const 179cdf0e10cSrcweir { 180cdf0e10cSrcweir return 0; 181cdf0e10cSrcweir } 182cdf0e10cSrcweir CleanupFillProperties(SfxItemSet & rItemSet)183cdf0e10cSrcweir void CleanupFillProperties( SfxItemSet& rItemSet ) 184cdf0e10cSrcweir { 185cdf0e10cSrcweir const bool bFillBitmap = rItemSet.GetItemState(XATTR_FILLBITMAP, sal_False) == SFX_ITEM_SET; 186cdf0e10cSrcweir const bool bFillGradient = rItemSet.GetItemState(XATTR_FILLGRADIENT, sal_False) == SFX_ITEM_SET; 187cdf0e10cSrcweir const bool bFillHatch = rItemSet.GetItemState(XATTR_FILLHATCH, sal_False) == SFX_ITEM_SET; 188cdf0e10cSrcweir if( bFillBitmap || bFillGradient || bFillHatch ) 189cdf0e10cSrcweir { 190cdf0e10cSrcweir const XFillStyleItem* pFillStyleItem = dynamic_cast< const XFillStyleItem* >( rItemSet.GetItem(XATTR_FILLSTYLE) ); 191cdf0e10cSrcweir if( pFillStyleItem ) 192cdf0e10cSrcweir { 193cdf0e10cSrcweir if( bFillBitmap && (pFillStyleItem->GetValue() != XFILL_BITMAP) ) 194cdf0e10cSrcweir { 195cdf0e10cSrcweir rItemSet.ClearItem( XATTR_FILLBITMAP ); 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir if( bFillGradient && (pFillStyleItem->GetValue() != XFILL_GRADIENT) ) 199cdf0e10cSrcweir { 200cdf0e10cSrcweir rItemSet.ClearItem( XATTR_FILLGRADIENT ); 201cdf0e10cSrcweir } 202cdf0e10cSrcweir 203cdf0e10cSrcweir if( bFillHatch && (pFillStyleItem->GetValue() != XFILL_HATCH) ) 204cdf0e10cSrcweir { 205cdf0e10cSrcweir rItemSet.ClearItem( XATTR_FILLHATCH ); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir } 208cdf0e10cSrcweir } 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir } // end of namespace properties 212cdf0e10cSrcweir } // end of namespace sdr 213cdf0e10cSrcweir 214cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 215cdf0e10cSrcweir // eof 216