1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir #include <svx/sdr/properties/customshapeproperties.hxx> 31*cdf0e10cSrcweir #include <svl/itemset.hxx> 32*cdf0e10cSrcweir #include <svl/style.hxx> 33*cdf0e10cSrcweir #include <svx/svdoashp.hxx> 34*cdf0e10cSrcweir #include <editeng/eeitem.hxx> 35*cdf0e10cSrcweir #include <svx/sdtagitm.hxx> 36*cdf0e10cSrcweir #include <svl/whiter.hxx> 37*cdf0e10cSrcweir #include <svl/itemset.hxx> 38*cdf0e10cSrcweir #include <svl/smplhint.hxx> 39*cdf0e10cSrcweir 40*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir namespace sdr 43*cdf0e10cSrcweir { 44*cdf0e10cSrcweir namespace properties 45*cdf0e10cSrcweir { 46*cdf0e10cSrcweir void CustomShapeProperties::UpdateTextFrameStatus() 47*cdf0e10cSrcweir { 48*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 49*cdf0e10cSrcweir SdrTextAutoGrowHeightItem& rAutoGrowHeightItem = 50*cdf0e10cSrcweir (SdrTextAutoGrowHeightItem&)rObj.GetMergedItem( SDRATTR_TEXT_AUTOGROWHEIGHT ); 51*cdf0e10cSrcweir rObj.bTextFrame = rAutoGrowHeightItem.GetValue() != 0; 52*cdf0e10cSrcweir 53*cdf0e10cSrcweir if ( rObj.bTextFrame ) 54*cdf0e10cSrcweir rObj.NbcAdjustTextFrameWidthAndHeight(); 55*cdf0e10cSrcweir } 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir SfxItemSet& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool& rPool) 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir return *(new SfxItemSet(rPool, 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir // ranges from SdrAttrObj 62*cdf0e10cSrcweir SDRATTR_START, SDRATTR_SHADOW_LAST, 63*cdf0e10cSrcweir SDRATTR_MISC_FIRST, SDRATTR_MISC_LAST, 64*cdf0e10cSrcweir SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir // Graphic Attributes 67*cdf0e10cSrcweir SDRATTR_GRAF_FIRST, SDRATTR_GRAF_LAST, 68*cdf0e10cSrcweir 69*cdf0e10cSrcweir // 3d Properties 70*cdf0e10cSrcweir SDRATTR_3D_FIRST, SDRATTR_3D_LAST, 71*cdf0e10cSrcweir 72*cdf0e10cSrcweir // CustomShape properties 73*cdf0e10cSrcweir SDRATTR_CUSTOMSHAPE_FIRST, SDRATTR_CUSTOMSHAPE_LAST, 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir // range from SdrTextObj 76*cdf0e10cSrcweir EE_ITEMS_START, EE_ITEMS_END, 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir // end 79*cdf0e10cSrcweir 0, 0)); 80*cdf0e10cSrcweir } 81*cdf0e10cSrcweir sal_Bool CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem ) const 82*cdf0e10cSrcweir { 83*cdf0e10cSrcweir sal_Bool bAllowItemChange = sal_True; 84*cdf0e10cSrcweir if ( !pNewItem ) 85*cdf0e10cSrcweir { 86*cdf0e10cSrcweir if ( ( nWhich >= SDRATTR_CUSTOMSHAPE_FIRST ) && ( nWhich <= SDRATTR_CUSTOMSHAPE_LAST ) ) 87*cdf0e10cSrcweir bAllowItemChange = sal_False; 88*cdf0e10cSrcweir } 89*cdf0e10cSrcweir if ( bAllowItemChange ) 90*cdf0e10cSrcweir bAllowItemChange = TextProperties::AllowItemChange( nWhich, pNewItem ); 91*cdf0e10cSrcweir return bAllowItemChange; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich) 94*cdf0e10cSrcweir { 95*cdf0e10cSrcweir if ( !nWhich ) 96*cdf0e10cSrcweir { 97*cdf0e10cSrcweir SfxWhichIter aIter( *mpItemSet ); 98*cdf0e10cSrcweir sal_uInt16 nWhich2 = aIter.FirstWhich(); 99*cdf0e10cSrcweir while( nWhich2 ) 100*cdf0e10cSrcweir { 101*cdf0e10cSrcweir TextProperties::ClearObjectItemDirect( nWhich2 ); 102*cdf0e10cSrcweir nWhich2 = aIter.NextWhich(); 103*cdf0e10cSrcweir } 104*cdf0e10cSrcweir SfxItemSet aSet((SfxItemPool&)(*GetSdrObject().GetObjectItemPool())); 105*cdf0e10cSrcweir ItemSetChanged(aSet); 106*cdf0e10cSrcweir } 107*cdf0e10cSrcweir else 108*cdf0e10cSrcweir TextProperties::ClearObjectItem( nWhich ); 109*cdf0e10cSrcweir } 110*cdf0e10cSrcweir void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich) 111*cdf0e10cSrcweir { 112*cdf0e10cSrcweir if ( !nWhich ) 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir SfxWhichIter aIter( *mpItemSet ); 115*cdf0e10cSrcweir sal_uInt16 nWhich2 = aIter.FirstWhich(); 116*cdf0e10cSrcweir while( nWhich2 ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir TextProperties::ClearObjectItemDirect( nWhich2 ); 119*cdf0e10cSrcweir nWhich2 = aIter.NextWhich(); 120*cdf0e10cSrcweir } 121*cdf0e10cSrcweir } 122*cdf0e10cSrcweir else 123*cdf0e10cSrcweir TextProperties::ClearObjectItemDirect( nWhich ); 124*cdf0e10cSrcweir } 125*cdf0e10cSrcweir void CustomShapeProperties::ItemSetChanged(const SfxItemSet& rSet) 126*cdf0e10cSrcweir { 127*cdf0e10cSrcweir SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject(); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir rObj.bTextFrame = ((SdrTextAutoGrowHeightItem&)rSet.Get( SDRATTR_TEXT_AUTOGROWHEIGHT )).GetValue() != 0; 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir // call parent 135*cdf0e10cSrcweir TextProperties::ItemSetChanged(rSet); 136*cdf0e10cSrcweir 137*cdf0e10cSrcweir // local changes, removing cached objects 138*cdf0e10cSrcweir rObj.InvalidateRenderGeometry(); 139*cdf0e10cSrcweir } 140*cdf0e10cSrcweir void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich, const SfxPoolItem* pNewItem) 141*cdf0e10cSrcweir { 142*cdf0e10cSrcweir SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject(); 143*cdf0e10cSrcweir //OutlinerParaObject* pParaObj = rObj.GetOutlinerParaObject(); 144*cdf0e10cSrcweir 145*cdf0e10cSrcweir if( pNewItem && ( SDRATTR_TEXT_AUTOGROWHEIGHT == nWhich ) ) 146*cdf0e10cSrcweir { 147*cdf0e10cSrcweir rObj.bTextFrame = ((SdrTextAutoGrowHeightItem*)pNewItem)->GetValue() != 0; 148*cdf0e10cSrcweir } 149*cdf0e10cSrcweir // call parent 150*cdf0e10cSrcweir TextProperties::ItemChange( nWhich, pNewItem ); 151*cdf0e10cSrcweir 152*cdf0e10cSrcweir rObj.InvalidateRenderGeometry(); 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir void CustomShapeProperties::SetStyleSheet(SfxStyleSheet* pNewStyleSheet, sal_Bool bDontRemoveHardAttr) 155*cdf0e10cSrcweir { 156*cdf0e10cSrcweir TextProperties::SetStyleSheet( pNewStyleSheet, bDontRemoveHardAttr ); 157*cdf0e10cSrcweir UpdateTextFrameStatus(); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir void CustomShapeProperties::ForceDefaultAttributes() 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir UpdateTextFrameStatus(); 162*cdf0e10cSrcweir 163*cdf0e10cSrcweir /* SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml 164*cdf0e10cSrcweir 165*cdf0e10cSrcweir SdrTextObj& rObj = (SdrTextObj&)GetSdrObject(); 166*cdf0e10cSrcweir sal_Bool bTextFrame(rObj.IsTextFrame()); 167*cdf0e10cSrcweir 168*cdf0e10cSrcweir // force ItemSet 169*cdf0e10cSrcweir GetObjectItemSet(); 170*cdf0e10cSrcweir 171*cdf0e10cSrcweir if(bTextFrame) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir mpItemSet->Put(XLineStyleItem(XLINE_NONE)); 174*cdf0e10cSrcweir mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE))); 175*cdf0e10cSrcweir mpItemSet->Put(XFillStyleItem(XFILL_NONE)); 176*cdf0e10cSrcweir } 177*cdf0e10cSrcweir else 178*cdf0e10cSrcweir { 179*cdf0e10cSrcweir mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER)); 180*cdf0e10cSrcweir mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER)); 181*cdf0e10cSrcweir mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER)); 182*cdf0e10cSrcweir } 183*cdf0e10cSrcweir */ 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir CustomShapeProperties::CustomShapeProperties(SdrObject& rObj) 186*cdf0e10cSrcweir : TextProperties(rObj) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir 190*cdf0e10cSrcweir CustomShapeProperties::CustomShapeProperties(const CustomShapeProperties& rProps, SdrObject& rObj) 191*cdf0e10cSrcweir : TextProperties(rProps, rObj) 192*cdf0e10cSrcweir { 193*cdf0e10cSrcweir } 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir CustomShapeProperties::~CustomShapeProperties() 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir 199*cdf0e10cSrcweir BaseProperties& CustomShapeProperties::Clone(SdrObject& rObj) const 200*cdf0e10cSrcweir { 201*cdf0e10cSrcweir return *(new CustomShapeProperties(*this, rObj)); 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir void CustomShapeProperties::Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) 204*cdf0e10cSrcweir { 205*cdf0e10cSrcweir TextProperties::Notify( rBC, rHint ); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir sal_Bool bRemoveRenderGeometry = sal_False; 208*cdf0e10cSrcweir 209*cdf0e10cSrcweir const SfxStyleSheetHint *pStyleHint = PTR_CAST( SfxStyleSheetHint, &rHint ); 210*cdf0e10cSrcweir const SfxSimpleHint *pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint ); 211*cdf0e10cSrcweir if ( pStyleHint && pStyleHint->GetStyleSheet() == GetStyleSheet() ) 212*cdf0e10cSrcweir { 213*cdf0e10cSrcweir switch( pStyleHint->GetHint() ) 214*cdf0e10cSrcweir { 215*cdf0e10cSrcweir case SFX_STYLESHEET_MODIFIED : 216*cdf0e10cSrcweir case SFX_STYLESHEET_CHANGED : 217*cdf0e10cSrcweir bRemoveRenderGeometry = sal_True; 218*cdf0e10cSrcweir break; 219*cdf0e10cSrcweir }; 220*cdf0e10cSrcweir } 221*cdf0e10cSrcweir else if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DATACHANGED ) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir bRemoveRenderGeometry = sal_True; 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir if ( bRemoveRenderGeometry ) 226*cdf0e10cSrcweir { 227*cdf0e10cSrcweir UpdateTextFrameStatus(); 228*cdf0e10cSrcweir 229*cdf0e10cSrcweir // local changes, removing cached objects 230*cdf0e10cSrcweir SdrObjCustomShape& rObj = (SdrObjCustomShape&)GetSdrObject(); 231*cdf0e10cSrcweir rObj.InvalidateRenderGeometry(); 232*cdf0e10cSrcweir } 233*cdf0e10cSrcweir 234*cdf0e10cSrcweir } 235*cdf0e10cSrcweir } // end of namespace properties 236*cdf0e10cSrcweir } // end of namespace sdr 237*cdf0e10cSrcweir 238*cdf0e10cSrcweir ////////////////////////////////////////////////////////////////////////////// 239*cdf0e10cSrcweir // eof 240