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