1f6e50924SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f6e50924SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f6e50924SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f6e50924SAndrew Rist * distributed with this work for additional information 6f6e50924SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f6e50924SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f6e50924SAndrew Rist * "License"); you may not use this file except in compliance 9f6e50924SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11f6e50924SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13f6e50924SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f6e50924SAndrew Rist * software distributed under the License is distributed on an 15f6e50924SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f6e50924SAndrew Rist * KIND, either express or implied. See the License for the 17f6e50924SAndrew Rist * specific language governing permissions and limitations 18f6e50924SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20f6e50924SAndrew Rist *************************************************************/ 21f6e50924SAndrew Rist 22f6e50924SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svx.hxx" 26cdf0e10cSrcweir #include <svx/sdr/properties/customshapeproperties.hxx> 27cdf0e10cSrcweir #include <svl/itemset.hxx> 28cdf0e10cSrcweir #include <svl/style.hxx> 29cdf0e10cSrcweir #include <svx/svdoashp.hxx> 30cdf0e10cSrcweir #include <editeng/eeitem.hxx> 31cdf0e10cSrcweir #include <svx/sdtagitm.hxx> 32cdf0e10cSrcweir #include <svl/whiter.hxx> 33cdf0e10cSrcweir #include <svl/itemset.hxx> 34cdf0e10cSrcweir #include <svl/smplhint.hxx> 35cdf0e10cSrcweir 36cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 37cdf0e10cSrcweir 38cdf0e10cSrcweir namespace sdr 39cdf0e10cSrcweir { 40cdf0e10cSrcweir namespace properties 41cdf0e10cSrcweir { UpdateTextFrameStatus(bool bInvalidateRenderGeometry)42*e88cae92SArmin Le Grand void CustomShapeProperties::UpdateTextFrameStatus(bool bInvalidateRenderGeometry) 43cdf0e10cSrcweir { 44215d8f42SArmin Le Grand SdrObjCustomShape& rObj = static_cast< SdrObjCustomShape& >(GetSdrObject()); 45215d8f42SArmin Le Grand const bool bOld(rObj.bTextFrame); 46cdf0e10cSrcweir 47*e88cae92SArmin Le Grand // change TextFrame flag when bResizeShapeToFitText changes (which is mapped 48*e88cae92SArmin Le Grand // on the item SDRATTR_TEXT_AUTOGROWHEIGHT for custom shapes, argh) 49215d8f42SArmin Le Grand rObj.bTextFrame = 0 != static_cast< const SdrTextAutoGrowHeightItem& >(GetObjectItemSet().Get(SDRATTR_TEXT_AUTOGROWHEIGHT)).GetValue(); 50215d8f42SArmin Le Grand 51*e88cae92SArmin Le Grand // check if it did change 52215d8f42SArmin Le Grand if(rObj.bTextFrame != bOld) 53215d8f42SArmin Le Grand { 54*e88cae92SArmin Le Grand // on change also invalidate render geometry 55*e88cae92SArmin Le Grand bInvalidateRenderGeometry = true; 56215d8f42SArmin Le Grand 57*e88cae92SArmin Le Grand // #115391# Potential recursion, since it calls SetObjectItemSet again, but rObj.bTextFrame 58*e88cae92SArmin Le Grand // will not change again. Thus it will be only one level and terminate safely 59215d8f42SArmin Le Grand rObj.AdaptTextMinSize(); 60215d8f42SArmin Le Grand } 61*e88cae92SArmin Le Grand 62*e88cae92SArmin Le Grand if(bInvalidateRenderGeometry) 63*e88cae92SArmin Le Grand { 64*e88cae92SArmin Le Grand // if asked for or bResizeShapeToFitText changed, make sure that 65*e88cae92SArmin Le Grand // the render geometry is reconstructed using changed parameters 66*e88cae92SArmin Le Grand rObj.InvalidateRenderGeometry(); 67*e88cae92SArmin Le Grand } 68cdf0e10cSrcweir } 69cdf0e10cSrcweir CreateObjectSpecificItemSet(SfxItemPool & rPool)70cdf0e10cSrcweir SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) 71cdf0e10cSrcweir { 72cdf0e10cSrcweir return *(new SfxItemSet(rPool, 73cdf0e10cSrcweir 74cdf0e10cSrcweir // ranges from SdrAttrObj 75cdf0e10cSrcweir SDRATTR_START, SDRATTR_SHADOW_LAST, 76cdf0e10cSrcweir SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, 77cdf0e10cSrcweir SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 78cdf0e10cSrcweir 79cdf0e10cSrcweir // Graphic Attributes 80cdf0e10cSrcweir SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, 81cdf0e10cSrcweir 82cdf0e10cSrcweir // 3d Properties 83cdf0e10cSrcweir SDRATTR_3D_FIRST, SDRATTR_3D_LAST, 84cdf0e10cSrcweir 85cdf0e10cSrcweir // CustomShape properties 86cdf0e10cSrcweir SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST, 87cdf0e10cSrcweir 88cdf0e10cSrcweir // range from SdrTextObj 89cdf0e10cSrcweir EE_ITEMS_START, EE_ITEMS_END, 90cdf0e10cSrcweir 91cdf0e10cSrcweir // end 92cdf0e10cSrcweir 0, 0)); 93cdf0e10cSrcweir } 94215d8f42SArmin Le Grand AllowItemChange(const sal_uInt16 nWhich,const SfxPoolItem * pNewItem) const95cdf0e10cSrcweir sal_Bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const 96cdf0e10cSrcweir { 97cdf0e10cSrcweir sal_Bool bAllowItemChange = sal_True; 98cdf0e10cSrcweir if ( !pNewItem ) 99cdf0e10cSrcweir { 100cdf0e10cSrcweir if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) ) 101cdf0e10cSrcweir bAllowItemChange = sal_False; 102cdf0e10cSrcweir } 103cdf0e10cSrcweir if ( bAllowItemChange ) 104cdf0e10cSrcweir bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem ); 105cdf0e10cSrcweir return bAllowItemChange; 106cdf0e10cSrcweir } 107215d8f42SArmin Le Grand ClearObjectItem(const sal_uInt16 nWhich)108cdf0e10cSrcweir void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir if ( !nWhich ) 111cdf0e10cSrcweir { 112cdf0e10cSrcweir SfxWhichIter aIter( *mpItemSet ); 113cdf0e10cSrcweir sal_uInt16 nWhich2 = aIter.FirstWhich(); 114cdf0e10cSrcweir while( nWhich2 ) 115cdf0e10cSrcweir { 116cdf0e10cSrcweir TextProperties::ClearObjectItemDirect( nWhich2 ); 117cdf0e10cSrcweir nWhich2 = aIter.NextWhich(); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir SfxItemSet aSet((SfxItemPool&)(*GetSdrObject().GetObjectItemPool())); 120cdf0e10cSrcweir ItemSetChanged(aSet); 121cdf0e10cSrcweir } 122cdf0e10cSrcweir else 123cdf0e10cSrcweir TextProperties::ClearObjectItem( nWhich ); 124cdf0e10cSrcweir } 125215d8f42SArmin Le Grand ClearObjectItemDirect(const sal_uInt16 nWhich)126cdf0e10cSrcweir void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich) 127cdf0e10cSrcweir { 128cdf0e10cSrcweir if ( !nWhich ) 129cdf0e10cSrcweir { 130cdf0e10cSrcweir SfxWhichIter aIter( *mpItemSet ); 131cdf0e10cSrcweir sal_uInt16 nWhich2 = aIter.FirstWhich(); 132cdf0e10cSrcweir while( nWhich2 ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir TextProperties::ClearObjectItemDirect( nWhich2 ); 135cdf0e10cSrcweir nWhich2 = aIter.NextWhich(); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir } 138cdf0e10cSrcweir else 139cdf0e10cSrcweir TextProperties::ClearObjectItemDirect( nWhich ); 140cdf0e10cSrcweir } 141215d8f42SArmin Le Grand ItemSetChanged(const SfxItemSet & rSet)142cdf0e10cSrcweir void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet) 143cdf0e10cSrcweir { 144cdf0e10cSrcweir // call parent 145cdf0e10cSrcweir TextProperties::ItemSetChanged(rSet); 146cdf0e10cSrcweir 147215d8f42SArmin Le Grand // update bTextFrame and RenderGeometry 148*e88cae92SArmin Le Grand UpdateTextFrameStatus(true); 149cdf0e10cSrcweir } 150215d8f42SArmin Le Grand PostItemChange(const sal_uInt16 nWhich)151215d8f42SArmin Le Grand void CustomShapeProperties::PostItemChange(const sal_uInt16 nWhich) 152215d8f42SArmin Le Grand { 153215d8f42SArmin Le Grand switch(nWhich) 154215d8f42SArmin Le Grand { 155215d8f42SArmin Le Grand case SDRATTR_TEXT_AUTOGROWHEIGHT: 156215d8f42SArmin Le Grand { 157215d8f42SArmin Le Grand // #115391# update bTextFrame and RenderGeometry using AdaptTextMinSize() 158*e88cae92SArmin Le Grand UpdateTextFrameStatus(false); 159215d8f42SArmin Le Grand break; 160215d8f42SArmin Le Grand } 161215d8f42SArmin Le Grand default: 162215d8f42SArmin Le Grand { 163215d8f42SArmin Le Grand break; 164215d8f42SArmin Le Grand } 165215d8f42SArmin Le Grand } 166215d8f42SArmin Le Grand 167215d8f42SArmin Le Grand // call parent 168215d8f42SArmin Le Grand TextProperties::PostItemChange(nWhich); 169215d8f42SArmin Le Grand } 170215d8f42SArmin Le Grand ItemChange(const sal_uInt16 nWhich,const SfxPoolItem * pNewItem)171cdf0e10cSrcweir void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir // call parent 174cdf0e10cSrcweir TextProperties::ItemChange( nWhich, pNewItem ); 175cdf0e10cSrcweir 176215d8f42SArmin Le Grand // update bTextFrame and RenderGeometry 177*e88cae92SArmin Le Grand UpdateTextFrameStatus(true); 178cdf0e10cSrcweir } 179215d8f42SArmin Le Grand SetStyleSheet(SfxStyleSheet * pNewStyleSheet,sal_Bool bDontRemoveHardAttr)180cdf0e10cSrcweir void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) 181cdf0e10cSrcweir { 182215d8f42SArmin Le Grand // call parent 183cdf0e10cSrcweir TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); 184215d8f42SArmin Le Grand 185215d8f42SArmin Le Grand // update bTextFrame and RenderGeometry 186*e88cae92SArmin Le Grand UpdateTextFrameStatus(true); 187cdf0e10cSrcweir } 188215d8f42SArmin Le Grand ForceDefaultAttributes()189cdf0e10cSrcweir void CustomShapeProperties::ForceDefaultAttributes() 190cdf0e10cSrcweir { 191215d8f42SArmin Le Grand // update bTextFrame and RenderGeometry 192*e88cae92SArmin Le Grand UpdateTextFrameStatus(true); 193cdf0e10cSrcweir 194215d8f42SArmin Le Grand // SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml 195215d8f42SArmin Le Grand // This means: Do *not* call parent here is by purpose... 196cdf0e10cSrcweir } 197215d8f42SArmin Le Grand CustomShapeProperties(SdrObject & rObj)198cdf0e10cSrcweir CustomShapeProperties::CustomShapeProperties(SdrObject& rObj) 199cdf0e10cSrcweir : TextProperties(rObj) 200cdf0e10cSrcweir { 201cdf0e10cSrcweir } 202cdf0e10cSrcweir CustomShapeProperties(const CustomShapeProperties & rProps,SdrObject & rObj)203cdf0e10cSrcweir CustomShapeProperties::CustomShapeProperties(const CustomShapeProperties& rProps, SdrObject& rObj) 204cdf0e10cSrcweir : TextProperties(rProps, rObj) 205cdf0e10cSrcweir { 206cdf0e10cSrcweir } 207cdf0e10cSrcweir ~CustomShapeProperties()208cdf0e10cSrcweir CustomShapeProperties::~CustomShapeProperties() 209cdf0e10cSrcweir { 210cdf0e10cSrcweir } 211cdf0e10cSrcweir Clone(SdrObject & rObj) const212cdf0e10cSrcweir BaseProperties& CustomShapeProperties::Clone(SdrObject& rObj) const 213cdf0e10cSrcweir { 214cdf0e10cSrcweir return *(new CustomShapeProperties(*this, rObj)); 215cdf0e10cSrcweir } 216215d8f42SArmin Le Grand Notify(SfxBroadcaster & rBC,const SfxHint & rHint)217cdf0e10cSrcweir void CustomShapeProperties::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 218cdf0e10cSrcweir { 219cdf0e10cSrcweir TextProperties::Notify( rBC, rHint ); 220cdf0e10cSrcweir 221cdf0e10cSrcweir sal_Bool bRemoveRenderGeometry = sal_False; 222cdf0e10cSrcweir const SfxStyleSheetHint *pStyleHint = PTR_CAST( SfxStyleSheetHint, &rHint ); 223cdf0e10cSrcweir const SfxSimpleHint *pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint ); 224215d8f42SArmin Le Grand 225cdf0e10cSrcweir if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() ) 226cdf0e10cSrcweir { 227cdf0e10cSrcweir switch( pStyleHint->GetHint() ) 228cdf0e10cSrcweir { 229cdf0e10cSrcweir case SFX_STYLESHEET_MODIFIED : 230cdf0e10cSrcweir case SFX_STYLESHEET_CHANGED : 231cdf0e10cSrcweir bRemoveRenderGeometry = sal_True; 232cdf0e10cSrcweir break; 233cdf0e10cSrcweir }; 234cdf0e10cSrcweir } 235cdf0e10cSrcweir else if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DATACHANGED ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir bRemoveRenderGeometry = sal_True; 238cdf0e10cSrcweir } 239215d8f42SArmin Le Grand 240215d8f42SArmin Le Grand // update bTextFrame and RenderGeometry 241*e88cae92SArmin Le Grand UpdateTextFrameStatus(bRemoveRenderGeometry); 242cdf0e10cSrcweir } 243cdf0e10cSrcweir } // end of namespace properties 244cdf0e10cSrcweir } // end of namespace sdr 245cdf0e10cSrcweir 246cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 247cdf0e10cSrcweir // eof 248