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