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