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