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 const char g_sExtrusionDirection[] = ".uno:ExtrusionDirection";
48 const char g_sExtrusionProjection[] = ".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 
102 static const char* aDirectionStrs[] =
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, 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_clicked(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl));
146  mxParallel->connect_clicked(LINK(this, ExtrusionDirectionWindow, SelectToolbarMenuHdl));
147 
148  AddStatusListener( g_sExtrusionDirection );
149  AddStatusListener( g_sExtrusionProjection );
150 }
151 
153 {
154  mxDirectionSet->GrabFocus();
155 }
156 
158 {
159 }
160 
161 void ExtrusionDirectionWindow::implSetDirection( sal_Int32 nSkew, bool bEnabled )
162 {
163  sal_uInt16 nItemId;
164  for( nItemId = DIRECTION_NW; nItemId <= DIRECTION_SE; nItemId++ )
165  {
166  if( gSkewList[nItemId] == nSkew )
167  break;
168  }
169 
170  if( nItemId <= DIRECTION_SE )
171  {
172  mxDirectionSet->SelectItem( nItemId+1 );
173  }
174  else
175  {
176  mxDirectionSet->SetNoSelection();
177  }
178 
179  if (bEnabled)
180  mxDirectionSet->Enable();
181  else
182  mxDirectionSet->Disable();
183 }
184 
185 void ExtrusionDirectionWindow::implSetProjection( sal_Int32 nProjection, bool bEnabled )
186 {
187  mxPerspective->set_active(nProjection == 0 && bEnabled);
188  mxParallel->set_active(nProjection == 1 && bEnabled);
189  mxPerspective->set_sensitive(bEnabled);
190  mxParallel->set_sensitive(bEnabled);
191 }
192 
194  const css::frame::FeatureStateEvent& Event
195 )
196 {
197  if( Event.FeatureURL.Main == g_sExtrusionDirection )
198  {
199  if( !Event.IsEnabled )
200  {
201  implSetDirection( -1, false );
202  }
203  else
204  {
205  sal_Int32 nValue = 0;
206  if( Event.State >>= nValue )
207  implSetDirection( nValue, true );
208  }
209  }
210  else if( Event.FeatureURL.Main == g_sExtrusionProjection )
211  {
212  if( !Event.IsEnabled )
213  {
214  implSetProjection( -1, false );
215  }
216  else
217  {
218  sal_Int32 nValue = 0;
219  if( Event.State >>= nValue )
220  implSetProjection( nValue, true );
221  }
222  }
223 }
224 
226 {
227  Sequence< PropertyValue > aArgs( 1 );
228  aArgs[0].Name = OUString(g_sExtrusionDirection).copy(5);
229  aArgs[0].Value <<= gSkewList[mxDirectionSet->GetSelectedItemId()-1];
230 
231  mxControl->dispatchCommand( g_sExtrusionDirection, aArgs );
232 
233  mxControl->EndPopupMode();
234 }
235 
237 {
238  int nProjection = mxPerspective->get_active() ? 0 : 1;
239 
240  Sequence< PropertyValue > aArgs( 1 );
241  aArgs[0].Name = OUString(g_sExtrusionProjection).copy(5);
242  aArgs[0].Value <<= 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;
281  sal_uInt16 nId = 0;
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 {
346  mxDepth0->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
347  mxDepth1->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
348  mxDepth2->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
349  mxDepth3->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
350  mxDepth4->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
351  mxInfinity->connect_toggled(LINK(this, ExtrusionDepthWindow, SelectHdl));
352  mxCustom->connect_clicked(LINK(this, ExtrusionDepthWindow, ClickHdl));
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 char* 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 char* 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  assert(SAL_N_ELEMENTS(aDepths) == SAL_N_ELEMENTS(aDepthsInch));
405 
406  const char** 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  SelectHdl(*mxCustom);
450 }
451 
453 {
454  if (mbSettingValue || !rButton.get_active())
455  return;
456 
457  if (mxCustom->get_active())
458  {
459  Sequence< PropertyValue > aArgs( 2 );
460  aArgs[0].Name = "Depth";
461  aArgs[0].Value <<= mfDepth;
462  aArgs[1].Name = "Metric";
463  aArgs[1].Value <<= static_cast<sal_Int32>( meUnit );
464 
465  rtl::Reference<svt::PopupWindowController> xControl(mxControl);
466  xControl->EndPopupMode();
467  xControl->dispatchCommand(".uno:ExtrusionDepthDialog", aArgs);
468  }
469  else
470  {
471  double fDepth;
472 
473  if (mxInfinity->get_active())
474  {
475  fDepth = 338666.6;
476  }
477  else
478  {
479  int nSelected;
480  if (mxDepth0->get_active())
481  nSelected = 0;
482  else if (mxDepth1->get_active())
483  nSelected = 1;
484  else if (mxDepth2->get_active())
485  nSelected = 2;
486  else if (mxDepth3->get_active())
487  nSelected = 3;
488  else
489  nSelected = 4;
490 
491  fDepth = IsMetric( meUnit ) ? aDepthListMM[nSelected] : aDepthListInch[nSelected];
492  }
493 
494  Sequence< PropertyValue > aArgs( 1 );
495  aArgs[0].Name = OUString(gsExtrusionDepth).copy(5);
496  aArgs[0].Value <<= fDepth;
497 
498  mxControl->dispatchCommand( gsExtrusionDepth, aArgs );
499  implSetDepth( fDepth );
500 
501  mxControl->EndPopupMode();
502  }
503 }
504 
505 // ExtrusionDirectionControl
507  const Reference< XComponentContext >& rxContext
508 ) : svt::PopupWindowController(
509  rxContext,
510  Reference< css::frame::XFrame >(),
511  ".uno:ExtrusionDepthFloater"
512  )
513 {
514 }
515 
516 std::unique_ptr<WeldToolbarPopup> ExtrusionDepthController::weldPopupWindow()
517 {
518  return std::make_unique<ExtrusionDepthWindow>(this, m_pToolbar);
519 }
520 
522 {
523  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
524  std::make_unique<ExtrusionDepthWindow>(this, pParent->GetFrameWeld()));
525 
526  mxInterimPopover->Show();
527 
528  return mxInterimPopover;
529 }
530 
531 // XInitialization
532 void SAL_CALL ExtrusionDepthController::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
533 {
534  svt::PopupWindowController::initialize( aArguments );
535 
536  ToolBox* pToolBox = nullptr;
537  sal_uInt16 nId = 0;
538  if ( getToolboxId( nId, &pToolBox ) )
539  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
540 }
541 
542 // XServiceInfo
543 
544 
546 {
547  return "com.sun.star.comp.svx.ExtrusionDepthController";
548 }
549 
550 
552 {
553  return { "com.sun.star.frame.ToolbarController" };
554 }
555 
556 
557 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
559  css::uno::XComponentContext* xContext,
560  css::uno::Sequence<css::uno::Any> const &)
561 {
562  return cppu::acquire(new ExtrusionDepthController(xContext));
563 }
564 
565 
566 const char g_sExtrusionLightingDirection[] = ".uno:ExtrusionLightingDirection";
567 const char g_sExtrusionLightingIntensity[] = ".uno:ExtrusionLightingIntensity";
568 
570  weld::Widget* pParent)
571  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/lightingwindow.ui", "LightingWindow")
572  , mxControl(pControl)
573  , mxLightingSet(new ValueSet(nullptr))
574  , mxLightingSetWin(new weld::CustomWeld(*m_xBuilder, "valueset", *mxLightingSet))
575  , mxBright(m_xBuilder->weld_radio_button("bright"))
576  , mxNormal(m_xBuilder->weld_radio_button("normal"))
577  , mxDim(m_xBuilder->weld_radio_button("dim"))
578 {
580 
581  for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
582  {
583  if( i != FROM_FRONT )
584  {
585  maImgLightingOff[i] = Image(StockImage::Yes, aLightOffBmps[i]);
586  maImgLightingOn[i] = Image(StockImage::Yes, aLightOnBmps[i]);
587  }
588  maImgLightingPreview[i] = Image(StockImage::Yes, aLightPreviewBmps[i]);
589  }
590 
592 
593  mxLightingSet->SetSelectHdl( LINK( this, ExtrusionLightingWindow, SelectValueSetHdl ) );
594  mxLightingSet->SetColCount( 3 );
595  mxLightingSet->EnableFullItemMode( false );
596 
597  for (sal_uInt16 i = FROM_TOP_LEFT; i <= FROM_BOTTOM_RIGHT; ++i)
598  {
599  if( i != FROM_FRONT )
600  {
601  mxLightingSet->InsertItem( i+1, maImgLightingOff[i] );
602  }
603  else
604  {
605  mxLightingSet->InsertItem( 5, maImgLightingPreview[FROM_FRONT] );
606  }
607  }
608  Size aSize(72, 72);
609  mxLightingSet->GetDrawingArea()->set_size_request(aSize.Width(), aSize.Height());
610  mxLightingSet->SetOutputSizePixel(aSize);
611 
612  mxBright->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
613  mxNormal->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
614  mxDim->connect_clicked(LINK(this, ExtrusionLightingWindow, SelectToolbarMenuHdl));
615 
616  AddStatusListener( g_sExtrusionLightingDirection );
617  AddStatusListener( g_sExtrusionLightingIntensity );
618 }
619 
621 {
622  mxLightingSet->GrabFocus();
623 }
624 
626 {
627 }
628 
629 void ExtrusionLightingWindow::implSetIntensity( int nLevel, bool bEnabled )
630 {
631  mxBright->set_sensitive(bEnabled);
632  mxBright->set_active(nLevel == 0 && bEnabled);
633  mxNormal->set_sensitive(bEnabled);
634  mxNormal->set_active(nLevel == 1 && bEnabled);
635  mxDim->set_sensitive(bEnabled);
636  mxDim->set_active(nLevel == 2 && bEnabled);
637 }
638 
639 void ExtrusionLightingWindow::implSetDirection( int nDirection, bool bEnabled )
640 {
641  if( !bEnabled )
642  nDirection = FROM_FRONT;
643 
644  sal_uInt16 nItemId;
645  for( nItemId = FROM_TOP_LEFT; nItemId <= FROM_BOTTOM_RIGHT; nItemId++ )
646  {
647  if( nItemId == FROM_FRONT )
648  {
649  mxLightingSet->SetItemImage( nItemId + 1, maImgLightingPreview[ nDirection ] );
650  }
651  else
652  {
653  mxLightingSet->SetItemImage(
654  nItemId + 1,
655  static_cast<sal_uInt16>(nDirection) == nItemId ? maImgLightingOn[nItemId] : maImgLightingOff[nItemId]
656  );
657  }
658  }
659 
660  if (bEnabled)
661  mxLightingSet->Enable();
662  else
663  mxLightingSet->Disable();
664 }
665 
667  const css::frame::FeatureStateEvent& Event
668 )
669 {
670  if( Event.FeatureURL.Main == g_sExtrusionLightingIntensity )
671  {
672  if( !Event.IsEnabled )
673  {
674  implSetIntensity( 0, false );
675  }
676  else
677  {
678  sal_Int32 nValue = 0;
679  if( Event.State >>= nValue )
680  implSetIntensity( nValue, true );
681  }
682  }
683  else if( Event.FeatureURL.Main == g_sExtrusionLightingDirection )
684  {
685  if( !Event.IsEnabled )
686  {
687  implSetDirection( 0, false );
688  }
689  else
690  {
691  sal_Int32 nValue = 0;
692  if( Event.State >>= nValue )
693  implSetDirection( nValue, true );
694  }
695  }
696 }
697 
699 {
700  sal_Int32 nDirection = mxLightingSet->GetSelectedItemId();
701 
702  if( (nDirection > 0) && (nDirection < 10) )
703  {
704  nDirection--;
705 
706  Sequence< PropertyValue > aArgs( 1 );
707  aArgs[0].Name = OUString(g_sExtrusionLightingDirection).copy(5);
708  aArgs[0].Value <<= nDirection;
709 
710  mxControl->dispatchCommand( g_sExtrusionLightingDirection, aArgs );
711 
712  implSetDirection( nDirection, true );
713  }
714 
715  mxControl->EndPopupMode();
716 }
717 
719 {
720  int nLevel;
721  if (mxBright->get_active())
722  nLevel = 0;
723  else if (mxNormal->get_active())
724  nLevel = 1;
725  else
726  nLevel = 2;
727 
728  Sequence< PropertyValue > aArgs( 1 );
729  aArgs[0].Name = OUString(g_sExtrusionLightingIntensity).copy(5);
730  aArgs[0].Value <<= static_cast<sal_Int32>(nLevel);
731 
732  mxControl->dispatchCommand( g_sExtrusionLightingIntensity, aArgs );
733 
734  implSetIntensity( nLevel, true );
735 
736  mxControl->EndPopupMode();
737 }
738 
740  const Reference< XComponentContext >& rxContext
741 ) : svt::PopupWindowController( rxContext,
742  Reference< css::frame::XFrame >(),
743  ".uno:ExtrusionDirectionFloater"
744  )
745 {
746 }
747 
748 std::unique_ptr<WeldToolbarPopup> ExtrusionLightingControl::weldPopupWindow()
749 {
750  return std::make_unique<ExtrusionLightingWindow>(this, m_pToolbar);
751 }
752 
754 {
755  mxInterimPopover = VclPtr<InterimToolbarPopup>::Create(getFrameInterface(), pParent,
756  std::make_unique<ExtrusionLightingWindow>(this, pParent->GetFrameWeld()));
757 
758  mxInterimPopover->Show();
759 
760  return mxInterimPopover;
761 }
762 
763 // XInitialization
764 void SAL_CALL ExtrusionLightingControl::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
765 {
766  svt::PopupWindowController::initialize( aArguments );
767 
768  ToolBox* pToolBox = nullptr;
769  sal_uInt16 nId = 0;
770  if ( getToolboxId( nId, &pToolBox ) )
771  pToolBox->SetItemBits( nId, pToolBox->GetItemBits( nId ) | ToolBoxItemBits::DROPDOWNONLY );
772 }
773 
774 // XServiceInfo
775 
776 
778 {
779  return "com.sun.star.comp.svx.ExtrusionLightingController";
780 }
781 
782 
784 {
785  return { "com.sun.star.frame.ToolbarController" };
786 }
787 
788 
789 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
791  css::uno::XComponentContext* xContext,
792  css::uno::Sequence<css::uno::Any> const &)
793 {
794  return cppu::acquire(new ExtrusionLightingControl(xContext));
795 }
796 
797 
798 const char g_sExtrusionSurface[] = ".uno:ExtrusionSurface";
799 
801  : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/surfacewindow.ui", "SurfaceWindow")
802  , mxControl(pControl)
803  , mxWireFrame(m_xBuilder->weld_radio_button("wireframe"))
804  , mxMatt(m_xBuilder->weld_radio_button("matt"))
805  , mxPlastic(m_xBuilder->weld_radio_button("plastic"))
806  , mxMetal(m_xBuilder->weld_radio_button("metal"))
807 {
808  mxWireFrame->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
809  mxMatt->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
810  mxPlastic->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
811  mxMetal->connect_clicked(LINK(this, ExtrusionSurfaceWindow, SelectHdl));
812 
813  AddStatusListener( g_sExtrusionSurface );
814 }
815 
817 {
818  mxWireFrame->grab_focus();
819 }
820 
821 void ExtrusionSurfaceWindow::implSetSurface( int nSurface, bool bEnabled )
822 {
823  mxWireFrame->set_active(nSurface == 0 && bEnabled);
824  mxWireFrame->set_sensitive(bEnabled);
825  mxMatt->set_active(nSurface == 1 && bEnabled);
826  mxMatt->set_sensitive(bEnabled);
827  mxPlastic->set_active(nSurface == 2 && bEnabled);
828  mxPlastic->set_sensitive(bEnabled);
829  mxMetal->set_active(nSurface == 3 && bEnabled);
830  mxMetal->set_sensitive(bEnabled);
831 }
832 
834  const css::frame::FeatureStateEvent& Event
835 )
836 {
837  if( Event.FeatureURL.Main != g_sExtrusionSurface )
838  return;
839 
840  if( !Event.IsEnabled )
841  {
842  implSetSurface( 0, false );
843  }
844  else
845  {
846  sal_Int32 nValue = 0;
847  if( Event.State >>= nValue )
848  implSetSurface( nValue, true );
849  }
850 }
851 
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;
907  sal_uInt16 nId = 0;
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
void AddStatusListener(const OUString &rCommandURL)
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
double const aDepthListInch[]
#define WB_MENUSTYLEVALUESET
virtual ~ExtrusionLightingWindow() override
void implSetIntensity(int nLevel, bool bEnabled)
ToolBoxItemBits GetItemBits(sal_uInt16 nItemId) const
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 &)
std::unique_ptr< ValueSet > mxDirectionSet
NONE
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
OUString SvxResId(const char *pId)
Definition: dialmgr.cxx:25
exports com.sun.star. frame
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
const char g_sExtrusionLightingDirection[]
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)
const char g_sExtrusionSurface[]
const std::u16string_view aLightPreviewBmps[]
ExtrusionSurfaceControl(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
virtual void GrabFocus() override
virtual OUString SAL_CALL getImplementationName() override
virtual void statusChanged(const css::frame::FeatureStateEvent &Event) override
std::unique_ptr< weld::RadioButton > mxDepth3
const char g_sExtrusionLightingIntensity[]
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
void SetItemBits(sal_uInt16 nItemId, ToolBoxItemBits nBits)
#define HID_VALUESET_EXTRUSION_LIGHTING
Definition: helpids.h:40
ExtrusionDirectionWindow(svt::PopupWindowController *pControl, weld::Widget *pParentWindow)
tools::Long Width() const
std::unique_ptr< weld::RadioButton > mxBright
float u
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override
const std::u16string_view aLightOffBmps[]
virtual void GrabFocus() override
IMPL_LINK(HangulHanjaConversionDialog, ClickByCharacterHdl, weld::ToggleButton &, rBox, void)
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
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
#define WB_NO_DIRECTSELECT
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
tools::Long Height() const
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
const char g_sExtrusionDirection[]
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
static const char * aDirectionStrs[]
virtual VclPtr< vcl::Window > createVclPopupWindow(vcl::Window *pParent) override
constexpr OUStringLiteral gsMetricUnit(u".uno:MetricUnit")
const char g_sExtrusionProjection[]
#define DIRECTION_NW
void implSetDepth(double fDepth)
void implSetDirection(sal_Int32 nSkew, bool bEnabled)
sal_Int16 nValue
Definition: fmsrccfg.cxx:81
virtual std::unique_ptr< WeldToolbarPopup > weldPopupWindow() override