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 
24 #include <svtools/toolbarmenu.hxx>
25 #include <vcl/toolbox.hxx>
26 
27 #include <svx/strings.hrc>
28 #include <svx/svdtrans.hxx>
29 #include <svx/dialmgr.hxx>
30 
31 #include <helpids.h>
32 #include "extrusioncontrols.hxx"
33 #include <extrusiondepthdialog.hxx>
34 
35 #include <bitmaps.hlst>
36 
37 using namespace ::com::sun::star::uno;
38 using namespace ::com::sun::star::lang;
39 using namespace ::com::sun::star::beans;
40 using namespace ::com::sun::star::util;
41 using namespace ::com::sun::star::graphic;
42 
43 namespace svx
44 {
45 
46 const sal_Int32 gSkewList[] = { 135, 90, 45, 180, 0, -360, -135, -90, -45 };
47 constexpr OUStringLiteral g_sExtrusionDirection = u".uno:ExtrusionDirection";
48 constexpr OUStringLiteral g_sExtrusionProjection = u".uno:ExtrusionProjection";
49 
50 const std::u16string_view aLightOffBmps[] =
51 {
52  u"" RID_SVXBMP_LIGHT_OFF_FROM_TOP_LEFT,
53  u"" RID_SVXBMP_LIGHT_OFF_FROM_TOP,
54  u"" RID_SVXBMP_LIGHT_OFF_FROM_TOP_RIGHT,
55  u"" RID_SVXBMP_LIGHT_OFF_FROM_LEFT,
56  u"",
57  u"" RID_SVXBMP_LIGHT_OFF_FROM_RIGHT,
58  u"" RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_LEFT,
59  u"" RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM,
60  u"" RID_SVXBMP_LIGHT_OFF_FROM_BOTTOM_RIGHT
61 };
62 
63 const std::u16string_view aLightOnBmps[] =
64 {
65  u"" RID_SVXBMP_LIGHT_ON_FROM_TOP_LEFT,
66  u"" RID_SVXBMP_LIGHT_ON_FROM_TOP,
67  u"" RID_SVXBMP_LIGHT_ON_FROM_TOP_RIGHT,
68  u"" RID_SVXBMP_LIGHT_ON_FROM_LEFT,
69  u"",
70  u"" RID_SVXBMP_LIGHT_ON_FROM_RIGHT,
71  u"" RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_LEFT,
72  u"" RID_SVXBMP_LIGHT_ON_FROM_BOTTOM,
73  u"" RID_SVXBMP_LIGHT_ON_FROM_BOTTOM_RIGHT
74 };
75 
76 const std::u16string_view aLightPreviewBmps[] =
77 {
78  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_LEFT,
79  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP,
80  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_TOP_RIGHT,
81  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_LEFT,
82  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_RIGHT,
83  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_FRONT,
84  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_LEFT,
85  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM,
86  u"" RID_SVXBMP_LIGHT_PREVIEW_FROM_BOTTOM_RIGHT
87 };
88 
89 const std::u16string_view aDirectionBmps[] =
90 {
91  u"" RID_SVXBMP_DIRECTION_DIRECTION_NW,
92  u"" RID_SVXBMP_DIRECTION_DIRECTION_N,
93  u"" RID_SVXBMP_DIRECTION_DIRECTION_NE,
94  u"" RID_SVXBMP_DIRECTION_DIRECTION_W,
95  u"" RID_SVXBMP_DIRECTION_DIRECTION_NONE,
96  u"" RID_SVXBMP_DIRECTION_DIRECTION_E,
97  u"" RID_SVXBMP_DIRECTION_DIRECTION_SW,
98  u"" RID_SVXBMP_DIRECTION_DIRECTION_S,
99  u"" 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( 1 );
227  aArgs[0].Name = OUString(g_sExtrusionDirection).copy(5);
228  aArgs[0].Value <<= 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( 1 );
240  aArgs[0].Name = OUString(g_sExtrusionProjection).copy(5);
241  aArgs[0].Value <<= static_cast<sal_Int32>(nProjection);
242 
243  mxControl->dispatchCommand( g_sExtrusionProjection, aArgs );
244  implSetProjection( nProjection, true );
245 
246  mxControl->EndPopupMode();
247 }
248 
250  const Reference< XComponentContext >& rxContext
251 ) : svt::PopupWindowController(
252  rxContext,
253  Reference< css::frame::XFrame >(),
254  ".uno:ExtrusionDirectionFloater"
255  )
256 {
257 }
258 
259 std::unique_ptr<WeldToolbarPopup> ExtrusionDirectionControl::weldPopupWindow()
260 {
261  return std::make_unique<ExtrusionDirectionWindow>(this, m_pToolbar);
262 }
263 
265 {
266  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
267  std::make_unique<ExtrusionDirectionWindow>(this, pParent->GetFrameWeld()));
268 
269  mxInterimPopover->Show();
270 
271  return mxInterimPopover;
272 }
273 
274 // XInitialization
275 void SAL_CALL ExtrusionDirectionControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
276 {
277  svt::PopupWindowController::initialize( aArguments );
278 
279  ToolBox* pToolBox = nullptr;
281  if ( getToolboxId( nId, &pToolBox ) )
282  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
283 }
284 
285 // XServiceInfo
286 
287 
289 {
290  return "com.sun.star.comp.svx.ExtrusionDirectionController";
291 }
292 
293 
295 {
296  return { "com.sun.star.frame.ToolbarController" };
297 }
298 
299 
300 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
302  css::uno::XComponentContext* xContext,
303  css::uno::Sequence<css::uno::Any> const &)
304 {
305  return cppu::acquire(new ExtrusionDirectionControl(xContext));
306 }
307 
308 
310  : GenericDialogController(pParent, "svx/ui/extrustiondepthdialog.ui", "ExtrustionDepthDialog")
311  , m_xMtrDepth(m_xBuilder->weld_metric_spin_button("depth", eDefaultUnit))
312 {
313  m_xMtrDepth->set_value(static_cast<int>(fDepth) * 100, FieldUnit::MM_100TH);
314 }
315 
317 {
318 }
319 
321 {
322  return static_cast<double>(m_xMtrDepth->get_value(FieldUnit::MM_100TH)) / 100.0;
323 }
324 
325 double const aDepthListInch[] = { 0, 1270,2540,5080,10160 };
326 double const aDepthListMM[] = { 0, 1000, 2500, 5000, 10000 };
327 
328 constexpr OUStringLiteral gsExtrusionDepth( u".uno:ExtrusionDepth" );
329 constexpr OUStringLiteral gsMetricUnit( u".uno:MetricUnit" );
330 
332  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/depthwindow.ui", "DepthWindow")
333  , mxControl(pControl)
334  , mxDepth0(m_xBuilder->weld_radio_button("depth0"))
335  , mxDepth1(m_xBuilder->weld_radio_button("depth1"))
336  , mxDepth2(m_xBuilder->weld_radio_button("depth2"))
337  , mxDepth3(m_xBuilder->weld_radio_button("depth3"))
338  , mxDepth4(m_xBuilder->weld_radio_button("depth4"))
339  , mxInfinity(m_xBuilder->weld_radio_button("infinity"))
340  , mxCustom(m_xBuilder->weld_radio_button("custom"))
341  , meUnit(FieldUnit::NONE)
342  , mfDepth( -1.0 )
343  , mbSettingValue(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 
355 }
356 
358 {
359  mxDepth0->grab_focus();
360 }
361 
363 {
364  mfDepth = fDepth;
365 
366  bool bSettingValue = mbSettingValue;
367  mbSettingValue = true;
368 
369  mxCustom->set_active(true);
370  bool bIsMetric = IsMetric(meUnit);
371  mxDepth0->set_active(fDepth == (bIsMetric ? aDepthListMM[0] : aDepthListInch[0]));
372  mxDepth1->set_active(fDepth == (bIsMetric ? aDepthListMM[1] : aDepthListInch[1]));
373  mxDepth2->set_active(fDepth == (bIsMetric ? aDepthListMM[2] : aDepthListInch[2]));
374  mxDepth3->set_active(fDepth == (bIsMetric ? aDepthListMM[3] : aDepthListInch[3]));
375  mxDepth4->set_active(fDepth == (bIsMetric ? aDepthListMM[4] : aDepthListInch[4]));
376  mxInfinity->set_active(fDepth >= 338666);
377 
378  mbSettingValue = bSettingValue;
379 }
380 
382 {
383  meUnit = eUnit;
384 
385  const TranslateId aDepths[] =
386  {
387  RID_SVXSTR_DEPTH_0,
388  RID_SVXSTR_DEPTH_1,
389  RID_SVXSTR_DEPTH_2,
390  RID_SVXSTR_DEPTH_3,
391  RID_SVXSTR_DEPTH_4
392  };
393 
394  const TranslateId aDepthsInch[] =
395  {
396  RID_SVXSTR_DEPTH_0_INCH,
397  RID_SVXSTR_DEPTH_1_INCH,
398  RID_SVXSTR_DEPTH_2_INCH,
399  RID_SVXSTR_DEPTH_3_INCH,
400  RID_SVXSTR_DEPTH_4_INCH
401  };
402 
403  assert(SAL_N_ELEMENTS(aDepths) == SAL_N_ELEMENTS(aDepthsInch));
404 
405  const TranslateId* pResource = IsMetric(eUnit) ? aDepths : aDepthsInch;
406 
407  mxDepth0->set_label(SvxResId(pResource[0]));
408  mxDepth1->set_label(SvxResId(pResource[1]));
409  mxDepth2->set_label(SvxResId(pResource[2]));
410  mxDepth3->set_label(SvxResId(pResource[3]));
411  mxDepth4->set_label(SvxResId(pResource[4]));
412 }
413 
415  const css::frame::FeatureStateEvent& Event
416 )
417 {
418  if( Event.FeatureURL.Main == gsExtrusionDepth )
419  {
420  if( !Event.IsEnabled )
421  {
422  implSetDepth( 0 );
423  }
424  else
425  {
426  double fValue = 0.0;
427  if( Event.State >>= fValue )
428  implSetDepth( fValue );
429  }
430  }
431  else if( Event.FeatureURL.Main == gsMetricUnit )
432  {
433  if( Event.IsEnabled )
434  {
435  sal_Int32 nValue = 0;
436  if( Event.State >>= nValue )
437  {
438  implFillStrings( static_cast<FieldUnit>(nValue) );
439  if( mfDepth >= 0.0 )
441  }
442  }
443  }
444 }
445 
446 IMPL_LINK(ExtrusionDepthWindow, SelectHdl, weld::Toggleable&, rButton, void)
447 {
448  if (mbSettingValue || !rButton.get_active())
449  return;
450 
451  if (mxCustom->get_active())
452  {
453  Sequence< PropertyValue > aArgs( 2 );
454  aArgs[0].Name = "Depth";
455  aArgs[0].Value <<= mfDepth;
456  aArgs[1].Name = "Metric";
457  aArgs[1].Value <<= static_cast<sal_Int32>( meUnit );
458 
459  rtl::Reference<svt::PopupWindowController> xControl(mxControl);
460  xControl->EndPopupMode();
461  xControl->dispatchCommand(".uno:ExtrusionDepthDialog", aArgs);
462  }
463  else
464  {
465  double fDepth;
466 
467  if (mxInfinity->get_active())
468  {
469  fDepth = 338666.6;
470  }
471  else
472  {
473  int nSelected;
474  if (mxDepth0->get_active())
475  nSelected = 0;
476  else if (mxDepth1->get_active())
477  nSelected = 1;
478  else if (mxDepth2->get_active())
479  nSelected = 2;
480  else if (mxDepth3->get_active())
481  nSelected = 3;
482  else
483  nSelected = 4;
484 
485  fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
486  }
487 
488  Sequence< PropertyValue > aArgs( 1 );
489  aArgs[0].Name = OUString(gsExtrusionDepth).copy(5);
490  aArgs[0].Value <<= fDepth;
491 
492  mxControl->dispatchCommand( gsExtrusionDepth, aArgs );
493  implSetDepth( fDepth );
494 
495  mxControl->EndPopupMode();
496  }
497 }
498 
499 // ExtrusionDirectionControl
501  const Reference< XComponentContext >& rxContext
502 ) : svt::PopupWindowController(
503  rxContext,
504  Reference< css::frame::XFrame >(),
505  ".uno:ExtrusionDepthFloater"
506  )
507 {
508 }
509 
510 std::unique_ptr<WeldToolbarPopup> ExtrusionDepthController::weldPopupWindow()
511 {
512  return std::make_unique<ExtrusionDepthWindow>(this, m_pToolbar);
513 }
514 
516 {
517  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
518  std::make_unique<ExtrusionDepthWindow>(this, pParent->GetFrameWeld()));
519 
520  mxInterimPopover->Show();
521 
522  return mxInterimPopover;
523 }
524 
525 // XInitialization
526 void SAL_CALL ExtrusionDepthController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
527 {
528  svt::PopupWindowController::initialize( aArguments );
529 
530  ToolBox* pToolBox = nullptr;
532  if ( getToolboxId( nId, &pToolBox ) )
533  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
534 }
535 
536 // XServiceInfo
537 
538 
540 {
541  return "com.sun.star.comp.svx.ExtrusionDepthController";
542 }
543 
544 
546 {
547  return { "com.sun.star.frame.ToolbarController" };
548 }
549 
550 
551 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
553  css::uno::XComponentContext* xContext,
554  css::uno::Sequence<css::uno::Any> const &)
555 {
556  return cppu::acquire(new ExtrusionDepthController(xContext));
557 }
558 
559 
560 constexpr OUStringLiteral g_sExtrusionLightingDirection = u".uno:ExtrusionLightingDirection";
561 constexpr OUStringLiteral g_sExtrusionLightingIntensity = u".uno:ExtrusionLightingIntensity";
562 
564  weld::Widget* pParent)
565  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/lightingwindow.ui", "LightingWindow")
566  , mxControl(pControl)
567  , mxLightingSet(new ValueSet(nullptr))
568  , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLightingSet))
569  , mxBright(m_xBuilder->weld_radio_button("bright"))
570  , mxNormal(m_xBuilder->weld_radio_button("normal"))
571  , mxDim(m_xBuilder->weld_radio_button("dim"))
572 {
574 
575  for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
576  {
577  if( i != FROM_FRONT )
578  {
579  maImgLightingOff[i] = Image(StockImage::Yes, OUString(aLightOffBmps[i]));
580  maImgLightingOn[i] = Image(StockImage::Yes, OUString(aLightOnBmps[i]));
581  }
582  maImgLightingPreview[i] = Image(StockImage::Yes, OUString(aLightPreviewBmps[i]));
583  }
584 
586 
587  mxLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) );
588  mxLightingSet->SetColCount( 3 );
589  mxLightingSet->EnableFullItemMode( false );
590 
591  for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
592  {
593  if( i != FROM_FRONT )
594  {
595  mxLightingSet->InsertItem( i+1, maImgLightingOff[i] );
596  }
597  else
598  {
599  mxLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
600  }
601  }
602  Size aSize(72, 72);
603  mxLightingSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
604  mxLightingSet->SetOutputSizePixel(aSize);
605 
606  mxBright->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
607  mxNormal->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
608  mxDim->connect_toggled(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
609 
610  AddStatusListener( g_sExtrusionLightingDirection );
611  AddStatusListener( g_sExtrusionLightingIntensity );
612 }
613 
615 {
616  mxLightingSet->GrabFocus();
617 }
618 
620 {
621 }
622 
623 void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
624 {
625  mxBright->set_sensitive(bEnabled);
626  mxBright->set_active(nLevel == 0 && bEnabled);
627  mxNormal->set_sensitive(bEnabled);
628  mxNormal->set_active(nLevel == 1 && bEnabled);
629  mxDim->set_sensitive(bEnabled);
630  mxDim->set_active(nLevel == 2 && bEnabled);
631 }
632 
633 void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
634 {
635  if( !bEnabled )
636  nDirection = FROM_FRONT;
637 
638  sal_uInt16 nItemId;
639  for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
640  {
641  if( nItemId == FROM_FRONT )
642  {
643  mxLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
644  }
645  else
646  {
647  mxLightingSet->SetItemImage(
648  nItemId + 1,
649  static_cast<sal_uInt16>(nDirection) == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
650  );
651  }
652  }
653 
654  if (bEnabled)
655  mxLightingSet->Enable();
656  else
657  mxLightingSet->Disable();
658 }
659 
661  const css::frame::FeatureStateEvent& Event
662 )
663 {
664  if( Event.FeatureURL.Main == g_sExtrusionLightingIntensity )
665  {
666  if( !Event.IsEnabled )
667  {
668  implSetIntensity( 0, false );
669  }
670  else
671  {
672  sal_Int32 nValue = 0;
673  if( Event.State >>= nValue )
674  implSetIntensity( nValue, true );
675  }
676  }
677  else if( Event.FeatureURL.Main == g_sExtrusionLightingDirection )
678  {
679  if( !Event.IsEnabled )
680  {
681  implSetDirection( 0, false );
682  }
683  else
684  {
685  sal_Int32 nValue = 0;
686  if( Event.State >>= nValue )
687  implSetDirection( nValue, true );
688  }
689  }
690 }
691 
693 {
694  sal_Int32 nDirection = mxLightingSet->GetSelectedItemId();
695 
696  if( (nDirection > 0) && (nDirection < 10) )
697  {
698  nDirection--;
699 
700  Sequence< PropertyValue > aArgs( 1 );
701  aArgs[0].Name = OUString(g_sExtrusionLightingDirection).copy(5);
702  aArgs[0].Value <<= nDirection;
703 
704  mxControl->dispatchCommand( g_sExtrusionLightingDirection, aArgs );
705 
706  implSetDirection( nDirection, true );
707  }
708 
709  mxControl->EndPopupMode();
710 }
711 
712 IMPL_LINK(ExtrusionLightingWindow, SelectToolbarMenuHdl, weld::Toggleable&, rButton, void)
713 {
714  if (!rButton.get_active())
715  return;
716 
717  int nLevel;
718  if (mxBright->get_active())
719  nLevel = 0;
720  else if (mxNormal->get_active())
721  nLevel = 1;
722  else
723  nLevel = 2;
724 
725  Sequence< PropertyValue > aArgs( 1 );
726  aArgs[0].Name = OUString(g_sExtrusionLightingIntensity).copy(5);
727  aArgs[0].Value <<= static_cast<sal_Int32>(nLevel);
728 
729  mxControl->dispatchCommand( g_sExtrusionLightingIntensity, aArgs );
730 
731  implSetIntensity( nLevel, true );
732 
733  mxControl->EndPopupMode();
734 }
735 
737  const Reference< XComponentContext >& rxContext
738 ) : svt::PopupWindowController( rxContext,
739  Reference< css::frame::XFrame >(),
740  ".uno:ExtrusionDirectionFloater"
741  )
742 {
743 }
744 
745 std::unique_ptr<WeldToolbarPopup> ExtrusionLightingControl::weldPopupWindow()
746 {
747  return std::make_unique<ExtrusionLightingWindow>(this, m_pToolbar);
748 }
749 
751 {
752  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
753  std::make_unique<ExtrusionLightingWindow>(this, pParent->GetFrameWeld()));
754 
755  mxInterimPopover->Show();
756 
757  return mxInterimPopover;
758 }
759 
760 // XInitialization
761 void SAL_CALL ExtrusionLightingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
762 {
763  svt::PopupWindowController::initialize( aArguments );
764 
765  ToolBox* pToolBox = nullptr;
767  if ( getToolboxId( nId, &pToolBox ) )
768  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
769 }
770 
771 // XServiceInfo
772 
773 
775 {
776  return "com.sun.star.comp.svx.ExtrusionLightingController";
777 }
778 
779 
781 {
782  return { "com.sun.star.frame.ToolbarController" };
783 }
784 
785 
786 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
788  css::uno::XComponentContext* xContext,
789  css::uno::Sequence<css::uno::Any> const &)
790 {
791  return cppu::acquire(new ExtrusionLightingControl(xContext));
792 }
793 
794 
795 constexpr OUStringLiteral g_sExtrusionSurface = u".uno:ExtrusionSurface";
796 
798  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/surfacewindow.ui", "SurfaceWindow")
799  , mxControl(pControl)
800  , mxWireFrame(m_xBuilder->weld_radio_button("wireframe"))
801  , mxMatt(m_xBuilder->weld_radio_button("matt"))
802  , mxPlastic(m_xBuilder->weld_radio_button("plastic"))
803  , mxMetal(m_xBuilder->weld_radio_button("metal"))
804 {
805  mxWireFrame->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
806  mxMatt->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
807  mxPlastic->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
808  mxMetal->connect_toggled(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
809 
810  AddStatusListener( g_sExtrusionSurface );
811 }
812 
814 {
815  mxWireFrame->grab_focus();
816 }
817 
818 void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
819 {
820  mxWireFrame->set_active(nSurface == 0 && bEnabled);
821  mxWireFrame->set_sensitive(bEnabled);
822  mxMatt->set_active(nSurface == 1 && bEnabled);
823  mxMatt->set_sensitive(bEnabled);
824  mxPlastic->set_active(nSurface == 2 && bEnabled);
825  mxPlastic->set_sensitive(bEnabled);
826  mxMetal->set_active(nSurface == 3 && bEnabled);
827  mxMetal->set_sensitive(bEnabled);
828 }
829 
831  const css::frame::FeatureStateEvent& Event
832 )
833 {
834  if( Event.FeatureURL.Main != g_sExtrusionSurface )
835  return;
836 
837  if( !Event.IsEnabled )
838  {
839  implSetSurface( 0, false );
840  }
841  else
842  {
843  sal_Int32 nValue = 0;
844  if( Event.State >>= nValue )
845  implSetSurface( nValue, true );
846  }
847 }
848 
850 {
851  if (!rButton.get_active())
852  return;
853 
854  sal_Int32 nSurface;
855  if (mxWireFrame->get_active())
856  nSurface = 0;
857  else if (mxMatt->get_active())
858  nSurface = 1;
859  else if (mxPlastic->get_active())
860  nSurface = 2;
861  else
862  nSurface = 3;
863 
864  Sequence< PropertyValue > aArgs( 1 );
865  aArgs[0].Name = OUString(g_sExtrusionSurface).copy(5);
866  aArgs[0].Value <<= nSurface;
867 
868  mxControl->dispatchCommand( g_sExtrusionSurface, aArgs );
869 
870  implSetSurface( nSurface, true );
871 
872  mxControl->EndPopupMode();
873 }
874 
876  const Reference< XComponentContext >& rxContext
877 )
878 : svt::PopupWindowController(
879  rxContext,
880  Reference< css::frame::XFrame >(),
881  ".uno:ExtrusionSurfaceFloater"
882  )
883 {
884 }
885 
886 std::unique_ptr<WeldToolbarPopup> ExtrusionSurfaceControl::weldPopupWindow()
887 {
888  return std::make_unique<ExtrusionSurfaceWindow>(this, m_pToolbar);
889 }
890 
892 {
893  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
894  std::make_unique<ExtrusionSurfaceWindow>(this, pParent->GetFrameWeld()));
895 
896  mxInterimPopover->Show();
897 
898  return mxInterimPopover;
899 }
900 
901 // XInitialization
902 void SAL_CALL ExtrusionSurfaceControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
903 {
904  svt::PopupWindowController::initialize( aArguments );
905 
906  ToolBox* pToolBox = nullptr;
908  if ( getToolboxId( nId, &pToolBox ) )
909  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
910 }
911 
912 // XServiceInfo
913 
914 
916 {
917  return "com.sun.star.comp.svx.ExtrusionSurfaceController";
918 }
919 
920 
922 {
923  return { "com.sun.star.frame.ToolbarController" };
924 }
925 
926 
927 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
929  css::uno::XComponentContext* xContext,
930  css::uno::Sequence<css::uno::Any> const &)
931 {
932  return cppu::acquire(new ExtrusionSurfaceControl(xContext));
933 }
934 
935 }
936 
937 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::RadioButton > mxCustom
#define FROM_TOP_LEFT
virtual OUString SAL_CALL getImplementationName() override
const std::u16string_view aLightOnBmps[]
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)
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
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:255
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
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
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
const std::u16string_view aLightPreviewBmps[]
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
const std::u16string_view aDirectionBmps[]
virtual ~ExtrusionDepthDialog() override
std::unique_ptr< weld::RadioButton > mxDepth0
std::unique_ptr< weld::RadioButton > mxDim
#define HID_VALUESET_EXTRUSION_LIGHTING
Definition: helpids.h:40
ExtrusionDirectionWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
std::unique_ptr< weld::RadioButton > mxBright
float u
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
const std::u16string_view aLightOffBmps[]
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
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