update dev300-m58
[ooovba.git] / svx / source / toolbars / extrusionbar.cxx
blob21125101620d02b8017fa67ec543dbe547a6dab2
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: extrusionbar.cxx,v $
10 * $Revision: 1.18 $
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"
34 #ifndef _COM_SUN_STAR_DRAWING_ENHANCEDCUSTOMSHAPEPARAMETERPARIR_HPP_
35 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
36 #endif
37 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
38 #include <com/sun/star/drawing/ShadeMode.hpp>
39 #include <com/sun/star/drawing/Position3D.hpp>
40 #include <com/sun/star/drawing/Direction3D.hpp>
41 #include <com/sun/star/drawing/ProjectionMode.hpp>
42 #include <svx/svdundo.hxx>
43 #include <sfx2/app.hxx>
44 #include <sfx2/request.hxx>
45 #include <sfx2/objface.hxx>
46 #include <sfx2/viewsh.hxx>
47 #include <sfx2/bindings.hxx>
48 #include <svx/xsflclit.hxx>
49 #include <svx/dialmgr.hxx>
50 #include <svx/svdoashp.hxx>
51 #ifndef _SVX_DIALOGS_HRC
52 #include <svx/dialogs.hrc>
53 #endif
54 #include <svx/svdview.hxx>
55 #include <svx/colritem.hxx>
56 #include "chrtitem.hxx"
58 #include <svx/extrusionbar.hxx>
59 #include "extrusioncontrols.hxx"
61 using namespace ::svx;
62 using namespace ::rtl;
63 using namespace ::cppu;
64 using namespace ::com::sun::star::beans;
65 using namespace ::com::sun::star::drawing;
66 using namespace ::com::sun::star::uno;
68 /*************************************************************************
70 |* Standardinterface deklarieren (Die Slotmap darf nicht leer sein, also
71 |* tragen wir etwas ein, was hier (hoffentlich) nie vorkommt).
73 \************************************************************************/
75 #define ShellClass ExtrusionBar
77 SFX_SLOTMAP(ExtrusionBar)
79 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
82 SFX_IMPL_INTERFACE(ExtrusionBar, SfxShell, SVX_RES(RID_SVX_EXTRUSION_BAR))
84 SFX_OBJECTBAR_REGISTRATION( SFX_OBJECTBAR_OBJECT, SVX_RES(RID_SVX_EXTRUSION_BAR) );
87 TYPEINIT1( ExtrusionBar, SfxShell );
90 /*************************************************************************
92 |* Standard-Konstruktor
94 \************************************************************************/
96 ExtrusionBar::ExtrusionBar(SfxViewShell* pViewShell )
97 : SfxShell(pViewShell)
99 DBG_ASSERT( pViewShell, "svx::ExtrusionBar::ExtrusionBar(), I need a viewshell!" );
100 if( pViewShell )
101 SetPool(&pViewShell->GetPool());
103 SetHelpId( SVX_INTERFACE_EXTRUSION_BAR );
104 SetName( String( SVX_RES( RID_SVX_EXTRUSION_BAR )));
108 /*************************************************************************
110 |* Destruktor
112 \************************************************************************/
114 ExtrusionBar::~ExtrusionBar()
116 SetRepeatTarget(NULL);
119 void getLightingDirectionDefaults( const Direction3D **pLighting1Defaults, const Direction3D **pLighting2Defaults )
122 static const Direction3D aLighting1Defaults[9] =
124 Direction3D( -50000, -50000, 10000 ),
125 Direction3D( 0, -50000, 10000 ),
126 Direction3D( 50000, -50000, 10000 ),
127 Direction3D( -50000, 0, 10000 ),
128 Direction3D( 0, 0, 10000 ),
129 Direction3D( 50000, 0, 10000 ),
130 Direction3D( -50000, 50000, 10000 ),
131 Direction3D( 0, 50000, 10000 ),
132 Direction3D( 50000, 50000, 10000 )
135 static const Direction3D aLighting2Defaults[9] =
137 Direction3D( 50000,0, 10000 ),
138 Direction3D( 0, 50000, 10000 ),
139 Direction3D( -50000, 0, 10000 ),
140 Direction3D( 50000, 0, 10000 ),
141 Direction3D( 0, 0, 10000 ),
142 Direction3D( -50000, 0, 10000 ),
143 Direction3D( 50000, 0, 10000 ),
144 Direction3D( 0, -50000, 10000 ),
145 Direction3D( -50000, 0, 10000 )
148 *pLighting1Defaults = (const Direction3D *)aLighting1Defaults;
149 *pLighting2Defaults = (const Direction3D *)aLighting2Defaults;
152 static void impl_execute( SdrView*, SfxRequest& rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
154 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
155 static const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
156 static const rtl::OUString sRotateAngle( RTL_CONSTASCII_USTRINGPARAM ( "RotateAngle" ) );
157 static const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
158 static const rtl::OUString sOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
159 static const rtl::OUString sSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
160 static const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
162 sal_uInt16 nSID = rReq.GetSlot();
163 switch( nSID )
165 case SID_EXTRUSION_TOOGLE:
167 com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
169 if( pAny )
171 sal_Bool bOn;
172 (*pAny) >>= bOn;
173 bOn = !bOn;
174 (*pAny) <<= bOn;
176 else
178 com::sun::star::beans::PropertyValue aPropValue;
179 aPropValue.Name = sExtrusion;
180 aPropValue.Value <<= sal_True;
181 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
184 break;
186 case SID_EXTRUSION_TILT_DOWN:
187 case SID_EXTRUSION_TILT_UP:
188 case SID_EXTRUSION_TILT_LEFT:
189 case SID_EXTRUSION_TILT_RIGHT:
191 sal_Bool bHorizontal = ( nSID == SID_EXTRUSION_TILT_DOWN ) || ( nSID == SID_EXTRUSION_TILT_UP );
192 sal_Int32 nDiff = ( nSID == SID_EXTRUSION_TILT_LEFT ) || ( nSID == SID_EXTRUSION_TILT_UP ) ? 5 : -5;
193 EnhancedCustomShapeParameterPair aRotateAnglePropPair;
194 double fX = 0.0;
195 double fY = 0.0;
196 aRotateAnglePropPair.First.Value <<= fX;
197 aRotateAnglePropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
198 aRotateAnglePropPair.Second.Value <<= fY;
199 aRotateAnglePropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
200 com::sun::star::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sRotateAngle );
201 if( pAny && ( *pAny >>= aRotateAnglePropPair ) )
203 aRotateAnglePropPair.First.Value >>= fX;
204 aRotateAnglePropPair.Second.Value >>= fY;
206 if ( bHorizontal )
207 fX += nDiff;
208 else
209 fY += nDiff;
210 aRotateAnglePropPair.First.Value <<= fX;
211 aRotateAnglePropPair.Second.Value <<= fY;
212 com::sun::star::beans::PropertyValue aPropValue;
213 aPropValue.Name = sRotateAngle;
214 aPropValue.Value <<= aRotateAnglePropPair;
215 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
217 break;
219 case SID_EXTRUSION_DIRECTION:
221 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_DIRECTION ) == SFX_ITEM_SET )
223 sal_Int32 nSkew = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_DIRECTION))->GetValue();
225 Position3D aViewPoint( 3472, -3472, 25000 );
226 double fOriginX = 0.50;
227 double fOriginY = -0.50;
228 double fSkewAngle = nSkew;
229 double fSkew = 50.0;
231 switch( nSkew )
233 case 135:
234 aViewPoint.PositionY = 3472;
235 fOriginY = 0.50;
236 break;
237 case 90:
238 aViewPoint.PositionX = 0;
239 aViewPoint.PositionY = 3472;
240 fOriginX = 0;
241 fOriginY = -0.50;
242 break;
243 case 45:
244 aViewPoint.PositionX = -3472;
245 aViewPoint.PositionY = 3472;
246 fOriginX = -0.50;
247 fOriginY = 0.50;
248 break;
249 case 180:
250 aViewPoint.PositionY = 0;
251 fOriginY = 0;
252 break;
253 case 0:
254 aViewPoint.PositionX = 0;
255 aViewPoint.PositionY = 0;
256 fOriginX = 0;
257 fOriginY = 0;
258 fSkew = 0.0;
259 break;
260 case -360:
261 aViewPoint.PositionX = -3472;
262 aViewPoint.PositionY = 0;
263 fOriginX = -0.50;
264 fOriginY = 0;
265 break;
266 case -90:
267 aViewPoint.PositionX = 0;
268 fOriginX = 0;
269 break;
270 case -45:
271 aViewPoint.PositionX = -3472;
272 fOriginX = -0.50;
273 break;
276 com::sun::star::beans::PropertyValue aPropValue;
278 aPropValue.Name = sViewPoint;
279 aPropValue.Value <<= aViewPoint;
280 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
283 EnhancedCustomShapeParameterPair aOriginPropPair;
284 aOriginPropPair.First.Value <<= fOriginX;
285 aOriginPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
286 aOriginPropPair.Second.Value <<= fOriginY;
287 aOriginPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
288 aPropValue.Name = sOrigin;
289 aPropValue.Value <<= aOriginPropPair;
290 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
292 EnhancedCustomShapeParameterPair aSkewPropPair;
293 aSkewPropPair.First.Value <<= fSkew;
294 aSkewPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
295 aSkewPropPair.Second.Value <<= fSkewAngle;
296 aSkewPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
297 aPropValue.Name = sSkew;
298 aPropValue.Value <<= aSkewPropPair;
299 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
302 break;
303 case SID_EXTRUSION_PROJECTION:
305 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_PROJECTION ) == SFX_ITEM_SET )
307 sal_Int32 nProjection = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_PROJECTION))->GetValue();
308 ProjectionMode eProjectionMode = nProjection == 1 ? ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE;
309 com::sun::star::beans::PropertyValue aPropValue;
310 aPropValue.Name = sProjectionMode;
311 aPropValue.Value <<= eProjectionMode;
312 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
315 break;
316 case SID_EXTRUSION_DEPTH:
318 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == SFX_ITEM_SET)
320 double fDepth = ((const SvxDoubleItem*)rReq.GetArgs()->GetItem(SID_EXTRUSION_DEPTH))->GetValue();
321 double fFraction = 0.0;
322 EnhancedCustomShapeParameterPair aDepthPropPair;
323 aDepthPropPair.First.Value <<= fDepth;
324 aDepthPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
325 aDepthPropPair.Second.Value <<= fFraction;
326 aDepthPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
328 com::sun::star::beans::PropertyValue aPropValue;
329 aPropValue.Name = sDepth;
330 aPropValue.Value <<= aDepthPropPair;
331 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
334 break;
335 case SID_EXTRUSION_3D_COLOR:
337 static const rtl::OUString sExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
339 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_3D_COLOR ) == SFX_ITEM_SET)
341 Color aColor( ((const SvxColorItem&)rReq.GetArgs()->Get(SID_EXTRUSION_3D_COLOR)).GetValue() );
343 const bool bAuto = aColor == COL_AUTO;
345 com::sun::star::beans::PropertyValue aPropValue;
346 aPropValue.Name = sExtrusionColor;
347 aPropValue.Value <<= bAuto ? sal_False : sal_True;
348 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
350 if( bAuto )
352 pObj->ClearMergedItem( XATTR_SECONDARYFILLCOLOR );
354 else
356 pObj->SetMergedItem( XSecondaryFillColorItem( String(), aColor ) );
358 pObj->BroadcastObjectChange();
361 break;
362 case SID_EXTRUSION_SURFACE:
364 static const rtl::OUString sShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
365 static const rtl::OUString sSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
366 static const rtl::OUString sDiffusion( RTL_CONSTASCII_USTRINGPARAM ( "Diffusion" ) );
367 static const rtl::OUString sMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
369 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_SURFACE ) == SFX_ITEM_SET)
371 sal_Int32 nSurface = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_SURFACE))->GetValue();
373 ShadeMode eShadeMode( ShadeMode_FLAT );
374 sal_Bool bMetal = sal_False;
375 double fSpecularity = 0;
376 double fDiffusion = 0;
378 switch( nSurface )
380 case 0: // wireframe
381 eShadeMode = ShadeMode_DRAFT;
382 break;
383 case 1: // matte
384 break;
385 case 2: // plastic
386 fSpecularity = 122.0;
387 break;
388 case 3: // metal
389 bMetal = true;
390 fSpecularity = 122.0;
391 fDiffusion = 122.0;
392 break;
395 com::sun::star::beans::PropertyValue aPropValue;
396 aPropValue.Name = sShadeMode;
397 aPropValue.Value <<= eShadeMode;
398 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
400 aPropValue.Name = sMetal;
401 aPropValue.Value <<= bMetal;
402 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
404 aPropValue.Name = sSpecularity;
405 aPropValue.Value <<= fSpecularity;
406 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
408 aPropValue.Name = sDiffusion;
409 aPropValue.Value <<= fDiffusion;
410 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
413 break;
414 case SID_EXTRUSION_LIGHTING_INTENSITY:
416 static const rtl::OUString sBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
417 static const rtl::OUString sLightFace( RTL_CONSTASCII_USTRINGPARAM ( "LightFace" ) );
418 static const rtl::OUString sFirstLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightHarsh" ) );
419 static const rtl::OUString sSecondLightHarsh( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightHarsh" ) );
420 static const rtl::OUString sFirstLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightLevel" ) );
421 static const rtl::OUString sSecondLightLevel( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightLevel" ) );
423 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_LIGHTING_INTENSITY ) == SFX_ITEM_SET)
425 sal_Int32 nLevel = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_LIGHTING_INTENSITY))->GetValue();
427 double fBrightness;
428 sal_Bool bHarsh2;
429 double fLevel1;
430 double fLevel2;
432 switch( nLevel )
434 case 0: // bright
435 fBrightness = 34.0;
436 bHarsh2 = sal_False;
437 fLevel1 = 66.0;
438 fLevel2 = 66.0;
439 break;
440 case 1: // normal
441 fBrightness = 15.0;
442 bHarsh2 = sal_False;
443 fLevel1 = 67.0;
444 fLevel2 = 37.0;
445 break;
446 case 2: // dim
447 fBrightness = 6.0;
448 bHarsh2 = sal_True;
449 fLevel1 = 79.0;
450 fLevel2 = 21.0;
451 break;
454 com::sun::star::beans::PropertyValue aPropValue;
455 aPropValue.Name = sBrightness;
456 aPropValue.Value <<= fBrightness;
457 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
459 aPropValue.Name = sLightFace;
460 aPropValue.Value <<= sal_True;
461 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
463 aPropValue.Name = sFirstLightHarsh;
464 aPropValue.Value <<= sal_True;
465 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
467 aPropValue.Name = sSecondLightHarsh;
468 aPropValue.Value <<= bHarsh2;
469 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
471 aPropValue.Name = sFirstLightLevel;
472 aPropValue.Value <<= fLevel1;
473 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
475 aPropValue.Name = sSecondLightLevel;
476 aPropValue.Value <<= fLevel2;
477 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
480 break;
481 case SID_EXTRUSION_LIGHTING_DIRECTION:
483 if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_LIGHTING_DIRECTION ) == SFX_ITEM_SET)
485 sal_Int32 nDirection = ((const SfxInt32Item*)rReq.GetArgs()->GetItem(SID_EXTRUSION_LIGHTING_DIRECTION))->GetValue();
487 if((nDirection >= 0) && (nDirection < 9))
489 const rtl::OUString sFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
490 const rtl::OUString sSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
492 const Direction3D * pLighting1Defaults;
493 const Direction3D * pLighting2Defaults;
495 getLightingDirectionDefaults( &pLighting1Defaults, &pLighting2Defaults );
497 com::sun::star::beans::PropertyValue aPropValue;
498 aPropValue.Name = sFirstLightDirection;
499 aPropValue.Value <<= pLighting1Defaults[nDirection];
500 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
502 aPropValue.Name = sSecondLightDirection;
503 aPropValue.Value <<= pLighting2Defaults[nDirection];
504 rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
508 break;
513 void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest& rReq, SfxBindings& rBindings )
515 sal_uInt16 nSID = rReq.GetSlot();
516 sal_uInt16 nStrResId = 0;
518 const bool bUndo = pSdrView && pSdrView->IsUndoEnabled();
520 switch( nSID )
522 case SID_EXTRUSION_TOOGLE:
524 if ( !nStrResId )
525 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF;
526 } // PASSTROUGH
527 case SID_EXTRUSION_TILT_DOWN:
529 if ( !nStrResId )
530 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_DOWN;
531 } // PASSTROUGH
532 case SID_EXTRUSION_TILT_UP:
534 if ( !nStrResId )
535 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_UP;
536 } // PASSTROUGH
537 case SID_EXTRUSION_TILT_LEFT:
539 if ( !nStrResId )
540 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_LEFT;
541 } // PASSTROUGH
542 case SID_EXTRUSION_TILT_RIGHT:
544 if ( !nStrResId )
545 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_RIGHT;
546 } // PASSTROUGH
547 case SID_EXTRUSION_DIRECTION:
549 if ( !nStrResId )
550 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ORIENTATION;
551 } // PASSTROUGH
552 case SID_EXTRUSION_PROJECTION:
554 if ( !nStrResId )
555 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_PROJECTION;
556 } // PASSTROUGH
557 case SID_EXTRUSION_DEPTH:
559 if ( !nStrResId )
560 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_DEPTH;
561 } // PASSTROUGH
562 case SID_EXTRUSION_3D_COLOR:
564 if ( !nStrResId )
565 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_COLOR;
566 } // PASSTROUGH
567 case SID_EXTRUSION_SURFACE:
569 if ( !nStrResId )
570 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_SURFACE;
571 } // PASSTROUGH
572 case SID_EXTRUSION_LIGHTING_INTENSITY:
574 if ( !nStrResId )
575 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_BRIGHTNESS;
576 } // PASSTROUGH
577 case SID_EXTRUSION_LIGHTING_DIRECTION:
579 if ( !nStrResId )
580 nStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_LIGHTING;
582 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
583 ULONG nCount = rMarkList.GetMarkCount(), i;
585 for(i=0; i<nCount; i++)
587 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
588 if( pObj->ISA(SdrObjCustomShape) )
590 if( bUndo )
592 String aStr( SVX_RES( nStrResId ) );
593 pSdrView->BegUndo( aStr );
594 pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
596 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
597 impl_execute( pSdrView, rReq, aGeometryItem, pObj );
598 pObj->SetMergedItem( aGeometryItem );
599 pObj->BroadcastObjectChange();
600 if( bUndo )
601 pSdrView->EndUndo();
603 // simulate a context change:
604 // force SelectionHasChanged() being called
605 // so that extrusion bar will be visible/hidden
606 pSdrView->MarkListHasChanged();
610 break;
612 case SID_EXTRUSION_DEPTH_DIALOG:
613 if( rReq.GetArgs() &&
614 (rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == SFX_ITEM_SET) &&
615 (rReq.GetArgs()->GetItemState( SID_ATTR_METRIC ) == SFX_ITEM_SET))
617 double fDepth = ((const SvxDoubleItem*)rReq.GetArgs()->GetItem(SID_EXTRUSION_DEPTH))->GetValue();
618 FieldUnit eUnit = (FieldUnit)((const SfxUInt16Item*)rReq.GetArgs()->GetItem(SID_ATTR_METRIC))->GetValue();
620 ExtrusionDepthDialog aDlg( 0L, fDepth, eUnit );
621 USHORT nRet = aDlg.Execute();
622 if( nRet != 0 )
624 fDepth = aDlg.getDepth();
626 SvxDoubleItem aItem( fDepth, SID_EXTRUSION_DEPTH );
627 SfxPoolItem* aItems[] = { &aItem, 0 };
628 rBindings.Execute( SID_EXTRUSION_DEPTH, (const SfxPoolItem**)aItems );
631 break;
634 if( nSID == SID_EXTRUSION_TOOGLE )
636 static USHORT SidArray[] = {
637 SID_EXTRUSION_TILT_DOWN,
638 SID_EXTRUSION_TILT_UP,
639 SID_EXTRUSION_TILT_LEFT,
640 SID_EXTRUSION_TILT_RIGHT,
641 SID_EXTRUSION_DEPTH_FLOATER,
642 SID_EXTRUSION_DIRECTION_FLOATER,
643 SID_EXTRUSION_LIGHTING_FLOATER,
644 SID_EXTRUSION_SURFACE_FLOATER,
645 SID_EXTRUSION_3D_COLOR,
646 SID_EXTRUSION_DEPTH,
647 SID_EXTRUSION_DIRECTION,
648 SID_EXTRUSION_PROJECTION,
649 SID_EXTRUSION_LIGHTING_DIRECTION,
650 SID_EXTRUSION_LIGHTING_INTENSITY,
651 SID_EXTRUSION_SURFACE,
652 0 };
654 rBindings.Invalidate( SidArray );
658 void getExtrusionDirectionState( SdrView* pSdrView, SfxItemSet& rSet )
660 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
661 ULONG nCount = rMarkList.GetMarkCount(), i;
663 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
664 static const rtl::OUString sViewPoint( RTL_CONSTASCII_USTRINGPARAM ( "ViewPoint" ) );
665 static const rtl::OUString sOrigin( RTL_CONSTASCII_USTRINGPARAM ( "Origin" ) );
666 static const rtl::OUString sSkew( RTL_CONSTASCII_USTRINGPARAM ( "Skew" ) );
667 static const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
669 com::sun::star::uno::Any* pAny;
671 double fFinalSkewAngle = -1;
672 bool bHasCustomShape = false;
674 for(i=0;i<nCount; i++)
676 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
677 if( pObj->ISA(SdrObjCustomShape) )
679 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
681 // see if this is an extruded customshape
682 if( !bHasCustomShape )
684 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
685 if( pAny_ )
686 *pAny_ >>= bHasCustomShape;
688 if( !bHasCustomShape )
689 continue;
692 sal_Bool bParallel = sal_True;
693 Position3D aViewPoint( 3472, -3472, 25000 );
694 double fOriginX = 0.50;
695 double fOriginY = -0.50;
696 double fSkewAngle = -135;
697 double fSkew = 50.0;
699 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sProjectionMode );
700 sal_Int16 nProjectionMode = sal_Int16();
701 if( pAny && ( *pAny >>= nProjectionMode ) )
702 bParallel = nProjectionMode == ProjectionMode_PARALLEL;
704 if( bParallel )
706 EnhancedCustomShapeParameterPair aSkewPropPair;
707 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sSkew );
708 if( pAny && ( *pAny >>= aSkewPropPair ) )
710 aSkewPropPair.First.Value >>= fSkew;
711 aSkewPropPair.Second.Value >>= fSkewAngle;
713 if ( fSkew == 0.0 )
714 fSkewAngle = 0.0;
715 else if ( fSkewAngle == 0.0 )
716 fSkewAngle = -360.0;
718 else
720 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sViewPoint );
721 if( pAny )
722 *pAny >>= aViewPoint;
724 EnhancedCustomShapeParameterPair aOriginPropPair;
725 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sOrigin );
726 if( pAny && ( *pAny >>= aOriginPropPair ) )
728 aOriginPropPair.First.Value >>= fOriginX;
729 aOriginPropPair.Second.Value >>= fOriginY;
731 fSkewAngle = -1;
732 const double e = 0.0001;
733 if( aViewPoint.PositionX > e )
735 if( aViewPoint.PositionY > e )
737 if( (fOriginX > e ) && ( fOriginY > e ) )
738 fSkewAngle = 135.0;
740 else if( aViewPoint.PositionY < -e )
742 if( ( fOriginX > e ) && ( fOriginY < -e ) )
743 fSkewAngle = -135.0;
745 else
747 if( ( fOriginX > e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
748 fSkewAngle = 180.0;
751 else if( aViewPoint.PositionX < -e )
753 if( aViewPoint.PositionY < -e )
755 if( ( fOriginX < -e ) && ( fOriginY < -e ) )
756 fSkewAngle = -45.0;
758 else if( aViewPoint.PositionY > e )
760 if( ( fOriginX < -e ) && ( fOriginY > e ) )
761 fSkewAngle = 45.0;
763 else
765 if( ( fOriginX < e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
766 fSkewAngle = -360.0;
769 else
771 if( aViewPoint.PositionY < -e )
773 if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY < -e ) )
774 fSkewAngle = -90.0;
776 else if( aViewPoint.PositionY > e )
778 if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY > e ) )
779 fSkewAngle = 90.0;
781 else
783 if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
784 fSkewAngle = 0.0;
789 if( fFinalSkewAngle == -1.0 )
791 fFinalSkewAngle = fSkewAngle;
793 else if( fSkewAngle != fFinalSkewAngle )
795 fFinalSkewAngle = -1.0;
798 if( fFinalSkewAngle == -1.0 )
799 break;
803 if( bHasCustomShape )
804 rSet.Put( SfxInt32Item( SID_EXTRUSION_DIRECTION, (sal_Int32)fFinalSkewAngle ) );
805 else
806 rSet.DisableItem( SID_EXTRUSION_DIRECTION );
809 void getExtrusionProjectionState( SdrView* pSdrView, SfxItemSet& rSet )
811 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
812 ULONG nCount = rMarkList.GetMarkCount(), i;
814 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
815 static const rtl::OUString sProjectionMode( RTL_CONSTASCII_USTRINGPARAM ( "ProjectionMode" ) );
817 com::sun::star::uno::Any* pAny;
819 sal_Int32 nFinalProjection = -1;
820 bool bHasCustomShape = false;
822 for(i=0;i<nCount; i++)
824 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
825 if( pObj->ISA(SdrObjCustomShape) )
827 // see if this is an extruded customshape
828 if( !bHasCustomShape )
830 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
831 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
832 if( pAny_ )
833 *pAny_ >>= bHasCustomShape;
835 if( !bHasCustomShape )
836 continue;
839 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
841 sal_Bool bParallel = sal_True;
842 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sProjectionMode );
843 ProjectionMode eProjectionMode;
844 if( pAny && ( *pAny >>= eProjectionMode ) )
845 bParallel = eProjectionMode == ProjectionMode_PARALLEL;
847 if( nFinalProjection == -1 )
849 nFinalProjection = bParallel;
851 else if( nFinalProjection != bParallel )
853 nFinalProjection = -1;
854 break;
859 if( bHasCustomShape )
860 rSet.Put( SfxInt32Item( SID_EXTRUSION_PROJECTION, nFinalProjection ) );
861 else
862 rSet.DisableItem( SID_EXTRUSION_PROJECTION );
865 void getExtrusionSurfaceState( SdrView* pSdrView, SfxItemSet& rSet )
867 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
868 ULONG nCount = rMarkList.GetMarkCount(), i;
870 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
871 static const rtl::OUString sShadeMode( RTL_CONSTASCII_USTRINGPARAM ( "ShadeMode" ) );
872 static const rtl::OUString sSpecularity( RTL_CONSTASCII_USTRINGPARAM ( "Specularity" ) );
873 static const rtl::OUString sDiffusion( RTL_CONSTASCII_USTRINGPARAM ( "Diffusion" ) );
874 static const rtl::OUString sMetal( RTL_CONSTASCII_USTRINGPARAM ( "Metal" ) );
876 com::sun::star::uno::Any* pAny;
878 sal_Int32 nFinalSurface = -1;
879 bool bHasCustomShape = false;
881 for(i=0;i<nCount; i++)
883 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
884 if( pObj->ISA(SdrObjCustomShape) )
886 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
888 // see if this is an extruded customshape
889 if( !bHasCustomShape )
891 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
892 if( pAny_ )
893 *pAny_ >>= bHasCustomShape;
895 if( !bHasCustomShape )
896 continue;
899 sal_Int32 nSurface = 0; // wire frame
901 ShadeMode eShadeMode( ShadeMode_FLAT );
902 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sShadeMode );
903 if( pAny )
904 *pAny >>= eShadeMode;
906 if( eShadeMode == ShadeMode_FLAT )
908 sal_Bool bMetal = sal_False;
909 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sMetal );
910 if( pAny )
911 *pAny >>= bMetal;
913 if( bMetal )
915 nSurface = 3; // metal
917 else
919 double fSpecularity = 0;
920 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sSpecularity );
921 if( pAny )
922 *pAny >>= fSpecularity;
924 const double e = 0.0001;
925 if( (fSpecularity > -e) && (fSpecularity < e) )
927 nSurface = 1; // matte
929 else
931 nSurface = 2; // plastic
936 if( nFinalSurface == -1 )
938 nFinalSurface = nSurface;
940 else if( nFinalSurface != nSurface )
942 nFinalSurface = -1;
943 break;
948 if( bHasCustomShape )
949 rSet.Put( SfxInt32Item( SID_EXTRUSION_SURFACE, nFinalSurface ) );
950 else
951 rSet.DisableItem( SID_EXTRUSION_SURFACE );
954 void getExtrusionDepthState( SdrView* pSdrView, SfxItemSet& rSet )
956 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
957 ULONG nCount = rMarkList.GetMarkCount(), i;
959 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
960 static const rtl::OUString sDepth( RTL_CONSTASCII_USTRINGPARAM ( "Depth" ) );
962 com::sun::star::uno::Any* pAny;
964 double fFinalDepth = -1;
965 bool bHasCustomShape = false;
967 for(i=0;i<nCount; i++)
969 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
970 if( pObj->ISA(SdrObjCustomShape) )
972 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
974 // see if this is an extruded customshape
975 if( !bHasCustomShape )
977 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
978 if( pAny_ )
979 *pAny_ >>= bHasCustomShape;
981 if( !bHasCustomShape )
982 continue;
985 double fDepth = 1270.0;
986 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sDepth );
987 if( pAny )
989 EnhancedCustomShapeParameterPair aDepthPropPair;
990 if ( *pAny >>= aDepthPropPair )
991 aDepthPropPair.First.Value >>= fDepth;
994 if( fFinalDepth == -1 )
996 fFinalDepth = fDepth;
998 else if( fFinalDepth != fDepth )
1000 fFinalDepth = -1;
1001 break;
1006 if( pSdrView->GetModel() )
1008 FieldUnit eUnit = pSdrView->GetModel()->GetUIUnit();
1009 rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, (USHORT)eUnit ) );
1012 if( bHasCustomShape )
1013 rSet.Put( SvxDoubleItem( fFinalDepth, SID_EXTRUSION_DEPTH ) );
1014 else
1015 rSet.DisableItem( SID_EXTRUSION_DEPTH );
1018 static bool compare_direction( const Direction3D& d1, const Direction3D& d2 )
1020 if( ((d1.DirectionX < 0) && (d2.DirectionX < 0)) || ((d1.DirectionX == 0) && (d2.DirectionX == 0)) || ((d1.DirectionX > 0) && (d2.DirectionX > 0)) )
1022 if( ((d1.DirectionY < 0) && (d2.DirectionY < 0)) || ((d1.DirectionY == 0) && (d2.DirectionY == 0)) || ((d1.DirectionY > 0) && (d2.DirectionY > 0)) )
1024 if( ((d1.DirectionZ < 0) && (d2.DirectionZ < 0)) || ((d1.DirectionZ == 0) && (d2.DirectionZ == 0)) || ((d1.DirectionZ > 0) && (d2.DirectionZ > 0)) )
1026 return true;
1031 return false;
1034 void getExtrusionLightingDirectionState( SdrView* pSdrView, SfxItemSet& rSet )
1036 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1037 ULONG nCount = rMarkList.GetMarkCount(), i;
1039 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
1040 static const rtl::OUString sFirstLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "FirstLightDirection" ) );
1041 static const rtl::OUString sSecondLightDirection( RTL_CONSTASCII_USTRINGPARAM ( "SecondLightDirection" ) );
1043 const Direction3D * pLighting1Defaults;
1044 const Direction3D * pLighting2Defaults;
1046 getLightingDirectionDefaults( &pLighting1Defaults, &pLighting2Defaults );
1048 com::sun::star::uno::Any* pAny;
1050 int nFinalDirection = -1;
1051 bool bHasCustomShape = false;
1053 for(i=0;i<nCount; i++)
1055 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1056 if( pObj->ISA(SdrObjCustomShape) )
1058 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1060 // see if this is an extruded customshape
1061 if( !bHasCustomShape )
1063 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1064 if( pAny_ )
1065 *pAny_ >>= bHasCustomShape;
1067 if( !bHasCustomShape )
1068 continue;
1071 Direction3D aFirstLightDirection( 50000, 0, 10000 );
1072 Direction3D aSecondLightDirection( -50000, 0, 10000 );
1074 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sFirstLightDirection );
1075 if( pAny )
1076 *pAny >>= aFirstLightDirection;
1078 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sSecondLightDirection );
1079 if( pAny )
1080 *pAny >>= aSecondLightDirection;
1082 int nDirection = -1;
1084 int j;
1085 for( j = 0; j < 9; j++ )
1087 if( compare_direction( aFirstLightDirection, pLighting1Defaults[j] ) &&
1088 compare_direction( aSecondLightDirection, pLighting2Defaults[j] ))
1090 nDirection = j;
1091 break;
1095 if( nFinalDirection == -1 )
1097 nFinalDirection = nDirection;
1099 else if( nDirection != nFinalDirection )
1101 nFinalDirection = -1;
1104 if( nFinalDirection == -1 )
1105 break;
1109 if( bHasCustomShape )
1110 rSet.Put( SfxInt32Item( SID_EXTRUSION_LIGHTING_DIRECTION, (sal_Int32)nFinalDirection ) );
1111 else
1112 rSet.DisableItem( SID_EXTRUSION_LIGHTING_DIRECTION );
1115 void getExtrusionLightingIntensityState( SdrView* pSdrView, SfxItemSet& rSet )
1117 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1118 ULONG nCount = rMarkList.GetMarkCount(), i;
1120 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
1121 static const rtl::OUString sBrightness( RTL_CONSTASCII_USTRINGPARAM ( "Brightness" ) );
1123 com::sun::star::uno::Any* pAny;
1125 int nFinalLevel = -1;
1126 bool bHasCustomShape = false;
1128 for(i=0;i<nCount; i++)
1130 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1131 if( pObj->ISA(SdrObjCustomShape) )
1133 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1135 // see if this is an extruded customshape
1136 if( !bHasCustomShape )
1138 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1139 if( pAny_ )
1140 *pAny_ >>= bHasCustomShape;
1142 if( !bHasCustomShape )
1143 continue;
1146 double fBrightness = 22178.0 / 655.36;
1147 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sBrightness );
1148 if( pAny )
1149 *pAny >>= fBrightness;
1151 int nLevel;
1152 if( fBrightness >= 30.0 )
1154 nLevel = 0; // Bright
1156 else if( fBrightness >= 10.0 )
1158 nLevel = 1; // Noraml;
1160 else
1162 nLevel = 2; // Dim
1165 if( nFinalLevel == -1 )
1167 nFinalLevel = nLevel;
1169 else if( nFinalLevel != nLevel )
1171 nFinalLevel = -1;
1172 break;
1177 if( bHasCustomShape )
1178 rSet.Put( SfxInt32Item( SID_EXTRUSION_LIGHTING_INTENSITY, nFinalLevel ) );
1179 else
1180 rSet.DisableItem( SID_EXTRUSION_LIGHTING_INTENSITY );
1183 void getExtrusionColorState( SdrView* pSdrView, SfxItemSet& rSet )
1185 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1186 ULONG nCount = rMarkList.GetMarkCount(), i;
1188 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
1189 static const rtl::OUString sExtrusionColor( RTL_CONSTASCII_USTRINGPARAM ( "Color" ) );
1191 com::sun::star::uno::Any* pAny;
1193 bool bInit = false;
1194 bool bAmbigius = false;
1195 Color aFinalColor;
1196 bool bHasCustomShape = false;
1198 for(i=0;i<nCount; i++)
1200 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1201 if( pObj->ISA(SdrObjCustomShape) )
1203 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1205 // see if this is an extruded customshape
1206 if( !bHasCustomShape )
1208 Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1209 if( pAny_ )
1210 *pAny_ >>= bHasCustomShape;
1212 if( !bHasCustomShape )
1213 continue;
1216 Color aColor;
1218 bool bUseColor = false;
1219 pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusionColor );
1220 if( pAny )
1221 *pAny >>= bUseColor;
1223 if( bUseColor )
1225 const XSecondaryFillColorItem& rItem = *(XSecondaryFillColorItem*)&(pObj->GetMergedItem( XATTR_SECONDARYFILLCOLOR ));
1226 aColor = rItem.GetColorValue();
1228 else
1230 aColor = COL_AUTO;
1233 if( !bInit )
1235 aFinalColor = aColor;
1236 bInit = true;
1238 else if( aFinalColor != aColor )
1240 bAmbigius = true;
1241 break;
1246 if( bAmbigius )
1247 aFinalColor = COL_AUTO;
1249 if( bHasCustomShape )
1250 rSet.Put( SvxColorItem( aFinalColor, SID_EXTRUSION_3D_COLOR ) );
1251 else
1252 rSet.DisableItem( SID_EXTRUSION_3D_COLOR );
1255 namespace svx {
1256 bool checkForSelectedCustomShapes( SdrView* pSdrView, bool bOnlyExtruded )
1258 static const rtl::OUString sExtrusion( RTL_CONSTASCII_USTRINGPARAM ( "Extrusion" ) );
1260 const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1261 ULONG nCount = rMarkList.GetMarkCount(), i;
1262 bool bFound = false;
1264 for(i=0;(i<nCount) && !bFound ; i++)
1266 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1267 if( pObj->ISA(SdrObjCustomShape) )
1269 if( bOnlyExtruded )
1271 SdrCustomShapeGeometryItem aGeometryItem( (SdrCustomShapeGeometryItem&)pObj->GetMergedItem( SDRATTR_CUSTOMSHAPE_GEOMETRY ) );
1272 Any* pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1273 if( pAny )
1274 *pAny >>= bFound;
1276 else
1278 bFound = true;
1283 return bFound;
1287 void ExtrusionBar::getState( SdrView* pSdrView, SfxItemSet& rSet )
1289 if (rSet.GetItemState(SID_EXTRUSION_DIRECTION) != SFX_ITEM_UNKNOWN)
1291 getExtrusionDirectionState( pSdrView, rSet );
1293 if (rSet.GetItemState(SID_EXTRUSION_PROJECTION) != SFX_ITEM_UNKNOWN)
1295 getExtrusionProjectionState( pSdrView, rSet );
1297 const bool bOnlyExtrudedCustomShapes =
1298 checkForSelectedCustomShapes( pSdrView, true );
1299 if (rSet.GetItemState(SID_EXTRUSION_TILT_DOWN) != SFX_ITEM_UNKNOWN)
1301 if (! bOnlyExtrudedCustomShapes)
1302 rSet.DisableItem( SID_EXTRUSION_TILT_DOWN );
1304 if (rSet.GetItemState(SID_EXTRUSION_TILT_DOWN) != SFX_ITEM_UNKNOWN)
1306 if (! bOnlyExtrudedCustomShapes)
1307 rSet.DisableItem( SID_EXTRUSION_TILT_DOWN );
1309 if (rSet.GetItemState(SID_EXTRUSION_TILT_UP) != SFX_ITEM_UNKNOWN)
1311 if (! bOnlyExtrudedCustomShapes)
1312 rSet.DisableItem( SID_EXTRUSION_TILT_UP );
1314 if (rSet.GetItemState(SID_EXTRUSION_TILT_LEFT) != SFX_ITEM_UNKNOWN)
1316 if (! bOnlyExtrudedCustomShapes)
1317 rSet.DisableItem( SID_EXTRUSION_TILT_LEFT );
1319 if (rSet.GetItemState(SID_EXTRUSION_TILT_RIGHT) != SFX_ITEM_UNKNOWN)
1321 if (! bOnlyExtrudedCustomShapes)
1322 rSet.DisableItem( SID_EXTRUSION_TILT_RIGHT );
1324 if (rSet.GetItemState(SID_EXTRUSION_3D_COLOR) != SFX_ITEM_UNKNOWN)
1326 if (! bOnlyExtrudedCustomShapes)
1327 rSet.DisableItem( SID_EXTRUSION_3D_COLOR );
1329 if (rSet.GetItemState(SID_EXTRUSION_DEPTH_FLOATER) != SFX_ITEM_UNKNOWN)
1331 if (! bOnlyExtrudedCustomShapes)
1332 rSet.DisableItem( SID_EXTRUSION_DEPTH_FLOATER );
1334 if (rSet.GetItemState(SID_EXTRUSION_DIRECTION_FLOATER) != SFX_ITEM_UNKNOWN)
1336 if (! bOnlyExtrudedCustomShapes)
1337 rSet.DisableItem( SID_EXTRUSION_DIRECTION_FLOATER );
1339 if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_FLOATER) != SFX_ITEM_UNKNOWN)
1341 if (! bOnlyExtrudedCustomShapes)
1342 rSet.DisableItem( SID_EXTRUSION_LIGHTING_FLOATER );
1344 if (rSet.GetItemState(SID_EXTRUSION_SURFACE_FLOATER) != SFX_ITEM_UNKNOWN)
1346 if(! bOnlyExtrudedCustomShapes)
1347 rSet.DisableItem( SID_EXTRUSION_SURFACE_FLOATER );
1349 if (rSet.GetItemState(SID_EXTRUSION_TOOGLE) != SFX_ITEM_UNKNOWN)
1351 if( !checkForSelectedCustomShapes( pSdrView, false ) )
1352 rSet.DisableItem( SID_EXTRUSION_TOOGLE );
1354 if (rSet.GetItemState(SID_EXTRUSION_DEPTH) != SFX_ITEM_UNKNOWN)
1356 getExtrusionDepthState( pSdrView, rSet );
1358 if (rSet.GetItemState(SID_EXTRUSION_SURFACE) != SFX_ITEM_UNKNOWN)
1360 getExtrusionSurfaceState( pSdrView, rSet );
1362 if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_INTENSITY) != SFX_ITEM_UNKNOWN)
1364 getExtrusionLightingIntensityState( pSdrView, rSet );
1367 if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_DIRECTION) != SFX_ITEM_UNKNOWN)
1369 getExtrusionLightingDirectionState( pSdrView, rSet );
1372 if (rSet.GetItemState(SID_EXTRUSION_3D_COLOR) != SFX_ITEM_UNKNOWN)
1374 getExtrusionColorState( pSdrView, rSet );