LibreOffice Module svx (master)  1
extrusionbar.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 
21 #include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
22 #include <com/sun/star/drawing/EnhancedCustomShapeParameterType.hpp>
23 #include <com/sun/star/drawing/ShadeMode.hpp>
24 #include <com/sun/star/drawing/Position3D.hpp>
25 #include <com/sun/star/drawing/Direction3D.hpp>
26 #include <com/sun/star/drawing/ProjectionMode.hpp>
27 #include <svx/svxids.hrc>
28 #include <svx/svdundo.hxx>
29 #include <sfx2/request.hxx>
30 #include <sfx2/objface.hxx>
31 #include <sfx2/viewsh.hxx>
32 #include <sfx2/bindings.hxx>
33 #include <svx/xsflclit.hxx>
34 #include <svx/dialmgr.hxx>
35 #include <svx/svdoashp.hxx>
36 #include <svx/strings.hrc>
37 #include <svx/svdview.hxx>
38 #include <editeng/colritem.hxx>
39 #include <svx/chrtitem.hxx>
40 #include <svx/sdasitm.hxx>
41 #include <svl/intitem.hxx>
42 
43 #include <svx/extrusionbar.hxx>
44 #include <extrusiondepthdialog.hxx>
45 
46 using namespace ::svx;
47 using namespace ::cppu;
48 using namespace ::com::sun::star::beans;
49 using namespace ::com::sun::star::drawing;
50 using namespace ::com::sun::star::uno;
51 
52 // Declare the default interface. (The slotmap must not be empty, so
53 // we enter something which never occurs here (hopefully).)
55 {
56  { 0, SfxGroupId::NONE, SfxSlotMode::NONE, 0, 0, nullptr, nullptr, nullptr, nullptr, nullptr, 0, SfxDisableFlags::NONE, nullptr }
57 };
58 
59 SFX_IMPL_INTERFACE(ExtrusionBar, SfxShell)
60 
61 void ExtrusionBar::InitInterface_Impl()
62 {
63  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Svx_Extrusion_Bar);
64 }
65 
66 
67 ExtrusionBar::ExtrusionBar(SfxViewShell* pViewShell )
68 : SfxShell(pViewShell)
69 {
70  DBG_ASSERT( pViewShell, "svx::ExtrusionBar::ExtrusionBar(), I need a viewshell!" );
71  if( pViewShell )
72  SetPool(&pViewShell->GetPool());
73 
74  SetName(SvxResId(RID_SVX_EXTRUSION_BAR));
75 }
76 
78 {
79  SetRepeatTarget(nullptr);
80 }
81 
82 static void getLightingDirectionDefaults( const Direction3D **pLighting1Defaults, const Direction3D **pLighting2Defaults )
83 {
84 
85  static const Direction3D aLighting1Defaults[9] =
86  {
87  Direction3D( -50000, -50000, 10000 ),
88  Direction3D( 0, -50000, 10000 ),
89  Direction3D( 50000, -50000, 10000 ),
90  Direction3D( -50000, 0, 10000 ),
91  Direction3D( 0, 0, 10000 ),
92  Direction3D( 50000, 0, 10000 ),
93  Direction3D( -50000, 50000, 10000 ),
94  Direction3D( 0, 50000, 10000 ),
95  Direction3D( 50000, 50000, 10000 )
96  };
97 
98  static const Direction3D aLighting2Defaults[9] =
99  {
100  Direction3D( 50000,0, 10000 ),
101  Direction3D( 0, 50000, 10000 ),
102  Direction3D( -50000, 0, 10000 ),
103  Direction3D( 50000, 0, 10000 ),
104  Direction3D( 0, 0, 10000 ),
105  Direction3D( -50000, 0, 10000 ),
106  Direction3D( 50000, 0, 10000 ),
107  Direction3D( 0, -50000, 10000 ),
108  Direction3D( -50000, 0, 10000 )
109  };
110 
111  *pLighting1Defaults = aLighting1Defaults;
112  *pLighting2Defaults = aLighting2Defaults;
113 };
114 
115 static void impl_execute( SfxRequest const & rReq, SdrCustomShapeGeometryItem& rGeometryItem, SdrObject* pObj )
116 {
117  static const char sExtrusion[] = "Extrusion";
118  static const char sRotateAngle[] = "RotateAngle";
119 
120  sal_uInt16 nSID = rReq.GetSlot();
121  switch( nSID )
122  {
123  case SID_EXTRUSION_TOGGLE:
124  {
125  css::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
126 
127  if( pAny )
128  {
129  bool bOn(false);
130  (*pAny) >>= bOn;
131  bOn = !bOn;
132  (*pAny) <<= bOn;
133  }
134  else
135  {
136  css::beans::PropertyValue aPropValue;
137  aPropValue.Name = sExtrusion;
138  aPropValue.Value <<= true;
139  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
140  }
141  }
142  break;
143 
144  case SID_EXTRUSION_TILT_DOWN:
145  case SID_EXTRUSION_TILT_UP:
146  case SID_EXTRUSION_TILT_LEFT:
147  case SID_EXTRUSION_TILT_RIGHT:
148  {
149  bool bHorizontal = ( nSID == SID_EXTRUSION_TILT_DOWN ) || ( nSID == SID_EXTRUSION_TILT_UP );
150  sal_Int32 nDiff = ( nSID == SID_EXTRUSION_TILT_LEFT ) || ( nSID == SID_EXTRUSION_TILT_UP ) ? 5 : -5;
151  EnhancedCustomShapeParameterPair aRotateAnglePropPair;
152  double fX = 0.0;
153  double fY = 0.0;
154  aRotateAnglePropPair.First.Value <<= fX;
155  aRotateAnglePropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
156  aRotateAnglePropPair.Second.Value <<= fY;
157  aRotateAnglePropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
158  css::uno::Any* pAny = rGeometryItem.GetPropertyValueByName( sExtrusion, sRotateAngle );
159  if( pAny && ( *pAny >>= aRotateAnglePropPair ) )
160  {
161  aRotateAnglePropPair.First.Value >>= fX;
162  aRotateAnglePropPair.Second.Value >>= fY;
163  }
164  if ( bHorizontal )
165  fX += nDiff;
166  else
167  fY += nDiff;
168  aRotateAnglePropPair.First.Value <<= fX;
169  aRotateAnglePropPair.Second.Value <<= fY;
170  css::beans::PropertyValue aPropValue;
171  aPropValue.Name = sRotateAngle;
172  aPropValue.Value <<= aRotateAnglePropPair;
173  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
174  }
175  break;
176 
177  case SID_EXTRUSION_DIRECTION:
178  {
179  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_DIRECTION ) == SfxItemState::SET )
180  {
181  sal_Int32 nSkew = rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_DIRECTION)->GetValue();
182 
183  Position3D aViewPoint( 3472, -3472, 25000 );
184  double fOriginX = 0.50;
185  double fOriginY = -0.50;
186  double fSkewAngle = nSkew;
187  double fSkew = 50.0;
188 
189  switch( nSkew )
190  {
191  case 135:
192  aViewPoint.PositionY = 3472;
193  fOriginY = 0.50;
194  break;
195  case 90:
196  aViewPoint.PositionX = 0;
197  aViewPoint.PositionY = 3472;
198  fOriginX = 0;
199  fOriginY = -0.50;
200  break;
201  case 45:
202  aViewPoint.PositionX = -3472;
203  aViewPoint.PositionY = 3472;
204  fOriginX = -0.50;
205  fOriginY = 0.50;
206  break;
207  case 180:
208  aViewPoint.PositionY = 0;
209  fOriginY = 0;
210  break;
211  case 0:
212  aViewPoint.PositionX = 0;
213  aViewPoint.PositionY = 0;
214  fOriginX = 0;
215  fOriginY = 0;
216  fSkew = 0.0;
217  break;
218  case -360:
219  aViewPoint.PositionX = -3472;
220  aViewPoint.PositionY = 0;
221  fOriginX = -0.50;
222  fOriginY = 0;
223  break;
224  case -90:
225  aViewPoint.PositionX = 0;
226  fOriginX = 0;
227  break;
228  case -45:
229  aViewPoint.PositionX = -3472;
230  fOriginX = -0.50;
231  break;
232  }
233 
234  css::beans::PropertyValue aPropValue;
235 
236  aPropValue.Name = "ViewPoint";
237  aPropValue.Value <<= aViewPoint;
238  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
239 
240 
241  EnhancedCustomShapeParameterPair aOriginPropPair;
242  aOriginPropPair.First.Value <<= fOriginX;
243  aOriginPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
244  aOriginPropPair.Second.Value <<= fOriginY;
245  aOriginPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
246  aPropValue.Name = "Origin";
247  aPropValue.Value <<= aOriginPropPair;
248  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
249 
250  EnhancedCustomShapeParameterPair aSkewPropPair;
251  aSkewPropPair.First.Value <<= fSkew;
252  aSkewPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
253  aSkewPropPair.Second.Value <<= fSkewAngle;
254  aSkewPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
255  aPropValue.Name = "Skew";
256  aPropValue.Value <<= aSkewPropPair;
257  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
258  }
259  }
260  break;
261  case SID_EXTRUSION_PROJECTION:
262  {
263  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_PROJECTION ) == SfxItemState::SET )
264  {
265  sal_Int32 nProjection = rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_PROJECTION)->GetValue();
266  ProjectionMode eProjectionMode = nProjection == 1 ? ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE;
267  css::beans::PropertyValue aPropValue;
268  aPropValue.Name = "ProjectionMode";
269  aPropValue.Value <<= eProjectionMode;
270  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
271  }
272  }
273  break;
274  case SID_EXTRUSION_DEPTH:
275  {
276  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == SfxItemState::SET)
277  {
278  double fDepth = rReq.GetArgs()->GetItem<SvxDoubleItem>(SID_EXTRUSION_DEPTH)->GetValue();
279  EnhancedCustomShapeParameterPair aDepthPropPair;
280  aDepthPropPair.First.Value <<= fDepth;
281  aDepthPropPair.First.Type = EnhancedCustomShapeParameterType::NORMAL;
282  aDepthPropPair.Second.Value <<= 0.0; // fraction
283  aDepthPropPair.Second.Type = EnhancedCustomShapeParameterType::NORMAL;
284 
285  css::beans::PropertyValue aPropValue;
286  aPropValue.Name = "Depth";
287  aPropValue.Value <<= aDepthPropPair;
288  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
289  }
290  }
291  break;
292  case SID_EXTRUSION_3D_COLOR:
293  {
294  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_3D_COLOR ) == SfxItemState::SET)
295  {
296  Color aColor( static_cast<const SvxColorItem&>(rReq.GetArgs()->Get(SID_EXTRUSION_3D_COLOR)).GetValue() );
297 
298  const bool bAuto = aColor == COL_AUTO;
299 
300  css::beans::PropertyValue aPropValue;
301  aPropValue.Name = "Color";
302  aPropValue.Value <<= !bAuto;
303  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
304 
305  if( bAuto )
306  {
308  }
309  else
310  {
311  pObj->SetMergedItem( XSecondaryFillColorItem( "", aColor ) );
312  }
313  pObj->BroadcastObjectChange();
314  }
315  }
316  break;
317  case SID_EXTRUSION_SURFACE:
318  {
319  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_SURFACE ) == SfxItemState::SET)
320  {
321  sal_Int32 nSurface = rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_SURFACE)->GetValue();
322 
323  ShadeMode eShadeMode( ShadeMode_FLAT );
324  bool bMetal = false;
325  double fSpecularity = 0;
326  double fDiffusion = 0;
327 
328  switch( nSurface )
329  {
330  case 0: // wireframe
331  eShadeMode = ShadeMode_DRAFT;
332  break;
333  case 1: // matte
334  break;
335  case 2: // plastic
336  fSpecularity = 122.0;
337  break;
338  case 3: // metal
339  bMetal = true;
340  fSpecularity = 122.0;
341  fDiffusion = 122.0;
342  break;
343  }
344 
345  css::beans::PropertyValue aPropValue;
346  aPropValue.Name = "ShadeMode";
347  aPropValue.Value <<= eShadeMode;
348  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
349 
350  aPropValue.Name = "Metal";
351  aPropValue.Value <<= bMetal;
352  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
353 
354  aPropValue.Name = "Specularity";
355  aPropValue.Value <<= fSpecularity;
356  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
357 
358  aPropValue.Name = "Diffusion";
359  aPropValue.Value <<= fDiffusion;
360  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
361  }
362  }
363  break;
364  case SID_EXTRUSION_LIGHTING_INTENSITY:
365  {
366  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_LIGHTING_INTENSITY ) == SfxItemState::SET)
367  {
368  sal_Int32 nLevel = rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_LIGHTING_INTENSITY)->GetValue();
369 
370  double fBrightness;
371  bool bHarsh2 = false;
372  double fLevel1;
373  double fLevel2;
374 
375  switch( nLevel )
376  {
377  case 0: // bright
378  fBrightness = 34.0;
379  bHarsh2 = false;
380  fLevel1 = 66.0;
381  fLevel2 = 66.0;
382  break;
383  case 1: // normal
384  fBrightness = 15.0;
385  bHarsh2 = false;
386  fLevel1 = 67.0;
387  fLevel2 = 37.0;
388  break;
389  case 2: // dim
390  fBrightness = 6.0;
391  bHarsh2 = true;
392  fLevel1 = 79.0;
393  fLevel2 = 21.0;
394  break;
395  }
396 
397  css::beans::PropertyValue aPropValue;
398  aPropValue.Name = "Brightness";
399  aPropValue.Value <<= fBrightness;
400  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
401 
402  aPropValue.Name = "LightFace";
403  aPropValue.Value <<= true;
404  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
405 
406  aPropValue.Name = "FirstLightHarsh";
407  aPropValue.Value <<= true;
408  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
409 
410  aPropValue.Name = "SecondLightHarsh";
411  aPropValue.Value <<= bHarsh2;
412  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
413 
414  aPropValue.Name = "FirstLightLevel";
415  aPropValue.Value <<= fLevel1;
416  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
417 
418  aPropValue.Name = "SecondLightLevel";
419  aPropValue.Value <<= fLevel2;
420  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
421  }
422  }
423  break;
424  case SID_EXTRUSION_LIGHTING_DIRECTION:
425  {
426  if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( SID_EXTRUSION_LIGHTING_DIRECTION ) == SfxItemState::SET)
427  {
428  sal_Int32 nDirection = rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_LIGHTING_DIRECTION)->GetValue();
429 
430  if((nDirection >= 0) && (nDirection < 9))
431  {
432  const Direction3D * pLighting1Defaults;
433  const Direction3D * pLighting2Defaults;
434 
435  getLightingDirectionDefaults( &pLighting1Defaults, &pLighting2Defaults );
436 
437  css::beans::PropertyValue aPropValue;
438  aPropValue.Name = "FirstLightDirection";
439  aPropValue.Value <<= pLighting1Defaults[nDirection];
440  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
441 
442  aPropValue.Name = "SecondLightDirection";
443  aPropValue.Value <<= pLighting2Defaults[nDirection];
444  rGeometryItem.SetPropertyValue( sExtrusion, aPropValue );
445  }
446  }
447  }
448  break;
449 
450  }
451 }
452 
453 void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest const & rReq, SfxBindings& rBindings )
454 {
455  sal_uInt16 nSID = rReq.GetSlot();
456  const char* pStrResId = nullptr;
457 
458  const bool bUndo = pSdrView && pSdrView->IsUndoEnabled();
459 
460  switch( nSID )
461  {
462  case SID_EXTRUSION_TOGGLE:
463  {
464  if ( !pStrResId )
465  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ON_OFF;
466  [[fallthrough]];
467  }
468  case SID_EXTRUSION_TILT_DOWN:
469  {
470  if ( !pStrResId )
471  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_DOWN;
472  [[fallthrough]];
473  }
474  case SID_EXTRUSION_TILT_UP:
475  {
476  if ( !pStrResId )
477  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_UP;
478  [[fallthrough]];
479  }
480  case SID_EXTRUSION_TILT_LEFT:
481  {
482  if ( !pStrResId )
483  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_LEFT;
484  [[fallthrough]];
485  }
486  case SID_EXTRUSION_TILT_RIGHT:
487  {
488  if ( !pStrResId )
489  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ROTATE_RIGHT;
490  [[fallthrough]];
491  }
492  case SID_EXTRUSION_DIRECTION:
493  {
494  if ( !pStrResId )
495  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_ORIENTATION;
496  [[fallthrough]];
497  }
498  case SID_EXTRUSION_PROJECTION:
499  {
500  if ( !pStrResId )
501  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_PROJECTION;
502  [[fallthrough]];
503  }
504  case SID_EXTRUSION_DEPTH:
505  {
506  if ( !pStrResId )
507  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_DEPTH;
508  [[fallthrough]];
509  }
510  case SID_EXTRUSION_3D_COLOR:
511  {
512  if ( !pStrResId )
513  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_COLOR;
514  [[fallthrough]];
515  }
516  case SID_EXTRUSION_SURFACE:
517  {
518  if ( !pStrResId )
519  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_SURFACE;
520  [[fallthrough]];
521  }
522  case SID_EXTRUSION_LIGHTING_INTENSITY:
523  {
524  if ( !pStrResId )
525  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_BRIGHTNESS;
526  [[fallthrough]];
527  }
528  case SID_EXTRUSION_LIGHTING_DIRECTION:
529  {
530  if ( !pStrResId )
531  pStrResId = RID_SVXSTR_UNDO_APPLY_EXTRUSION_LIGHTING;
532 
533  if (pSdrView)
534  {
535  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
536  const size_t nCount = rMarkList.GetMarkCount();
537 
538  for(size_t i=0; i<nCount; ++i)
539  {
540  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
541  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
542  {
543  if( bUndo )
544  {
545  OUString aStr( SvxResId( pStrResId ) );
546  pSdrView->BegUndo( aStr );
547  pSdrView->AddUndo( pSdrView->GetModel()->GetSdrUndoFactory().CreateUndoAttrObject( *pObj ) );
548  }
550  impl_execute( rReq, aGeometryItem, pObj );
551  pObj->SetMergedItem( aGeometryItem );
552  pObj->BroadcastObjectChange();
553  if( bUndo )
554  pSdrView->EndUndo();
555 
556  // simulate a context change:
557  // force SelectionHasChanged() being called
558  // so that extrusion bar will be visible/hidden
559  pSdrView->MarkListHasChanged();
560  }
561  }
562  }
563  }
564  break;
565 
566  case SID_EXTRUSION_DEPTH_DIALOG:
567  if( rReq.GetArgs() &&
568  (rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == SfxItemState::SET) &&
569  (rReq.GetArgs()->GetItemState( SID_ATTR_METRIC ) == SfxItemState::SET))
570  {
571  double fDepth = rReq.GetArgs()->GetItem<SvxDoubleItem>(SID_EXTRUSION_DEPTH)->GetValue();
572  FieldUnit eUnit = static_cast<FieldUnit>(rReq.GetArgs()->GetItem<SfxUInt16Item>(SID_ATTR_METRIC)->GetValue());
573 
574  ExtrusionDepthDialog aDlg(rReq.GetFrameWeld(), fDepth, eUnit);
575  sal_uInt16 nRet = aDlg.run();
576  if (nRet == RET_OK)
577  {
578  fDepth = aDlg.getDepth();
579 
580  SvxDoubleItem aItem( fDepth, SID_EXTRUSION_DEPTH );
581  SfxPoolItem* aItems[] = { &aItem, nullptr };
582  rBindings.Execute( SID_EXTRUSION_DEPTH, const_cast<const SfxPoolItem**>(aItems) );
583  }
584  }
585  break;
586  }
587 
588  if( nSID == SID_EXTRUSION_TOGGLE )
589  {
590  static const sal_uInt16 SidArray[] = {
591  SID_EXTRUSION_TILT_DOWN,
592  SID_EXTRUSION_TILT_UP,
593  SID_EXTRUSION_TILT_LEFT,
594  SID_EXTRUSION_TILT_RIGHT,
595  SID_EXTRUSION_DEPTH_FLOATER,
596  SID_EXTRUSION_DIRECTION_FLOATER,
597  SID_EXTRUSION_LIGHTING_FLOATER,
598  SID_EXTRUSION_SURFACE_FLOATER,
599  SID_EXTRUSION_3D_COLOR,
600  SID_EXTRUSION_DEPTH,
601  SID_EXTRUSION_DIRECTION,
602  SID_EXTRUSION_PROJECTION,
603  SID_EXTRUSION_LIGHTING_DIRECTION,
604  SID_EXTRUSION_LIGHTING_INTENSITY,
605  SID_EXTRUSION_SURFACE,
606  0 };
607 
608  rBindings.Invalidate( SidArray );
609  }
610 }
611 
612 static void getExtrusionDirectionState( SdrView const * pSdrView, SfxItemSet& rSet )
613 {
614  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
615  const size_t nCount = rMarkList.GetMarkCount();
616 
617  static const char sExtrusion[] = "Extrusion";
618 
619  const css::uno::Any* pAny;
620 
621  double fFinalSkewAngle = -1;
622  bool bHasCustomShape = false;
623 
624  for(size_t i=0; i<nCount; ++i)
625  {
626  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
627  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
628  {
630 
631  // see if this is an extruded customshape
632  if( !bHasCustomShape )
633  {
634  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
635  if( pAny_ )
636  *pAny_ >>= bHasCustomShape;
637 
638  if( !bHasCustomShape )
639  continue;
640  }
641 
642  bool bParallel = true;
643  Position3D aViewPoint( 3472, -3472, 25000 );
644  double fSkewAngle = -135;
645 
646  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "ProjectionMode" );
647  sal_Int16 nProjectionMode = sal_Int16();
648  if( pAny && ( *pAny >>= nProjectionMode ) )
649  bParallel = static_cast<ProjectionMode>(nProjectionMode) == ProjectionMode_PARALLEL;
650 
651  if( bParallel )
652  {
653  double fSkew = 50.0;
654  EnhancedCustomShapeParameterPair aSkewPropPair;
655  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Skew" );
656  if( pAny && ( *pAny >>= aSkewPropPair ) )
657  {
658  aSkewPropPair.First.Value >>= fSkew;
659  aSkewPropPair.Second.Value >>= fSkewAngle;
660  }
661  if ( fSkew == 0.0 )
662  fSkewAngle = 0.0;
663  else if ( fSkewAngle == 0.0 )
664  fSkewAngle = -360.0;
665  }
666  else
667  {
668  double fOriginX = 0.50;
669  double fOriginY = -0.50;
670  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "ViewPoint" );
671  if( pAny )
672  *pAny >>= aViewPoint;
673 
674  EnhancedCustomShapeParameterPair aOriginPropPair;
675  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Origin" );
676  if( pAny && ( *pAny >>= aOriginPropPair ) )
677  {
678  aOriginPropPair.First.Value >>= fOriginX;
679  aOriginPropPair.Second.Value >>= fOriginY;
680  }
681  fSkewAngle = -1;
682  const double e = 0.0001;
683  if( aViewPoint.PositionX > e )
684  {
685  if( aViewPoint.PositionY > e )
686  {
687  if( (fOriginX > e ) && ( fOriginY > e ) )
688  fSkewAngle = 135.0;
689  }
690  else if( aViewPoint.PositionY < -e )
691  {
692  if( ( fOriginX > e ) && ( fOriginY < -e ) )
693  fSkewAngle = -135.0;
694  }
695  else
696  {
697  if( ( fOriginX > e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
698  fSkewAngle = 180.0;
699  }
700  }
701  else if( aViewPoint.PositionX < -e )
702  {
703  if( aViewPoint.PositionY < -e )
704  {
705  if( ( fOriginX < -e ) && ( fOriginY < -e ) )
706  fSkewAngle = -45.0;
707  }
708  else if( aViewPoint.PositionY > e )
709  {
710  if( ( fOriginX < -e ) && ( fOriginY > e ) )
711  fSkewAngle = 45.0;
712  }
713  else
714  {
715  if( ( fOriginX < e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
716  fSkewAngle = -360.0;
717  }
718  }
719  else
720  {
721  if( aViewPoint.PositionY < -e )
722  {
723  if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY < -e ) )
724  fSkewAngle = -90.0;
725  }
726  else if( aViewPoint.PositionY > e )
727  {
728  if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY > e ) )
729  fSkewAngle = 90.0;
730  }
731  else
732  {
733  if( ( fOriginX > -e ) && ( fOriginX < e ) && ( fOriginY > -e ) && ( fOriginY < e ) )
734  fSkewAngle = 0.0;
735  }
736  }
737  }
738 
739  if( rtl::math::approxEqual(fFinalSkewAngle, -1.0) )
740  {
741  fFinalSkewAngle = fSkewAngle;
742  }
743  else if( !rtl::math::approxEqual(fSkewAngle, fFinalSkewAngle) )
744  {
745  fFinalSkewAngle = -1.0;
746  }
747 
748  if( rtl::math::approxEqual(fFinalSkewAngle, -1.0) )
749  break;
750  }
751  }
752 
753  if( bHasCustomShape )
754  rSet.Put( SfxInt32Item( SID_EXTRUSION_DIRECTION, static_cast<sal_Int32>(fFinalSkewAngle) ) );
755  else
756  rSet.DisableItem( SID_EXTRUSION_DIRECTION );
757 }
758 
759 static void getExtrusionProjectionState( SdrView const * pSdrView, SfxItemSet& rSet )
760 {
761  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
762  const size_t nCount = rMarkList.GetMarkCount();
763 
764  static const char sExtrusion[] = "Extrusion";
765 
766  const css::uno::Any* pAny;
767 
768  sal_Int32 nFinalProjection = -1;
769  bool bHasCustomShape = false;
770 
771  for(size_t i=0; i<nCount; ++i)
772  {
773  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
774  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
775  {
776  // see if this is an extruded customshape
777  if( !bHasCustomShape )
778  {
780  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
781  if( pAny_ )
782  *pAny_ >>= bHasCustomShape;
783 
784  if( !bHasCustomShape )
785  continue;
786  }
787 
789 
790  bool bParallel = true;
791  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "ProjectionMode" );
792  ProjectionMode eProjectionMode;
793  if( pAny && ( *pAny >>= eProjectionMode ) )
794  bParallel = eProjectionMode == ProjectionMode_PARALLEL;
795 
796  if( nFinalProjection == -1 )
797  {
798  nFinalProjection = bParallel ? 1 : 0;
799  }
800  else if( nFinalProjection != (bParallel ? 1 : 0) )
801  {
802  nFinalProjection = -1;
803  break;
804  }
805  }
806  }
807 
808  if( bHasCustomShape )
809  rSet.Put( SfxInt32Item( SID_EXTRUSION_PROJECTION, nFinalProjection ) );
810  else
811  rSet.DisableItem( SID_EXTRUSION_PROJECTION );
812 }
813 
814 static void getExtrusionSurfaceState( SdrView const * pSdrView, SfxItemSet& rSet )
815 {
816  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
817  const size_t nCount = rMarkList.GetMarkCount();
818 
819  static const char sExtrusion[] = "Extrusion";
820 
821  const css::uno::Any* pAny;
822 
823  sal_Int32 nFinalSurface = -1;
824  bool bHasCustomShape = false;
825 
826  for(size_t i=0; i<nCount; ++i)
827  {
828  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
829  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
830  {
832 
833  // see if this is an extruded customshape
834  if( !bHasCustomShape )
835  {
836  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
837  if( pAny_ )
838  *pAny_ >>= bHasCustomShape;
839 
840  if( !bHasCustomShape )
841  continue;
842  }
843 
844  sal_Int32 nSurface = 0; // wire frame
845 
846  ShadeMode eShadeMode( ShadeMode_FLAT );
847  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "ShadeMode" );
848  if( pAny )
849  *pAny >>= eShadeMode;
850 
851  if( eShadeMode == ShadeMode_FLAT )
852  {
853  bool bMetal = false;
854  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Metal" );
855  if( pAny )
856  *pAny >>= bMetal;
857 
858  if( bMetal )
859  {
860  nSurface = 3; // metal
861  }
862  else
863  {
864  double fSpecularity = 0;
865  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Specularity" );
866  if( pAny )
867  *pAny >>= fSpecularity;
868 
869  const double e = 0.0001;
870  if( (fSpecularity > -e) && (fSpecularity < e) )
871  {
872  nSurface = 1; // matte
873  }
874  else
875  {
876  nSurface = 2; // plastic
877  }
878  }
879  }
880 
881  if( nFinalSurface == -1 )
882  {
883  nFinalSurface = nSurface;
884  }
885  else if( nFinalSurface != nSurface )
886  {
887  nFinalSurface = -1;
888  break;
889  }
890  }
891  }
892 
893  if( bHasCustomShape )
894  rSet.Put( SfxInt32Item( SID_EXTRUSION_SURFACE, nFinalSurface ) );
895  else
896  rSet.DisableItem( SID_EXTRUSION_SURFACE );
897 }
898 
899 static void getExtrusionDepthState( SdrView const * pSdrView, SfxItemSet& rSet )
900 {
901  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
902  const size_t nCount = rMarkList.GetMarkCount();
903 
904  static const char sExtrusion[] = "Extrusion";
905 
906  const css::uno::Any* pAny;
907 
908  double fFinalDepth = -1;
909  bool bHasCustomShape = false;
910 
911  for(size_t i=0; i<nCount; ++i)
912  {
913  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
914  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
915  {
917 
918  // see if this is an extruded customshape
919  if( !bHasCustomShape )
920  {
921  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
922  if( pAny_ )
923  *pAny_ >>= bHasCustomShape;
924 
925  if( !bHasCustomShape )
926  continue;
927  }
928 
929  double fDepth = 1270.0;
930  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Depth" );
931  if( pAny )
932  {
933  EnhancedCustomShapeParameterPair aDepthPropPair;
934  if ( *pAny >>= aDepthPropPair )
935  aDepthPropPair.First.Value >>= fDepth;
936  }
937 
938  if( fFinalDepth == -1 )
939  {
940  fFinalDepth = fDepth;
941  }
942  else if( !rtl::math::approxEqual(fFinalDepth, fDepth) )
943  {
944  fFinalDepth = -1;
945  break;
946  }
947  }
948  }
949 
950  if( pSdrView->GetModel() )
951  {
952  FieldUnit eUnit = pSdrView->GetModel()->GetUIUnit();
953  rSet.Put( SfxUInt16Item( SID_ATTR_METRIC, static_cast<sal_uInt16>(eUnit) ) );
954  }
955 
956  if( bHasCustomShape )
957  rSet.Put( SvxDoubleItem( fFinalDepth, SID_EXTRUSION_DEPTH ) );
958  else
959  rSet.DisableItem( SID_EXTRUSION_DEPTH );
960 }
961 
962 static bool compare_direction( const Direction3D& d1, const Direction3D& d2 )
963 {
964  if( ((d1.DirectionX < 0) && (d2.DirectionX < 0)) || ((d1.DirectionX == 0) && (d2.DirectionX == 0)) || ((d1.DirectionX > 0) && (d2.DirectionX > 0)) )
965  {
966  if( ((d1.DirectionY < 0) && (d2.DirectionY < 0)) || ((d1.DirectionY == 0) && (d2.DirectionY == 0)) || ((d1.DirectionY > 0) && (d2.DirectionY > 0)) )
967  {
968  if( ((d1.DirectionZ < 0) && (d2.DirectionZ < 0)) || ((d1.DirectionZ == 0) && (d2.DirectionZ == 0)) || ((d1.DirectionZ > 0) && (d2.DirectionZ > 0)) )
969  {
970  return true;
971  }
972  }
973  }
974 
975  return false;
976 }
977 
978 static void getExtrusionLightingDirectionState( SdrView const * pSdrView, SfxItemSet& rSet )
979 {
980  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
981  const size_t nCount = rMarkList.GetMarkCount();
982 
983  static const char sExtrusion[] = "Extrusion";
984 
985  const Direction3D * pLighting1Defaults;
986  const Direction3D * pLighting2Defaults;
987 
988  getLightingDirectionDefaults( &pLighting1Defaults, &pLighting2Defaults );
989 
990  const css::uno::Any* pAny;
991 
992  int nFinalDirection = -1;
993  bool bHasCustomShape = false;
994 
995  for(size_t i=0; i<nCount; ++i)
996  {
997  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
998  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
999  {
1001 
1002  // see if this is an extruded customshape
1003  if( !bHasCustomShape )
1004  {
1005  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1006  if( pAny_ )
1007  *pAny_ >>= bHasCustomShape;
1008 
1009  if( !bHasCustomShape )
1010  continue;
1011  }
1012 
1013  Direction3D aFirstLightDirection( 50000, 0, 10000 );
1014  Direction3D aSecondLightDirection( -50000, 0, 10000 );
1015 
1016  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "FirstLightDirection" );
1017  if( pAny )
1018  *pAny >>= aFirstLightDirection;
1019 
1020  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "SecondLightDirection" );
1021  if( pAny )
1022  *pAny >>= aSecondLightDirection;
1023 
1024  int nDirection = -1;
1025 
1026  int j;
1027  for( j = 0; j < 9; j++ )
1028  {
1029  if( compare_direction( aFirstLightDirection, pLighting1Defaults[j] ) &&
1030  compare_direction( aSecondLightDirection, pLighting2Defaults[j] ))
1031  {
1032  nDirection = j;
1033  break;
1034  }
1035  }
1036 
1037  if( nFinalDirection == -1 )
1038  {
1039  nFinalDirection = nDirection;
1040  }
1041  else if( nDirection != nFinalDirection )
1042  {
1043  nFinalDirection = -1;
1044  }
1045 
1046  if( nFinalDirection == -1 )
1047  break;
1048  }
1049  }
1050 
1051  if( bHasCustomShape )
1052  rSet.Put( SfxInt32Item( SID_EXTRUSION_LIGHTING_DIRECTION, static_cast<sal_Int32>(nFinalDirection) ) );
1053  else
1054  rSet.DisableItem( SID_EXTRUSION_LIGHTING_DIRECTION );
1055 }
1056 
1057 static void getExtrusionLightingIntensityState( SdrView const * pSdrView, SfxItemSet& rSet )
1058 {
1059  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1060  const size_t nCount = rMarkList.GetMarkCount();
1061 
1062  static const char sExtrusion[] = "Extrusion";
1063 
1064  const css::uno::Any* pAny;
1065 
1066  int nFinalLevel = -1;
1067  bool bHasCustomShape = false;
1068 
1069  for(size_t i=0; i<nCount; ++i)
1070  {
1071  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1072  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
1073  {
1075 
1076  // see if this is an extruded customshape
1077  if( !bHasCustomShape )
1078  {
1079  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1080  if( pAny_ )
1081  *pAny_ >>= bHasCustomShape;
1082 
1083  if( !bHasCustomShape )
1084  continue;
1085  }
1086 
1087  double fBrightness = 22178.0 / 655.36;
1088  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Brightness" );
1089  if( pAny )
1090  *pAny >>= fBrightness;
1091 
1092  int nLevel;
1093  if( fBrightness >= 30.0 )
1094  {
1095  nLevel = 0; // Bright
1096  }
1097  else if( fBrightness >= 10.0 )
1098  {
1099  nLevel = 1; // Normal;
1100  }
1101  else
1102  {
1103  nLevel = 2; // Dim
1104  }
1105 
1106  if( nFinalLevel == -1 )
1107  {
1108  nFinalLevel = nLevel;
1109  }
1110  else if( nFinalLevel != nLevel )
1111  {
1112  nFinalLevel = -1;
1113  break;
1114  }
1115  }
1116  }
1117 
1118  if( bHasCustomShape )
1119  rSet.Put( SfxInt32Item( SID_EXTRUSION_LIGHTING_INTENSITY, nFinalLevel ) );
1120  else
1121  rSet.DisableItem( SID_EXTRUSION_LIGHTING_INTENSITY );
1122 }
1123 
1124 static void getExtrusionColorState( SdrView const * pSdrView, SfxItemSet& rSet )
1125 {
1126  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1127  const size_t nCount = rMarkList.GetMarkCount();
1128 
1129  static const char sExtrusion[] = "Extrusion";
1130 
1131  const css::uno::Any* pAny;
1132 
1133  bool bInit = false;
1134  bool bAmbigius = false;
1135  Color aFinalColor;
1136  bool bHasCustomShape = false;
1137 
1138  for(size_t i=0; i<nCount; ++i)
1139  {
1140  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1141  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
1142  {
1144 
1145  // see if this is an extruded customshape
1146  if( !bHasCustomShape )
1147  {
1148  const Any* pAny_ = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1149  if( pAny_ )
1150  *pAny_ >>= bHasCustomShape;
1151 
1152  if( !bHasCustomShape )
1153  continue;
1154  }
1155 
1156  Color aColor;
1157 
1158  bool bUseColor = false;
1159  pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, "Color" );
1160  if( pAny )
1161  *pAny >>= bUseColor;
1162 
1163  if( bUseColor )
1164  {
1166  aColor = rItem.GetColorValue();
1167  }
1168  else
1169  {
1170  aColor = COL_AUTO;
1171  }
1172 
1173  if( !bInit )
1174  {
1175  aFinalColor = aColor;
1176  bInit = true;
1177  }
1178  else if( aFinalColor != aColor )
1179  {
1180  bAmbigius = true;
1181  break;
1182  }
1183  }
1184  }
1185 
1186  if( bAmbigius )
1187  aFinalColor = COL_AUTO;
1188 
1189  if( bHasCustomShape )
1190  rSet.Put( SvxColorItem( aFinalColor, SID_EXTRUSION_3D_COLOR ) );
1191  else
1192  rSet.DisableItem( SID_EXTRUSION_3D_COLOR );
1193 }
1194 
1195 namespace svx {
1196 bool checkForSelectedCustomShapes( SdrView const * pSdrView, bool bOnlyExtruded )
1197 {
1198  static const char sExtrusion[] = "Extrusion";
1199 
1200  const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
1201  const size_t nCount = rMarkList.GetMarkCount();
1202  bool bFound = false;
1203 
1204  for(size_t i=0;(i<nCount) && !bFound ; ++i)
1205  {
1206  SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1207  if( dynamic_cast<const SdrObjCustomShape*>( pObj) != nullptr )
1208  {
1209  if( bOnlyExtruded )
1210  {
1212  const Any* pAny = aGeometryItem.GetPropertyValueByName( sExtrusion, sExtrusion );
1213  if( pAny )
1214  *pAny >>= bFound;
1215  }
1216  else
1217  {
1218  bFound = true;
1219  }
1220  }
1221  }
1222 
1223  return bFound;
1224 }
1225 }
1226 
1227 void ExtrusionBar::getState( SdrView const * pSdrView, SfxItemSet& rSet )
1228 {
1229  if (rSet.GetItemState(SID_EXTRUSION_DIRECTION) != SfxItemState::UNKNOWN)
1230  {
1231  getExtrusionDirectionState( pSdrView, rSet );
1232  }
1233  if (rSet.GetItemState(SID_EXTRUSION_PROJECTION) != SfxItemState::UNKNOWN)
1234  {
1235  getExtrusionProjectionState( pSdrView, rSet );
1236  }
1237  const bool bOnlyExtrudedCustomShapes =
1238  checkForSelectedCustomShapes( pSdrView, true );
1239  if (rSet.GetItemState(SID_EXTRUSION_TILT_DOWN) != SfxItemState::UNKNOWN)
1240  {
1241  if (! bOnlyExtrudedCustomShapes)
1242  rSet.DisableItem( SID_EXTRUSION_TILT_DOWN );
1243  }
1244  if (rSet.GetItemState(SID_EXTRUSION_TILT_DOWN) != SfxItemState::UNKNOWN)
1245  {
1246  if (! bOnlyExtrudedCustomShapes)
1247  rSet.DisableItem( SID_EXTRUSION_TILT_DOWN );
1248  }
1249  if (rSet.GetItemState(SID_EXTRUSION_TILT_UP) != SfxItemState::UNKNOWN)
1250  {
1251  if (! bOnlyExtrudedCustomShapes)
1252  rSet.DisableItem( SID_EXTRUSION_TILT_UP );
1253  }
1254  if (rSet.GetItemState(SID_EXTRUSION_TILT_LEFT) != SfxItemState::UNKNOWN)
1255  {
1256  if (! bOnlyExtrudedCustomShapes)
1257  rSet.DisableItem( SID_EXTRUSION_TILT_LEFT );
1258  }
1259  if (rSet.GetItemState(SID_EXTRUSION_TILT_RIGHT) != SfxItemState::UNKNOWN)
1260  {
1261  if (! bOnlyExtrudedCustomShapes)
1262  rSet.DisableItem( SID_EXTRUSION_TILT_RIGHT );
1263  }
1264  if (rSet.GetItemState(SID_EXTRUSION_3D_COLOR) != SfxItemState::UNKNOWN)
1265  {
1266  if (! bOnlyExtrudedCustomShapes)
1267  rSet.DisableItem( SID_EXTRUSION_3D_COLOR );
1268  }
1269  if (rSet.GetItemState(SID_EXTRUSION_DEPTH_FLOATER) != SfxItemState::UNKNOWN)
1270  {
1271  if (! bOnlyExtrudedCustomShapes)
1272  rSet.DisableItem( SID_EXTRUSION_DEPTH_FLOATER );
1273  }
1274  if (rSet.GetItemState(SID_EXTRUSION_DIRECTION_FLOATER) != SfxItemState::UNKNOWN)
1275  {
1276  if (! bOnlyExtrudedCustomShapes)
1277  rSet.DisableItem( SID_EXTRUSION_DIRECTION_FLOATER );
1278  }
1279  if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_FLOATER) != SfxItemState::UNKNOWN)
1280  {
1281  if (! bOnlyExtrudedCustomShapes)
1282  rSet.DisableItem( SID_EXTRUSION_LIGHTING_FLOATER );
1283  }
1284  if (rSet.GetItemState(SID_EXTRUSION_SURFACE_FLOATER) != SfxItemState::UNKNOWN)
1285  {
1286  if(! bOnlyExtrudedCustomShapes)
1287  rSet.DisableItem( SID_EXTRUSION_SURFACE_FLOATER );
1288  }
1289  if (rSet.GetItemState(SID_EXTRUSION_TOGGLE) != SfxItemState::UNKNOWN)
1290  {
1291  if( !checkForSelectedCustomShapes( pSdrView, false ) )
1292  rSet.DisableItem( SID_EXTRUSION_TOGGLE );
1293  }
1294  if (rSet.GetItemState(SID_EXTRUSION_DEPTH) != SfxItemState::UNKNOWN)
1295  {
1296  getExtrusionDepthState( pSdrView, rSet );
1297  }
1298  if (rSet.GetItemState(SID_EXTRUSION_SURFACE) != SfxItemState::UNKNOWN)
1299  {
1300  getExtrusionSurfaceState( pSdrView, rSet );
1301  }
1302  if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_INTENSITY) != SfxItemState::UNKNOWN)
1303  {
1304  getExtrusionLightingIntensityState( pSdrView, rSet );
1305  }
1306 
1307  if (rSet.GetItemState(SID_EXTRUSION_LIGHTING_DIRECTION) != SfxItemState::UNKNOWN)
1308  {
1309  getExtrusionLightingDirectionState( pSdrView, rSet );
1310  }
1311 
1312  if (rSet.GetItemState(SID_EXTRUSION_3D_COLOR) != SfxItemState::UNKNOWN)
1313  {
1314  getExtrusionColorState( pSdrView, rSet );
1315  }
1316 }
1317 
1318 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void getExtrusionSurfaceState(SdrView const *pSdrView, SfxItemSet &rSet)
void SetPropertyValue(const css::beans::PropertyValue &rPropVal)
FieldUnit
size_t GetMarkCount() const
Definition: svdmark.hxx:180
#define SFX_IMPL_INTERFACE(Class, SuperClass)
virtual ~ExtrusionBar() override
std::string GetValue
bool IsUndoEnabled() const
Definition: svdedtv.cxx:1027
static void getExtrusionProjectionState(SdrView const *pSdrView, SfxItemSet &rSet)
void BegUndo()
Definition: svdedtv.hxx:179
SdrMark * GetMark(size_t nNum) const
Definition: svdmark.cxx:229
static SfxSlot aExtrusionBarSlots_Impl[]
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
virtual void MarkListHasChanged() override
Definition: svdedxv.cxx:2468
static void execute(SdrView *pSdrView, SfxRequest const &rReq, SfxBindings &rBindings)
constexpr::Color COL_AUTO(0xFF, 0xFF, 0xFF, 0xFF)
void ClearMergedItem(const sal_uInt16 nWhich=0)
Definition: svdobj.cxx:1898
#define SDRATTR_CUSTOMSHAPE_GEOMETRY
Definition: svddef.hxx:400
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:28
static void getLightingDirectionDefaults(const Direction3D **pLighting1Defaults, const Direction3D **pLighting2Defaults)
static void getState(SdrView const *pSdrView, SfxItemSet &rSet)
static bool compare_direction(const Direction3D &d1, const Direction3D &d2)
int nCount
static void getExtrusionColorState(SdrView const *pSdrView, SfxItemSet &rSet)
static void impl_execute(SfxRequest const &rReq, SdrCustomShapeGeometryItem &rGeometryItem, SdrObject *pObj)
bool checkForSelectedCustomShapes(SdrView const *pSdrView, bool bOnlyExtruded)
bool Execute(sal_uInt16 nSlot, const SfxPoolItem **pArgs=nullptr, SfxCallMode nCall=SfxCallMode::SLOT)
const Color & GetColorValue() const
Definition: xattr.cxx:309
void EndUndo()
Definition: svdedtv.cxx:275
FieldUnit GetUIUnit() const
Definition: svdmodel.hxx:380
SfxItemPool & GetPool() const
SdrObject * GetMarkedSdrObj() const
Definition: svdmark.hxx:68
void AddUndo(std::unique_ptr< SdrUndoAction > pUndo)
Definition: svdedtv.hxx:183
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
#define DBG_ASSERT(sCon, aError)
void SetRepeatTarget(SfxRepeatTarget *pTarget)
int i
static void getExtrusionDepthState(SdrView const *pSdrView, SfxItemSet &rSet)
static void getExtrusionDirectionState(SdrView const *pSdrView, SfxItemSet &rSet)
void BroadcastObjectChange() const
Definition: svdobj.cxx:904
const SdrMarkList & GetMarkedObjectList() const
Definition: svdmrkv.hxx:243
void SetPool(SfxItemPool *pNewPool)
void SetMergedItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1893
static bool bInit
Definition: objfac3d.cxx:30
void SetName(const OUString &rName)
const SfxPoolItem & GetMergedItem(const sal_uInt16 nWhich) const
Definition: svdobj.cxx:1918
Abstract DrawObject.
Definition: svdobj.hxx:312
SdrUndoFactory & GetSdrUndoFactory() const
returns the models undo factory.
Definition: svdmodel.cxx:1960
#define SFX_OBJECTBAR_OBJECT
static void getExtrusionLightingIntensityState(SdrView const *pSdrView, SfxItemSet &rSet)
#define XATTR_SECONDARYFILLCOLOR
Definition: xdef.hxx:119
weld::Window * GetFrameWeld() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
void DisableItem(sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
static void getExtrusionLightingDirectionState(SdrView const *pSdrView, SfxItemSet &rSet)
RET_OK
virtual short run()
css::uno::Any * GetPropertyValueByName(const OUString &rPropName)
virtual std::unique_ptr< SdrUndoAction > CreateUndoAttrObject(SdrObject &rObject, bool bStyleSheet1=false, bool bSaveText=false)
Definition: svdundo.cxx:1649
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
SdrModel * GetModel() const
Definition: svdpntv.hxx:271
aStr