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: customshapeproperties.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/customshapeproperties.hxx>
34 #include <svtools/itemset.hxx>
35 #include <svtools/style.hxx>
36 #include <svx/svdoashp.hxx>
37 #include <svx/eeitem.hxx>
38 #include <svx/sdtagitm.hxx>
39 #include <svtools/whiter.hxx>
40 #include <svtools/itemset.hxx>
41 #include <svtools/smplhint.hxx>
43 //////////////////////////////////////////////////////////////////////////////
49 void CustomShapeProperties::UpdateTextFrameStatus()
51 SdrTextObj
& rObj
= (SdrTextObj
&)GetSdrObject();
52 SdrTextAutoGrowHeightItem
& rAutoGrowHeightItem
=
53 (SdrTextAutoGrowHeightItem
&)rObj
.GetMergedItem( SDRATTR_TEXT_AUTOGROWHEIGHT
);
54 rObj
.bTextFrame
= rAutoGrowHeightItem
.GetValue() != 0;
56 if ( rObj
.bTextFrame
)
57 rObj
.NbcAdjustTextFrameWidthAndHeight();
60 SfxItemSet
& CustomShapeProperties::CreateObjectSpecificItemSet(SfxItemPool
& rPool
)
62 return *(new SfxItemSet(rPool
,
64 // ranges from SdrAttrObj
65 SDRATTR_START
, SDRATTR_SHADOW_LAST
,
66 SDRATTR_MISC_FIRST
, SDRATTR_MISC_LAST
,
67 SDRATTR_TEXTDIRECTION
, SDRATTR_TEXTDIRECTION
,
70 SDRATTR_GRAF_FIRST
, SDRATTR_GRAF_LAST
,
73 SDRATTR_3D_FIRST
, SDRATTR_3D_LAST
,
75 // CustomShape properties
76 SDRATTR_CUSTOMSHAPE_FIRST
, SDRATTR_CUSTOMSHAPE_LAST
,
78 // range from SdrTextObj
79 EE_ITEMS_START
, EE_ITEMS_END
,
84 sal_Bool
CustomShapeProperties::AllowItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
) const
86 sal_Bool bAllowItemChange
= sal_True
;
89 if ( ( nWhich
>= SDRATTR_CUSTOMSHAPE_FIRST
) && ( nWhich
<= SDRATTR_CUSTOMSHAPE_LAST
) )
90 bAllowItemChange
= sal_False
;
92 if ( bAllowItemChange
)
93 bAllowItemChange
= TextProperties::AllowItemChange( nWhich
, pNewItem
);
94 return bAllowItemChange
;
96 void CustomShapeProperties::ClearObjectItem(const sal_uInt16 nWhich
)
100 SfxWhichIter
aIter( *mpItemSet
);
101 sal_uInt16 nWhich2
= aIter
.FirstWhich();
104 TextProperties::ClearObjectItemDirect( nWhich2
);
105 nWhich2
= aIter
.NextWhich();
107 SfxItemSet
aSet((SfxItemPool
&)(*GetSdrObject().GetObjectItemPool()));
108 ItemSetChanged(aSet
);
111 TextProperties::ClearObjectItem( nWhich
);
113 void CustomShapeProperties::ClearObjectItemDirect(const sal_uInt16 nWhich
)
117 SfxWhichIter
aIter( *mpItemSet
);
118 sal_uInt16 nWhich2
= aIter
.FirstWhich();
121 TextProperties::ClearObjectItemDirect( nWhich2
);
122 nWhich2
= aIter
.NextWhich();
126 TextProperties::ClearObjectItemDirect( nWhich
);
128 void CustomShapeProperties::ItemSetChanged(const SfxItemSet
& rSet
)
130 SdrObjCustomShape
& rObj
= (SdrObjCustomShape
&)GetSdrObject();
132 if( SFX_ITEM_SET
== rSet
.GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT
) )
134 rObj
.bTextFrame
= ((SdrTextAutoGrowHeightItem
&)rSet
.Get( SDRATTR_TEXT_AUTOGROWHEIGHT
)).GetValue() != 0;
138 TextProperties::ItemSetChanged(rSet
);
140 // local changes, removing cached objects
141 rObj
.InvalidateRenderGeometry();
143 void CustomShapeProperties::ItemChange(const sal_uInt16 nWhich
, const SfxPoolItem
* pNewItem
)
145 SdrObjCustomShape
& rObj
= (SdrObjCustomShape
&)GetSdrObject();
146 //OutlinerParaObject* pParaObj = rObj.GetOutlinerParaObject();
148 if( pNewItem
&& ( SDRATTR_TEXT_AUTOGROWHEIGHT
== nWhich
) )
150 rObj
.bTextFrame
= ((SdrTextAutoGrowHeightItem
*)pNewItem
)->GetValue() != 0;
153 TextProperties::ItemChange( nWhich
, pNewItem
);
155 rObj
.InvalidateRenderGeometry();
157 void CustomShapeProperties::SetStyleSheet(SfxStyleSheet
* pNewStyleSheet
, sal_Bool bDontRemoveHardAttr
)
159 TextProperties::SetStyleSheet( pNewStyleSheet
, bDontRemoveHardAttr
);
160 UpdateTextFrameStatus();
162 void CustomShapeProperties::ForceDefaultAttributes()
164 UpdateTextFrameStatus();
166 /* SJ: Following is no good if creating customshapes, leading to objects that are white after loading via xml
168 SdrTextObj& rObj = (SdrTextObj&)GetSdrObject();
169 sal_Bool bTextFrame(rObj.IsTextFrame());
176 mpItemSet->Put(XLineStyleItem(XLINE_NONE));
177 mpItemSet->Put(XFillColorItem(String(), Color(COL_WHITE)));
178 mpItemSet->Put(XFillStyleItem(XFILL_NONE));
182 mpItemSet->Put(SvxAdjustItem(SVX_ADJUST_CENTER));
183 mpItemSet->Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_CENTER));
184 mpItemSet->Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
188 CustomShapeProperties::CustomShapeProperties(SdrObject
& rObj
)
189 : TextProperties(rObj
)
193 CustomShapeProperties::CustomShapeProperties(const CustomShapeProperties
& rProps
, SdrObject
& rObj
)
194 : TextProperties(rProps
, rObj
)
198 CustomShapeProperties::~CustomShapeProperties()
202 BaseProperties
& CustomShapeProperties::Clone(SdrObject
& rObj
) const
204 return *(new CustomShapeProperties(*this, rObj
));
206 void CustomShapeProperties::Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
)
208 TextProperties::Notify( rBC
, rHint
);
210 sal_Bool bRemoveRenderGeometry
= sal_False
;
212 const SfxStyleSheetHint
*pStyleHint
= PTR_CAST( SfxStyleSheetHint
, &rHint
);
213 const SfxSimpleHint
*pSimpleHint
= PTR_CAST( SfxSimpleHint
, &rHint
);
214 if ( pStyleHint
&& pStyleHint
->GetStyleSheet() == GetStyleSheet() )
216 switch( pStyleHint
->GetHint() )
218 case SFX_STYLESHEET_MODIFIED
:
219 case SFX_STYLESHEET_CHANGED
:
220 bRemoveRenderGeometry
= sal_True
;
224 else if ( pSimpleHint
&& pSimpleHint
->GetId() == SFX_HINT_DATACHANGED
)
226 bRemoveRenderGeometry
= sal_True
;
228 if ( bRemoveRenderGeometry
)
230 UpdateTextFrameStatus();
232 // local changes, removing cached objects
233 SdrObjCustomShape
& rObj
= (SdrObjCustomShape
&)GetSdrObject();
234 rObj
.InvalidateRenderGeometry();
238 } // end of namespace properties
239 } // end of namespace sdr
241 //////////////////////////////////////////////////////////////////////////////