LibreOffice Module svx (master)  1
extrusioncontrols.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 #include <sal/config.h>
21 
22 #include <string_view>
23 
25 #include <svtools/toolbarmenu.hxx>
26 #include <vcl/toolbox.hxx>
27 
28 #include <svx/strings.hrc>
29 #include <svx/svdtrans.hxx>
30 #include <svx/dialmgr.hxx>
31 
32 #include <helpids.h>
33 #include "extrusioncontrols.hxx"
34 #include <extrusiondepthdialog.hxx>
35 
36 #include <bitmaps.hlst>
37 
38 using namespace ::com::sun::star::uno;
39 using namespace ::com::sun::star::lang;
40 using namespace ::com::sun::star::beans;
41 using namespace ::com::sun::star::util;
42 using namespace ::com::sun::star::graphic;
43 
44 namespace svx
45 {
46 
47 const sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
48 constexpr OUStringLiteral g_sExtrusionDirection = u".uno:ExtrusionDirection";
49 constexpr OUStringLiteral g_sExtrusionProjection = u".uno:ExtrusionProjection";
50 constexpr OUStringLiteral EMPTY = u"";
51 
52 constexpr rtl::OUStringConstExpr aLightOffBmps[] =
53 {
54  RID_SVXBMP_LIGHT_OFF_FROM_TOP_LEFT,
55  RID_SVXBMP_LIGHT_OFF_FROM_TOP,
56  RID_SVXBMP_LIGHT_OFF_FROM_TOP_RIGHT,
57  RID_SVXBMP_LIGHT_OFF_FROM_LEFT,
58  EMPTY,
59  RID_SVXBMP_LIGHT_OFF_FROM_RIGHT,
60  RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_LEFT,
61  RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM,
62  RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_RIGHT
63 };
64 
65 constexpr rtl::OUStringConstExpr aLightOnBmps[] =
66 {
67  RID_SVXBMP_LIGHT_ON_FROM_TOP_LEFT,
68  RID_SVXBMP_LIGHT_ON_FROM_TOP,
69  RID_SVXBMP_LIGHT_ON_FROM_TOP_RIGHT,
70  RID_SVXBMP_LIGHT_ON_FROM_LEFT,
71  EMPTY,
72  RID_SVXBMP_LIGHT_ON_FROM_RIGHT,
73  RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_LEFT,
74  RID_SVXBMP_LIGHT_ON_FROM_BOTTOM,
75  RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_RIGHT
76 };
77 
78 constexpr rtl::OUStringConstExpr aLightPreviewBmps[] =
79 {
80  RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_LEFT,
81  RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP,
82  RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_RIGHT,
83  RID_SVXBMP_LIGHT_PREVIEW_FROM_LEFT,
84  RID_SVXBMP_LIGHT_PREVIEW_FROM_RIGHT,
85  RID_SVXBMP_LIGHT_PREVIEW_FROM_FRONT,
86  RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_LEFT,
87  RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM,
88  RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_RIGHT
89 };
90 
91 constexpr rtl::OUStringConstExpr aDirectionBmps[] =
92 {
93  RID_SVXBMP_DIRECTION_DIRECTION_NW,
94  RID_SVXBMP_DIRECTION_DIRECTION_N,
95  RID_SVXBMP_DIRECTION_DIRECTION_NE,
96  RID_SVXBMP_DIRECTION_DIRECTION_W,
97  RID_SVXBMP_DIRECTION_DIRECTION_NONE,
98  RID_SVXBMP_DIRECTION_DIRECTION_E,
99  RID_SVXBMP_DIRECTION_DIRECTION_SW,
100  RID_SVXBMP_DIRECTION_DIRECTION_S,
101  RID_SVXBMP_DIRECTION_DIRECTION_SE
102 };
103 
105 {
106  RID_SVXSTR_DIRECTION_NW,
107  RID_SVXSTR_DIRECTION_N,
108  RID_SVXSTR_DIRECTION_NE,
109  RID_SVXSTR_DIRECTION_W,
110  RID_SVXSTR_DIRECTION_NONE,
111  RID_SVXSTR_DIRECTION_E,
112  RID_SVXSTR_DIRECTION_SW,
113  RID_SVXSTR_DIRECTION_S,
114  RID_SVXSTR_DIRECTION_SE
115 };
116 
118  svt::PopupWindowController* pControl,
119  weld::Widget* pParent)
120  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/directionwindow.ui", "DirectionWindow")
121  , mxControl(pControl)
122  , mxDirectionSet(new ValueSet(nullptr))
123  , mxDirectionSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxDirectionSet))
124  , mxPerspective(m_xBuilder->weld_radio_button("perspective"))
125  , mxParallel(m_xBuilder->weld_radio_button("parallel"))
126 {
128 
129  for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
130  {
131  maImgDirection[i] = Image(StockImage::Yes, OUString(aDirectionBmps[i]));
132  }
133 
134  mxDirectionSet->SetSelectHdl( LINK( this, ExtrusionDirectionWindow, SelectValueSetHdl ) );
135  mxDirectionSet->SetColCount( 3 );
136  mxDirectionSet->EnableFullItemMode( false );
137 
138  for (sal_uInt16 i = DIRECTION_NW; i <= DIRECTION_SE; ++i)
139  {
140  mxDirectionSet->InsertItem(i + 1, maImgDirection[i], SvxResId(aDirectionStrs[i]));
141  }
142 
143  Size aSize(72, 72);
144  mxDirectionSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
145  mxDirectionSet->SetOutputSizePixel(aSize);
146 
147  mxPerspective->connect_toggled(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl));
148 
149  AddStatusListener( g_sExtrusionDirection );
150  AddStatusListener( g_sExtrusionProjection );
151 }
152 
154 {
155  mxDirectionSet->GrabFocus();
156 }
157 
159 {
160 }
161 
162 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
163 {
164  sal_uInt16 nItemId;
165  for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
166  {
167  if( gSkewList[nItemId] == nSkew )
168  break;
169  }
170 
171  if( nItemId <= DIRECTION_SE )
172  {
173  mxDirectionSet->SelectItem( nItemId+1 );
174  }
175  else
176  {
177  mxDirectionSet->SetNoSelection();
178  }
179 
180  if (bEnabled)
181  mxDirectionSet->Enable();
182  else
183  mxDirectionSet->Disable();
184 }
185 
186 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
187 {
188  mxPerspective->set_active(nProjection == 0 && bEnabled);
189  mxParallel->set_active(nProjection == 1 && bEnabled);
190  mxPerspective->set_sensitive(bEnabled);
191  mxParallel->set_sensitive(bEnabled);
192 }
193 
195  const css::frame::FeatureStateEvent& Event
196 )
197 {
198  if( Event.FeatureURL.Main == g_sExtrusionDirection )
199  {
200  if( !Event.IsEnabled )
201  {
202  implSetDirection( -1, false );
203  }
204  else
205  {
206  sal_Int32 nValue = 0;
207  if( Event.State >>= nValue )
208  implSetDirection( nValue, true );
209  }
210  }
211  else if( Event.FeatureURL.Main == g_sExtrusionProjection )
212  {
213  if( !Event.IsEnabled )
214  {
215  implSetProjection( -1, false );
216  }
217  else
218  {
219  sal_Int32 nValue = 0;
220  if( Event.State >>= nValue )
221  implSetProjection( nValue, true );
222  }
223  }
224 }
225 
227 {
228  Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
229  OUString(g_sExtrusionDirection).copy(5),
230  gSkewList[mxDirectionSet->GetSelectedItemId()-1]) };
231 
232  mxControl->dispatchCommand( g_sExtrusionDirection, aArgs );
233 
234  mxControl->EndPopupMode();
235 }
236 
238 {
239  int nProjection = mxPerspective->get_active() ? 0 : 1;
240 
241  Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
242  OUString(g_sExtrusionProjection).copy(5), static_cast<sal_Int32>(nProjection)) };
243 
244  mxControl->dispatchCommand( g_sExtrusionProjection, aArgs );
245  implSetProjection( nProjection, true );
246 
247  mxControl->EndPopupMode();
248 }
249 
251  const Reference< XComponentContext >& rxContext
252 ) : svt::PopupWindowController(
253  rxContext,
254  Reference< css::frame::XFrame >(),
255  ".uno:ExtrusionDirectionFloater"
256  )
257 {
258 }
259 
260 std::unique_ptr<WeldToolbarPopup> ExtrusionDirectionControl::weldPopupWindow()
261 {
262  return std::make_unique<ExtrusionDirectionWindow>(this, m_pToolbar);
263 }
264 
266 {
267  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
268  std::make_unique<ExtrusionDirectionWindow>(this, pParent->GetFrameWeld()));
269 
270  mxInterimPopover->Show();
271 
272  return mxInterimPopover;
273 }
274 
275 // XInitialization
276 void SAL_CALL ExtrusionDirectionControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
277 {
278  svt::PopupWindowController::initialize( aArguments );
279 
280  ToolBox* pToolBox = nullptr;
282  if ( getToolboxId( nId, &pToolBox ) )
283  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
284 }
285 
286 // XServiceInfo
287 
288 
290 {
291  return "com.sun.star.comp.svx.ExtrusionDirectionController";
292 }
293 
294 
296 {
297  return { "com.sun.star.frame.ToolbarController" };
298 }
299 
300 
301 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
303  css::uno::XComponentContext* xContext,
304  css::uno::Sequence<css::uno::Any> const &)
305 {
306  return cppu::acquire(new ExtrusionDirectionControl(xContext));
307 }
308 
309 
311  : GenericDialogController(pParent, "svx/ui/extrustiondepthdialog.ui", "ExtrustionDepthDialog")
312  , m_xMtrDepth(m_xBuilder->weld_metric_spin_button("depth", eDefaultUnit))
313 {
314  m_xMtrDepth->set_value(static_cast<int>(fDepth) * 100, FieldUnit::MM_100TH);
315 }
316 
318 {
319 }
320 
322 {
323  return static_cast<double>(m_xMtrDepth->get_value(FieldUnit::MM_100TH)) / 100.0;
324 }
325 
326 double const aDepthListInch[] = { 0, 1270,2540,5080,10160 };
327 double const aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
328 
329 constexpr OUStringLiteral gsExtrusionDepth( u".uno:ExtrusionDepth" );
330 constexpr OUStringLiteral gsMetricUnit( u".uno:MetricUnit" );
331 
333  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/depthwindow.ui", "DepthWindow")
334  , mxControl(pControl)
335  , mxDepth0(m_xBuilder->weld_radio_button("depth0"))
336  , mxDepth1(m_xBuilder->weld_radio_button("depth1"))
337  , mxDepth2(m_xBuilder->weld_radio_button("depth2"))
338  , mxDepth3(m_xBuilder->weld_radio_button("depth3"))
339  , mxDepth4(m_xBuilder->weld_radio_button("depth4"))
340  , mxInfinity(m_xBuilder->weld_radio_button("infinity"))
341  , mxCustom(m_xBuilder->weld_radio_button("custom"))
342  , meUnit(FieldUnit::NONE)
343  , mfDepth( -1.0 )
344  , mbSettingValue(false)
345  , mbCommandDispatched(false)
346 {
347  mxDepth0->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
348  mxDepth1->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
349  mxDepth2->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
350  mxDepth3->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
351  mxDepth4->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
352  mxInfinity->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
353  mxCustom->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
354  mxCustom->connect_mouse_release(LINK(this, ExtrusionDepthWindow, MouseReleaseHdl));
355 
358 }
359 
361 {
362  mxDepth0->grab_focus();
363 }
364 
366 {
367  mfDepth = fDepth;
368 
369  bool bSettingValue = mbSettingValue;
370  mbSettingValue = true;
371 
372  mxCustom->set_active(true);
373  bool bIsMetric = IsMetric(meUnit);
374  mxDepth0->set_active(fDepth == (bIsMetric ? aDepthListMM[0] : aDepthListInch[0]));
375  mxDepth1->set_active(fDepth == (bIsMetric ? aDepthListMM[1] : aDepthListInch[1]));
376  mxDepth2->set_active(fDepth == (bIsMetric ? aDepthListMM[2] : aDepthListInch[2]));
377  mxDepth3->set_active(fDepth == (bIsMetric ? aDepthListMM[3] : aDepthListInch[3]));
378  mxDepth4->set_active(fDepth == (bIsMetric ? aDepthListMM[4] : aDepthListInch[4]));
379  mxInfinity->set_active(fDepth >= 338666);
380 
381  mbSettingValue = bSettingValue;
382 }
383 
385 {
386  meUnit = eUnit;
387 
388  const TranslateId aDepths[] =
389  {
390  RID_SVXSTR_DEPTH_0,
391  RID_SVXSTR_DEPTH_1,
392  RID_SVXSTR_DEPTH_2,
393  RID_SVXSTR_DEPTH_3,
394  RID_SVXSTR_DEPTH_4
395  };
396 
397  const TranslateId aDepthsInch[] =
398  {
399  RID_SVXSTR_DEPTH_0_INCH,
400  RID_SVXSTR_DEPTH_1_INCH,
401  RID_SVXSTR_DEPTH_2_INCH,
402  RID_SVXSTR_DEPTH_3_INCH,
403  RID_SVXSTR_DEPTH_4_INCH
404  };
405 
406  static_assert(SAL_N_ELEMENTS(aDepths) == SAL_N_ELEMENTS(aDepthsInch));
407 
408  const TranslateId* pResource = IsMetric(eUnit) ? aDepths : aDepthsInch;
409 
410  mxDepth0->set_label(SvxResId(pResource[0]));
411  mxDepth1->set_label(SvxResId(pResource[1]));
412  mxDepth2->set_label(SvxResId(pResource[2]));
413  mxDepth3->set_label(SvxResId(pResource[3]));
414  mxDepth4->set_label(SvxResId(pResource[4]));
415 }
416 
418  const css::frame::FeatureStateEvent& Event
419 )
420 {
421  if( Event.FeatureURL.Main == gsExtrusionDepth )
422  {
423  if( !Event.IsEnabled )
424  {
425  implSetDepth( 0 );
426  }
427  else
428  {
429  double fValue = 0.0;
430  if( Event.State >>= fValue )
431  implSetDepth( fValue );
432  }
433  }
434  else if( Event.FeatureURL.Main == gsMetricUnit )
435  {
436  if( Event.IsEnabled )
437  {
438  sal_Int32 nValue = 0;
439  if( Event.State >>= nValue )
440  {
441  implFillStrings( static_cast<FieldUnit>(nValue) );
442  if( mfDepth >= 0.0 )
444  }
445  }
446  }
447 }
448 
450 {
451  Sequence< PropertyValue > aArgs{
453  comphelper::makePropertyValue("Metric", static_cast<sal_Int32>( meUnit ))
454  };
455 
457  xControl->EndPopupMode();
458  xControl->dispatchCommand(".uno:ExtrusionDepthDialog", aArgs);
459  mbCommandDispatched = true;
460 }
461 
462 IMPL_LINK(ExtrusionDepthWindow, SelectHdl, weld::Toggleable&, rButton, void)
463 {
464  if (mbSettingValue || !rButton.get_active())
465  return;
466 
467  // see MouseReleaseHdl for mbCommandDispatched check, there's no guarantee
468  // this toggle will happen before that mouse release though it does in
469  // practice for vcl and gtk
470  if (mbCommandDispatched)
471  return;
472 
473  if (mxCustom->get_active())
474  DispatchDepthDialog();
475  else
476  {
477  double fDepth;
478 
479  if (mxInfinity->get_active())
480  {
481  fDepth = 338666.6;
482  }
483  else
484  {
485  int nSelected;
486  if (mxDepth0->get_active())
487  nSelected = 0;
488  else if (mxDepth1->get_active())
489  nSelected = 1;
490  else if (mxDepth2->get_active())
491  nSelected = 2;
492  else if (mxDepth3->get_active())
493  nSelected = 3;
494  else
495  nSelected = 4;
496 
497  fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
498  }
499 
500  Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
501  OUString(gsExtrusionDepth).copy(5), fDepth) };
502 
503  mxControl->dispatchCommand( gsExtrusionDepth, aArgs );
504  mbCommandDispatched = true;
505  implSetDepth( fDepth );
506 
507  mxControl->EndPopupMode();
508  }
509 }
510 
511 IMPL_LINK_NOARG(ExtrusionDepthWindow, MouseReleaseHdl, const MouseEvent&, bool)
512 {
513  /*
514  tdf#145296 if the "custom" radiobutton was presented preselected as
515  toggled on and the user clicked on it then there's no toggled signal sent
516  because the item was already toggled on and didn't change state.
517 
518  So if that happens launch the custom spacing dialog explicitly here on
519  mouse release.
520  */
521  if (mxCustom->get_active() && !mbCommandDispatched)
522  {
523  DispatchDepthDialog();
524  return true;
525  }
526  return false;
527 }
528 
529 // ExtrusionDirectionControl
531  const Reference< XComponentContext >& rxContext
532 ) : svt::PopupWindowController(
533  rxContext,
534  Reference< css::frame::XFrame >(),
535  ".uno:ExtrusionDepthFloater"
536  )
537 {
538 }
539 
540 std::unique_ptr<WeldToolbarPopup> ExtrusionDepthController::weldPopupWindow()
541 {
542  return std::make_unique<ExtrusionDepthWindow>(this, m_pToolbar);
543 }
544 
546 {
547  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
548  std::make_unique<ExtrusionDepthWindow>(this, pParent->GetFrameWeld()));
549 
550  mxInterimPopover->Show();
551 
552  return mxInterimPopover;
553 }
554 
555 // XInitialization
556 void SAL_CALL ExtrusionDepthController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
557 {
558  svt::PopupWindowController::initialize( aArguments );
559 
560  ToolBox* pToolBox = nullptr;
562  if ( getToolboxId( nId, &pToolBox ) )
563  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
564 }
565 
566 // XServiceInfo
567 
568 
570 {
571  return "com.sun.star.comp.svx.ExtrusionDepthController";
572 }
573 
574 
576 {
577  return { "com.sun.star.frame.ToolbarController" };
578 }
579 
580 
581 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
583  css::uno::XComponentContext* xContext,
584  css::uno::Sequence<css::uno::Any> const &)
585 {
586  return cppu::acquire(new ExtrusionDepthController(xContext));
587 }
588 
589 
590 constexpr OUStringLiteral g_sExtrusionLightingDirection = u".uno:ExtrusionLightingDirection";
591 constexpr OUStringLiteral g_sExtrusionLightingIntensity = u".uno:ExtrusionLightingIntensity";
592 
594  weld::Widget* pParent)
595  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/lightingwindow.ui", "LightingWindow")
596  , mxControl(pControl)
597  , mxLightingSet(new ValueSet(nullptr))
598  , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLightingSet))
599  , mxBright(m_xBuilder->weld_radio_button("bright"))
600  , mxNormal(m_xBuilder->weld_radio_button("normal"))
601  , mxDim(m_xBuilder->weld_radio_button("dim"))
602 {
604 
605  for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
606  {
607  if( i != FROM_FRONT )
608  {
609  maImgLightingOff[i] = Image(StockImage::Yes, OUString(aLightOffBmps[i]));
610  maImgLightingOn[i] = Image(StockImage::Yes, OUString(aLightOnBmps[i]));
611  }
612  maImgLightingPreview[i] = Image(StockImage::Yes, OUString(aLightPreviewBmps[i]));
613  }
614 
616 
617  mxLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) );
618  mxLightingSet->SetColCount( 3 );
619  mxLightingSet->EnableFullItemMode( false );
620 
621  for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
622  {
623  if( i != FROM_FRONT )
624  {
625  mxLightingSet->InsertItem( i+1, maImgLightingOff[i] );
626  }
627  else
628  {
629  mxLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
630  }
631  }
632  Size aSize(72, 72);
633  mxLightingSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
634  mxLightingSet->SetOutputSizePixel(aSize);
635 
636  mxBright->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
637  mxNormal->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
638  mxDim->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
639 
640  AddStatusListener( g_sExtrusionLightingDirection );
641  AddStatusListener( g_sExtrusionLightingIntensity );
642 }
643 
645 {
646  mxLightingSet->GrabFocus();
647 }
648 
650 {
651 }
652 
653 void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
654 {
655  mxBright->set_sensitive(bEnabled);
656  mxBright->set_active(nLevel == 0 && bEnabled);
657  mxNormal->set_sensitive(bEnabled);
658  mxNormal->set_active(nLevel == 1 && bEnabled);
659  mxDim->set_sensitive(bEnabled);
660  mxDim->set_active(nLevel == 2 && bEnabled);
661 }
662 
663 void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
664 {
665  if( !bEnabled )
666  nDirection = FROM_FRONT;
667 
668  sal_uInt16 nItemId;
669  for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
670  {
671  if( nItemId == FROM_FRONT )
672  {
673  mxLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
674  }
675  else
676  {
677  mxLightingSet->SetItemImage(
678  nItemId + 1,
679  static_cast<sal_uInt16>(nDirection) == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
680  );
681  }
682  }
683 
684  if (bEnabled)
685  mxLightingSet->Enable();
686  else
687  mxLightingSet->Disable();
688 }
689 
691  const css::frame::FeatureStateEvent& Event
692 )
693 {
694  if( Event.FeatureURL.Main == g_sExtrusionLightingIntensity )
695  {
696  if( !Event.IsEnabled )
697  {
698  implSetIntensity( 0, false );
699  }
700  else
701  {
702  sal_Int32 nValue = 0;
703  if( Event.State >>= nValue )
704  implSetIntensity( nValue, true );
705  }
706  }
707  else if( Event.FeatureURL.Main == g_sExtrusionLightingDirection )
708  {
709  if( !Event.IsEnabled )
710  {
711  implSetDirection( 0, false );
712  }
713  else
714  {
715  sal_Int32 nValue = 0;
716  if( Event.State >>= nValue )
717  implSetDirection( nValue, true );
718  }
719  }
720 }
721 
723 {
724  sal_Int32 nDirection = mxLightingSet->GetSelectedItemId();
725 
726  if( (nDirection > 0) && (nDirection < 10) )
727  {
728  nDirection--;
729 
730  Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
731  OUString(g_sExtrusionLightingDirection).copy(5), nDirection) };
732 
733  mxControl->dispatchCommand( g_sExtrusionLightingDirection, aArgs );
734 
735  implSetDirection( nDirection, true );
736  }
737 
738  mxControl->EndPopupMode();
739 }
740 
741 IMPL_LINK(ExtrusionLightingWindow, SelectToolbarMenuHdl, weld::Toggleable&, rButton, void)
742 {
743  if (!rButton.get_active())
744  return;
745 
746  int nLevel;
747  if (mxBright->get_active())
748  nLevel = 0;
749  else if (mxNormal->get_active())
750  nLevel = 1;
751  else
752  nLevel = 2;
753 
754  Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
755  OUString(g_sExtrusionLightingIntensity).copy(5), static_cast<sal_Int32>(nLevel)) };
756 
757  mxControl->dispatchCommand( g_sExtrusionLightingIntensity, aArgs );
758 
759  implSetIntensity( nLevel, true );
760 
761  mxControl->EndPopupMode();
762 }
763 
765  const Reference< XComponentContext >& rxContext
766 ) : svt::PopupWindowController( rxContext,
767  Reference< css::frame::XFrame >(),
768  ".uno:ExtrusionDirectionFloater"
769  )
770 {
771 }
772 
773 std::unique_ptr<WeldToolbarPopup> ExtrusionLightingControl::weldPopupWindow()
774 {
775  return std::make_unique<ExtrusionLightingWindow>(this, m_pToolbar);
776 }
777 
779 {
780  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
781  std::make_unique<ExtrusionLightingWindow>(this, pParent->GetFrameWeld()));
782 
783  mxInterimPopover->Show();
784 
785  return mxInterimPopover;
786 }
787 
788 // XInitialization
789 void SAL_CALL ExtrusionLightingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
790 {
791  svt::PopupWindowController::initialize( aArguments );
792 
793  ToolBox* pToolBox = nullptr;
795  if ( getToolboxId( nId, &pToolBox ) )
796  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
797 }
798 
799 // XServiceInfo
800 
801 
803 {
804  return "com.sun.star.comp.svx.ExtrusionLightingController";
805 }
806 
807 
809 {
810  return { "com.sun.star.frame.ToolbarController" };
811 }
812 
813 
814 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
816  css::uno::XComponentContext* xContext,
817  css::uno::Sequence<css::uno::Any> const &)
818 {
819  return cppu::acquire(new ExtrusionLightingControl(xContext));
820 }
821 
822 
823 constexpr OUStringLiteral g_sExtrusionSurface = u".uno:ExtrusionSurface";
824 
826  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/surfacewindow.ui", "SurfaceWindow")
827  , mxControl(pControl)
828  , mxWireFrame(m_xBuilder->weld_radio_button("wireframe"))
829  , mxMatt(m_xBuilder->weld_radio_button("matt"))
830  , mxPlastic(m_xBuilder->weld_radio_button("plastic"))
831  , mxMetal(m_xBuilder->weld_radio_button("metal"))
832 {
833  mxWireFrame->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
834  mxMatt->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
835  mxPlastic->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
836  mxMetal->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
837 
838  AddStatusListener( g_sExtrusionSurface );
839 }
840 
842 {
843  mxWireFrame->grab_focus();
844 }
845 
846 void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
847 {
848  mxWireFrame->set_active(nSurface == 0 && bEnabled);
849  mxWireFrame->set_sensitive(bEnabled);
850  mxMatt->set_active(nSurface == 1 && bEnabled);
851  mxMatt->set_sensitive(bEnabled);
852  mxPlastic->set_active(nSurface == 2 && bEnabled);
853  mxPlastic->set_sensitive(bEnabled);
854  mxMetal->set_active(nSurface == 3 && bEnabled);
855  mxMetal->set_sensitive(bEnabled);
856 }
857 
859  const css::frame::FeatureStateEvent& Event
860 )
861 {
862  if( Event.FeatureURL.Main != g_sExtrusionSurface )
863  return;
864 
865  if( !Event.IsEnabled )
866  {
867  implSetSurface( 0, false );
868  }
869  else
870  {
871  sal_Int32 nValue = 0;
872  if( Event.State >>= nValue )
873  implSetSurface( nValue, true );
874  }
875 }
876 
878 {
879  if (!rButton.get_active())
880  return;
881 
882  sal_Int32 nSurface;
883  if (mxWireFrame->get_active())
884  nSurface = 0;
885  else if (mxMatt->get_active())
886  nSurface = 1;
887  else if (mxPlastic->get_active())
888  nSurface = 2;
889  else
890  nSurface = 3;
891 
892  Sequence< PropertyValue > aArgs{ comphelper::makePropertyValue(
893  OUString(g_sExtrusionSurface).copy(5), nSurface) };
894 
895  mxControl->dispatchCommand( g_sExtrusionSurface, aArgs );
896 
897  implSetSurface( nSurface, true );
898 
899  mxControl->EndPopupMode();
900 }
901 
903  const Reference< XComponentContext >& rxContext
904 )
905 : svt::PopupWindowController(
906  rxContext,
907  Reference< css::frame::XFrame >(),
908  ".uno:ExtrusionSurfaceFloater"
909  )
910 {
911 }
912 
913 std::unique_ptr<WeldToolbarPopup> ExtrusionSurfaceControl::weldPopupWindow()
914 {
915  return std::make_unique<ExtrusionSurfaceWindow>(this, m_pToolbar);
916 }
917 
919 {
920  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
921  std::make_unique<ExtrusionSurfaceWindow>(this, pParent->GetFrameWeld()));
922 
923  mxInterimPopover->Show();
924 
925  return mxInterimPopover;
926 }
927 
928 // XInitialization
929 void SAL_CALL ExtrusionSurfaceControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
930 {
931  svt::PopupWindowController::initialize( aArguments );
932 
933  ToolBox* pToolBox = nullptr;
935  if ( getToolboxId( nId, &pToolBox ) )
936  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
937 }
938 
939 // XServiceInfo
940 
941 
943 {
944  return "com.sun.star.comp.svx.ExtrusionSurfaceController";
945 }
946 
947 
949 {
950  return { "com.sun.star.frame.ToolbarController" };
951 }
952 
953 
954 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
956  css::uno::XComponentContext* xContext,
957  css::uno::Sequence<css::uno::Any> const &)
958 {
959  return cppu::acquire(new ExtrusionSurfaceControl(xContext));
960 }
961 
962 }
963 
964 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::RadioButton > mxCustom
#define FROM_TOP_LEFT
virtual OUString SAL_CALL getImplementationName() override
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
FieldUnit
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
ToolBoxItemBits GetItemBits(ToolBoxItemId nItemId) const
void AddStatusListener(const OUString &rCommandURL)
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
double const aDepthListInch[]
constexpr OUStringLiteral g_sExtrusionDirection
#define WB_MENUSTYLEVALUESET
virtual ~ExtrusionLightingWindow() override
void implSetIntensity(int nLevel, bool bEnabled)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
double const aDepthListMM[]
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
ExtrusionLightingControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
Reference
sal_Int16 nId
std::unique_ptr< weld::RadioButton > mxPlastic
constexpr rtl::OUStringConstExpr aLightOnBmps[]
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionDepthController_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
std::unique_ptr< weld::RadioButton > mxWireFrame
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
bool IsMetric(MapUnit eU)
Definition: svdtrans.hxx:242
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
rtl::Reference< svt::PopupWindowController > mxControl
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
std::unique_ptr< weld::RadioButton > mxMatt
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionSurfaceControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral g_sExtrusionProjection
std::unique_ptr< ValueSet > mxDirectionSet
static TranslateId aDirectionStrs[]
NONE
constexpr tools::Long Width() const
weld::Window * GetFrameWeld() const
constexpr rtl::OUStringConstExpr aLightOffBmps[]
ExtrusionDepthDialog(weld::Window *pParent, double fDepth, FieldUnit eDefaultUnit)
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
virtual void GrabFocus() override
virtual void GrabFocus() override
exports com.sun.star. frame
void SetItemBits(ToolBoxItemId nItemId, ToolBoxItemBits nBits)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
const sal_Int32 gSkewList[]
std::unique_ptr< weld::RadioButton > mxDepth1
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionLightingControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
std::unique_ptr< weld::RadioButton > mxDepth2
#define SAL_N_ELEMENTS(arr)
IMPL_LINK_NOARG(SuggestionDisplay, SelectSuggestionValueSetHdl, ValueSet *, void)
constexpr OUStringLiteral g_sExtrusionSurface
ExtrusionSurfaceControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void GrabFocus() override
IMPL_LINK(HangulHanjaConversionDialog, ClickByCharacterHdl, weld::Toggleable &, rBox, void)
virtual OUString SAL_CALL getImplementationName() override
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
std::unique_ptr< weld::RadioButton > mxDepth3
std::unique_ptr< weld::RadioButton > mxPerspective
std::unique_ptr< weld::RadioButton > mxParallel
ExtrusionLightingWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
int i
virtual ~ExtrusionDirectionWindow() override
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
virtual ~ExtrusionDepthDialog() override
constexpr OUStringLiteral EMPTY
std::unique_ptr< weld::RadioButton > mxDepth0
std::unique_ptr< weld::RadioButton > mxDim
constexpr rtl::OUStringConstExpr aLightPreviewBmps[]
constexpr OStringLiteral HID_VALUESET_EXTRUSION_LIGHTING
Definition: helpids.h:42
ExtrusionDirectionWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxBright
float u
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
virtual void GrabFocus() override
VclPtr< InterimToolbarPopup > mxInterimPopover
ExtrusionDepthWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxNormal
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
ExtrusionDepthController(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
ExtrusionSurfaceWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
WinBits const WB_NOBORDER
constexpr OUStringLiteral g_sExtrusionLightingIntensity
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
#define WB_NO_DIRECTSELECT
constexpr tools::Long Height() const
std::unique_ptr< weld::RadioButton > mxInfinity
void implSetProjection(sal_Int32 nProjection, bool bEnabled)
#define FROM_BOTTOM_RIGHT
std::unique_ptr< ValueSet > mxLightingSet
std::unique_ptr< weld::RadioButton > mxDepth4
virtual void SAL_CALL initialize(const css::uno::Sequence< css::uno::Any > &aArguments) override
static VclPtr< reference_type > Create(Arg &&...arg)
virtual OUString SAL_CALL getImplementationName() override
constexpr rtl::OUStringConstExpr aDirectionBmps[]
void copy(const fs::path &src, const fs::path &dest)
std::unique_ptr< weld::RadioButton > mxMetal
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_svx_ExtrusionDirectionControl_get_implementation(css::uno::XComponentContext *xContext, css::uno::Sequence< css::uno::Any > const &)
ExtrusionDirectionControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
WinBits const WB_TABSTOP
#define FROM_FRONT
std::unique_ptr< weld::MetricSpinButton > m_xMtrDepth
void implSetDirection(int nDirection, bool bEnabled)
void implSetSurface(int nSurface, bool bEnabled)
void implFillStrings(FieldUnit eUnit)
constexpr OUStringLiteral gsExtrusionDepth(u".uno:ExtrusionDepth")
#define DIRECTION_SE
#define WB_FLATVALUESET
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
constexpr OUStringLiteral gsMetricUnit(u".uno:MetricUnit")
#define DIRECTION_NW
void implSetDepth(double fDepth)
void implSetDirection(sal_Int32 nSkew, bool bEnabled)
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
constexpr OUStringLiteral g_sExtrusionLightingDirection
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override